X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fpazpar2_config.c;h=290a39a7ea25a47ecf3ea90c39a701172eec5817;hb=24ad8ea356d71c764af19897e2719670a94a3a05;hp=902c0e692005082981ff9748d6e114b1238e7f42;hpb=9e1ece04d1151feae63d6ef0a9b3eebbbb4bc2a3;p=pazpar2-moved-to-github.git diff --git a/src/pazpar2_config.c b/src/pazpar2_config.c index 902c0e6..290a39a 100644 --- a/src/pazpar2_config.c +++ b/src/pazpar2_config.c @@ -53,9 +53,10 @@ struct conf_config struct conf_server *servers; int no_threads; + int max_sockets; WRBUF confdir; + char *path; iochan_man_t iochan_man; - database_hosts_t database_hosts; }; struct service_xslt @@ -169,7 +170,8 @@ static struct conf_metadata* conf_service_add_metadata( enum conf_metadata_mergekey mt, const char *facetrule, const char *limitmap, - const char *limitcluster + const char *limitcluster, + const char *icurule ) { struct conf_metadata * md = 0; @@ -201,6 +203,7 @@ static struct conf_metadata* conf_service_add_metadata( md->facetrule = nmem_strdup_null(nmem, facetrule); md->limitmap = nmem_strdup_null(nmem, limitmap); md->limitcluster = nmem_strdup_null(nmem, limitcluster); + md->icurule = nmem_strdup_null(nmem, icurule); return md; } @@ -256,13 +259,20 @@ int conf_service_sortkey_field_id(struct conf_service *service, static void conf_dir_path(struct conf_config *config, WRBUF w, const char *src) { - if (config->confdir && wrbuf_len(config->confdir) > 0 && - !yaz_is_abspath(src)) + char full_path[1024]; + if (yaz_filepath_resolve(src, config->path, + wrbuf_len(config->confdir) > 0 ? + wrbuf_cstr(config->confdir) : ".", + full_path)) { - wrbuf_printf(w, "%s/%s", wrbuf_cstr(config->confdir), src); + wrbuf_puts(w, full_path); } else + { + yaz_log(YLOG_WARN, "File not found: fname=%s path=%s base=%s", src, + config->path, wrbuf_cstr(config->confdir)); wrbuf_puts(w, src); + } } void service_destroy(struct conf_service *service) @@ -307,6 +317,7 @@ static int parse_metadata(struct conf_service *service, xmlNode *n, xmlChar *xml_limitmap = 0; xmlChar *xml_limitcluster = 0; xmlChar *xml_icu_chain = 0; + xmlChar *xml_icurule = 0; struct _xmlAttr *attr; @@ -350,6 +361,9 @@ static int parse_metadata(struct conf_service *service, xmlNode *n, else if (!xmlStrcmp(attr->name, BAD_CAST "limitcluster") && attr->children && attr->children->type == XML_TEXT_NODE) xml_limitcluster = attr->children->content; + else if (!xmlStrcmp(attr->name, BAD_CAST "icurule") && + attr->children && attr->children->type == XML_TEXT_NODE) + xml_icurule = attr->children->content; else { yaz_log(YLOG_FATAL, "Unknown metadata attribute '%s'", attr->name); @@ -507,13 +521,15 @@ static int parse_metadata(struct conf_service *service, xmlNode *n, mergekey_type, (const char *) xml_icu_chain, (const char *) xml_limitmap, - (const char *) xml_limitcluster); + (const char *) xml_limitcluster, + (const char *) xml_icurule + ); (*md_node)++; return 0; } -static void service_add_metadata(xmlNode *n, int *num_metadata, int *num_sortkeys) +static void count_metadata(xmlNode *n, int *num_metadata, int *num_sortkeys) { xmlChar *sortkey = xmlGetProp(n, (xmlChar *) "sortkey"); (*num_metadata)++; @@ -549,11 +565,11 @@ static struct conf_service *service_create_static(struct conf_server *server, { if (m->type == XML_ELEMENT_NODE && !strcmp((const char *) m->name, "metadata")) - service_add_metadata(m, &num_metadata, &num_sortkeys); + count_metadata(m, &num_metadata, &num_sortkeys); } } else // This is a metadata-element proper, count it right away. - service_add_metadata(n, &num_metadata, &num_sortkeys); + count_metadata(n, &num_metadata, &num_sortkeys); } service = service_init(server, num_metadata, num_sortkeys, service_id); @@ -641,8 +657,8 @@ static struct conf_service *service_create_static(struct conf_server *server, { if (!service->charsets) service->charsets = pp2_charset_fact_create(); - if (pp2_charset_fact_define(service->charsets, - n->children, (const char *) n->name)) + if (pp2_charset_fact_define(service->charsets, n, + (const char *) n->name)) { yaz_log(YLOG_FATAL, "ICU chain definition error"); return 0; @@ -680,7 +696,7 @@ static struct conf_service *service_create_static(struct conf_server *server, service->rank_cluster = 1; else if (!strcmp(rank_cluster, "no")) service->rank_cluster = 0; - else + else { yaz_log(YLOG_FATAL, "service: rank@cluster boolean"); return 0; @@ -864,7 +880,6 @@ static struct conf_server *server_create(struct conf_config *config, server->charsets = 0; server->http_server = 0; server->iochan_man = 0; - server->database_hosts = config->database_hosts; server->settings_fname = 0; if (server_id) @@ -944,8 +959,8 @@ static struct conf_server *server_create(struct conf_config *config, { if (!server->charsets) server->charsets = pp2_charset_fact_create(); - if (pp2_charset_fact_define(server->charsets, - n->children, (const char *) n->name)) + if (pp2_charset_fact_define(server->charsets, n, + (const char *) n->name)) { yaz_log(YLOG_FATAL, "ICU chain definition error"); return 0; @@ -1067,6 +1082,9 @@ static void info_service_metadata(struct conf_service *service, WRBUF w) case Metadata_type_position: wrbuf_puts(w, "position"); break; + case Metadata_type_retrieval: + wrbuf_puts(w, "retrieval"); + break; default: wrbuf_puts(w, "yes"); break; @@ -1087,8 +1105,7 @@ static void info_service_metadata(struct conf_service *service, WRBUF w) case Metadata_type_float: wrbuf_puts(w, " type=\"float\""); break; - case Metadata_type_relevance: - case Metadata_type_position: + default: break; } switch (md->merge) @@ -1129,15 +1146,14 @@ static void info_service_metadata(struct conf_service *service, WRBUF w) static void info_service_databases(struct conf_service *service, WRBUF w) { - struct database *db; - struct setting *s; - int i; if (service->databases) { + struct database *db; wrbuf_puts(w, " \n"); - for(db = service->databases; db; db = db->next) + for (db = service->databases; db; db = db->next) { + int i; wrbuf_puts(w, " id) { @@ -1148,18 +1164,16 @@ static void info_service_databases(struct conf_service *service, WRBUF w) wrbuf_puts(w, ">\n"); for (i = 0; i < db->num_settings; i++) { - s = db->settings[i]; - while (s != NULL) + struct setting *s = db->settings[i]; + for (; s; s = s->next) { - wrbuf_puts(w, " name); wrbuf_puts(w, "\""); wrbuf_puts(w, " value=\""); wrbuf_xmlputs(w, s->value); wrbuf_puts(w, "\""); wrbuf_puts(w, " />\n"); - s = s->next; } } wrbuf_puts(w, " \n"); @@ -1172,7 +1186,6 @@ void info_services(struct conf_server *server, WRBUF w) { struct conf_service *s = server->service; int i; - struct setting *S; wrbuf_puts(w, " \n"); for (; s; s = s->next) @@ -1187,34 +1200,30 @@ void info_services(struct conf_server *server, WRBUF w) wrbuf_puts(w, ">\n"); if (s->settings) { - for (i=0; isettings->num_settings; i++) + for (i = 0; i < s->settings->num_settings; i++) { - S = s->settings->settings[i]; - while (S != NULL) { - wrbuf_puts(w, " settings->settings[i]; + for (; S; S = S->next) + { + wrbuf_puts(w, " name); wrbuf_puts(w, "\""); wrbuf_puts(w, " value=\""); wrbuf_xmlputs(w, S->value); wrbuf_puts(w, "\""); - if (S->target) { + if (S->target) + { wrbuf_puts(w, " target=\""); wrbuf_xmlputs(w, S->target); wrbuf_puts(w, "\""); } - wrbuf_puts(w, " />\n"); - - S = S->next; } } } info_service_metadata(s, w); info_service_databases(s, w); - wrbuf_puts(w, " "); - - wrbuf_puts(w, "\n"); + wrbuf_puts(w, " \n"); } wrbuf_puts(w, " \n"); } @@ -1244,6 +1253,24 @@ static int parse_config(struct conf_config *config, xmlNode *root) xmlFree(number); } } + else if (!strcmp((const char *) n->name, "sockets")) + { + xmlChar *number = xmlGetProp(n, (xmlChar *) "max"); + if (number) + { + config->max_sockets = atoi((const char *) number); + xmlFree(number); + } + } + else if (!strcmp((const char *) n->name, "file")) + { + xmlChar *path = xmlGetProp(n, (xmlChar *) "path"); + if (path) + { + config->path = nmem_strdup(config->nmem, (const char *) path); + xmlFree(path); + } + } else if (!strcmp((const char *) n->name, "targetprofiles")) { yaz_log(YLOG_FATAL, "targetprofiles unsupported here. Must be part of service"); @@ -1259,7 +1286,7 @@ static int parse_config(struct conf_config *config, xmlNode *root) return 0; } -struct conf_config *config_create(const char *fname, int verbose) +struct conf_config *config_create(const char *fname) { xmlDoc *doc = xmlReadFile(fname, NULL, @@ -1290,9 +1317,10 @@ struct conf_config *config_create(const char *fname, int verbose) config->nmem = nmem; config->servers = 0; + config->path = nmem_strdup(nmem, "."); config->no_threads = 0; + config->max_sockets = 0; config->iochan_man = 0; - config->database_hosts = database_hosts_create(); config->confdir = wrbuf_alloc(); if ((p = strrchr(fname, @@ -1312,16 +1340,15 @@ struct conf_config *config_create(const char *fname, int verbose) r = yaz_xml_include_simple(n, wrbuf_cstr(config->confdir)); if (r == 0) /* OK */ { - if (verbose) - { - yaz_log(YLOG_LOG, "Configuration %s after include processing", - fname); +#ifndef WIN32 + yaz_log(YLOG_LOG, "Configuration %s after include processing", + fname); #if LIBXML_VERSION >= 20600 - xmlDocFormatDump(yaz_log_file(), doc, 0); + xmlDocFormatDump(yaz_log_file(), doc, 0); #else - xmlDocDump(yaz_log_file(), doc); + xmlDocDump(yaz_log_file(), doc); +#endif #endif - } r = parse_config(config, n); } xmlFreeDoc(doc); @@ -1358,7 +1385,6 @@ void config_destroy(struct conf_config *config) struct conf_server *s_next = server->next; server_destroy(server); server = s_next; - database_hosts_destroy(&config->database_hosts); } wrbuf_destroy(config->confdir); nmem_destroy(config->nmem); @@ -1396,7 +1422,7 @@ int config_start_listeners(struct conf_config *conf, { struct conf_server *ser; - conf->iochan_man = iochan_man_create(conf->no_threads); + conf->iochan_man = iochan_man_create(conf->no_threads, conf->max_sockets); for (ser = conf->servers; ser; ser = ser->next) { WRBUF w;