-/* $Id: config.c,v 1.11 2007-01-14 17:34:31 adam Exp $ */
+/* $Id: config.c,v 1.14 2007-02-05 16:15:41 quinn Exp $ */
#include <string.h>
xmlNode *n;
struct conf_service *r = nmem_malloc(nmem, sizeof(struct conf_service));
int md_node = 0;
+ int sk_node = 0;
r->num_sortkeys = r->num_metadata = 0;
- // Allocate array of conf metadata structs, if necessary
+ // Allocate array of conf metadata and sortkey tructs, if necessary
for (n = node->children; n; n = n->next)
if (n->type == XML_ELEMENT_NODE && !strcmp(n->name, "metadata"))
{
{
if (!strcmp(type, "generic"))
md->type = Metadata_type_generic;
- else if (!strcmp(type, "integer"))
- md->type = Metadata_type_integer;
else if (!strcmp(type, "year"))
md->type = Metadata_type_year;
else
else
md->type = Metadata_type_generic;
- if (sortkey)
- {
- if (!strcmp(sortkey, "no"))
- md->sortkey = Metadata_sortkey_no;
- else if (!strcmp(sortkey, "numeric"))
- md->sortkey = Metadata_sortkey_numeric;
- else if (!strcmp(sortkey, "range"))
- md->sortkey = Metadata_sortkey_range;
- else if (!strcmp(sortkey, "skiparticle"))
- md->sortkey = Metadata_sortkey_skiparticle;
- else
- {
- yaz_log(YLOG_FATAL, "Unknown sortkey in metadata element: %s", sortkey);
- return 0;
- }
- }
- else
- md->sortkey = Metadata_sortkey_no;
-
if (merge)
{
if (!strcmp(merge, "no"))
else
md->merge = Metadata_merge_no;
+ if (sortkey && strcmp(sortkey, "no"))
+ {
+ struct conf_sortkey *sk = &r->sortkeys[sk_node];
+ if (md->merge == Metadata_merge_no)
+ {
+ yaz_log(YLOG_FATAL, "Can't specify sortkey on a non-merged field");
+ return 0;
+ }
+ if (!strcmp(sortkey, "numeric"))
+ sk->type = Metadata_sortkey_numeric;
+ else if (!strcmp(sortkey, "skiparticle"))
+ sk->type = Metadata_sortkey_skiparticle;
+ else
+ {
+ yaz_log(YLOG_FATAL, "Unknown sortkey in metadata element: %s", sortkey);
+ return 0;
+ }
+ sk->name = md->name;
+ md->sortkey_offset = sk_node;
+ sk_node++;
+ }
+ else
+ md->sortkey_offset = -1;
+
xmlFree(name);
xmlFree(brief);
xmlFree(sortkey);
r->port = 0;
r->proxy_host = 0;
r->proxy_port = 0;
+ r->myurl = 0;
r->service = 0;
r->next = 0;
{
xmlChar *port = xmlGetProp(n, "port");
xmlChar *host = xmlGetProp(n, "host");
+ xmlChar *myurl = xmlGetProp(n, "myurl");
if (port)
r->proxy_port = atoi(port);
if (host)
r->proxy_host = nmem_strdup(nmem, host);
+ if (myurl)
+ r->myurl = nmem_strdup(nmem, myurl);
+ else
+ {
+ yaz_log(YLOG_FATAL, "Must specify @myurl for proxy");
+ return 0;
+ }
xmlFree(port);
xmlFree(host);
+ xmlFree(myurl);
}
else if (!strcmp(n->name, "service"))
{
yaz_log(YLOG_WARN, "Missing name in 'nativesyntax' element");
return 0;
}
+ if (encoding)
+ r->native_encoding = encoding;
if (!strcmp(name, "iso2709"))
{
r->native_syntax = Nativesyn_iso2709;
// Set a few defaults, too
r->native_format = Nativeform_marc21;
r->native_mapto = Nativemapto_marcxml;
- r->native_encoding = "marc-8";
+ if (!r->native_encoding)
+ r->native_encoding = "marc-8";
setup_marc(r);
}
else if (!strcmp(name, "xml"))
return 0;
}
}
- if (encoding)
- r->native_encoding = encoding;
if (mapto)
{
if (!strcmp(mapto, "marcxml"))