32 #include "conf.h" |
32 #include "conf.h" |
33 |
33 |
34 #ifdef __cplusplus |
34 #ifdef __cplusplus |
35 extern "C" { |
35 extern "C" { |
36 #endif |
36 #endif |
37 |
37 |
|
38 #define CFG_LEVEL_PREPEND(list, level) \ |
|
39 cx_linked_list_prepend((void**)list, NULL, -1, offsetof(ConfigParserLevel, next), level) |
|
40 |
38 typedef struct _conf_object { |
41 typedef struct _conf_object { |
39 ConfigLine *begin; |
42 ConfigLine *begin; |
40 ConfigLine *end; |
43 ConfigLine *end; |
41 |
44 |
42 sstr_t name; |
45 cxmutstr name; |
43 sstr_t ppath; |
46 cxmutstr ppath; |
44 // directives |
47 // directives |
45 UcxList *directives[7]; |
48 ConfigDirectiveList *directives[7]; |
46 } ConfigObject; |
49 } ConfigObject; |
47 |
50 |
48 /* |
51 /* |
49 * representing a xml like level in the obj.conf tree |
52 * representing a xml like level in the obj.conf tree |
50 */ |
53 */ |
51 typedef struct _conf_parser_level { |
54 typedef struct ConfigParserLevel ConfigParserLevel; |
|
55 struct ConfigParserLevel { |
52 ConfigTag *iftag; // last if tag |
56 ConfigTag *iftag; // last if tag |
53 ConfigTag *tag; // root of this level |
57 ConfigTag *tag; // root of this level |
54 int levelnum; |
58 int levelnum; |
55 } ConfigParserLevel; |
59 ConfigParserLevel *next; |
|
60 }; |
56 |
61 |
57 typedef struct _obj_conf { |
62 typedef struct _obj_conf { |
58 ConfigParser parser; |
63 ConfigParser parser; |
59 char *file; |
64 char *file; |
60 //UcxDlist *lines; |
65 //UcxDlist *lines; |
61 UcxList *conditions; |
66 //UcxList *conditions; |
62 UcxList *objects; |
67 CxList *objects; |
63 |
68 |
64 // private parser temp var |
69 // private parser temp var |
65 ConfigObject *obj; // add directives to this object |
70 ConfigObject *obj; // add directives to this object |
66 // private parser temp var |
71 // private parser temp var |
67 UcxList *levels; // tree levels (stack) |
72 ConfigParserLevel *levels; // tree levels (stack) |
68 |
73 |
69 } ObjectConfig; |
74 } ObjectConfig; |
70 |
75 |
71 ObjectConfig *load_object_config(char *file); |
76 ObjectConfig *load_object_config(char *file); |
72 |
77 |
73 void free_object_config(ObjectConfig *conf); |
78 void free_object_config(ObjectConfig *conf); |
74 |
79 |
75 int objconf_parse(void *p, ConfigLine *begin, ConfigLine *end, sstr_t line); |
80 int objconf_parse(void *p, ConfigLine *begin, ConfigLine *end, cxmutstr line); |
76 |
81 |
77 int objconf_on_begin_tag(ObjectConfig *conf, ConfigTag *tag); |
82 int objconf_on_begin_tag(ObjectConfig *conf, ConfigTag *tag); |
78 |
83 |
79 int objconf_on_end_tag(ObjectConfig *conf, sstr_t tagname); |
84 int objconf_on_end_tag(ObjectConfig *conf, cxmutstr tagname); |
80 |
85 |
81 int objconf_on_directive(ObjectConfig *conf, ConfigDirective *dir); |
86 int objconf_on_directive(ObjectConfig *conf, ConfigDirective *dir); |
82 |
87 |
83 |
88 |
84 #ifdef __cplusplus |
89 #ifdef __cplusplus |