// 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
};
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;
}
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)
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);
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)))
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)))
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);