pazpar2  1.13.0
pazpar2_config.c
Go to the documentation of this file.
1 /* This file is part of Pazpar2.
2  Copyright (C) Index Data
3 
4 Pazpar2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8 
9 Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 
18 */
19 
20 #if HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23 
24 #include <string.h>
25 #include <assert.h>
26 
27 #include <libxml/parser.h>
28 #include <libxml/tree.h>
29 #include <libxml/xinclude.h>
30 
31 #include <yaz/yaz-util.h>
32 #include <yaz/nmem.h>
33 #include <yaz/snprintf.h>
34 #include <yaz/tpath.h>
35 #include <yaz/xml_include.h>
36 
37 #include <sys/types.h>
38 #include <sys/stat.h>
39 #if HAVE_UNISTD_H
40 #include <unistd.h>
41 #endif
42 #include "ppmutex.h"
43 #include "incref.h"
44 #include "pazpar2_config.h"
45 #include "service_xslt.h"
46 #include "settings.h"
47 #include "eventl.h"
48 #include "http.h"
49 
51 {
52  NMEM nmem; /* for conf_config and servers memory */
54 
57  WRBUF confdir;
58  char *path;
60 };
61 
63 {
64  char *id;
65  xsltStylesheetPtr xsp;
66  struct service_xslt *next;
67 };
68 
69 static char *xml_context(const xmlNode *ptr, char *res, size_t len)
70 {
71  xmlAttr *attr = ptr->properties;
72  size_t off = len - 1;
73 
74  res[off] = '\0';
75  for (; attr; attr = attr->next)
76  {
77  size_t l = strlen((const char *) attr->name);
78  if (off <= l + 1)
79  break;
80  off = off - l;
81  memcpy(res + off, attr->name, l);
82  res[--off] = '@';
83  }
84  while (ptr && ptr->type == XML_ELEMENT_NODE)
85  {
86  size_t l = strlen((const char *) ptr->name);
87  if (off <= l + 1)
88  break;
89 
90  off = off - l;
91  memcpy(res + off, ptr->name, l);
92  res[--off] = '/';
93 
94  ptr = ptr->parent;
95  }
96  return res + off;
97 }
98 
100  int num_metadata, int num_sortkeys,
101  const char *service_id)
102 {
103  struct conf_service * service = 0;
104  NMEM nmem = nmem_create();
105 
106 
107  service = nmem_malloc(nmem, sizeof(struct conf_service));
108  service->mutex = 0;
109  service->ref_count = 1;
110  service->nmem = nmem;
111  service->next = 0;
112  service->databases = 0;
113  service->xslt_list = 0;
114  service->ccl_bibset = 0;
115  service->server = server;
116  service->session_timeout = 60; /* default session timeout */
117  service->z3950_session_timeout = 180;
118  service->z3950_operation_timeout = 30;
119  service->rank_cluster = 1;
120  service->rank_debug = 0;
121  service->rank_follow = 0.0;
122  service->rank_lead = 0.0;
123  service->rank_length = 2;
124 
125  service->charsets = 0;
126 
127  service->id = service_id ? nmem_strdup(nmem, service_id) : 0;
128 
129  // Setup a dictionary from server.
130  service->dictionary = 0;
131 
132  service->settings = nmem_malloc(nmem, sizeof(*service->settings));
133  service->settings->num_settings = PZ_MAX_EOF;
134  service->settings->settings = nmem_malloc(nmem, sizeof(struct setting*) * service->settings->num_settings);
135  memset(service->settings->settings, 0, sizeof(struct setting*) * service->settings->num_settings);
136  // inherit_server_settings_values(service);
137 
138  service->next = 0;
139 
140  service->num_metadata = num_metadata;
141 
142  service->metadata = 0;
143  if (service->num_metadata)
144  service->metadata
145  = nmem_malloc(nmem,
146  sizeof(struct conf_metadata) * service->num_metadata);
147  service->num_sortkeys = num_sortkeys;
148 
149  service->default_sort = nmem_strdup(nmem, "relevance");
150  service->sortkeys = 0;
151  if (service->num_sortkeys)
152  service->sortkeys
153  = nmem_malloc(nmem,
154  sizeof(struct conf_sortkey) * service->num_sortkeys);
155  service->xml_node = 0;
156  return service;
157 }
158 
160  struct conf_service *service,
161  int field_id,
162  const char *name,
166  int brief,
167  int termlist,
168  const char *rank,
169  int sortkey_offset,
170  enum conf_metadata_mergekey mt,
171  const char *facetrule,
172  const char *limitmap,
173  const char *limitcluster,
174  const char *icurule
175  )
176 {
177  struct conf_metadata * md = 0;
178  NMEM nmem = service->nmem;
179 
180  if (!service->metadata || !service->num_metadata
181  || field_id < 0 || !(field_id < service->num_metadata))
182  return 0;
183 
184  md = service->metadata + field_id;
185  assert(nmem && md && name);
186 
187  md->name = nmem_strdup(nmem, name);
188 
189  md->type = type;
190 
191  // enforcing that type_year is always range_merge
192  if (md->type == Metadata_type_year)
194  else
195  md->merge = merge;
196 
197  md->setting = setting;
198  md->brief = brief;
199  md->termlist = termlist;
200  md->rank = nmem_strdup_null(nmem, rank);
202  md->mergekey = mt;
203  md->facetrule = nmem_strdup_null(nmem, facetrule);
204  md->limitmap = nmem_strdup_null(nmem, limitmap);
205  md->limitcluster = nmem_strdup_null(nmem, limitcluster);
206  md->icurule = nmem_strdup_null(nmem, icurule);
207  return md;
208 }
209 
211  struct conf_service *service,
212  int field_id,
213  const char *name,
215 {
216  struct conf_sortkey *sk = 0;
217  NMEM nmem = service->nmem;
218 
219  if (!service->sortkeys || !service->num_sortkeys
220  || field_id < 0 || !(field_id < service->num_sortkeys))
221  return 0;
222 
223  sk = service->sortkeys + field_id;
224 
225  assert(nmem && sk && name);
226 
227  sk->name = nmem_strdup(nmem, name);
228  sk->type = type;
229  return sk;
230 }
231 
233  const char * name)
234 {
235  int i = 0;
236 
237  if (!service || !service->metadata || !service->num_metadata)
238  return -1;
239 
240  for (i = 0; i < service->num_metadata; i++)
241  if (!strcmp(name, (service->metadata[i]).name))
242  return i;
243  return -1;
244 }
245 
247  const char * name)
248 {
249  int i = 0;
250 
251  if (!service || !service->sortkeys || !service->num_sortkeys)
252  return -1;
253 
254  for (i = 0; i < service->num_sortkeys; i++)
255  if (!strcmp(name, (service->sortkeys[i]).name))
256  return i;
257  return -1;
258 }
259 
260 static void conf_dir_path(struct conf_config *config, WRBUF w, const char *src)
261 {
262  char full_path[1024];
263  if (yaz_filepath_resolve(src, config->path,
264  wrbuf_len(config->confdir) > 0 ?
265  wrbuf_cstr(config->confdir) : ".",
266  full_path))
267  {
268  wrbuf_puts(w, full_path);
269  }
270  else
271  {
272  yaz_log(YLOG_WARN, "File not found: fname=%s path=%s base=%s", src,
273  config->path, wrbuf_cstr(config->confdir));
274  wrbuf_puts(w, src);
275  }
276 }
277 
278 void service_destroy(struct conf_service *service)
279 {
280  if (service)
281  {
282  if (!pazpar2_decref(&service->ref_count, service->mutex))
283  {
284  service_xslt_destroy(service);
286  ccl_qual_rm(&service->ccl_bibset);
287  yaz_mutex_destroy(&service->mutex);
288  nmem_destroy(service->nmem);
289  }
290  }
291 }
292 
293 void service_incref(struct conf_service *service)
294 {
295  pazpar2_incref(&service->ref_count, service->mutex);
296 }
297 
298 static int parse_metadata(struct conf_service *service, xmlNode *n,
299  int *md_node, int *sk_node)
300 {
304  enum conf_metadata_mergekey mergekey_type = Metadata_mergekey_no;
305  int brief = 0;
306  int termlist = 0;
307  int sortkey_offset = 0;
308  xmlChar *xml_name = 0;
309  xmlChar *xml_brief = 0;
310  xmlChar *xml_sortkey = 0;
311  xmlChar *xml_merge = 0;
312  xmlChar *xml_type = 0;
313  xmlChar *xml_termlist = 0;
314  xmlChar *xml_rank = 0;
315  xmlChar *xml_setting = 0;
316  xmlChar *xml_mergekey = 0;
317  xmlChar *xml_limitmap = 0;
318  xmlChar *xml_limitcluster = 0;
319  xmlChar *xml_icu_chain = 0;
320  xmlChar *xml_icurule = 0;
321 
322  struct _xmlAttr *attr;
323 
324  assert(service);
325 
326  for (attr = n->properties; attr; attr = attr->next)
327  {
328  if (!xmlStrcmp(attr->name, BAD_CAST "name") &&
329  attr->children && attr->children->type == XML_TEXT_NODE)
330  xml_name = attr->children->content;
331  else if (!xmlStrcmp(attr->name, BAD_CAST "brief") &&
332  attr->children && attr->children->type == XML_TEXT_NODE)
333  xml_brief = attr->children->content;
334  else if (!xmlStrcmp(attr->name, BAD_CAST "sortkey") &&
335  attr->children && attr->children->type == XML_TEXT_NODE)
336  xml_sortkey = attr->children->content;
337  else if (!xmlStrcmp(attr->name, BAD_CAST "merge") &&
338  attr->children && attr->children->type == XML_TEXT_NODE)
339  xml_merge = attr->children->content;
340  else if (!xmlStrcmp(attr->name, BAD_CAST "type") &&
341  attr->children && attr->children->type == XML_TEXT_NODE)
342  xml_type = attr->children->content;
343  else if (!xmlStrcmp(attr->name, BAD_CAST "termlist") &&
344  attr->children && attr->children->type == XML_TEXT_NODE)
345  xml_termlist = attr->children->content;
346  else if (!xmlStrcmp(attr->name, BAD_CAST "rank") &&
347  attr->children && attr->children->type == XML_TEXT_NODE)
348  xml_rank = attr->children->content;
349  else if (!xmlStrcmp(attr->name, BAD_CAST "setting") &&
350  attr->children && attr->children->type == XML_TEXT_NODE)
351  xml_setting = attr->children->content;
352  else if (!xmlStrcmp(attr->name, BAD_CAST "mergekey") &&
353  attr->children && attr->children->type == XML_TEXT_NODE)
354  xml_mergekey = attr->children->content;
355  else if (!xmlStrcmp(attr->name, BAD_CAST "facetrule") &&
356  attr->children && attr->children->type == XML_TEXT_NODE)
357  xml_icu_chain = attr->children->content;
358  else if (!xmlStrcmp(attr->name, BAD_CAST "limitmap") &&
359  attr->children && attr->children->type == XML_TEXT_NODE)
360  xml_limitmap = attr->children->content;
361  else if (!xmlStrcmp(attr->name, BAD_CAST "limitcluster") &&
362  attr->children && attr->children->type == XML_TEXT_NODE)
363  xml_limitcluster = attr->children->content;
364  else if (!xmlStrcmp(attr->name, BAD_CAST "icurule") &&
365  attr->children && attr->children->type == XML_TEXT_NODE)
366  xml_icurule = attr->children->content;
367  else
368  {
369  yaz_log(YLOG_FATAL, "Unknown metadata attribute '%s'", attr->name);
370  return -1;
371  }
372  }
373 
374  // now do the parsing logic
375  if (!xml_name)
376  {
377  yaz_log(YLOG_FATAL, "Must specify name in metadata element");
378  return -1;
379  }
380  if (xml_brief)
381  {
382  if (!strcmp((const char *) xml_brief, "yes"))
383  brief = 1;
384  else if (strcmp((const char *) xml_brief, "no"))
385  {
386  yaz_log(YLOG_FATAL, "metadata/brief must be yes or no");
387  return -1;
388  }
389  }
390 
391  if (xml_termlist)
392  {
393  if (!strcmp((const char *) xml_termlist, "yes"))
394  termlist = 1;
395  else if (strcmp((const char *) xml_termlist, "no"))
396  {
397  yaz_log(YLOG_FATAL, "metadata/termlist must be yes or no");
398  return -1;
399  }
400  }
401 
402  if (xml_type)
403  {
404  if (!strcmp((const char *) xml_type, "generic"))
405  type = Metadata_type_generic;
406  else if (!strcmp((const char *) xml_type, "year"))
407  type = Metadata_type_year;
408  else if (!strcmp((const char *) xml_type, "date"))
409  type = Metadata_type_date;
410  else if (!strcmp((const char *) xml_type, "float"))
411  type = Metadata_type_float;
412  else
413  {
414  yaz_log(YLOG_FATAL,
415  "Unknown value for metadata/type: %s", xml_type);
416  return -1;
417  }
418  }
419 
420  if (xml_merge)
421  {
422  if (!strcmp((const char *) xml_merge, "no"))
423  merge = Metadata_merge_no;
424  else if (!strcmp((const char *) xml_merge, "unique"))
425  merge = Metadata_merge_unique;
426  else if (!strcmp((const char *) xml_merge, "longest"))
427  merge = Metadata_merge_longest;
428  else if (!strcmp((const char *) xml_merge, "range"))
429  merge = Metadata_merge_range;
430  else if (!strcmp((const char *) xml_merge, "all"))
431  merge = Metadata_merge_all;
432  else if (!strcmp((const char *) xml_merge, "first"))
433  merge = Metadata_merge_first;
434  else
435  {
436  yaz_log(YLOG_FATAL,
437  "Unknown value for metadata/merge: %s", xml_merge);
438  return -1;
439  }
440  }
441 
442  if (xml_setting)
443  {
444  if (!strcmp((const char *) xml_setting, "no"))
445  setting = Metadata_setting_no;
446  else if (!strcmp((const char *) xml_setting, "postproc"))
447  setting = Metadata_setting_postproc;
448  else if (!strcmp((const char *) xml_setting, "parameter"))
449  setting = Metadata_setting_parameter;
450  else
451  {
452  yaz_log(YLOG_FATAL,
453  "Unknown value for metadata/setting: %s", xml_setting);
454  return -1;
455  }
456  }
457 
458  // add a sortkey if so specified
459  if (xml_sortkey && strcmp((const char *) xml_sortkey, "no"))
460  {
461  enum conf_metadata_type sk_type = type;
462  if (merge == Metadata_merge_no)
463  {
464  yaz_log(YLOG_FATAL,
465  "Can't specify sortkey on a non-merged field");
466  return -1;
467  }
468  if (!strcmp((const char *) xml_sortkey, "yes"))
469  ;
470  if (!strcmp((const char *) xml_sortkey, "numeric"))
471  ;
472  else if (!strcmp((const char *) xml_sortkey, "skiparticle"))
473  {
474  if (sk_type == Metadata_type_generic)
475  sk_type = Metadata_type_skiparticle;
476  else
477  {
478  yaz_log(YLOG_FATAL,
479  "skiparticle only supported for type=generic: %s",
480  xml_type);
481  return -1;
482  }
483  }
484  else
485  {
486  yaz_log(YLOG_FATAL,
487  "Unknown sortkey in metadata element: %s",
488  xml_sortkey);
489  return -1;
490  }
491  sortkey_offset = *sk_node;
492 
493  conf_service_add_sortkey(service, *sk_node,
494  (const char *) xml_name, sk_type);
495  (*sk_node)++;
496  }
497  else
498  sortkey_offset = -1;
499 
500  if (xml_mergekey)
501  {
502  if (!strcmp((const char *) xml_mergekey, "required"))
503  mergekey_type = Metadata_mergekey_required;
504  else if (!strcmp((const char *) xml_mergekey, "optional"))
505  mergekey_type = Metadata_mergekey_optional;
506  else if (!strcmp((const char *) xml_mergekey, "no"))
507  mergekey_type = Metadata_mergekey_no;
508  else
509  {
510  yaz_log(YLOG_FATAL, "Unknown value for mergekey: %s", xml_mergekey);
511  return -1;
512  }
513  }
514 
515  // metadata known, assign values
516  conf_service_add_metadata(service, *md_node,
517  (const char *) xml_name,
518  type, merge, setting,
519  brief, termlist,
520  (const char *) xml_rank, sortkey_offset,
521  mergekey_type,
522  (const char *) xml_icu_chain,
523  (const char *) xml_limitmap,
524  (const char *) xml_limitcluster,
525  (const char *) xml_icurule
526  );
527  (*md_node)++;
528  return 0;
529 }
530 
531 
532 static void count_metadata(xmlNode *n, int *num_metadata, int *num_sortkeys)
533 {
534  xmlChar *sortkey = xmlGetProp(n, (xmlChar *) "sortkey");
535  (*num_metadata)++;
536 
537  if (sortkey && strcmp((const char *) sortkey, "no"))
538  (*num_sortkeys)++;
539  xmlFree(sortkey);
540 }
541 
542 
544  xmlNode *node,
545  const char *service_id)
546 {
547  xmlNode *n;
548  int md_node = 0;
549  int sk_node = 0;
550 
551  struct conf_service *service = 0;
552  int num_metadata = 0;
553  int num_sortkeys = 0;
554  int got_settings = 0;
555 
556  // count num_metadata and num_sortkeys
557  for (n = node->children; n; n = n->next)
558  if (n->type == XML_ELEMENT_NODE && !strcmp((const char *)
559  n->name, "metadata"))
560  {
561  if (n->children) // This is a <metadata> container, look at its contents.
562  {
563  xmlNode *m;
564  for (m = n->children; m; m = m->next)
565  {
566  if (m->type == XML_ELEMENT_NODE &&
567  !strcmp((const char *) m->name, "metadata"))
568  count_metadata(m, &num_metadata, &num_sortkeys);
569  }
570  }
571  else // This is a metadata-element proper, count it right away.
572  count_metadata(n, &num_metadata, &num_sortkeys);
573  }
574 
575  service = service_init(server, num_metadata, num_sortkeys, service_id);
576 
577  for (n = node->children; n; n = n->next)
578  {
579  if (n->type != XML_ELEMENT_NODE)
580  continue;
581  if (!strcmp((const char *) n->name, "timeout"))
582  {
583  xmlChar *src = xmlGetProp(n, (xmlChar *) "session");
584  if (src)
585  {
586  service->session_timeout = atoi((const char *) src);
587  xmlFree(src);
588  if (service->session_timeout < 9)
589  {
590  yaz_log(YLOG_FATAL, "session timeout out of range");
591  return 0;
592  }
593  }
594  src = xmlGetProp(n, (xmlChar *) "z3950_operation");
595  if (src)
596  {
597  service->z3950_operation_timeout = atoi((const char *) src);
598  xmlFree(src);
599  if (service->z3950_session_timeout < 9)
600  {
601  yaz_log(YLOG_FATAL, "Z39.50 operation timeout out of range");
602  return 0;
603  }
604  }
605  src = xmlGetProp(n, (xmlChar *) "z3950_session");
606  if (src)
607  {
608  service->z3950_session_timeout = atoi((const char *) src);
609  xmlFree(src);
610  if (service->z3950_session_timeout < 9)
611  {
612  yaz_log(YLOG_FATAL, "Z39.50 session timeout out of range");
613  return 0;
614  }
615  }
616  }
617  else if (!strcmp((const char *) n->name, "ccldirective"))
618  {
619  char *name;
620  char *value;
621  if (!service->ccl_bibset)
622  service->ccl_bibset = ccl_qual_mk();
623  name = (char *) xmlGetProp(n, (xmlChar *) "name");
624  if (!name)
625  {
626  yaz_log(YLOG_FATAL, "ccldirective: missing @name");
627  return 0;
628  }
629  value = (char *) xmlGetProp(n, (xmlChar *) "value");
630  if (!value)
631  {
632  xmlFree(name);
633  yaz_log(YLOG_FATAL, "ccldirective: missing @value");
634  return 0;
635  }
636  ccl_qual_add_special(service->ccl_bibset, name, value);
637  xmlFree(value);
638  xmlFree(name);
639  }
640  else if (!strcmp((const char *) n->name, "settings"))
641  got_settings++;
642  else if (!strcmp((const char *) n->name, "icu_chain"))
643  {
644  if (!service->charsets)
645  service->charsets = pp2_charset_fact_create();
646  if (pp2_charset_fact_define(service->charsets, n, 0))
647  {
648  yaz_log(YLOG_FATAL, "ICU chain definition error");
649  return 0;
650  }
651  }
652  else if (!strcmp((const char *) n->name, "relevance")
653  || !strcmp((const char *) n->name, "sort")
654  || !strcmp((const char *) n->name, "mergekey")
655  || !strcmp((const char *) n->name, "facet"))
656 
657  {
658  if (!service->charsets)
659  service->charsets = pp2_charset_fact_create();
660  if (pp2_charset_fact_define(service->charsets, n,
661  (const char *) n->name))
662  {
663  yaz_log(YLOG_FATAL, "ICU chain definition error");
664  return 0;
665  }
666  }
667  else if (!strcmp((const char *) n->name, (const char *) "metadata"))
668  {
669  if (n->children) // This is a <metadata> container, look at its content.
670  {
671  xmlNode *m;
672  for (m = n->children; m; m = m->next)
673  if ((!strcmp((const char *) m->name, (const char *) "metadata")))
674  if (parse_metadata(service, m, &md_node, &sk_node))
675  return 0;
676  }
677  else // This is a metadata-element proper, count it right away.
678  if (parse_metadata(service, n, &md_node, &sk_node))
679  return 0;
680  }
681  else if (!strcmp((const char *) n->name, (const char *) "xslt"))
682  {
683  if (service_xslt_config(service, n))
684  return 0;
685  }
686  else if (!strcmp((const char *) n->name, "rank"))
687  {
688  char *rank_cluster = (char *) xmlGetProp(n, (xmlChar *) "cluster");
689  char *rank_debug = (char *) xmlGetProp(n, (xmlChar *) "debug");
690  char *rank_follow = (char *) xmlGetProp(n, (xmlChar *) "follow");
691  char *rank_lead = (char *) xmlGetProp(n, (xmlChar *) "lead");
692  char *rank_length= (char *) xmlGetProp(n, (xmlChar *) "length");
693  if (rank_cluster)
694  {
695  if (!strcmp(rank_cluster, "yes"))
696  service->rank_cluster = 1;
697  else if (!strcmp(rank_cluster, "no"))
698  service->rank_cluster = 0;
699  else
700  {
701  yaz_log(YLOG_FATAL, "service: rank@cluster boolean");
702  return 0;
703  }
704  }
705  if (rank_debug)
706  {
707  if (!strcmp(rank_debug, "yes"))
708  service->rank_debug = 1;
709  else if (!strcmp(rank_debug, "no"))
710  service->rank_debug = 0;
711  else
712  {
713  yaz_log(YLOG_FATAL, "service: rank@debug boolean");
714  return 0;
715  }
716  }
717  if (rank_follow)
718  {
719  service->rank_follow = atof(rank_follow);
720  }
721  if (rank_lead)
722  {
723  service->rank_lead = atof(rank_lead);
724  }
725  if (rank_length)
726  {
727  if (!strcmp(rank_length, "linear"))
728  service->rank_length = 2;
729  else if (!strcmp(rank_length, "log"))
730  service->rank_length = 1;
731  else if (!strcmp(rank_length, "none"))
732  service->rank_length = 0;
733  else
734  {
735  yaz_log(YLOG_FATAL, "service: rank@length linear|log|none");
736  return 0;
737  }
738  }
739  xmlFree(rank_cluster);
740  xmlFree(rank_debug);
741  xmlFree(rank_follow);
742  xmlFree(rank_lead);
743  xmlFree(rank_length);
744  }
745  else if (!strcmp((const char *) n->name, "sort-default"))
746  {
747  char *default_sort = (char *) xmlGetProp(n, (xmlChar *) "field");
748 
749  if (default_sort && strcmp(default_sort, "")) {
750  service->default_sort = nmem_strdup(service->nmem, default_sort);
751  yaz_log(YLOG_LOG, "service %s: default sort order configured to: %s",
752  service_id ? service_id : "unnamed", default_sort);
753  }
754  else
755  {
756  yaz_log(YLOG_FATAL, "default sort order is invalid: %s", default_sort);
757  return 0;
758  }
759  xmlFree(default_sort);
760  }
761  else
762  {
763  char tmp[80];
764  yaz_log(YLOG_FATAL, "Bad element: %s . Context: %s", n->name,
765  xml_context(n, tmp, sizeof tmp));
766  return 0;
767  }
768  }
769  if (got_settings)
770  {
771  int pass;
772  /* metadata has been read.. Consider now settings */
773  init_settings(service);
774  for (pass = 1; pass <= 2; pass++)
775  {
776  for (n = node->children; n; n = n->next)
777  {
778  if (n->type != XML_ELEMENT_NODE)
779  continue;
780  if (!strcmp((const char *) n->name, "settings"))
781  {
782  int ret;
783  xmlChar *src = xmlGetProp(n, (xmlChar *) "src");
784  if (src)
785  {
786  WRBUF w = wrbuf_alloc();
787  conf_dir_path(server->config, w, (const char *) src);
788  ret = settings_read_file(service, wrbuf_cstr(w), pass);
789  wrbuf_destroy(w);
790  xmlFree(src);
791  }
792  else
793  {
794  ret = settings_read_node(service, n, pass);
795  }
796  if (ret)
797  return 0;
798  }
799  }
800  }
801  }
802 
803  {
804  xmlBufferPtr buf = xmlBufferCreate();
805  xmlNodeDump(buf, node->doc, node, 0, 0);
806  service->xml_node =
807  nmem_strdupn(service->nmem, (const char *) buf->content, buf->use);
808  xmlBufferFree(buf);
809  }
810  return service;
811 }
812 
814 {
815  int ret = 0;
816  struct conf_server *server = s->server;
817  if (!s->dictionary) /* service has no config settings ? */
818  {
819  if (server->settings_fname)
820  {
821  /* inherit settings from server */
822  init_settings(s);
823  if (settings_read_file(s, server->settings_fname, 1))
824  ret = -1;
825  if (settings_read_file(s, server->settings_fname, 2))
826  ret = -1;
827  }
828  else
829  {
830  yaz_log(YLOG_WARN, "server '%s' has no settings", s->id ? s->id : "unnamed");
831  init_settings(s);
832  }
833  }
834 
835  /* use relevance/sort/mergekey/facet from server if not defined
836  for this service.. */
837  if (!s->charsets)
838  {
839  if (server->charsets)
840  {
841  s->charsets = server->charsets;
843  }
844  else
845  {
847  }
848  }
849  return ret;
850 }
851 
853  xmlNode *node)
854 {
855  struct conf_service *service = service_create_static(server, node, 0);
856  if (service)
857  {
858  inherit_server_settings(service);
859  assert(service->mutex == 0);
860  pazpar2_mutex_create(&service->mutex, "conf");
861  }
862  return service;
863 }
864 
866  NMEM nmem, xmlNode *node)
867 {
868  xmlNode *n;
869  struct conf_server *server = nmem_malloc(nmem, sizeof(struct conf_server));
870  xmlChar *server_id = xmlGetProp(node, (xmlChar *) "id");
871 
872  server->host = "@";
873  server->port = 0;
874  server->proxy_host = 0;
875  server->proxy_port = 0;
876  server->myurl = 0;
877  server->service = 0;
878  server->config = config;
879  server->next = 0;
880  server->charsets = 0;
881  server->http_server = 0;
882  server->iochan_man = 0;
883  server->settings_fname = 0;
884 
885  if (server_id)
886  {
887  server->server_id = nmem_strdup(nmem, (const char *)server_id);
888  xmlFree(server_id);
889  }
890  else
891  server->server_id = 0;
892  for (n = node->children; n; n = n->next)
893  {
894  if (n->type != XML_ELEMENT_NODE)
895  continue;
896  if (!strcmp((const char *) n->name, "listen"))
897  {
898  xmlChar *port = xmlGetProp(n, (xmlChar *) "port");
899  xmlChar *host = xmlGetProp(n, (xmlChar *) "host");
900 
901  if (port)
902  server->port = nmem_strdup(nmem, (const char *) port);
903  if (host)
904  server->host = nmem_strdup(nmem, (const char *) host);
905 
906  xmlFree(port);
907  xmlFree(host);
908  }
909  else if (!strcmp((const char *) n->name, "proxy"))
910  {
911  xmlChar *port = xmlGetProp(n, (xmlChar *) "port");
912  xmlChar *host = xmlGetProp(n, (xmlChar *) "host");
913  xmlChar *myurl = xmlGetProp(n, (xmlChar *) "myurl");
914  if (port)
915  server->proxy_port = atoi((const char *) port);
916  if (host)
917  server->proxy_host = nmem_strdup(nmem, (const char *) host);
918  if (myurl)
919  server->myurl = nmem_strdup(nmem, (const char *) myurl);
920  xmlFree(port);
921  xmlFree(host);
922  xmlFree(myurl);
923  }
924  else if (!strcmp((const char *) n->name, "settings"))
925  {
926  xmlChar *src = xmlGetProp(n, (xmlChar *) "src");
927  WRBUF w;
928  if (!src)
929  {
930  yaz_log(YLOG_FATAL, "Missing src attribute for settings");
931  return 0;
932  }
933  if (server->settings_fname)
934  {
935  xmlFree(src);
936  yaz_log(YLOG_FATAL, "Can't repeat 'settings'");
937  return 0;
938  }
939  w = wrbuf_alloc();
940  conf_dir_path(config, w, (const char *) src);
941  server->settings_fname = nmem_strdup(nmem, wrbuf_cstr(w));
942  wrbuf_destroy(w);
943  xmlFree(src);
944  }
945  else if (!strcmp((const char *) n->name, "icu_chain"))
946  {
947  if (!server->charsets)
948  server->charsets = pp2_charset_fact_create();
949  if (pp2_charset_fact_define(server->charsets, n, 0))
950  {
951  yaz_log(YLOG_FATAL, "ICU chain definition error");
952  return 0;
953  }
954  }
955  else if (!strcmp((const char *) n->name, "relevance")
956  || !strcmp((const char *) n->name, "sort")
957  || !strcmp((const char *) n->name, "mergekey")
958  || !strcmp((const char *) n->name, "facet"))
959  {
960  if (!server->charsets)
961  server->charsets = pp2_charset_fact_create();
962  if (pp2_charset_fact_define(server->charsets, n,
963  (const char *) n->name))
964  {
965  yaz_log(YLOG_FATAL, "ICU chain definition error");
966  return 0;
967  }
968  }
969  else if (!strcmp((const char *) n->name, "service"))
970  {
971  char *service_id = (char *)
972  xmlGetProp(n, (xmlChar *) "id");
973 
974  struct conf_service **sp = &server->service;
975  for (; *sp; sp = &(*sp)->next)
976  if ((*sp)->id && service_id &&
977  0 == strcmp((*sp)->id, service_id))
978  {
979  yaz_log(YLOG_FATAL, "Duplicate service: %s", service_id);
980  break;
981  }
982  else if (!(*sp)->id && !service_id)
983  {
984  yaz_log(YLOG_FATAL, "Duplicate unnamed service");
985  break;
986  }
987 
988  if (*sp) /* service already exist */
989  {
990  xmlFree(service_id);
991  return 0;
992  }
993  else
994  {
995  struct conf_service *s = service_create_static(server, n,
996  service_id);
997  xmlFree(service_id);
998  if (!s)
999  return 0;
1000  *sp = s;
1001  }
1002  }
1003  else
1004  {
1005  yaz_log(YLOG_FATAL, "Bad element: %s", n->name);
1006  return 0;
1007  }
1008  }
1009  if (!server->port)
1010  {
1011  yaz_log(YLOG_FATAL, "No listening port given");
1012  return 0;
1013  }
1014  if (server->service)
1015  {
1016  struct conf_service *s;
1017  for (s = server->service; s; s = s->next)
1019  }
1020  return server;
1021 }
1022 
1023 WRBUF conf_get_fname(struct conf_config *config, const char *fname)
1024 {
1025  WRBUF w = wrbuf_alloc();
1026 
1027  conf_dir_path(config, w, fname);
1028  return w;
1029 }
1030 
1032  const char *service_id)
1033 {
1034  struct conf_service *s = server->service;
1035  for (; s; s = s->next)
1036  if (s->id && service_id && 0 == strcmp(s->id, service_id))
1037  break;
1038  else if (!s->id && !service_id)
1039  break;
1040  if (s)
1041  service_incref(s);
1042  return s;
1043 }
1044 
1045 static void info_service_metadata(struct conf_service *service, WRBUF w)
1046 {
1047  int i;
1048  struct conf_metadata *md;
1049 
1050  if (service->num_metadata)
1051  {
1052  for (i = 0; i < service->num_metadata; i++)
1053  {
1054  md = &(service->metadata[i]);
1055  wrbuf_puts(w, " <metadata");
1056  if (md->name) {
1057  wrbuf_puts(w, " name=\"");
1058  wrbuf_xmlputs(w, md->name);
1059  wrbuf_puts(w, "\"");
1060  }
1061  if (md->brief) {
1062  wrbuf_puts(w, " brief=\"yes\"");
1063  }
1064  if (md->termlist) {
1065  wrbuf_puts(w, " termlist=\"yes\"");
1066  }
1067  if (md->rank) {
1068  wrbuf_puts(w, " rank=\"");
1069  wrbuf_xmlputs(w, md->rank);
1070  wrbuf_puts(w, "\"");
1071  }
1072  if (md->sortkey_offset > 0) {
1073  wrbuf_puts(w, " sortkey=\"");
1074  switch (service->sortkeys[md->sortkey_offset].type)
1075  {
1077  wrbuf_puts(w, "relevance");
1078  break;
1080  wrbuf_puts(w, "skiparticle");
1081  break;
1083  wrbuf_puts(w, "position");
1084  break;
1086  wrbuf_puts(w, "retrieval");
1087  break;
1088  default:
1089  wrbuf_puts(w, "yes");
1090  break;
1091  }
1092  wrbuf_puts(w, "\"");
1093  }
1094  switch (md->type)
1095  {
1096  case Metadata_type_generic:
1098  break;
1099  case Metadata_type_year:
1100  wrbuf_puts(w, " type=\"year\"");
1101  break;
1102  case Metadata_type_date:
1103  wrbuf_puts(w, " type=\"date\"");
1104  break;
1105  case Metadata_type_float:
1106  wrbuf_puts(w, " type=\"float\"");
1107  break;
1108  default:
1109  break;
1110  }
1111  switch (md->merge)
1112  {
1113  case Metadata_merge_no:
1114  break;
1115  case Metadata_merge_unique:
1116  wrbuf_puts(w, " merge=\"unique\"");
1117  break;
1119  wrbuf_puts(w, " merge=\"longest\"");
1120  break;
1121  case Metadata_merge_range:
1122  wrbuf_puts(w, " merge=\"range\"");
1123  break;
1124  case Metadata_merge_all:
1125  wrbuf_puts(w, " merge=\"all\"");
1126  break;
1127  case Metadata_merge_first:
1128  wrbuf_puts(w, " merge=\"first\"");
1129  break;
1130  }
1131  switch (md->mergekey)
1132  {
1133  case Metadata_mergekey_no:
1134  break;
1136  wrbuf_puts(w, " mergekey=\"optional\"");
1137  break;
1139  wrbuf_puts(w, " mergekey=\"required\"");
1140  break;
1141  }
1142  wrbuf_puts(w, " />\n");
1143  }
1144  }
1145 }
1146 
1147 static void info_service_databases(struct conf_service *service, WRBUF w)
1148 {
1149 
1150  if (service->databases)
1151  {
1152  struct database *db;
1153  wrbuf_puts(w, " <databases>\n");
1154  for (db = service->databases; db; db = db->next)
1155  {
1156  int i;
1157  wrbuf_puts(w, " <database");
1158  if (db->id)
1159  {
1160  wrbuf_puts(w, " id=\"");
1161  wrbuf_printf(w, "%s", db->id);
1162  wrbuf_puts(w, "\"");
1163  }
1164  wrbuf_puts(w, ">\n");
1165  for (i = 0; i < db->num_settings; i++)
1166  {
1167  struct setting *s = db->settings[i];
1168  for (; s; s = s->next)
1169  {
1170  wrbuf_puts(w, " <setting name=\"");
1171  wrbuf_xmlputs(w, s->name);
1172  wrbuf_puts(w, "\"");
1173  wrbuf_puts(w, " value=\"");
1174  wrbuf_xmlputs(w, s->value);
1175  wrbuf_puts(w, "\"");
1176  wrbuf_puts(w, " />\n");
1177  }
1178  }
1179  wrbuf_puts(w, " </database>\n");
1180  }
1181  wrbuf_puts(w, " </databases>\n");
1182  }
1183 }
1184 
1185 void info_services(struct conf_server *server, WRBUF w)
1186 {
1187  struct conf_service *s = server->service;
1188  int i;
1189 
1190  wrbuf_puts(w, " <services>\n");
1191  for (; s; s = s->next)
1192  {
1193  wrbuf_puts(w, " <service");
1194  if (s->id)
1195  {
1196  wrbuf_puts(w, " id=\"");
1197  wrbuf_xmlputs(w, s->id);
1198  wrbuf_puts(w, "\"");
1199  }
1200  wrbuf_puts(w, ">\n");
1201  if (s->settings)
1202  {
1203  for (i = 0; i < s->settings->num_settings; i++)
1204  {
1205  struct setting *S = s->settings->settings[i];
1206  for (; S; S = S->next)
1207  {
1208  wrbuf_puts(w, " <setting name=\"");
1209  wrbuf_xmlputs(w, S->name);
1210  wrbuf_puts(w, "\"");
1211  wrbuf_puts(w, " value=\"");
1212  wrbuf_xmlputs(w, S->value);
1213  wrbuf_puts(w, "\"");
1214  if (S->target)
1215  {
1216  wrbuf_puts(w, " target=\"");
1217  wrbuf_xmlputs(w, S->target);
1218  wrbuf_puts(w, "\"");
1219  }
1220  wrbuf_puts(w, " />\n");
1221  }
1222  }
1223  }
1224  info_service_metadata(s, w);
1225  info_service_databases(s, w);
1226  wrbuf_puts(w, " </service>\n");
1227  }
1228  wrbuf_puts(w, " </services>\n");
1229 }
1230 
1231 static int parse_config(struct conf_config *config, xmlNode *root)
1232 {
1233  xmlNode *n;
1234 
1235  for (n = root->children; n; n = n->next)
1236  {
1237  if (n->type != XML_ELEMENT_NODE)
1238  continue;
1239  if (!strcmp((const char *) n->name, "server"))
1240  {
1241  struct conf_server *tmp = server_create(config, config->nmem, n);
1242  if (!tmp)
1243  return -1;
1244  tmp->next = config->servers;
1245  config->servers = tmp;
1246  }
1247  else if (!strcmp((const char *) n->name, "threads"))
1248  {
1249  xmlChar *number = xmlGetProp(n, (xmlChar *) "number");
1250  if (number)
1251  {
1252  config->no_threads = atoi((const char *) number);
1253  xmlFree(number);
1254  }
1255  }
1256  else if (!strcmp((const char *) n->name, "sockets"))
1257  {
1258  xmlChar *number = xmlGetProp(n, (xmlChar *) "max");
1259  if (number)
1260  {
1261  config->max_sockets = atoi((const char *) number);
1262  xmlFree(number);
1263  }
1264  }
1265  else if (!strcmp((const char *) n->name, "file"))
1266  {
1267  xmlChar *path = xmlGetProp(n, (xmlChar *) "path");
1268  if (path)
1269  {
1270  config->path = nmem_strdup(config->nmem, (const char *) path);
1271  xmlFree(path);
1272  }
1273  }
1274  else if (!strcmp((const char *) n->name, "targetprofiles"))
1275  {
1276  yaz_log(YLOG_FATAL, "targetprofiles unsupported here. Must be part of service");
1277  return -1;
1278 
1279  }
1280  else
1281  {
1282  yaz_log(YLOG_FATAL, "Bad element: %s", n->name);
1283  return -1;
1284  }
1285  }
1286  return 0;
1287 }
1288 
1289 struct conf_config *config_create(const char *fname)
1290 {
1291  xmlDoc *doc = xmlReadFile(fname,
1292  NULL,
1293  XML_PARSE_XINCLUDE
1294  + XML_PARSE_NSCLEAN + XML_PARSE_NONET);
1295  xmlNode *n;
1296  const char *p;
1297  int r;
1298  NMEM nmem = nmem_create();
1299  struct conf_config *config = nmem_malloc(nmem, sizeof(struct conf_config));
1300 
1301  xmlSubstituteEntitiesDefault(1);
1302  xmlLoadExtDtdDefaultValue = 1;
1303  if (!doc)
1304  {
1305  yaz_log(YLOG_FATAL, "Failed to read %s", fname);
1306  nmem_destroy(nmem);
1307  return 0;
1308  }
1309 
1310  // Perform XInclude.
1311  r = xmlXIncludeProcess(doc);
1312  if (r == -1)
1313  {
1314  yaz_log(YLOG_FATAL, "XInclude processing failed");
1315  return 0;
1316  }
1317 
1318  config->nmem = nmem;
1319  config->servers = 0;
1320  config->path = nmem_strdup(nmem, ".");
1321  config->no_threads = 0;
1322  config->max_sockets = 0;
1323  config->iochan_man = 0;
1324 
1325  config->confdir = wrbuf_alloc();
1326  if ((p = strrchr(fname,
1327 #ifdef WIN32
1328  '\\'
1329 #else
1330  '/'
1331 #endif
1332  )))
1333  {
1334  int len = p - fname;
1335  wrbuf_write(config->confdir, fname, len);
1336  }
1337  wrbuf_puts(config->confdir, "");
1338 
1339  n = xmlDocGetRootElement(doc);
1340  r = yaz_xml_include_simple(n, wrbuf_cstr(config->confdir));
1341  if (r == 0) /* OK */
1342  {
1343  xmlChar *buf_out;
1344  int len_out;
1345  yaz_log(YLOG_LOG, "Configuration %s after include processing",
1346  fname);
1347  xmlDocDumpMemory(doc, &buf_out, &len_out);
1348  yaz_log(YLOG_LOG, "%.*s", len_out, buf_out);
1349  r = parse_config(config, n);
1350  }
1351  xmlFreeDoc(doc);
1352 
1353  if (r)
1354  {
1355  config_destroy(config);
1356  return 0;
1357  }
1358  return config;
1359 }
1360 
1361 void server_destroy(struct conf_server *server)
1362 {
1363  struct conf_service *s = server->service;
1364  while (s)
1365  {
1366  struct conf_service *s_next = s->next;
1367  service_destroy(s);
1368  s = s_next;
1369  }
1372 }
1373 
1374 void config_destroy(struct conf_config *config)
1375 {
1376  if (config)
1377  {
1378  struct conf_server *server = config->servers;
1379  iochan_man_destroy(&config->iochan_man);
1380  while (server)
1381  {
1382  struct conf_server *s_next = server->next;
1383  server_destroy(server);
1384  server = s_next;
1385  }
1386  wrbuf_destroy(config->confdir);
1387  nmem_destroy(config->nmem);
1388  }
1389 }
1390 
1392 {
1393  struct conf_server *ser;
1394  for (ser = conf->servers; ser; ser = ser->next)
1395  http_close_server(ser);
1396 }
1397 
1399 {
1400  struct conf_server *ser;
1401 
1402  for (ser = conf->servers; ser; ser = ser->next)
1403  {
1404  struct conf_service *s = ser->service;
1405 
1406  for (;s ; s = s->next)
1407  {
1408  assert(s->mutex == 0);
1409  pazpar2_mutex_create(&s->mutex, "service");
1410  }
1411  http_mutex_init(ser);
1412  }
1414 }
1415 
1417  const char *listener_override,
1418  const char *record_fname)
1419 {
1420  struct conf_server *ser;
1421 
1422  conf->iochan_man = iochan_man_create(conf->no_threads, conf->max_sockets);
1423  for (ser = conf->servers; ser; ser = ser->next)
1424  {
1425  WRBUF w;
1426  int r;
1427 
1428  ser->iochan_man = conf->iochan_man;
1429  if (listener_override)
1430  {
1431  const char *cp = strrchr(listener_override, ':');
1432  if (cp)
1433  {
1434  ser->host = nmem_strdupn(conf->nmem, listener_override,
1435  cp - listener_override);
1436  ser->port = nmem_strdup(conf->nmem, cp + 1);
1437  }
1438  else
1439  {
1440  ser->host = "@";
1441  ser->port = nmem_strdup(conf->nmem, listener_override);
1442  }
1443  listener_override = 0; /* only first server is overriden */
1444  }
1445  r = http_init(ser, record_fname);
1446  if (r)
1447  return -1;
1448 
1449  w = wrbuf_alloc();
1450  if (ser->proxy_host || ser->proxy_port)
1451  {
1452  if (ser->proxy_host)
1453  wrbuf_puts(w, ser->proxy_host);
1454  if (ser->proxy_port)
1455  {
1456  if (wrbuf_len(w))
1457  wrbuf_puts(w, ":");
1458  wrbuf_printf(w, "%d", ser->proxy_port);
1459  }
1460  }
1461  if (wrbuf_len(w))
1462  http_set_proxyaddr(wrbuf_cstr(w), ser);
1463  wrbuf_destroy(w);
1464  }
1465  return 0;
1466 }
1467 
1468 /*
1469  * Local variables:
1470  * c-basic-offset: 4
1471  * c-file-style: "Stroustrup"
1472  * indent-tabs-mode: nil
1473  * End:
1474  * vim: shiftwidth=4 tabstop=8 expandtab
1475  */
1476 
http_server_t http_server
struct setting * next
Definition: settings.h:71
WRBUF conf_get_fname(struct conf_config *config, const char *fname)
void service_destroy(struct conf_service *service)
void info_services(struct conf_server *server, WRBUF w)
void config_destroy(struct conf_config *config)
enum conf_setting_type setting
conf_setting_type
void service_xslt_destroy(struct conf_service *service)
Definition: service_xslt.c:55
int http_init(struct conf_server *server, const char *record_fname)
Definition: http.c:1238
void pazpar2_incref(int *ref, YAZ_MUTEX mutex)
Definition: incref.c:30
int num_settings
Definition: settings.h:77
struct setting ** settings
Definition: settings.h:78
void http_server_destroy(http_server_t hs)
Definition: http.c:1476
int settings_read_node(struct conf_service *service, xmlNode *n, int pass)
Definition: settings.c:572
iochan_man_t iochan_man
static void info_service_metadata(struct conf_service *service, WRBUF w)
struct conf_config * config
conf_metadata_type
static int parse_config(struct conf_config *config, xmlNode *root)
enum conf_metadata_type type
void config_stop_listeners(struct conf_config *conf)
iochan_man_t iochan_man
void pp2_charset_fact_destroy(pp2_charset_fact_t pft)
Definition: charsets.c:123
struct conf_server * next
CCL_bibset ccl_bibset
static void info_service_databases(struct conf_service *service, WRBUF w)
int pp2_charset_fact_define(pp2_charset_fact_t pft, xmlNode *xml_node, const char *id)
Definition: charsets.c:169
xsltStylesheetPtr xsp
char * settings_fname
struct service_xslt * xslt_list
struct conf_metadata * metadata
static char * xml_context(const xmlNode *ptr, char *res, size_t len)
struct setting ** settings
Definition: settings.h:85
const char * name
Definition: settings.h:69
static struct conf_metadata * conf_service_add_metadata(struct conf_service *service, int field_id, const char *name, enum conf_metadata_type type, enum conf_metadata_merge merge, enum conf_setting_type setting, int brief, int termlist, const char *rank, int sortkey_offset, enum conf_metadata_mergekey mt, const char *facetrule, const char *limitmap, const char *limitcluster, const char *icurule)
struct conf_service * service
static int parse_metadata(struct conf_service *service, xmlNode *n, int *md_node, int *sk_node)
struct conf_server * server
void pp2_charset_fact_incref(pp2_charset_fact_t pft)
Definition: charsets.c:207
enum conf_metadata_merge merge
int conf_service_metadata_field_id(struct conf_service *service, const char *name)
char * name
char * id
Definition: settings.h:76
struct conf_service * locate_service(struct conf_server *server, const char *service_id)
int pazpar2_decref(int *ref, YAZ_MUTEX mutex)
Definition: incref.c:38
pp2_charset_fact_t pp2_charset_fact_create(void)
Definition: charsets.c:110
void iochan_man_events(iochan_man_t man)
Definition: eventl.c:433
char * proxy_host
static struct conf_service * service_create_static(struct conf_server *server, xmlNode *node, const char *service_id)
int conf_service_sortkey_field_id(struct conf_service *service, const char *name)
struct conf_config * config_create(const char *fname)
static struct conf_sortkey * conf_service_add_sortkey(struct conf_service *service, int field_id, const char *name, enum conf_metadata_type type)
int z3950_operation_timeout
struct database * databases
const char * target
Definition: settings.h:68
void service_incref(struct conf_service *service)
void http_set_proxyaddr(const char *host, struct conf_server *server)
Definition: http.c:1372
void http_close_server(struct conf_server *server)
Definition: http.c:1359
enum conf_metadata_type type
iochan_man_t iochan_man_create(int no_threads, int max_sockets)
Definition: eventl.c:113
int service_xslt_config(struct conf_service *service, xmlNode *n)
Definition: service_xslt.c:62
conf_metadata_merge
enum conf_metadata_mergekey mergekey
void server_destroy(struct conf_server *server)
void config_process_events(struct conf_config *conf)
double rank_follow
YAZ_MUTEX mutex
int num_settings
Definition: settings.h:86
pp2_charset_fact_t charsets
struct conf_service * service_init(struct conf_server *server, int num_metadata, int num_sortkeys, const char *service_id)
MUTEX protect ref counts.
char * server_id
const char * rank
conf_metadata_mergekey
int z3950_session_timeout
struct conf_service * service_create(struct conf_server *server, xmlNode *node)
void init_settings(struct conf_service *service)
Definition: settings.c:550
void pazpar2_mutex_create(YAZ_MUTEX *p, const char *name)
Definition: ppmutex.c:39
pp2_charset_fact_t charsets
void iochan_man_destroy(iochan_man_t *mp)
Definition: eventl.c:152
struct conf_service * next
struct conf_server * servers
static int inherit_server_settings(struct conf_service *s)
static void conf_dir_path(struct conf_config *config, WRBUF w, const char *src)
int config_start_listeners(struct conf_config *conf, const char *listener_override, const char *record_fname)
static void count_metadata(xmlNode *n, int *num_metadata, int *num_sortkeys)
struct service_xslt * next
struct database * next
Definition: settings.h:79
struct conf_sortkey * sortkeys
struct settings_array * settings
static struct conf_server * server_create(struct conf_config *config, NMEM nmem, xmlNode *node)
void http_mutex_init(struct conf_server *server)
Definition: http.c:1506
const char * value
Definition: settings.h:70
struct setting_dictionary * dictionary
char * default_sort
char * limitcluster
int settings_read_file(struct conf_service *service, const char *path, int pass)
Definition: settings.c:563
#define PZ_MAX_EOF
Definition: settings.h:63
control MUTEX debugging