X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fpazpar2_config.c;h=bff5810edb365ff88318e491e31f08dc44994cef;hb=1db48a73126beef112e9a3de775832173fa317f3;hp=2e5f984a32c6457e1897dcce66bc515d9bbb5776;hpb=7aa45df8e1aeb4cd15434b945b66e56af3928fe0;p=pazpar2-moved-to-github.git diff --git a/src/pazpar2_config.c b/src/pazpar2_config.c index 2e5f984..bff5810 100644 --- a/src/pazpar2_config.c +++ b/src/pazpar2_config.c @@ -112,13 +112,14 @@ static void conf_sortkey_assign(NMEM nmem, sortkey->type = type; } -static struct conf_service *service_init(struct conf_server *server, +struct conf_service *service_init(struct conf_server *server, int num_metadata, int num_sortkeys, const char *service_id) { struct conf_service * service = 0; NMEM nmem = nmem_create(); + service = nmem_malloc(nmem, sizeof(struct conf_service)); service->mutex = 0; service->ref_count = 1; @@ -134,7 +135,19 @@ static struct conf_service *service_init(struct conf_server *server, service->charsets = 0; service->id = service_id ? nmem_strdup(nmem, service_id) : 0; + // Setup a dictionary from server. + service->dictionary = 0; + + service->settings = nmem_malloc(nmem, sizeof(*service->settings)); + service->settings->num_settings = PZ_MAX_EOF; + service->settings->settings = nmem_malloc(nmem, sizeof(struct setting*) * service->settings->num_settings); + memset(service->settings->settings, 0, sizeof(struct setting*) * service->settings->num_settings); + // inherit_server_settings_values(service); + + service->next = 0; + service->num_metadata = num_metadata; + service->metadata = 0; if (service->num_metadata) service->metadata @@ -146,7 +159,8 @@ static struct conf_service *service_init(struct conf_server *server, service->sortkeys = nmem_malloc(nmem, sizeof(struct conf_sortkey) * service->num_sortkeys); - service->dictionary = 0; + + return service; } @@ -310,12 +324,12 @@ static int parse_metadata(struct conf_service *service, xmlNode *n, else if (!xmlStrcmp(attr->name, BAD_CAST "mergekey") && attr->children && attr->children->type == XML_TEXT_NODE) xml_mergekey = attr->children->content; - else if (!xmlStrcmp(attr->name, BAD_CAST "limitmap") && - attr->children && attr->children->type == XML_TEXT_NODE) - xml_limitmap = attr->children->content; else if (!xmlStrcmp(attr->name, BAD_CAST "facetrule") && attr->children && attr->children->type == XML_TEXT_NODE) xml_icu_chain = attr->children->content; + else if (!xmlStrcmp(attr->name, BAD_CAST "limitmap") && + attr->children && attr->children->type == XML_TEXT_NODE) + xml_limitmap = attr->children->content; else { yaz_log(YLOG_FATAL, "Unknown metadata attribute '%s'", attr->name); @@ -565,6 +579,15 @@ static struct conf_service *service_create_static(struct conf_server *server, 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 { yaz_log(YLOG_FATAL, "Bad element: %s", n->name); @@ -584,19 +607,22 @@ static struct conf_service *service_create_static(struct conf_server *server, continue; if (!strcmp((const char *) n->name, "settings")) { + int ret; xmlChar *src = xmlGetProp(n, (xmlChar *) "src"); if (src) { WRBUF w = wrbuf_alloc(); conf_dir_path(server->config, w, (const char *) src); - settings_read_file(service, wrbuf_cstr(w), pass); + ret = settings_read_file(service, wrbuf_cstr(w), pass); wrbuf_destroy(w); xmlFree(src); } else { - settings_read_node(service, n, pass); + ret = settings_read_node(service, n, pass); } + if (ret) + return 0; } } } @@ -604,8 +630,9 @@ static struct conf_service *service_create_static(struct conf_server *server, return service; } -static void inherit_server_settings(struct conf_service *s) +static int inherit_server_settings(struct conf_service *s) { + int ret = 0; struct conf_server *server = s->server; if (!s->dictionary) /* service has no config settings ? */ { @@ -613,13 +640,14 @@ static void inherit_server_settings(struct conf_service *s) { /* inherit settings from server */ init_settings(s); - settings_read_file(s, server->settings_fname, 1); - settings_read_file(s, server->settings_fname, 2); + if (settings_read_file(s, server->settings_fname, 1)) + ret = -1; + if (settings_read_file(s, server->settings_fname, 2)) + ret = -1; } else { - yaz_log(YLOG_WARN, "service '%s' has no settings", - s->id ? s->id : "unnamed"); + yaz_log(YLOG_WARN, "server '%s' has no settings", s->id ? s->id : "unnamed"); init_settings(s); } } @@ -638,13 +666,13 @@ static void inherit_server_settings(struct conf_service *s) s->charsets = pp2_charset_fact_create(); } } + return ret; } struct conf_service *service_create(struct conf_server *server, xmlNode *node) { - struct conf_service *service = service_create_static(server, - node, 0); + struct conf_service *service = service_create_static(server, node, 0); if (service) { inherit_server_settings(service);