X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fconfig.c;h=3ceb42715b17e4020def9aa1ecf8200c5190cf77;hb=bec266c19b530f61fa576d2b27198ada7d7f5fe3;hp=de471522cdbba76c7726a1dd44022f4fe7007bf2;hpb=a3b7b22328617db1ffdb8118c661d3167905918e;p=pazpar2-moved-to-github.git diff --git a/src/config.c b/src/config.c index de47152..3ceb427 100644 --- a/src/config.c +++ b/src/config.c @@ -1,4 +1,4 @@ -/* $Id: config.c,v 1.10 2007-01-12 15:08:44 quinn Exp $ */ +/* $Id: config.c,v 1.13 2007-01-15 16:56:51 quinn Exp $ */ #include @@ -31,9 +31,10 @@ static struct conf_service *parse_service(xmlNode *node) 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")) { @@ -108,8 +109,6 @@ static struct conf_service *parse_service(xmlNode *node) { 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 @@ -121,25 +120,6 @@ static struct conf_service *parse_service(xmlNode *node) 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")) @@ -161,6 +141,30 @@ static struct conf_service *parse_service(xmlNode *node) 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); @@ -287,13 +291,16 @@ static struct conf_retrievalprofile *parse_retrievalprofile(xmlNode *node) 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")) @@ -313,8 +320,6 @@ static struct conf_retrievalprofile *parse_retrievalprofile(xmlNode *node) return 0; } } - if (encoding) - r->native_encoding = encoding; if (mapto) { if (!strcmp(mapto, "marcxml")) @@ -418,7 +423,7 @@ static struct conf_config *parse_config(xmlNode *root) int read_config(const char *fname) { - xmlDoc *doc = xmlReadFile(fname, NULL, 0); + xmlDoc *doc = xmlParseFile(fname); const char *p; if (!nmem) // Initialize