src/server/config/serverconf.c

branch
config
changeset 253
ddfead6ea863
parent 115
51d9a15eac98
child 254
4784c14aa639
equal deleted inserted replaced
210:21274e5950af 253:ddfead6ea863
114 } 114 }
115 return 0; 115 return 0;
116 } 116 }
117 117
118 118
119 UcxList* srvcfg_get_listeners(ServerConfig *cfg, UcxAllocator *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(elm, list) {
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 = OBJ_NEW_N(mp, 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_a(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_a(mp, vs);
156 }
157 if(threadpool.ptr) {
158 listener->threadpool = sstrdup_a(mp, threadpool);
159 }
160
161 lslist = ucx_list_append_a(mp, lslist, listener);
162 }
163
164 return lslist;
165 }

mercurial