src/server/config/objconf.c

changeset 628
c95f04c14112
parent 584
f3ddd6dc8e7b
child 629
1e1da9adc532
--- a/src/server/config/objconf.c	Tue Nov 11 16:53:23 2025 +0100
+++ b/src/server/config/objconf.c	Wed Nov 12 18:15:26 2025 +0100
@@ -200,182 +200,3 @@
     free(conf);
 }
 
-
-
-int objconf_parse(void *p, ConfigLine *begin, ConfigLine *end, cxmutstr line) {
-    ObjectConfig *conf = p;
-
-    begin->type = cfg_get_line_type(line);
-    switch(begin->type) {
-        case LINE_BEGIN_TAG: {
-            ConfigTag *tag = cfg_parse_begin_tag(line, conf->parser.a);
-            if(tag == NULL) {
-                ws_cfg_log(LOG_FAILURE, "Parse error in %s", conf->file);
-                exit(-1); // TODO: better error handling
-            }
-            tag->begin = begin;
-            tag->end = end;
-            tag->type_num = cfg_get_tag_type(cx_strcast(tag->name));
-            //printf("line {%s}\n", cx_strdub(ll).ptr);
-            if(objconf_on_begin_tag(conf, tag) != 0) {
-                fprintf(stderr, "1error\n");
-                exit(-1);
-            }
-            break;
-        }
-        case LINE_END_TAG: {
-            cxmutstr tag = cfg_get_end_tag_name(line);
-            if(objconf_on_end_tag(conf, tag) != 0) {
-                fprintf(stderr, "2error\n");
-                exit(-1);
-            }
-
-            break;
-        }
-        case LINE_DIRECTIVE: {
-            ConfigDirective *dir = cfg_parse_directive(
-                    line,
-                    conf->parser.a);
-            dir->begin = begin;
-            dir->end = end;
-            if(objconf_on_directive(conf, dir) != 0) {
-                fprintf(stderr, "3error\n");
-                exit(-1);
-            }
-        }
-    }
-    return 0;
-}
-
-int objconf_on_begin_tag(ObjectConfig *conf, ConfigTag *tag) {
-    CxAllocator *mp = conf->parser.a;
-    if(tag->type_num != TAG_OBJECT) {
-        ConfigParserLevel *l = conf->levels;
-        if(l->tag->type_num != TAG_OBJECT) {
-            tag->parent = l->tag;
-        }
-    }
-    
-
-    switch(tag->type_num) {
-        case TAG_OBJECT: {
-            ConfigObject *obj = OBJ_NEW_N(mp, ConfigObject);
-            obj->begin = tag->begin;
-            obj->end = tag->end;
-            
-            obj->name = cfg_param_get(tag->param, cx_str("name"));
-            obj->ppath = cfg_param_get(tag->param, cx_str("ppath"));
-
-            conf->obj = obj;
-            //conf->objects = ucx_list_append_a(mp, conf->objects, obj);
-            cxListAdd(conf->objects, obj);
-
-            // create tree level object
-            ConfigParserLevel *lvl = OBJ_NEW(mp, ConfigParserLevel);
-            lvl->iftag = NULL;
-            lvl->levelnum = 1;
-            lvl->tag = tag;
-            lvl->next = NULL;
-            //conf->levels = ucx_list_prepend_a(mp, conf->levels, lvl);
-            CFG_LEVEL_PREPEND(&conf->levels, lvl);
-
-            break;
-        }
-        case TAG_IF: {
-            // create tree level object
-            ConfigParserLevel *last_lvl = conf->levels;
-
-            ConfigParserLevel *lvl = OBJ_NEW(mp, ConfigParserLevel);
-            
-            lvl->iftag = NULL;
-            lvl->levelnum = last_lvl->levelnum + 1;
-            lvl->tag = tag;
-            //conf->levels = ucx_list_prepend_a(mp, conf->levels, lvl);
-            CFG_LEVEL_PREPEND(&conf->levels, lvl);
-            last_lvl->iftag = tag;
-
-            break;
-        }
-        case TAG_ELSEIF: {
-        }
-        case TAG_ELSE: {
-            // create tree level object
-            ConfigParserLevel *last_lvl = conf->levels;
-            tag->iftag = last_lvl->iftag;
-
-            ConfigParserLevel *lvl = OBJ_NEW(
-                    conf->parser.a,
-                    ConfigParserLevel);
-            
-            lvl->iftag = last_lvl->tag;
-            lvl->levelnum = last_lvl->levelnum + 1;
-            lvl->tag = tag;
-            //conf->levels = ucx_list_prepend(conf->levels, lvl);
-            CFG_LEVEL_PREPEND(&conf->levels, lvl);
-
-            break;
-        }
-        case TAG_CLIENT: {
-            // create tree level object
-            
-            // TODO
-            
-            break;
-        }
-        default: {
-            ws_cfg_log(LOG_FAILURE, "objconf: unknown tag");
-            return 1;
-        }
-    }
-
-    return 0;
-}
-
-int objconf_on_end_tag(ObjectConfig *conf, cxmutstr tagname) {
-    int type = cfg_get_tag_type(cx_strcast(tagname));
-    if(type == -1) {
-        ws_cfg_log(LOG_FAILURE, "objconf: unknown tag");
-        return 1;
-    } else {
-        if(type == TAG_OBJECT) {
-            conf->obj = NULL;
-        }
-
-        // remove level
-        /*
-        conf->levels = ucx_list_remove_a(
-                conf->parser.mp,
-                conf->levels,
-                conf->levels);
-        */
-        conf->levels = conf->levels->next;
-    }
-    
-    return 0;
-}
-
-int objconf_on_directive(ObjectConfig *conf, ConfigDirective *dir) {
-    ConfigParserLevel *lvl = conf->levels;
-
-    // check if we have a condition for the directive
-    // if the level tag is not an object tag, use it as condition
-    if(lvl->tag->type_num != TAG_OBJECT) {
-        dir->condition = lvl->tag;
-    }
-
-    // add directive to current object
-    /*
-    conf->obj->directives[dir->type_num] = ucx_list_append_a(
-            conf->parser.mp,
-            conf->obj->directives[dir->type_num],
-            dir);
-    */
-    
-    ConfigDirectiveList *dir_entry = cxMalloc(conf->parser.a, sizeof(ConfigDirectiveList));
-    dir_entry->directive = dir;
-    dir_entry->next = NULL;
-    CFG_DIRECTIVES_ADD(&conf->obj->directives[dir->type_num], dir_entry);
-
-    return 0;
-}
-

mercurial