/* This file is part of Pazpar2.
- Copyright (C) 2006-2012 Index Data
+ Copyright (C) 2006-2013 Index Data
Pazpar2 is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
struct service_xslt *next;
};
+static char *xml_context(const xmlNode *ptr, char *res, size_t len)
+{
+ size_t off = len - 1;
+ res[off] = '\0';
+ while (ptr && ptr->type == XML_ELEMENT_NODE)
+ {
+ size_t l = strlen((const char *) ptr->name);
+ if (off <= l + 1)
+ break;
+
+ off = off - l;
+ memcpy(res + off, ptr->name, l);
+ res[--off] = '/';
+
+ ptr = ptr->parent;
+ }
+ return res + off;
+}
+
struct conf_service *service_init(struct conf_server *server,
int num_metadata, int num_sortkeys,
const char *service_id)
merge = Metadata_merge_range;
else if (!strcmp((const char *) xml_merge, "all"))
merge = Metadata_merge_all;
+ else if (!strcmp((const char *) xml_merge, "first"))
+ merge = Metadata_merge_first;
else
{
yaz_log(YLOG_FATAL,
if (service_xslt_config(service, n))
return 0;
}
- else if (!strcmp((const char *) n->name, (const char *) "set"))
- {
- xmlChar *name= xmlGetProp(n, (xmlChar *) "name");
- xmlChar *value = xmlGetProp(n, (xmlChar *) "value");
- if (service->dictionary && name && value) {
- yaz_log(YLOG_DEBUG, "service set: %s=%s (Not implemented)", (char *) name, (char *) value);
- //service_aply_setting(service, name, value);
- }
- }
else if (!strcmp((const char *) n->name, "rank"))
{
char *rank_cluster = (char *) xmlGetProp(n, (xmlChar *) "cluster");
}
else
{
- yaz_log(YLOG_FATAL, "Bad element: %s", n->name);
+ char tmp[80];
+ yaz_log(YLOG_FATAL, "Bad element: %s . Context: %s", n->name,
+ xml_context(n, tmp, sizeof tmp));
return 0;
}
}
struct conf_server *server = nmem_malloc(nmem, sizeof(struct conf_server));
xmlChar *server_id = xmlGetProp(node, (xmlChar *) "id");
- server->host = 0;
+ server->host = "@";
server->port = 0;
server->proxy_host = 0;
server->proxy_port = 0;
{
xmlChar *port = xmlGetProp(n, (xmlChar *) "port");
xmlChar *host = xmlGetProp(n, (xmlChar *) "host");
+
if (port)
- server->port = atoi((const char *) port);
+ server->port = nmem_strdup(nmem, (const char *) port);
if (host)
server->host = nmem_strdup(nmem, (const char *) host);
+
xmlFree(port);
xmlFree(host);
}
return 0;
}
}
+ if (!server->port)
+ {
+ yaz_log(YLOG_FATAL, "No listening port given");
+ return 0;
+ }
if (server->service)
{
struct conf_service *s;
conf->iochan_man = iochan_man_create(conf->no_threads);
for (ser = conf->servers; ser; ser = ser->next)
{
- WRBUF w = wrbuf_alloc();
+ WRBUF w;
int r;
ser->iochan_man = conf->iochan_man;
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)
+ const char *cp = strrchr(listener_override, ':');
+ if (cp)
{
- if (wrbuf_len(w))
- wrbuf_puts(w, ":");
- wrbuf_printf(w, "%d", ser->port);
+ ser->host = nmem_strdupn(conf->nmem, listener_override,
+ cp - listener_override);
+ ser->port = nmem_strdup(conf->nmem, cp + 1);
}
+ else
+ {
+ ser->host = "@";
+ ser->port = nmem_strdup(conf->nmem, listener_override);
+ }
+ listener_override = 0; /* only first server is overriden */
}
- r = http_init(wrbuf_cstr(w), ser, record_fname);
- wrbuf_destroy(w);
+ r = http_init(ser, record_fname);
if (r)
return -1;