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