src/server/config/serverconfig.h

changeset 415
d938228c382e
parent 269
3dfbd0b91950
child 417
90805bb9fbd6
--- a/src/server/config/serverconfig.h	Wed Nov 02 19:19:01 2022 +0100
+++ b/src/server/config/serverconfig.h	Sun Nov 06 15:53:32 2022 +0100
@@ -29,27 +29,31 @@
 #ifndef WS_CONFIG_SERVERCONFIG_H
 #define WS_CONFIG_SERVERCONFIG_H
 
-#include <ucx/list.h>
-#include <ucx/map.h>
-#include <ucx/mempool.h>
+#include <cx/linked_list.h>
+#include <cx/hash_map.h>
+#include <cx/mempool.h>
+#include <cx/string.h>
+
+#include "conf.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-
+#define CFG_NODE_ADD(list_begin, list_end, elm) \
+    cx_linked_list_add((void**)list_begin, (void**)list_end, offsetof(ConfigNode, prev), offsetof(ConfigNode, next), elm)
+    
 typedef struct ServerConfig    ServerConfig;
 typedef struct ConfigNode      ConfigNode;
-typedef struct ConfigArg       ConfigArg;
 typedef struct CFGToken        CFGToken;
 
 typedef enum ConfigNodeType    ConfigNodeType;
 typedef enum CFGTokenType      CFGTokenType;
 
 struct ServerConfig {
-    UcxMempool *mp;
+    CxMempool  *mp;
     ConfigNode *root;
-    sstr_t tab;
+    cxmutstr   tab;
 };
 
 enum ConfigNodeType {
@@ -62,21 +66,25 @@
 };
 
 struct ConfigNode {
-    sstr_t text_begin;
-    sstr_t text_end; 
+    cxmutstr text_begin;
+    cxmutstr text_end; 
     ConfigNodeType type;
     
-    sstr_t name;
-    UcxList *args;
-    UcxList *children;
+    cxmutstr name;
+    ConfigParam *args;
+    ConfigNode *children_begin;
+    ConfigNode *children_end;
+    
+    ConfigNode *prev;
+    ConfigNode *next;
 };
 
-struct ConfigArg {
-    sstr_t name;
-    sstr_t value;
+typedef struct ConfigNodeStack ConfigNodeStack;
+struct ConfigNodeStack {
+    ConfigNode      *node;
+    ConfigNodeStack *next;
 };
 
-
 enum CFGTokenType {
     CFG_NO_TOKEN = 0,
     CFG_TOKEN_COMMENT,
@@ -86,23 +94,23 @@
 };
 
 struct CFGToken {
-    scstr_t content;
+    cxstring content;
     CFGTokenType type;
 };
 
 ServerConfig* serverconfig_load(const char *file);
 
-ServerConfig* serverconfig_parse(scstr_t content);
+ServerConfig* serverconfig_parse(cxstring content);
 
 void serverconfig_free(ServerConfig *cfg);
 
-ConfigNode* serverconfig_get_node(ConfigNode *parent, ConfigNodeType type, scstr_t name);
+ConfigNode* serverconfig_get_node(ConfigNode *parent, ConfigNodeType type, cxstring name);
 
-UcxList* serverconfig_get_node_list(ConfigNode *parent, ConfigNodeType type, scstr_t name);
+CxList* serverconfig_get_node_list(ConfigNode *parent, ConfigNodeType type, cxstring name);
 
-scstr_t serverconfig_directive_value(ConfigNode *obj, scstr_t name);
+cxstring serverconfig_directive_value(ConfigNode *obj, cxstring name);
 
-sstr_t serverconfig_arg_name_value(UcxAllocator *a, scstr_t str, scstr_t *name);
+cxmutstr serverconfig_arg_name_value(CxAllocator *a, cxstring str, cxstring *name);
 
 #ifdef __cplusplus
 }

mercurial