From: Adam Dickmeiss Date: Wed, 23 Sep 2009 12:29:48 +0000 (+0200) Subject: Re-structure conf/server/service ptrs X-Git-Tag: v1.2.1~27 X-Git-Url: http://lists.indexdata.com/cgi-bin?a=commitdiff_plain;h=77c88af0dbe56288a1673315822c37bad9579cde;p=pazpar2-moved-to-github.git Re-structure conf/server/service ptrs --- diff --git a/src/http.c b/src/http.c index bb5a36c..0c4e4b8 100644 --- a/src/http.c +++ b/src/http.c @@ -90,8 +90,8 @@ struct http_channel_observer_s { }; -static const char *http_lookup_header(struct http_header *header, - const char *name) +const char *http_lookup_header(struct http_header *header, + const char *name) { for (; header; header = header->next) if (!strcasecmp(name, header->name)) diff --git a/src/http.h b/src/http.h index e3f6078..f24147b 100644 --- a/src/http.h +++ b/src/http.h @@ -106,6 +106,8 @@ int http_init(const char *addr, struct conf_server *ser); void http_close_server(struct conf_server *ser); void http_addheader(struct http_response *r, const char *name, const char *value); +const char *http_lookup_header(struct http_header *header, + const char *name); struct http_header * http_header_append(struct http_channel *ch, struct http_header * hp, const char *name, diff --git a/src/logic.c b/src/logic.c index 2abae16..cfefc67 100644 --- a/src/logic.c +++ b/src/logic.c @@ -357,7 +357,7 @@ static int prepare_map(struct session *se, struct session_database *sdb) if (!strcmp(&stylesheets[i][strlen(stylesheets[i])-4], ".xsl")) { (*m)->marcmap = NULL; - if (!((*m)->stylesheet = conf_load_stylesheet(se->service->config, stylesheets[i]))) + if (!((*m)->stylesheet = conf_load_stylesheet(se->service, stylesheets[i]))) { yaz_log(YLOG_FATAL|YLOG_ERRNO, "Unable to load stylesheet: %s", stylesheets[i]); diff --git a/src/pazpar2_config.c b/src/pazpar2_config.c index dfb4509..818eff4 100644 --- a/src/pazpar2_config.c +++ b/src/pazpar2_config.c @@ -114,7 +114,7 @@ static void conf_sortkey_assign(NMEM nmem, } -static struct conf_service *service_init(struct conf_config *config, +static struct conf_service *service_init(struct conf_server *server, int num_metadata, int num_sortkeys, const char *service_id) { @@ -127,7 +127,7 @@ static struct conf_service *service_init(struct conf_config *config, service->settings = 0; service->databases = 0; service->targetprofiles = 0; - service->config = config; + service->server = server; service->session_timeout = 60; /* default session timeout */ service->z3950_session_timeout = 180; service->z3950_connect_timeout = 15; @@ -426,7 +426,7 @@ static int parse_metadata(struct conf_service *service, xmlNode *n, return 0; } -static struct conf_service *service_create(struct conf_config *config, +static struct conf_service *service_create(struct conf_server *server, xmlNode *node, const char *service_id) { @@ -451,7 +451,7 @@ static struct conf_service *service_create(struct conf_config *config, xmlFree(sortkey); } - service = service_init(config, num_metadata, num_sortkeys, service_id); + service = service_init(server, num_metadata, num_sortkeys, service_id); for (n = node->children; n; n = n->next) { @@ -576,7 +576,7 @@ static struct conf_service *service_create(struct conf_config *config, if (src) { WRBUF w = wrbuf_alloc(); - conf_dir_path(config, w, (const char *) src); + conf_dir_path(server->config, w, (const char *) src); settings_read_file(service, wrbuf_cstr(w), pass); wrbuf_destroy(w); xmlFree(src); @@ -686,6 +686,7 @@ static struct conf_server *server_create(struct conf_config *config, server->myurl = 0; server->proxy_addr = 0; server->service = 0; + server->config = config; server->next = 0; server->relevance_pct = 0; server->sort_pct = 0; @@ -777,7 +778,7 @@ static struct conf_server *server_create(struct conf_config *config, } else { - struct conf_service *s = service_create(config, n, + struct conf_service *s = service_create(server, n, service_id); xmlFree(service_id); if (!s) @@ -795,9 +796,10 @@ static struct conf_server *server_create(struct conf_config *config, return server; } -xsltStylesheet *conf_load_stylesheet(struct conf_config *config, +xsltStylesheet *conf_load_stylesheet(struct conf_service *service, const char *fname) { + struct conf_config *config = service->server->config; WRBUF w = wrbuf_alloc(); xsltStylesheet *s; diff --git a/src/pazpar2_config.h b/src/pazpar2_config.h index 6c4b33e..f56ea7f 100644 --- a/src/pazpar2_config.h +++ b/src/pazpar2_config.h @@ -90,6 +90,8 @@ struct conf_sortkey enum conf_sortkey_type type; }; +struct conf_server; + // It is conceivable that there will eventually be several 'services' // offered from one server, with separate configuration -- possibly // more than one services associated with the same port. For now, @@ -116,13 +118,9 @@ struct conf_service struct database *databases; struct conf_targetprofiles *targetprofiles; - struct conf_config *config; + struct conf_server *server; }; -struct conf_service * conf_service_create(struct conf_config *config, - int num_metadata, int num_sortkeys, - const char *service_id); - int conf_service_metadata_field_id(struct conf_service *service, const char * name); int conf_service_sortkey_field_id(struct conf_service *service, const char * name); @@ -143,6 +141,7 @@ struct conf_server pp2_charset_t mergekey_pct; struct conf_service *service; struct conf_server *next; + struct conf_config *config; }; struct conf_targetprofiles @@ -155,7 +154,7 @@ struct conf_targetprofiles struct conf_config *config_create(const char *fname, int verbose); void config_destroy(struct conf_config *config); -xsltStylesheet *conf_load_stylesheet(struct conf_config *config, +xsltStylesheet *conf_load_stylesheet(struct conf_service *service, const char *fname); void config_start_databases(struct conf_config *config);