X-Git-Url: http://lists.indexdata.com/cgi-bin?a=blobdiff_plain;f=src%2Fpazpar2_config.c;h=ccd7be4769669a45c8082f4444de435eac4be797;hb=9781a15c4874c98656c0ae8d3be9cacc75e19649;hp=094d7fe78df298bc36c4c81d2be5e10a48769ecf;hpb=2cfd7518dc740c913602ea8306ec8f27509b00d4;p=pazpar2-moved-to-github.git diff --git a/src/pazpar2_config.c b/src/pazpar2_config.c index 094d7fe..ccd7be4 100644 --- a/src/pazpar2_config.c +++ b/src/pazpar2_config.c @@ -1,5 +1,5 @@ /* This file is part of Pazpar2. - Copyright (C) 2006-2010 Index Data + Copyright (C) 2006-2011 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 @@ -60,9 +60,6 @@ struct conf_config static char *parse_settings(struct conf_config *config, NMEM nmem, xmlNode *node); -static struct conf_targetprofiles *parse_targetprofiles(NMEM nmem, - xmlNode *node); - static void conf_metadata_assign(NMEM nmem, struct conf_metadata * metadata, const char *name, @@ -122,7 +119,6 @@ static struct conf_service *service_init(struct conf_server *server, service->next = 0; service->settings = 0; service->databases = 0; - service->targetprofiles = 0; service->server = server; service->session_timeout = 60; /* default session timeout */ service->z3950_session_timeout = 180; @@ -131,6 +127,7 @@ static struct conf_service *service_init(struct conf_server *server, service->relevance_pct = 0; service->sort_pct = 0; service->mergekey_pct = 0; + service->facet_pct = 0; service->id = service_id ? nmem_strdup(nmem, service_id) : 0; service->num_metadata = num_metadata; @@ -249,6 +246,7 @@ void service_destroy(struct conf_service *service) pp2_charset_destroy(service->relevance_pct); pp2_charset_destroy(service->sort_pct); pp2_charset_destroy(service->mergekey_pct); + pp2_charset_destroy(service->facet_pct); yaz_mutex_destroy(&service->mutex); nmem_destroy(service->nmem); } @@ -513,17 +511,6 @@ static struct conf_service *service_create_static(struct conf_server *server, } else if (!strcmp((const char *) n->name, "settings")) got_settings++; - else if (!strcmp((const char *) n->name, (const char *) "targetprofiles")) - { - if (service->targetprofiles) - { - yaz_log(YLOG_FATAL, "Can't repeat targetprofiles"); - return 0; - } - if (!(service->targetprofiles = - parse_targetprofiles(service->nmem, n))) - return 0; - } else if (!strcmp((const char *) n->name, "relevance")) { if (service->relevance_pct) @@ -566,6 +553,20 @@ static struct conf_service *service_create_static(struct conf_server *server, return 0; } } + else if (!strcmp((const char *) n->name, "facet")) + { + if (service->mergekey_pct) + { + yaz_log(YLOG_LOG, "facety may not repeat in service"); + return 0; + } + else + { + service->facet_pct = pp2_charset_create_xml(n); + if (!service->mergekey_pct) + return 0; + } + } else if (!strcmp((const char *) n->name, (const char *) "metadata")) { if (parse_metadata(service, n, &md_node, &sk_node)) @@ -652,7 +653,7 @@ static void inherit_server_settings(struct conf_service *s) } } - /* use relevance/sort/mergekey from server if not defined + /* use relevance/sort/mergekey/facet from server if not defined for this service.. */ if (!s->relevance_pct) { @@ -662,7 +663,7 @@ static void inherit_server_settings(struct conf_service *s) pp2_charset_incref(s->relevance_pct); } else - s->relevance_pct = pp2_charset_create(0); + s->relevance_pct = pp2_charset_create_a_to_z(); } if (!s->sort_pct) @@ -673,7 +674,7 @@ static void inherit_server_settings(struct conf_service *s) pp2_charset_incref(s->sort_pct); } else - s->sort_pct = pp2_charset_create(0); + s->sort_pct = pp2_charset_create_a_to_z(); } if (!s->mergekey_pct) @@ -684,7 +685,18 @@ static void inherit_server_settings(struct conf_service *s) pp2_charset_incref(s->mergekey_pct); } else - s->mergekey_pct = pp2_charset_create(0); + s->mergekey_pct = pp2_charset_create_a_to_z(); + } + + if (!s->facet_pct) + { + if (server->facet_pct) + { + s->facet_pct = server->facet_pct; + pp2_charset_incref(s->facet_pct); + } + else + s->facet_pct = pp2_charset_create(0); } } @@ -721,6 +733,7 @@ static struct conf_server *server_create(struct conf_config *config, server->relevance_pct = 0; server->sort_pct = 0; server->mergekey_pct = 0; + server->facet_pct = 0; server->server_settings = 0; server->http_server = 0; server->iochan_man = 0; @@ -791,6 +804,12 @@ static struct conf_server *server_create(struct conf_config *config, if (!server->mergekey_pct) return 0; } + else if (!strcmp((const char *) n->name, "facet")) + { + server->facet_pct = pp2_charset_create_xml(n); + if (!server->facet_pct) + return 0; + } else if (!strcmp((const char *) n->name, "service")) { char *service_id = (char *) @@ -840,52 +859,14 @@ static struct conf_server *server_create(struct conf_config *config, return server; } -WRBUF conf_get_fname(struct conf_service *service, const char *fname) +WRBUF conf_get_fname(struct conf_config *config, const char *fname) { - struct conf_config *config = service->server->config; WRBUF w = wrbuf_alloc(); conf_dir_path(config, w, fname); return w; } -static struct conf_targetprofiles *parse_targetprofiles(NMEM nmem, - xmlNode *node) -{ - struct conf_targetprofiles *r = nmem_malloc(nmem, sizeof(*r)); - xmlChar *type = xmlGetProp(node, (xmlChar *) "type"); - xmlChar *src = xmlGetProp(node, (xmlChar *) "src"); - - memset(r, 0, sizeof(*r)); - - if (type) - { - if (!strcmp((const char *) type, "local")) - r->type = Targetprofiles_local; - else - { - yaz_log(YLOG_FATAL, "Unknown targetprofile type"); - return 0; - } - } - else - { - yaz_log(YLOG_FATAL, "Must specify type for targetprofile"); - return 0; - } - - if (src) - r->src = nmem_strdup(nmem, (const char *) src); - else - { - yaz_log(YLOG_FATAL, "Must specify src in targetprofile"); - return 0; - } - xmlFree(type); - xmlFree(src); - return r; -} - struct conf_service *locate_service(struct conf_server *server, const char *service_id) { @@ -900,6 +881,25 @@ struct conf_service *locate_service(struct conf_server *server, return s; } +void info_services(struct conf_server *server, WRBUF w) +{ + struct conf_service *s = server->service; + wrbuf_puts(w, " \n"); + for (; s; s = s->next) + { + wrbuf_puts(w, " id) + { + wrbuf_puts(w, " id=\""); + wrbuf_xmlputs(w, s->id); + wrbuf_puts(w, "\""); + } + wrbuf_puts(w, "/>"); + + wrbuf_puts(w, "\n"); + } + wrbuf_puts(w, " \n"); +} static int parse_config(struct conf_config *config, xmlNode *root) { @@ -1016,6 +1016,7 @@ void server_destroy(struct conf_server *server) pp2_charset_destroy(server->relevance_pct); pp2_charset_destroy(server->sort_pct); pp2_charset_destroy(server->mergekey_pct); + pp2_charset_destroy(server->facet_pct); yaz_log(YLOG_LOG, "server_destroy server=%p", server); http_server_destroy(server->http_server); } @@ -1069,7 +1070,8 @@ void config_process_events(struct conf_config *conf) } int config_start_listeners(struct conf_config *conf, - const char *listener_override) + const char *listener_override, + const char *record_fname) { struct conf_server *ser; @@ -1096,7 +1098,7 @@ int config_start_listeners(struct conf_config *conf, wrbuf_printf(w, "%d", ser->port); } } - r = http_init(wrbuf_cstr(w), ser); + r = http_init(wrbuf_cstr(w), ser, record_fname); wrbuf_destroy(w); if (r) return -1;