X-Git-Url: http://git.pk910.de/?p=NeonServV5.git;a=blobdiff_plain;f=src%2FConfigParser.c;h=bbf479131800b177e0331cc9828f4c4791057d89;hp=8ce6cde088e3758123259395873bc9a522510bee;hb=902ebfe5551be2daa3edf8141bcee91f62c0a5e0;hpb=8a990d2c87f8f8a6ca26dd2c6afef161dab2eb9e diff --git a/src/ConfigParser.c b/src/ConfigParser.c index 8ce6cde..bbf4791 100644 --- a/src/ConfigParser.c +++ b/src/ConfigParser.c @@ -299,6 +299,52 @@ char *get_string_field(char *field_path) { return NULL; } +char **get_all_fieldnames(char *block_path) { + struct ConfigEntry *centry = root_entry; + char *a, *b = block_path; + struct ConfigEntry *subentry; + while((a = strstr(b, ".")) && centry) { + if(centry->type == ENTRYTYPE_BLOCK) { + int found = 0; + for(subentry = centry->value; subentry; subentry = subentry->next) { + if(!stricmplen(subentry->name, b, a-b)) { + centry = subentry; + found = 1; + break; + } + } + if(!found) + return NULL; + } else + return NULL; + b = a+1; + } + if(centry->type == ENTRYTYPE_BLOCK) { + int found = 0; + for(subentry = centry->value; subentry; subentry = subentry->next) { + if(!stricmp(subentry->name, b)) { + centry = subentry; + found = 1; + break; + } + } + if(!found) + return NULL; + } else + return NULL; + if(centry->type != ENTRYTYPE_BLOCK) return NULL; + int count = 0; + for(subentry = centry->value; subentry; subentry = subentry->next) { + count++; + } + char **fieldnames = calloc(count+1, sizeof(char *)); + count = 0; + for(subentry = centry->value; subentry; subentry = subentry->next) { + fieldnames[count++] = subentry->name; + } + return fieldnames; +} + void free_loaded_config() { if(root_entry) { free_entry_rekursiv(root_entry, 1);