removed trailing spaces ([[:space:]]+$)
This commit is contained in:
@@ -38,12 +38,12 @@ struct private_settings_t {
|
||||
* public functions
|
||||
*/
|
||||
settings_t public;
|
||||
|
||||
|
||||
/**
|
||||
* top level section
|
||||
*/
|
||||
section_t *top;
|
||||
|
||||
|
||||
/**
|
||||
* allocated file text
|
||||
*/
|
||||
@@ -64,7 +64,7 @@ struct section_t {
|
||||
* subsections, as section_t
|
||||
*/
|
||||
linked_list_t *sections;
|
||||
|
||||
|
||||
/**
|
||||
* key value pairs, as kv_t
|
||||
*/
|
||||
@@ -80,7 +80,7 @@ struct kv_t {
|
||||
* key string, relative
|
||||
*/
|
||||
char *key;
|
||||
|
||||
|
||||
/**
|
||||
* value as string
|
||||
*/
|
||||
@@ -95,7 +95,7 @@ static section_t *find_section(section_t *section, char *key, va_list args)
|
||||
char name[512], *pos;
|
||||
enumerator_t *enumerator;
|
||||
section_t *current, *found = NULL;
|
||||
|
||||
|
||||
if (section == NULL)
|
||||
{
|
||||
return NULL;
|
||||
@@ -104,7 +104,7 @@ static section_t *find_section(section_t *section, char *key, va_list args)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
pos = strchr(name, '.');
|
||||
if (pos)
|
||||
{
|
||||
@@ -134,17 +134,17 @@ static char *find_value(section_t *section, char *key, va_list args)
|
||||
enumerator_t *enumerator;
|
||||
kv_t *kv;
|
||||
section_t *current, *found = NULL;
|
||||
|
||||
|
||||
if (section == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (vsnprintf(name, sizeof(name), key, args) >= sizeof(name))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
pos = strchr(name, '.');
|
||||
if (pos)
|
||||
{
|
||||
@@ -188,7 +188,7 @@ static char* get_str(private_settings_t *this, char *key, char *def, ...)
|
||||
{
|
||||
char *value;
|
||||
va_list args;
|
||||
|
||||
|
||||
va_start(args, def);
|
||||
value = find_value(this->top, key, args);
|
||||
va_end(args);
|
||||
@@ -206,7 +206,7 @@ static bool get_bool(private_settings_t *this, char *key, bool def, ...)
|
||||
{
|
||||
char *value;
|
||||
va_list args;
|
||||
|
||||
|
||||
va_start(args, def);
|
||||
value = find_value(this->top, key, args);
|
||||
va_end(args);
|
||||
@@ -238,7 +238,7 @@ static int get_int(private_settings_t *this, char *key, int def, ...)
|
||||
char *value;
|
||||
int intval;
|
||||
va_list args;
|
||||
|
||||
|
||||
va_start(args, def);
|
||||
value = find_value(this->top, key, args);
|
||||
va_end(args);
|
||||
@@ -262,7 +262,7 @@ static u_int32_t get_time(private_settings_t *this, char *key, u_int32_t def, ..
|
||||
char *value, *endptr;
|
||||
u_int32_t timeval;
|
||||
va_list args;
|
||||
|
||||
|
||||
va_start(args, def);
|
||||
value = find_value(this->top, key, args);
|
||||
va_end(args);
|
||||
@@ -310,13 +310,13 @@ static enumerator_t* create_section_enumerator(private_settings_t *this,
|
||||
{
|
||||
section_t *section;
|
||||
va_list args;
|
||||
|
||||
|
||||
va_start(args, key);
|
||||
section = find_section(this->top, key, args);
|
||||
va_end(args);
|
||||
|
||||
|
||||
if (!section)
|
||||
{
|
||||
{
|
||||
return enumerator_create_empty();
|
||||
}
|
||||
return enumerator_create_filter(
|
||||
@@ -331,7 +331,7 @@ static void section_destroy(section_t *this)
|
||||
{
|
||||
this->kv->destroy_function(this->kv, free);
|
||||
this->sections->destroy_function(this->sections, (void*)section_destroy);
|
||||
|
||||
|
||||
free(this);
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ static char parse(char **text, char *skip, char *term, char *br, char **token)
|
||||
{
|
||||
char *pos = *text;
|
||||
int level = 1;
|
||||
|
||||
|
||||
/* find terminator */
|
||||
while (*pos)
|
||||
{
|
||||
@@ -417,15 +417,15 @@ static section_t* parse_section(char **text, char *name)
|
||||
section_t *sub, *section;
|
||||
bool finished = FALSE;
|
||||
char *key, *value, *inner;
|
||||
|
||||
|
||||
static int lev = 0;
|
||||
lev++;
|
||||
|
||||
|
||||
section = malloc_thing(section_t);
|
||||
section->name = name;
|
||||
section->sections = linked_list_create();
|
||||
section->kv = linked_list_create();
|
||||
|
||||
|
||||
while (!finished)
|
||||
{
|
||||
switch (parse(text, "\t\n ", "{=#", NULL, &key))
|
||||
@@ -485,23 +485,23 @@ static void destroy(private_settings_t *this)
|
||||
settings_t *settings_create(char *file)
|
||||
{
|
||||
private_settings_t *this = malloc_thing(private_settings_t);
|
||||
|
||||
|
||||
this->public.get_str = (char*(*)(settings_t*, char *key, char* def, ...))get_str;
|
||||
this->public.get_int = (int(*)(settings_t*, char *key, int def, ...))get_int;
|
||||
this->public.get_time = (u_int32_t(*)(settings_t*, char *key, u_int32_t def, ...))get_time;
|
||||
this->public.get_bool = (bool(*)(settings_t*, char *key, bool def, ...))get_bool;
|
||||
this->public.create_section_enumerator = (enumerator_t*(*)(settings_t*,char *section, ...))create_section_enumerator;
|
||||
this->public.destroy = (void(*)(settings_t*))destroy;
|
||||
|
||||
|
||||
this->top = NULL;
|
||||
this->text = NULL;
|
||||
|
||||
|
||||
if (file)
|
||||
{
|
||||
FILE *fd;
|
||||
int len;
|
||||
char *pos;
|
||||
|
||||
|
||||
fd = fopen(file, "r");
|
||||
if (fd == NULL)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user