| 48 ConfigParser2 parser; |
48 ConfigParser2 parser; |
| 49 memset(&parser, 0, sizeof(ConfigParser2)); |
49 memset(&parser, 0, sizeof(ConfigParser2)); |
| 50 parser.mp = mp; |
50 parser.mp = mp; |
| 51 parser.filename = file; |
51 parser.filename = file; |
| 52 parser.allow_hierarchy = true; |
52 parser.allow_hierarchy = true; |
| 53 parser.delim = ""; |
53 parser.delim = "{}"; |
| 54 ConfigNode *root = serverconfig_load_file(&parser, file); |
54 ConfigNode *root = serverconfig_load_file(&parser, file); |
| 55 if(!root) { |
55 if(!root) { |
| 56 cxMempoolFree(mp); |
56 cxMempoolFree(mp); |
| 57 return NULL; |
57 return NULL; |
| 58 } |
58 } |
| 300 |
300 |
| 301 int text_start = 0; |
301 int text_start = 0; |
| 302 int err = 0; |
302 int err = 0; |
| 303 while((token = get_next_token(parser, content, &pos)).type != CFG_NO_TOKEN) { |
303 while((token = get_next_token(parser, content, &pos)).type != CFG_NO_TOKEN) { |
| 304 //printf("[%.*s]\n", (int)token.content.length, token.content.ptr); fflush(stdout); |
304 //printf("[%.*s]\n", (int)token.content.length, token.content.ptr); fflush(stdout); |
| 305 |
|
| 306 switch(token.type) { |
305 switch(token.type) { |
| 307 case CFG_NO_TOKEN: break; |
306 case CFG_NO_TOKEN: break; |
| 308 case CFG_TOKEN_COMMENT: { |
307 case CFG_TOKEN_COMMENT: { |
| 309 if(current->type == CONFIG_NODE_SPACE) { |
308 if(current->type == CONFIG_NODE_SPACE) { |
| 310 current->type = CONFIG_NODE_COMMENT; |
309 current->type = CONFIG_NODE_COMMENT; |
| 329 err = 1; |
328 err = 1; |
| 330 break; |
329 break; |
| 331 } |
330 } |
| 332 // done with this object, remove it from the stack |
331 // done with this object, remove it from the stack |
| 333 ConfigNodeStack *remove_item = node_stack; |
332 ConfigNodeStack *remove_item = node_stack; |
| |
333 if(!node_stack) { |
| |
334 err = 1; |
| |
335 break; |
| |
336 } |
| 334 node_stack = node_stack->next; |
337 node_stack = node_stack->next; |
| 335 cxFree(a, remove_item); |
338 cxFree(a, remove_item); |
| 336 } else if(current->type == CONFIG_NODE_OPEN_OBJECT) { |
339 } else if(current->type == CONFIG_NODE_OPEN_OBJECT) { |
| 337 // newline after a object is opened with '{' |
340 // newline after a object is opened with '{' |
| 338 // append '{' to the object text |
341 // append '{' to the object text |