Introduce a default limitmap
[pazpar2-moved-to-github.git] / src / pazpar2_config.h
1 /* This file is part of Pazpar2.
2    Copyright (C) 2006-2012 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 #ifndef PAZPAR2_CONFIG_H
21 #define PAZPAR2_CONFIG_H
22
23 #include "normalize_cache.h"
24
25 #include <yaz/nmem.h>
26 #include <yaz/mutex.h>
27 #include "charsets.h"
28 #include "http.h"
29 #include "database.h"
30 #include "host.h"
31
32 enum conf_metadata_type {
33     Metadata_type_generic,    // Generic text field
34     Metadata_type_year,        // A number
35     Metadata_type_date        // 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     Metadata_sortkey_position       // Position
52 };
53
54 // This controls the ability to insert 'static' values from settings into retrieval recs
55 enum conf_setting_type {
56     Metadata_setting_no,
57     Metadata_setting_postproc,      // Insert setting value into normalized record
58     Metadata_setting_parameter      // Expose value to normalization stylesheets
59 };
60
61 enum conf_metadata_mergekey {
62     Metadata_mergekey_no,
63     Metadata_mergekey_optional,
64     Metadata_mergekey_required
65 };
66
67 // Describes known metadata elements and how they are to be manipulated
68 // An array of these structure provides a 'map' against which
69 // discovered metadata elements are matched. It also governs storage,
70 // to minimize number of cycles needed at various tages of processing
71 struct conf_metadata 
72 {
73     char *name;  // The field name. Output by normalization stylesheet
74     int brief;   // Is this element to be returned in the brief format?
75     int termlist;// Is this field to be treated as a termlist for browsing?
76     int rank;    // Rank factor. 0 means don't use this field for ranking, 
77                  // 1 is default
78                  // values >1  give additional significance to a field
79     int sortkey_offset; // -1 if it's not a sortkey, otherwise index
80                         // into service/record_cluster->sortkey array
81     enum conf_metadata_type type;
82     enum conf_metadata_merge merge;
83     enum conf_setting_type setting; // Value is to be taken from session/db settings?
84     enum conf_metadata_mergekey mergekey;
85     char *facetrule;
86     char *limitmap;
87 };
88
89
90
91 // Controls sorting
92 struct conf_sortkey
93 {
94     char *name;
95     enum conf_sortkey_type type;
96 };
97
98 struct conf_server;
99
100 // It is conceivable that there will eventually be several 'services'
101 // offered from one server, with separate configuration -- possibly
102 // more than one services associated with the same port. For now,
103 // however, only a single service is possible.
104 struct conf_service
105 {
106     YAZ_MUTEX mutex;
107     int num_metadata;
108     struct conf_metadata *metadata;
109     int num_sortkeys;
110     struct conf_sortkey *sortkeys;
111     struct setting_dictionary *dictionary;
112     struct conf_service *next;
113     char *id;
114     NMEM nmem;
115     int session_timeout;
116     int z3950_session_timeout;
117     int z3950_operation_timeout;
118
119     int ref_count;
120     /* duplicated from conf_server */
121     pp2_charset_fact_t charsets;
122
123     struct service_xslt *xslt_list;
124
125     struct database *databases;
126     struct conf_server *server;
127 };
128
129 int conf_service_metadata_field_id(struct conf_service *service, const char * name);
130
131 int conf_service_sortkey_field_id(struct conf_service *service, const char * name);
132
133 struct conf_server
134 {
135     char *host;
136     int port;
137     char *proxy_host;
138     int proxy_port;
139     char *myurl;
140     char *settings_fname;
141     char *server_id;
142
143     pp2_charset_fact_t charsets;
144
145     struct conf_service *service;
146     struct conf_server *next;
147     struct conf_config *config;
148     http_server_t http_server;
149     iochan_man_t iochan_man;
150     database_hosts_t database_hosts;
151 };
152
153 struct conf_config *config_create(const char *fname, int verbose);
154 void config_destroy(struct conf_config *config);
155 void config_process_events(struct conf_config *config);
156 void info_services(struct conf_server *server, WRBUF w);
157
158 struct conf_service *locate_service(struct conf_server *server,
159                                     const char *service_id);
160
161 struct conf_service *service_create(struct conf_server *server,
162                                     xmlNode *node);
163 void service_incref(struct conf_service *service);
164 void service_destroy(struct conf_service *service);
165
166 int config_start_listeners(struct conf_config *conf,
167                            const char *listener_override,
168                            const char *record_fname);
169
170 void config_stop_listeners(struct conf_config *conf);
171
172 WRBUF conf_get_fname(struct conf_config *config, const char *fname);
173
174 #endif
175
176 /*
177  * Local variables:
178  * c-basic-offset: 4
179  * c-file-style: "Stroustrup"
180  * indent-tabs-mode: nil
181  * End:
182  * vim: shiftwidth=4 tabstop=8 expandtab
183  */
184