+void server_destroy(struct conf_server *server)
+{
+ struct conf_service *s = server->service;
+ while (s)
+ {
+ struct conf_service *s_next = s->next;
+ service_destroy(s);
+ s = s_next;
+ }
+ pp2_charset_destroy(server->relevance_pct);
+ pp2_charset_destroy(server->sort_pct);
+ pp2_charset_destroy(server->mergekey_pct);
+}
+
+void config_destroy(struct conf_config *config)
+{
+ if (config)
+ {
+ struct conf_server *server = config->servers;
+ while (server)
+ {
+ struct conf_server *s_next = server->next;
+ server_destroy(server);
+ server = s_next;
+ }
+ wrbuf_destroy(config->confdir);
+ nmem_destroy(config->nmem);
+ }
+}
+
+void config_read_settings(struct conf_config *config)
+{
+ struct conf_service *s = config->servers->service;
+ for (;s ; s = s->next)
+ {
+ init_settings(s);
+ if (s->settings)
+ settings_read(s, s->settings);
+ else if (config->servers->server_settings)
+ settings_read(s, config->servers->server_settings);
+ else
+ yaz_log(YLOG_WARN, "No settings for service");
+ }
+}
+
+void config_stop_listeners(struct conf_config *conf)
+{
+ struct conf_server *ser;
+ for (ser = conf->servers; ser; ser = ser->next)
+ http_close_server(ser);
+}
+
+int config_start_listeners(struct conf_config *conf,
+ const char *listener_override)
+{
+ struct conf_server *ser;
+ for (ser = conf->servers; ser; ser = ser->next)
+ {
+ WRBUF w = wrbuf_alloc();
+ int r;
+ if (listener_override)
+ {
+ wrbuf_puts(w, listener_override);
+ listener_override = 0; /* only first server is overriden */
+ }
+ else
+ {
+ if (ser->host)
+ wrbuf_puts(w, ser->host);
+ if (ser->port)
+ {
+ if (wrbuf_len(w))
+ wrbuf_puts(w, ":");
+ wrbuf_printf(w, "%d", ser->port);
+ }
+ }
+ r = http_init(wrbuf_cstr(w), ser);
+ wrbuf_destroy(w);
+ if (r)
+ return -1;
+
+ w = wrbuf_alloc();
+ if (ser->proxy_host || ser->proxy_port)
+ {
+ if (ser->proxy_host)
+ wrbuf_puts(w, ser->proxy_host);
+ if (ser->proxy_port)
+ {
+ if (wrbuf_len(w))
+ wrbuf_puts(w, ":");
+ wrbuf_printf(w, "%d", ser->proxy_port);
+ }
+ }
+ if (wrbuf_len(w))
+ http_set_proxyaddr(wrbuf_cstr(w), ser);
+ wrbuf_destroy(w);
+ }
+ return 0;
+}