Migrated settings_t to INIT/METHOD macros
This commit is contained in:
@@ -265,10 +265,8 @@ static char *find_value(section_t *section, char *key, va_list args)
|
|||||||
return find_value_buffered(section, keybuf, keybuf, args, buf, sizeof(buf));
|
return find_value_buffered(section, keybuf, keybuf, args, buf, sizeof(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(settings_t, get_str, char*,
|
||||||
* Implementation of settings_t.get.
|
private_settings_t *this, char *key, char *def, ...)
|
||||||
*/
|
|
||||||
static char* get_str(private_settings_t *this, char *key, char *def, ...)
|
|
||||||
{
|
{
|
||||||
char *value;
|
char *value;
|
||||||
va_list args;
|
va_list args;
|
||||||
@@ -283,10 +281,8 @@ static char* get_str(private_settings_t *this, char *key, char *def, ...)
|
|||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(settings_t, get_bool, bool,
|
||||||
* Implementation of settings_t.get_bool.
|
private_settings_t *this, char *key, bool def, ...)
|
||||||
*/
|
|
||||||
static bool get_bool(private_settings_t *this, char *key, bool def, ...)
|
|
||||||
{
|
{
|
||||||
char *value;
|
char *value;
|
||||||
va_list args;
|
va_list args;
|
||||||
@@ -314,10 +310,8 @@ static bool get_bool(private_settings_t *this, char *key, bool def, ...)
|
|||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(settings_t, get_int, int,
|
||||||
* Implementation of settings_t.get_int.
|
private_settings_t *this, char *key, int def, ...)
|
||||||
*/
|
|
||||||
static int get_int(private_settings_t *this, char *key, int def, ...)
|
|
||||||
{
|
{
|
||||||
char *value;
|
char *value;
|
||||||
int intval;
|
int intval;
|
||||||
@@ -338,10 +332,8 @@ static int get_int(private_settings_t *this, char *key, int def, ...)
|
|||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(settings_t, get_double, double,
|
||||||
* Implementation of settings_t.get_double.
|
private_settings_t *this, char *key, double def, ...)
|
||||||
*/
|
|
||||||
static double get_double(private_settings_t *this, char *key, double def, ...)
|
|
||||||
{
|
{
|
||||||
char *value;
|
char *value;
|
||||||
double dval;
|
double dval;
|
||||||
@@ -362,10 +354,8 @@ static double get_double(private_settings_t *this, char *key, double def, ...)
|
|||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(settings_t, get_time, u_int32_t,
|
||||||
* Implementation of settings_t.get_time.
|
private_settings_t *this, char *key, u_int32_t def, ...)
|
||||||
*/
|
|
||||||
static u_int32_t get_time(private_settings_t *this, char *key, u_int32_t def, ...)
|
|
||||||
{
|
{
|
||||||
char *value, *endptr;
|
char *value, *endptr;
|
||||||
u_int32_t timeval;
|
u_int32_t timeval;
|
||||||
@@ -410,11 +400,8 @@ static bool section_filter(void *null, section_t **in, char **out)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(settings_t, create_section_enumerator, enumerator_t*,
|
||||||
* Implementation of settings_t.create_section_enumerator
|
private_settings_t *this, char *key, ...)
|
||||||
*/
|
|
||||||
static enumerator_t* create_section_enumerator(private_settings_t *this,
|
|
||||||
char *key, ...)
|
|
||||||
{
|
{
|
||||||
section_t *section;
|
section_t *section;
|
||||||
va_list args;
|
va_list args;
|
||||||
@@ -443,11 +430,8 @@ static bool kv_filter(void *null, kv_t **in, char **key,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(settings_t, create_key_value_enumerator, enumerator_t*,
|
||||||
* Implementation of settings_t.create_key_value_enumerator
|
private_settings_t *this, char *key, ...)
|
||||||
*/
|
|
||||||
static enumerator_t* create_key_value_enumerator(private_settings_t *this,
|
|
||||||
char *key, ...)
|
|
||||||
{
|
{
|
||||||
section_t *section;
|
section_t *section;
|
||||||
va_list args;
|
va_list args;
|
||||||
@@ -607,10 +591,8 @@ static section_t* parse_section(char **text, char *name)
|
|||||||
return section;
|
return section;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(settings_t, destroy, void,
|
||||||
* Implementation of settings_t.destroy
|
private_settings_t *this)
|
||||||
*/
|
|
||||||
static void destroy(private_settings_t *this)
|
|
||||||
{
|
{
|
||||||
if (this->top)
|
if (this->top)
|
||||||
{
|
{
|
||||||
@@ -630,18 +612,18 @@ settings_t *settings_create(char *file)
|
|||||||
FILE *fd;
|
FILE *fd;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
this = malloc_thing(private_settings_t);
|
INIT(this,
|
||||||
this->public.get_str = (char*(*)(settings_t*, char *key, char* def, ...))get_str;
|
.public = {
|
||||||
this->public.get_int = (int(*)(settings_t*, char *key, int def, ...))get_int;
|
.get_str = _get_str,
|
||||||
this->public.get_double = (double(*)(settings_t*, char *key, double def, ...))get_double;
|
.get_int = _get_int,
|
||||||
this->public.get_time = (u_int32_t(*)(settings_t*, char *key, u_int32_t def, ...))get_time;
|
.get_double = _get_double,
|
||||||
this->public.get_bool = (bool(*)(settings_t*, char *key, bool def, ...))get_bool;
|
.get_time = _get_time,
|
||||||
this->public.create_section_enumerator = (enumerator_t*(*)(settings_t*,char *section, ...))create_section_enumerator;
|
.get_bool = _get_bool,
|
||||||
this->public.create_key_value_enumerator = (enumerator_t*(*)(settings_t*, char *key, ...))create_key_value_enumerator;
|
.create_section_enumerator = _create_section_enumerator,
|
||||||
this->public.destroy = (void(*)(settings_t*))destroy;
|
.create_key_value_enumerator = _create_key_value_enumerator,
|
||||||
|
.destroy = _destroy,
|
||||||
this->top = NULL;
|
},
|
||||||
this->text = NULL;
|
);
|
||||||
|
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user