Lower _connect_ timeout to 15 seconds.
[pazpar2-moved-to-github.git] / src / config.h
1 /* $Id: config.h,v 1.27 2007-09-10 16:25:50 adam Exp $
2    Copyright (c) 2006-2007, Index Data.
3
4 This file is part of Pazpar2.
5
6 Pazpar2 is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
9 version.
10
11 Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Pazpar2; see the file LICENSE.  If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA.
20  */
21
22 #ifndef CONFIG_H
23 #define CONFIG_H
24
25 #include <libxslt/xslt.h>
26 #include <libxslt/transform.h>
27 #include <libxslt/xsltutils.h>
28
29 #include <yaz/nmem.h>
30 #include "charsets.h"
31
32 enum conf_metadata_type {
33     Metadata_type_generic,    // Generic text field
34     Metadata_type_number,     // A number
35     Metadata_type_year        // A number
36 };
37
38 enum conf_metadata_merge {
39     Metadata_merge_no,        // Don't merge
40     Metadata_merge_unique,    // Include unique elements in merged block
41     Metadata_merge_longest,   // Include the longest (strlen) value
42     Metadata_merge_range,     // Store value as a range of lowest-highest
43     Metadata_merge_all        // Just include all elements found
44 };
45
46 enum conf_sortkey_type {
47     Metadata_sortkey_relevance,
48     Metadata_sortkey_numeric,       // Standard numerical sorting
49     Metadata_sortkey_skiparticle,   // Skip leading article when sorting
50     Metadata_sortkey_string         // Flat string
51 };
52
53 // This controls the ability to insert 'static' values from settings into retrieval recs
54 enum conf_setting_type {
55     Metadata_setting_no,
56     Metadata_setting_postproc,      // Insert setting value into normalized record
57     Metadata_setting_parameter      // Expose value to normalization stylesheets
58 };
59
60 // Describes known metadata elements and how they are to be manipulated
61 // An array of these structure provides a 'map' against which
62 // discovered metadata elements are matched. It also governs storage,
63 // to minimize number of cycles needed at various tages of processing
64 struct conf_metadata 
65 {
66     char *name;  // The field name. Output by normalization stylesheet
67     int brief;   // Is this element to be returned in the brief format?
68     int termlist;// Is this field to be treated as a termlist for browsing?
69     int rank;    // Rank factor. 0 means don't use this field for ranking, 
70                  // 1 is default
71                  // values >1  give additional significance to a field
72     int sortkey_offset; // -1 if it's not a sortkey, otherwise index
73                         // into service/record_cluster->sortkey array
74     enum conf_metadata_type type;
75     enum conf_metadata_merge merge;
76     enum conf_setting_type setting; // Value is to be taken from session/db settings?
77 };
78
79
80
81 struct conf_metadata * conf_metadata_assign(NMEM nmem, 
82                                             struct conf_metadata * metadata,
83                                             const char *name,
84                                             enum conf_metadata_type type,
85                                             enum conf_metadata_merge merge,
86                                             enum conf_setting_type setting,
87                                             int brief,
88                                             int termlist,
89                                             int rank,
90                                             int sortkey_offset);
91
92
93
94 // Controls sorting
95 struct conf_sortkey
96 {
97     char *name;
98     enum conf_sortkey_type type;
99 };
100
101 struct conf_sortkey * conf_sortkey_assign(NMEM nmem, 
102                                             struct conf_sortkey * sortkey,
103                                             const char *name,
104                                             enum conf_sortkey_type type);
105
106
107
108 // It is conceivable that there will eventually be several 'services'
109 // offered from one server, with separate configuration -- possibly
110 // more than one services associated with the same port. For now,
111 // however, only a single service is possible.
112 struct conf_service
113 {
114     int num_metadata;
115     struct conf_metadata *metadata;
116     int num_sortkeys;
117     struct conf_sortkey *sortkeys;
118
119 };
120
121 struct conf_service * conf_service_create(NMEM nmem, 
122                                           int num_metadata, int num_sortkeys);
123
124
125 struct conf_metadata* conf_service_add_metadata(NMEM nmem, 
126                                                 struct conf_service *service,
127                                                 int field_id,
128                                                 const char *name,
129                                                 enum conf_metadata_type type,
130                                                 enum conf_metadata_merge merge,
131                                                 enum conf_setting_type setting,
132                                                 int brief,
133                                                 int termlist,
134                                                 int rank,
135                                                 int sortkey_offset);
136
137 struct conf_sortkey * conf_service_add_sortkey(NMEM nmem,
138                                                struct conf_service *service,
139                                                int field_id,
140                                                const char *name,
141                                                enum conf_sortkey_type type);
142
143
144 int conf_service_metadata_field_id(struct conf_service *service, const char * name);
145
146 int conf_service_sortkey_field_id(struct conf_service *service, const char * name);
147
148
149 struct conf_server
150 {
151     char *host;
152     int port;
153     char *proxy_host;
154     int proxy_port;
155     char *myurl;
156     char *settings;
157
158     pp2_charset_t relevance_pct;
159     pp2_charset_t sort_pct;
160     pp2_charset_t mergekey_pct;
161
162     struct conf_service *service;
163     struct conf_server *next;
164 };
165
166 struct conf_targetprofiles
167 {
168     enum {
169         Targetprofiles_local
170     } type;
171     char *src;
172 };
173
174 struct conf_config
175 {
176     struct conf_server *servers;
177     struct conf_targetprofiles *targetprofiles;
178 };
179
180 #ifndef CONFIG_NOEXTERNS
181
182 extern struct conf_config *config;
183
184 #endif
185
186 int read_config(const char *fname);
187 xsltStylesheet *conf_load_stylesheet(const char *fname);
188
189 #endif
190
191 /*
192  * Local variables:
193  * c-basic-offset: 4
194  * indent-tabs-mode: nil
195  * End:
196  * vim: shiftwidth=4 tabstop=8 expandtab
197  */