src/server/config/serverconf.c

changeset 81
d25825f37967
parent 79
f48cea237ec3
child 88
73b3485e96f1
equal deleted inserted replaced
80:0de4a90979e1 81:d25825f37967
112 conf->obj->directives = cfg_dlist_append(mp, conf->obj->directives, d); 112 conf->obj->directives = cfg_dlist_append(mp, conf->obj->directives, d);
113 } 113 }
114 } 114 }
115 return 0; 115 return 0;
116 } 116 }
117
118
119 UcxList* srvcfg_get_listeners(ServerConfig *cfg, UcxMempool *mp, int *error) {
120 mp = mp ? mp : cfg->parser.mp;
121
122 UcxList *list = ucx_map_sstr_get(cfg->objects, sstrn("Listener", 8));
123 UcxList *lslist = NULL;
124 UCX_FOREACH(UcxList*, list, elm) {
125 ServerConfigObject *ls = elm->data;
126 sstr_t name = cfg_directivelist_get_str(ls->directives, sstr("Name"));
127 sstr_t port = cfg_directivelist_get_str(ls->directives, sstr("Port"));
128 sstr_t vs = cfg_directivelist_get_str(
129 ls->directives,
130 sstr("DefaultVS"));
131 sstr_t threadpool = cfg_directivelist_get_str(
132 ls->directives,
133 sstr("Threadpool"));
134
135 CfgListener *listener = ucx_mempool_calloc(mp, 1, sizeof(CfgListener));
136 // threadpool is optional, all other configs must be set
137 if(!name.ptr || !port.ptr || !vs.ptr) {
138 // TODO: log error
139 *error = 1;
140 listener->cfg_correct = 0;
141 } else {
142 listener->cfg_correct = 1;
143 }
144
145 if(name.ptr) {
146 listener->name = sstrdup_mp(mp, name);
147 }
148 if(port.ptr) {
149 // don't expect that port is null terminated, sstrdup it to be sure
150 sstr_t portdp = sstrdup(port);
151 listener->port = atoi(portdp.ptr);
152 free(portdp.ptr);
153 }
154 if(vs.ptr) {
155 listener->vs = sstrdup_mp(mp, vs);
156 }
157 if(threadpool.ptr) {
158 listener->threadpool = sstrdup_mp(mp, threadpool);
159 }
160
161 lslist = cfg_list_append(mp, lslist, listener);
162 }
163
164 return lslist;
165 }

mercurial