src/server/config/serverconfig.c

changeset 631
867b1026b0de
parent 584
f3ddd6dc8e7b
child 635
b85d45fd3b01
equal deleted inserted replaced
630:aae6e06d70b8 631:867b1026b0de
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 }
121 int comment = 0; 121 int comment = 0;
122 122
123 int i; 123 int i;
124 char prev = 0; 124 char prev = 0;
125 for(i=start;i<content.length;i++) { 125 for(i=start;i<content.length;i++) {
126 char c = content.ptr[i]; 126 char c = content.ptr[i];
127 if(c == '\n') { 127 if(c == '\n') {
128 if(quote) { 128 if(quote) {
129 *pos = i; 129 *pos = i;
130 ws_cfg_log( 130 ws_cfg_log(
131 LOG_FAILURE, 131 LOG_FAILURE,
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

mercurial