diff -r 0de4a90979e1 -r d25825f37967 src/server/config/serverconf.c --- a/src/server/config/serverconf.c Wed Jun 26 17:14:45 2013 +0200 +++ b/src/server/config/serverconf.c Fri Jun 28 14:52:35 2013 +0200 @@ -114,3 +114,52 @@ } return 0; } + + +UcxList* srvcfg_get_listeners(ServerConfig *cfg, UcxMempool *mp, int *error) { + mp = mp ? mp : cfg->parser.mp; + + UcxList *list = ucx_map_sstr_get(cfg->objects, sstrn("Listener", 8)); + UcxList *lslist = NULL; + UCX_FOREACH(UcxList*, list, elm) { + ServerConfigObject *ls = elm->data; + sstr_t name = cfg_directivelist_get_str(ls->directives, sstr("Name")); + sstr_t port = cfg_directivelist_get_str(ls->directives, sstr("Port")); + sstr_t vs = cfg_directivelist_get_str( + ls->directives, + sstr("DefaultVS")); + sstr_t threadpool = cfg_directivelist_get_str( + ls->directives, + sstr("Threadpool")); + + CfgListener *listener = ucx_mempool_calloc(mp, 1, sizeof(CfgListener)); + // threadpool is optional, all other configs must be set + if(!name.ptr || !port.ptr || !vs.ptr) { + // TODO: log error + *error = 1; + listener->cfg_correct = 0; + } else { + listener->cfg_correct = 1; + } + + if(name.ptr) { + listener->name = sstrdup_mp(mp, name); + } + if(port.ptr) { + // don't expect that port is null terminated, sstrdup it to be sure + sstr_t portdp = sstrdup(port); + listener->port = atoi(portdp.ptr); + free(portdp.ptr); + } + if(vs.ptr) { + listener->vs = sstrdup_mp(mp, vs); + } + if(threadpool.ptr) { + listener->threadpool = sstrdup_mp(mp, threadpool); + } + + lslist = cfg_list_append(mp, lslist, listener); + } + + return lslist; +}