1 /* This file is part of Pazpar2.
2 Copyright (C) 2006-2010 Index Data
4 Pazpar2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 #include <libxml/parser.h>
28 #include <libxml/tree.h>
30 #include <yaz/yaz-util.h>
32 #include <yaz/snprintf.h>
33 #include <yaz/tpath.h>
36 #define USE_POSIX_GLOB 1
38 #define USE_POSIX_GLOB 0
45 #include <sys/types.h>
50 #include "pazpar2_config.h"
57 NMEM nmem; /* for conf_config and servers memory */
58 struct conf_server *servers;
63 static char *parse_settings(struct conf_config *config,
64 NMEM nmem, xmlNode *node);
66 static struct conf_targetprofiles *parse_targetprofiles(NMEM nmem,
69 static void conf_metadata_assign(NMEM nmem,
70 struct conf_metadata * metadata,
72 enum conf_metadata_type type,
73 enum conf_metadata_merge merge,
74 enum conf_setting_type setting,
79 enum conf_metadata_mergekey mt)
81 assert(nmem && metadata && name);
83 metadata->name = nmem_strdup(nmem, name);
85 metadata->type = type;
87 // enforcing that type_year is always range_merge
88 if (metadata->type == Metadata_type_year)
89 metadata->merge = Metadata_merge_range;
91 metadata->merge = merge;
93 metadata->setting = setting;
94 metadata->brief = brief;
95 metadata->termlist = termlist;
96 metadata->rank = rank;
97 metadata->sortkey_offset = sortkey_offset;
98 metadata->mergekey = mt;
102 static void conf_sortkey_assign(NMEM nmem,
103 struct conf_sortkey * sortkey,
105 enum conf_sortkey_type type)
107 assert(nmem && sortkey && name);
109 sortkey->name = nmem_strdup(nmem, name);
110 sortkey->type = type;
114 static struct conf_service *service_init(struct conf_server *server,
115 int num_metadata, int num_sortkeys,
116 const char *service_id)
118 struct conf_service * service = 0;
119 NMEM nmem = nmem_create();
121 service = nmem_malloc(nmem, sizeof(struct conf_service));
122 service->ref_count = 1;
123 service->nmem = nmem;
125 service->settings = 0;
126 service->databases = 0;
127 service->targetprofiles = 0;
128 service->server = server;
129 service->session_timeout = 60; /* default session timeout */
130 service->z3950_session_timeout = 180;
131 service->z3950_operation_timeout = 30;
133 service->relevance_pct = 0;
134 service->sort_pct = 0;
135 service->mergekey_pct = 0;
137 service->id = service_id ? nmem_strdup(nmem, service_id) : 0;
138 service->num_metadata = num_metadata;
139 service->metadata = 0;
140 if (service->num_metadata)
143 sizeof(struct conf_metadata) * service->num_metadata);
144 service->num_sortkeys = num_sortkeys;
145 service->sortkeys = 0;
146 if (service->num_sortkeys)
149 sizeof(struct conf_sortkey) * service->num_sortkeys);
150 service->dictionary = 0;
154 static struct conf_metadata* conf_service_add_metadata(
155 struct conf_service *service,
158 enum conf_metadata_type type,
159 enum conf_metadata_merge merge,
160 enum conf_setting_type setting,
165 enum conf_metadata_mergekey mt)
167 struct conf_metadata * md = 0;
169 if (!service || !service->metadata || !service->num_metadata
170 || field_id < 0 || !(field_id < service->num_metadata))
173 md = service->metadata + field_id;
174 conf_metadata_assign(service->nmem, md, name, type, merge, setting,
175 brief, termlist, rank, sortkey_offset,
181 static struct conf_sortkey * conf_service_add_sortkey(
182 struct conf_service *service,
185 enum conf_sortkey_type type)
187 struct conf_sortkey * sk = 0;
189 if (!service || !service->sortkeys || !service->num_sortkeys
190 || field_id < 0 || !(field_id < service->num_sortkeys))
193 //sk = &((service->sortkeys)[field_id]);
194 sk = service->sortkeys + field_id;
195 conf_sortkey_assign(service->nmem, sk, name, type);
201 int conf_service_metadata_field_id(struct conf_service *service,
206 if (!service || !service->metadata || !service->num_metadata)
209 for(i = 0; i < service->num_metadata; i++) {
210 if (!strcmp(name, (service->metadata[i]).name))
218 int conf_service_sortkey_field_id(struct conf_service *service,
223 if (!service || !service->sortkeys || !service->num_sortkeys)
226 for(i = 0; i < service->num_sortkeys; i++) {
227 if (!strcmp(name, (service->sortkeys[i]).name))
234 static void conf_dir_path(struct conf_config *config, WRBUF w, const char *src)
236 if (config->confdir && wrbuf_len(config->confdir) > 0 &&
237 !yaz_is_abspath(src))
239 wrbuf_printf(w, "%s/%s", wrbuf_cstr(config->confdir), src);
245 void service_destroy(struct conf_service *service)
249 assert(service->ref_count > 0);
250 service->ref_count--;
251 if (service->ref_count == 0)
253 pp2_charset_destroy(service->relevance_pct);
254 pp2_charset_destroy(service->sort_pct);
255 pp2_charset_destroy(service->mergekey_pct);
256 nmem_destroy(service->nmem);
261 void service_incref(struct conf_service *service)
263 service->ref_count++;
266 static int parse_metadata(struct conf_service *service, xmlNode *n,
267 int *md_node, int *sk_node)
269 xmlChar *xml_name = xmlGetProp(n, (xmlChar *) "name");
270 xmlChar *xml_brief = xmlGetProp(n, (xmlChar *) "brief");
271 xmlChar *xml_sortkey = xmlGetProp(n, (xmlChar *) "sortkey");
272 xmlChar *xml_merge = xmlGetProp(n, (xmlChar *) "merge");
273 xmlChar *xml_type = xmlGetProp(n, (xmlChar *) "type");
274 xmlChar *xml_termlist = xmlGetProp(n, (xmlChar *) "termlist");
275 xmlChar *xml_rank = xmlGetProp(n, (xmlChar *) "rank");
276 xmlChar *xml_setting = xmlGetProp(n, (xmlChar *) "setting");
277 xmlChar *xml_mergekey = xmlGetProp(n, (xmlChar *) "mergekey");
279 enum conf_metadata_type type = Metadata_type_generic;
280 enum conf_metadata_merge merge = Metadata_merge_no;
281 enum conf_setting_type setting = Metadata_setting_no;
282 enum conf_sortkey_type sk_type = Metadata_sortkey_relevance;
283 enum conf_metadata_mergekey mergekey_type = Metadata_mergekey_no;
287 int sortkey_offset = 0;
289 // now do the parsing logic
292 yaz_log(YLOG_FATAL, "Must specify name in metadata element");
297 if (!strcmp((const char *) xml_brief, "yes"))
299 else if (strcmp((const char *) xml_brief, "no"))
301 yaz_log(YLOG_FATAL, "metadata/brief must be yes or no");
310 if (!strcmp((const char *) xml_termlist, "yes"))
312 else if (strcmp((const char *) xml_termlist, "no"))
314 yaz_log(YLOG_FATAL, "metadata/termlist must be yes or no");
322 rank = atoi((const char *) xml_rank);
328 if (!strcmp((const char *) xml_type, "generic"))
329 type = Metadata_type_generic;
330 else if (!strcmp((const char *) xml_type, "year"))
331 type = Metadata_type_year;
332 else if (!strcmp((const char *) xml_type, "date"))
333 type = Metadata_type_date;
337 "Unknown value for metadata/type: %s", xml_type);
342 type = Metadata_type_generic;
346 if (!strcmp((const char *) xml_merge, "no"))
347 merge = Metadata_merge_no;
348 else if (!strcmp((const char *) xml_merge, "unique"))
349 merge = Metadata_merge_unique;
350 else if (!strcmp((const char *) xml_merge, "longest"))
351 merge = Metadata_merge_longest;
352 else if (!strcmp((const char *) xml_merge, "range"))
353 merge = Metadata_merge_range;
354 else if (!strcmp((const char *) xml_merge, "all"))
355 merge = Metadata_merge_all;
359 "Unknown value for metadata/merge: %s", xml_merge);
364 merge = Metadata_merge_no;
368 if (!strcmp((const char *) xml_setting, "no"))
369 setting = Metadata_setting_no;
370 else if (!strcmp((const char *) xml_setting, "postproc"))
371 setting = Metadata_setting_postproc;
372 else if (!strcmp((const char *) xml_setting, "parameter"))
373 setting = Metadata_setting_parameter;
377 "Unknown value for medadata/setting: %s", xml_setting);
382 // add a sortkey if so specified
383 if (xml_sortkey && strcmp((const char *) xml_sortkey, "no"))
385 if (merge == Metadata_merge_no)
388 "Can't specify sortkey on a non-merged field");
391 if (!strcmp((const char *) xml_sortkey, "numeric"))
392 sk_type = Metadata_sortkey_numeric;
393 else if (!strcmp((const char *) xml_sortkey, "skiparticle"))
394 sk_type = Metadata_sortkey_skiparticle;
398 "Unknown sortkey in metadata element: %s",
402 sortkey_offset = *sk_node;
404 conf_service_add_sortkey(service, *sk_node,
405 (const char *) xml_name, sk_type);
414 if (!strcmp((const char *) xml_mergekey, "required"))
415 mergekey_type = Metadata_mergekey_required;
416 else if (!strcmp((const char *) xml_mergekey, "optional"))
417 mergekey_type = Metadata_mergekey_optional;
418 else if (!strcmp((const char *) xml_mergekey, "no"))
419 mergekey_type = Metadata_mergekey_no;
422 yaz_log(YLOG_FATAL, "Unknown value for mergekey: %s", xml_mergekey);
428 // metadata known, assign values
429 conf_service_add_metadata(service, *md_node,
430 (const char *) xml_name,
431 type, merge, setting,
432 brief, termlist, rank, sortkey_offset,
437 xmlFree(xml_sortkey);
440 xmlFree(xml_termlist);
442 xmlFree(xml_setting);
443 xmlFree(xml_mergekey);
448 static struct conf_service *service_create_static(struct conf_server *server,
450 const char *service_id)
456 struct conf_service *service = 0;
457 int num_metadata = 0;
458 int num_sortkeys = 0;
459 int got_settings = 0;
461 // count num_metadata and num_sortkeys
462 for (n = node->children; n; n = n->next)
463 if (n->type == XML_ELEMENT_NODE && !strcmp((const char *)
464 n->name, "metadata"))
466 xmlChar *sortkey = xmlGetProp(n, (xmlChar *) "sortkey");
468 if (sortkey && strcmp((const char *) sortkey, "no"))
473 service = service_init(server, num_metadata, num_sortkeys, service_id);
475 for (n = node->children; n; n = n->next)
477 if (n->type != XML_ELEMENT_NODE)
479 if (!strcmp((const char *) n->name, "timeout"))
481 xmlChar *src = xmlGetProp(n, (xmlChar *) "session");
484 service->session_timeout = atoi((const char *) src);
486 if (service->session_timeout < 9)
488 yaz_log(YLOG_FATAL, "session timeout out of range");
492 src = xmlGetProp(n, (xmlChar *) "z3950_operation");
495 service->z3950_operation_timeout = atoi((const char *) src);
497 if (service->z3950_session_timeout < 9)
499 yaz_log(YLOG_FATAL, "Z39.50 operation timeout out of range");
503 src = xmlGetProp(n, (xmlChar *) "z3950_session");
506 service->z3950_session_timeout = atoi((const char *) src);
508 if (service->z3950_session_timeout < 9)
510 yaz_log(YLOG_FATAL, "Z39.50 session timeout out of range");
515 else if (!strcmp((const char *) n->name, "settings"))
517 else if (!strcmp((const char *) n->name, (const char *) "targetprofiles"))
519 if (service->targetprofiles)
521 yaz_log(YLOG_FATAL, "Can't repeat targetprofiles");
524 if (!(service->targetprofiles =
525 parse_targetprofiles(service->nmem, n)))
528 else if (!strcmp((const char *) n->name, "relevance"))
530 if (service->relevance_pct)
532 yaz_log(YLOG_LOG, "relevance may not repeat in service");
537 service->relevance_pct = pp2_charset_create_xml(n);
538 if (!service->relevance_pct)
542 else if (!strcmp((const char *) n->name, "sort"))
544 if (service->sort_pct)
546 yaz_log(YLOG_LOG, "sort may not repeat in service");
551 service->sort_pct = pp2_charset_create_xml(n);
552 if (!service->sort_pct)
556 else if (!strcmp((const char *) n->name, "mergekey"))
558 if (service->mergekey_pct)
560 yaz_log(YLOG_LOG, "mergekey may not repeat in service");
565 service->mergekey_pct = pp2_charset_create_xml(n);
566 if (!service->mergekey_pct)
570 else if (!strcmp((const char *) n->name, (const char *) "metadata"))
572 if (parse_metadata(service, n, &md_node, &sk_node))
577 yaz_log(YLOG_FATAL, "Bad element: %s", n->name);
584 /* metadata has been read.. Consider now settings */
585 init_settings(service);
586 for (pass = 1; pass <= 2; pass++)
588 for (n = node->children; n; n = n->next)
590 if (n->type != XML_ELEMENT_NODE)
592 if (!strcmp((const char *) n->name, "settings"))
594 xmlChar *src = xmlGetProp(n, (xmlChar *) "src");
597 WRBUF w = wrbuf_alloc();
598 conf_dir_path(server->config, w, (const char *) src);
599 settings_read_file(service, wrbuf_cstr(w), pass);
605 settings_read_node(service, n, pass);
614 static char *parse_settings(struct conf_config *config,
615 NMEM nmem, xmlNode *node)
617 xmlChar *src = xmlGetProp(node, (xmlChar *) "src");
622 WRBUF w = wrbuf_alloc();
623 conf_dir_path(config, w, (const char *) src);
624 r = nmem_strdup(nmem, wrbuf_cstr(w));
629 yaz_log(YLOG_FATAL, "Must specify src in targetprofile");
636 static void inherit_server_settings(struct conf_service *s)
638 struct conf_server *server = s->server;
639 if (!s->dictionary) /* service has no config settings ? */
641 if (server->server_settings)
643 /* inherit settings from server */
645 settings_read_file(s, server->server_settings, 1);
646 settings_read_file(s, server->server_settings, 2);
650 yaz_log(YLOG_WARN, "service '%s' has no settings",
651 s->id ? s->id : "unnamed");
656 /* use relevance/sort/mergekey from server if not defined
657 for this service.. */
658 if (!s->relevance_pct)
660 if (server->relevance_pct)
662 s->relevance_pct = server->relevance_pct;
663 pp2_charset_incref(s->relevance_pct);
666 s->relevance_pct = pp2_charset_create(0);
671 if (server->sort_pct)
673 s->sort_pct = server->sort_pct;
674 pp2_charset_incref(s->sort_pct);
677 s->sort_pct = pp2_charset_create(0);
680 if (!s->mergekey_pct)
682 if (server->mergekey_pct)
684 s->mergekey_pct = server->mergekey_pct;
685 pp2_charset_incref(s->mergekey_pct);
688 s->mergekey_pct = pp2_charset_create(0);
692 struct conf_service *service_create(struct conf_server *server,
695 struct conf_service *service = service_create_static(server,
699 inherit_server_settings(service);
700 resolve_databases(service);
705 static struct conf_server *server_create(struct conf_config *config,
706 NMEM nmem, xmlNode *node)
709 struct conf_server *server = nmem_malloc(nmem, sizeof(struct conf_server));
713 server->proxy_host = 0;
714 server->proxy_port = 0;
716 server->proxy_addr = 0;
718 server->config = config;
720 server->relevance_pct = 0;
721 server->sort_pct = 0;
722 server->mergekey_pct = 0;
723 server->server_settings = 0;
725 for (n = node->children; n; n = n->next)
727 if (n->type != XML_ELEMENT_NODE)
729 if (!strcmp((const char *) n->name, "listen"))
731 xmlChar *port = xmlGetProp(n, (xmlChar *) "port");
732 xmlChar *host = xmlGetProp(n, (xmlChar *) "host");
734 server->port = atoi((const char *) port);
736 server->host = nmem_strdup(nmem, (const char *) host);
740 else if (!strcmp((const char *) n->name, "proxy"))
742 xmlChar *port = xmlGetProp(n, (xmlChar *) "port");
743 xmlChar *host = xmlGetProp(n, (xmlChar *) "host");
744 xmlChar *myurl = xmlGetProp(n, (xmlChar *) "myurl");
746 server->proxy_port = atoi((const char *) port);
748 server->proxy_host = nmem_strdup(nmem, (const char *) host);
750 server->myurl = nmem_strdup(nmem, (const char *) myurl);
755 else if (!strcmp((const char *) n->name, "settings"))
757 if (server->server_settings)
759 yaz_log(YLOG_FATAL, "Can't repeat 'settings'");
762 if (!(server->server_settings = parse_settings(config, nmem, n)))
765 else if (!strcmp((const char *) n->name, "relevance"))
767 server->relevance_pct = pp2_charset_create_xml(n);
768 if (!server->relevance_pct)
771 else if (!strcmp((const char *) n->name, "sort"))
773 server->sort_pct = pp2_charset_create_xml(n);
774 if (!server->sort_pct)
777 else if (!strcmp((const char *) n->name, "mergekey"))
779 server->mergekey_pct = pp2_charset_create_xml(n);
780 if (!server->mergekey_pct)
783 else if (!strcmp((const char *) n->name, "service"))
785 char *service_id = (char *)
786 xmlGetProp(n, (xmlChar *) "id");
788 struct conf_service **sp = &server->service;
789 for (; *sp; sp = &(*sp)->next)
790 if ((*sp)->id && service_id &&
791 0 == strcmp((*sp)->id, service_id))
793 yaz_log(YLOG_FATAL, "Duplicate service: %s", service_id);
796 else if (!(*sp)->id && !service_id)
798 yaz_log(YLOG_FATAL, "Duplicate unnamed service");
802 if (*sp) /* service already exist */
809 struct conf_service *s = service_create_static(server, n,
819 yaz_log(YLOG_FATAL, "Bad element: %s", n->name);
825 struct conf_service *s;
826 for (s = server->service; s; s = s->next)
827 inherit_server_settings(s);
832 WRBUF conf_get_fname(struct conf_service *service, const char *fname)
834 struct conf_config *config = service->server->config;
835 WRBUF w = wrbuf_alloc();
837 conf_dir_path(config, w, fname);
841 static struct conf_targetprofiles *parse_targetprofiles(NMEM nmem,
844 struct conf_targetprofiles *r = nmem_malloc(nmem, sizeof(*r));
845 xmlChar *type = xmlGetProp(node, (xmlChar *) "type");
846 xmlChar *src = xmlGetProp(node, (xmlChar *) "src");
848 memset(r, 0, sizeof(*r));
852 if (!strcmp((const char *) type, "local"))
853 r->type = Targetprofiles_local;
856 yaz_log(YLOG_FATAL, "Unknown targetprofile type");
862 yaz_log(YLOG_FATAL, "Must specify type for targetprofile");
867 r->src = nmem_strdup(nmem, (const char *) src);
870 yaz_log(YLOG_FATAL, "Must specify src in targetprofile");
878 struct conf_service *locate_service(struct conf_server *server,
879 const char *service_id)
881 struct conf_service *s = server->service;
882 for (; s; s = s->next)
883 if (s->id && service_id && 0 == strcmp(s->id, service_id))
885 else if (!s->id && !service_id)
891 static int parse_config(struct conf_config *config, xmlNode *root)
895 for (n = root->children; n; n = n->next)
897 if (n->type != XML_ELEMENT_NODE)
899 if (!strcmp((const char *) n->name, "server"))
901 struct conf_server *tmp = server_create(config, config->nmem, n);
904 tmp->next = config->servers;
905 config->servers = tmp;
907 else if (!strcmp((const char *) n->name, "targetprofiles"))
909 yaz_log(YLOG_FATAL, "targetprofiles unsupported here. Must be part of service");
915 yaz_log(YLOG_FATAL, "Bad element: %s", n->name);
922 static int process_config_includes(struct conf_config *config, xmlNode *n);
924 static int config_include_one(struct conf_config *config, xmlNode **sib,
928 if (stat(path, &st) < 0)
930 yaz_log(YLOG_FATAL|YLOG_ERRNO, "stat %s", path);
935 if ((st.st_mode & S_IFMT) == S_IFREG)
937 xmlDoc *doc = xmlParseFile(path);
940 xmlNodePtr t = xmlDocGetRootElement(doc);
941 int ret = process_config_includes(config, t);
942 *sib = xmlAddNextSibling(*sib, xmlCopyNode(t, 1));
949 yaz_log(YLOG_FATAL, "Could not parse %s", path);
957 static int config_include_src(struct conf_config *config, xmlNode **np,
960 int ret = 0; /* return code. OK so far */
961 WRBUF w = wrbuf_alloc();
962 xmlNodePtr sib; /* our sibling that we append */
963 xmlNodePtr c; /* tmp node */
965 wrbuf_printf(w, " begin include src=\"%s\" ", src);
967 /* replace include element with a 'begin' comment */
968 sib = xmlNewComment((const xmlChar *) wrbuf_cstr(w));
969 xmlReplaceNode(*np, sib);
974 conf_dir_path(config, w, src);
979 glob(wrbuf_cstr(w), 0 /* flags */, 0 /* errfunc */, &glob_res);
981 for (i = 0; ret == 0 && i < glob_res.gl_pathc; i++)
983 const char *path = glob_res.gl_pathv[i];
984 ret = config_include_one(config, &sib, path);
989 ret = config_include_one(config, &sib, wrbuf_cstr(w));
992 wrbuf_printf(w, " end include src=\"%s\" ", src);
993 c = xmlNewComment((const xmlChar *) wrbuf_cstr(w));
994 sib = xmlAddNextSibling(sib, c);
1001 static int process_config_includes(struct conf_config *config, xmlNode *n)
1003 for (; n; n = n->next)
1005 if (n->type == XML_ELEMENT_NODE)
1007 if (!strcmp((const char *) n->name, "include"))
1009 xmlChar *src = xmlGetProp(n, (xmlChar *) "src");
1012 int ret = config_include_src(config, &n,
1013 (const char *) src);
1022 if (process_config_includes(config, n->children))
1030 struct conf_config *config_create(const char *fname, int verbose)
1032 xmlDoc *doc = xmlParseFile(fname);
1036 NMEM nmem = nmem_create();
1037 struct conf_config *config = nmem_malloc(nmem, sizeof(struct conf_config));
1039 xmlSubstituteEntitiesDefault(1);
1040 xmlLoadExtDtdDefaultValue = 1;
1043 yaz_log(YLOG_FATAL, "Failed to read %s", fname);
1048 config->nmem = nmem;
1049 config->servers = 0;
1051 config->confdir = wrbuf_alloc();
1052 if ((p = strrchr(fname,
1060 int len = p - fname;
1061 wrbuf_write(config->confdir, fname, len);
1063 wrbuf_puts(config->confdir, "");
1065 n = xmlDocGetRootElement(doc);
1066 r = process_config_includes(config, n);
1067 if (r == 0) /* OK */
1071 yaz_log(YLOG_LOG, "Configuration %s after include processing",
1073 #if LIBXML_VERSION >= 20600
1074 xmlDocFormatDump(yaz_log_file(), doc, 0);
1076 xmlDocDump(yaz_log_file(), doc);
1079 r = parse_config(config, n);
1085 config_destroy(config);
1091 void server_destroy(struct conf_server *server)
1093 struct conf_service *s = server->service;
1096 struct conf_service *s_next = s->next;
1100 pp2_charset_destroy(server->relevance_pct);
1101 pp2_charset_destroy(server->sort_pct);
1102 pp2_charset_destroy(server->mergekey_pct);
1105 void config_destroy(struct conf_config *config)
1109 struct conf_server *server = config->servers;
1112 struct conf_server *s_next = server->next;
1113 server_destroy(server);
1116 wrbuf_destroy(config->confdir);
1117 nmem_destroy(config->nmem);
1121 void config_stop_listeners(struct conf_config *conf)
1123 struct conf_server *ser;
1124 for (ser = conf->servers; ser; ser = ser->next)
1125 http_close_server(ser);
1128 void config_start_databases(struct conf_config *conf)
1130 struct conf_server *ser;
1131 for (ser = conf->servers; ser; ser = ser->next)
1133 struct conf_service *s = ser->service;
1134 for (;s ; s = s->next)
1135 resolve_databases(s);
1139 int config_start_listeners(struct conf_config *conf,
1140 const char *listener_override)
1142 struct conf_server *ser;
1143 for (ser = conf->servers; ser; ser = ser->next)
1145 WRBUF w = wrbuf_alloc();
1147 if (listener_override)
1149 wrbuf_puts(w, listener_override);
1150 listener_override = 0; /* only first server is overriden */
1155 wrbuf_puts(w, ser->host);
1160 wrbuf_printf(w, "%d", ser->port);
1163 r = http_init(wrbuf_cstr(w), ser);
1169 if (ser->proxy_host || ser->proxy_port)
1171 if (ser->proxy_host)
1172 wrbuf_puts(w, ser->proxy_host);
1173 if (ser->proxy_port)
1177 wrbuf_printf(w, "%d", ser->proxy_port);
1181 http_set_proxyaddr(wrbuf_cstr(w), ser);
1190 * c-file-style: "Stroustrup"
1191 * indent-tabs-mode: nil
1193 * vim: shiftwidth=4 tabstop=8 expandtab