-/* ConfigParser.c - NeonServ v5.3
- * Copyright (C) 2011 Philipp Kreil (pk910)
+/* ConfigParser.c - NeonServ v5.4
+ * Copyright (C) 2011-2012 Philipp Kreil (pk910)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
}
if(flags & PARSER_FLAG_COMMAND) {
int found_command = 0;
+ char *tmp_buffer;
switch(*buffer) {
case '/':
- buffer = strstr(buffer, "\n");
+ tmp_buffer = buffer;
+ buffer = strchr(buffer, '\r');
+ if(!buffer)
+ buffer = strchr(tmp_buffer, '\n');
+ if(!buffer)
+ buffer = tmp_buffer + strlen(tmp_buffer)-1;
found_command = 1;
break;
case '*':
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);