Browse Source

* config.[ch] : updated f2b_config_section_append()

master
Alex 'AdUser' Z 9 years ago
parent
commit
db1118f9cf
  1. 22
      src/config.c

22
src/config.c

@ -135,13 +135,27 @@ f2b_config_section_find(f2b_config_section_t *section, const char *name) {
f2b_config_section_t * f2b_config_section_t *
f2b_config_section_append(f2b_config_section_t *section, f2b_config_param_t *param) { f2b_config_section_append(f2b_config_section_t *section, f2b_config_param_t *param) {
if (section->param) { f2b_config_param_t *prev = NULL;
section->last->next = param;
section->last = section->last->next; assert(section != NULL);
} else { assert(param != NULL);
if (!section->param) {
/* no parameters yet */
section->param = param; section->param = param;
section->last = param; section->last = param;
return section;
} }
if ((prev = f2b_config_param_find(section->param, param->name)) != NULL) {
/* found param with same name */
strncpy(prev->value, param->value, sizeof(prev->value));
free(param);
return section;
}
section->last->next = param;
section->last = param;
return section; return section;
} }

Loading…
Cancel
Save