X-Git-Url: http://lists.indexdata.com/cgi-bin?a=blobdiff_plain;f=src%2Flogic.c;h=3ea153faf18540fc4abf738358e4594349292def;hb=26e2bf146ed32bc205eb2b76cdc2974c75504c58;hp=354fd7f090afe531faf68c463aa219ce7218b3b6;hpb=f5d345051217a4f54a53dac5a7397f5672e305ad;p=pazpar2-moved-to-github.git diff --git a/src/logic.c b/src/logic.c index 354fd7f..3ea153f 100644 --- a/src/logic.c +++ b/src/logic.c @@ -76,21 +76,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // Note: Some things in this structure will eventually move to configuration struct parameters global_parameters = { - "", - "", - "", - 0, 0, // dump_records 0, // debug_mode 30, // operations timeout - "81", - "Index Data PazPar2", - VERSION, 60, // session timeout 100, - MAX_CHUNK, - 0, - 0, 180, // Z39.50 session timeout 15 // Connect timeout }; @@ -532,7 +522,7 @@ enum pazpar2_error_code search(struct session *se, live_channels = select_targets(se, criteria); if (live_channels) { - int maxrecs = live_channels * global_parameters.toget; + int maxrecs = live_channels * global_parameters.toget; // This is buggy!!! se->reclist = reclist_create(se->nmem, maxrecs); se->expected_maxrecs = maxrecs; } @@ -877,50 +867,57 @@ void statistics(struct session *se, struct statistics *stat) stat->num_clients = count; } -int start_http_listener(void) +int start_http_listener(struct conf_config *conf, + const char *listener_override, + const char *proxy_override) { - char hp[128] = ""; - struct conf_server *ser = global_parameters.server; - - if (*global_parameters.listener_override) - strcpy(hp, global_parameters.listener_override); - else + struct conf_server *ser; + for (ser = conf->servers; ser; ser = ser->next) { - strcpy(hp, ser->host ? ser->host : ""); - if (ser->port) + WRBUF w = wrbuf_alloc(); + int r; + if (listener_override) { - if (*hp) - strcat(hp, ":"); - sprintf(hp + strlen(hp), "%d", ser->port); + wrbuf_puts(w, listener_override); + listener_override = 0; /* only first server is overriden */ } - } - return http_init(hp); -} - -void start_proxy(void) -{ - char hp[128] = ""; - struct conf_server *ser = global_parameters.server; + else + { + if (ser->host) + wrbuf_puts(w, ser->host); + if (ser->port) + { + if (wrbuf_len(w)) + wrbuf_puts(w, ":"); + wrbuf_printf(w, "%d", ser->port); + } + } + r = http_init(wrbuf_cstr(w), ser); + wrbuf_destroy(w); + if (r) + return -1; - if (*global_parameters.proxy_override) - strcpy(hp, global_parameters.proxy_override); - else if (ser->proxy_host || ser->proxy_port) - { - strcpy(hp, ser->proxy_host ? ser->proxy_host : ""); - if (ser->proxy_port) + w = wrbuf_alloc(); + if (proxy_override) + wrbuf_puts(w, proxy_override); + else if (ser->proxy_host || ser->proxy_port) { - if (*hp) - strcat(hp, ":"); - sprintf(hp + strlen(hp), "%d", ser->proxy_port); + if (ser->proxy_host) + wrbuf_puts(w, ser->proxy_host); + if (ser->proxy_port) + { + if (wrbuf_len(w)) + wrbuf_puts(w, ":"); + wrbuf_printf(w, "%d", ser->proxy_port); + } } + if (wrbuf_len(w)) + http_set_proxyaddr(wrbuf_cstr(w), ser); + wrbuf_destroy(w); } - else - return; - - http_set_proxyaddr(hp, ser->myurl ? ser->myurl : ""); + return 0; } - // Master list of connections we're handling events to static IOCHAN channel_list = 0; void pazpar2_add_channel(IOCHAN chan) @@ -964,8 +961,8 @@ static struct record_metadata *record_metadata_init( return rec_md; } -const char *get_mergekey(xmlDoc *doc, struct client *cl, int record_no, - struct conf_service *service, NMEM nmem) +static const char *get_mergekey(xmlDoc *doc, struct client *cl, int record_no, + struct conf_service *service, NMEM nmem) { char *mergekey_norm = 0; xmlNode *root = xmlDocGetRootElement(doc); @@ -979,7 +976,7 @@ const char *get_mergekey(xmlDoc *doc, struct client *cl, int record_no, const char *norm_str; pp2_relevance_token_t prt = pp2_relevance_tokenize( - global_parameters.server->mergekey_pct, + service->mergekey_pct, (const char *) mergekey); while ((norm_str = pp2_relevance_token_next(prt))) @@ -1023,7 +1020,7 @@ const char *get_mergekey(xmlDoc *doc, struct client *cl, int record_no, const char *norm_str; pp2_relevance_token_t prt = pp2_relevance_tokenize( - global_parameters.server->mergekey_pct, + service->mergekey_pct, (const char *) value); while ((norm_str = pp2_relevance_token_next(prt))) @@ -1209,7 +1206,7 @@ struct record *ingest_record(struct client *cl, const char *rec, sizeof(union data_types)); prt = pp2_relevance_tokenize( - global_parameters.server->sort_pct, + service->sort_pct, rec_md->data.text.disp); pp2_relevance_token_next(prt);