52 parser.filename = file; |
52 parser.filename = file; |
53 parser.allow_hierarchy = true; |
53 parser.allow_hierarchy = true; |
54 parser.delim = ""; |
54 parser.delim = ""; |
55 ConfigNode *root = serverconfig_load_file(&parser, file); |
55 ConfigNode *root = serverconfig_load_file(&parser, file); |
56 if(!root) { |
56 if(!root) { |
57 cxMempoolDestroy(mp); |
57 cxMempoolFree(mp); |
58 return NULL; |
58 return NULL; |
59 } |
59 } |
60 |
60 |
61 ServerConfig *scfg = cxMalloc(mp->allocator, sizeof(ServerConfig)); |
61 ServerConfig *scfg = cxMalloc(mp->allocator, sizeof(ServerConfig)); |
62 if(!scfg) { |
62 if(!scfg) { |
63 cxMempoolDestroy(mp); |
63 cxMempoolFree(mp); |
64 return NULL; |
64 return NULL; |
65 } |
65 } |
66 scfg->root = root; |
66 scfg->root = root; |
67 scfg->mp = mp; |
67 scfg->mp = mp; |
68 scfg->tab = cx_str("\t"); |
68 scfg->tab = cx_str("\t"); |
449 //test_print_config(&root_obj); |
449 //test_print_config(&root_obj); |
450 return root_obj; |
450 return root_obj; |
451 } |
451 } |
452 |
452 |
453 void serverconfig_free(ServerConfig *cfg) { |
453 void serverconfig_free(ServerConfig *cfg) { |
454 cxMempoolDestroy(cfg->mp); |
454 cxMempoolFree(cfg->mp); |
455 } |
455 } |
456 |
456 |
457 ConfigNode* serverconfig_get_node(ConfigNode *parent, ConfigNodeType type, cxstring name) { |
457 ConfigNode* serverconfig_get_node(ConfigNode *parent, ConfigNodeType type, cxstring name) { |
458 for(ConfigNode *node=parent->children_begin;node;node=node->next) { |
458 for(ConfigNode *node=parent->children_begin;node;node=node->next) { |
459 if(node->type == type && !cx_strcasecmp(cx_strcast(node->name), name)) { |
459 if(node->type == type && !cx_strcasecmp(cx_strcast(node->name), name)) { |