Remove support for option -t.
[pazpar2-moved-to-github.git] / src / pazpar2_config.h
1 /* This file is part of Pazpar2.
2    Copyright (C) 2006-2009 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 <libxslt/xslt.h>
24 #include <libxslt/transform.h>
25 #include <libxslt/xsltutils.h>
26
27 #include <yaz/nmem.h>
28 #include "charsets.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_yes
62 };
63
64 // Describes known metadata elements and how they are to be manipulated
65 // An array of these structure provides a 'map' against which
66 // discovered metadata elements are matched. It also governs storage,
67 // to minimize number of cycles needed at various tages of processing
68 struct conf_metadata 
69 {
70     char *name;  // The field name. Output by normalization stylesheet
71     int brief;   // Is this element to be returned in the brief format?
72     int termlist;// Is this field to be treated as a termlist for browsing?
73     int rank;    // Rank factor. 0 means don't use this field for ranking, 
74                  // 1 is default
75                  // values >1  give additional significance to a field
76     int sortkey_offset; // -1 if it's not a sortkey, otherwise index
77                         // into service/record_cluster->sortkey array
78     enum conf_metadata_type type;
79     enum conf_metadata_merge merge;
80     enum conf_setting_type setting; // Value is to be taken from session/db settings?
81     enum conf_metadata_type mergekey;
82 };
83
84
85
86 // Controls sorting
87 struct conf_sortkey
88 {
89     char *name;
90     enum conf_sortkey_type type;
91 };
92
93 // It is conceivable that there will eventually be several 'services'
94 // offered from one server, with separate configuration -- possibly
95 // more than one services associated with the same port. For now,
96 // however, only a single service is possible.
97 struct conf_service
98 {
99     int num_metadata;
100     struct conf_metadata *metadata;
101     int num_sortkeys;
102     struct conf_sortkey *sortkeys;
103     struct setting_dictionary *dictionary;
104     struct conf_service *next;
105     char *id;
106     char *settings;
107     NMEM nmem;
108
109     /* duplicated from conf_server */
110     pp2_charset_t relevance_pct;
111     pp2_charset_t sort_pct;
112     pp2_charset_t mergekey_pct;
113
114     struct database *databases;
115     struct conf_targetprofiles *targetprofiles;
116     struct conf_config *config;
117 };
118
119 struct conf_service * conf_service_create(struct conf_config *config,
120                                           int num_metadata, int num_sortkeys,
121                                           const char *service_id);
122
123 struct conf_metadata* conf_service_add_metadata(struct conf_service *service,
124                                                 int field_id,
125                                                 const char *name,
126                                                 enum conf_metadata_type type,
127                                                 enum conf_metadata_merge merge,
128                                                 enum conf_setting_type setting,
129                                                 int brief,
130                                                 int termlist,
131                                                 int rank,
132                                                 int sortkey_offset,
133                                                 enum conf_metadata_mergekey mt);
134
135 struct conf_sortkey * conf_service_add_sortkey(struct conf_service *service,
136                                                int field_id,
137                                                const char *name,
138                                                enum conf_sortkey_type type);
139
140
141 int conf_service_metadata_field_id(struct conf_service *service, const char * name);
142
143 int conf_service_sortkey_field_id(struct conf_service *service, const char * name);
144
145 struct conf_server
146 {
147     char *host;
148     int port;
149     char *proxy_host;
150     int proxy_port;
151     char *myurl;
152     struct sockaddr_in *proxy_addr;
153     int listener_socket;
154
155     char *server_settings;
156
157     pp2_charset_t relevance_pct;
158     pp2_charset_t sort_pct;
159     pp2_charset_t mergekey_pct;
160     struct conf_service *service;
161     struct conf_server *next;
162 };
163
164 struct conf_targetprofiles
165 {
166     enum {
167         Targetprofiles_local
168     } type;
169     char *src;
170 };
171
172 struct conf_config *config_create(const char *fname);
173 void config_destroy(struct conf_config *config);
174 xsltStylesheet *conf_load_stylesheet(struct conf_config *config,
175                                      const char *fname);
176
177 void config_read_settings(struct conf_config *config);
178
179 struct conf_service *locate_service(struct conf_server *server,
180                                     const char *service_id);
181
182
183 int config_start_listeners(struct conf_config *conf,
184                            const char *listener_override,
185                            const char *proxy_override);
186
187 void config_stop_listeners(struct conf_config *conf);
188
189 #endif
190
191 /*
192  * Local variables:
193  * c-basic-offset: 4
194  * c-file-style: "Stroustrup"
195  * indent-tabs-mode: nil
196  * End:
197  * vim: shiftwidth=4 tabstop=8 expandtab
198  */
199