ICU chain loaded imder configuration of server. This happens only if ICU support...
[pazpar2-moved-to-github.git] / src / config.h
1 /* $Id: config.h,v 1.23 2007-05-23 11:19:31 marc 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
31 #ifdef HAVE_ICU
32 #include "icu_I18N.h"
33 #endif // HAVE_ICU
34
35
36 enum conf_metadata_type {
37     Metadata_type_generic,    // Generic text field
38     Metadata_type_number,     // A number
39     Metadata_type_year        // A number
40 };
41
42 enum conf_metadata_merge {
43     Metadata_merge_no,        // Don't merge
44     Metadata_merge_unique,    // Include unique elements in merged block
45     Metadata_merge_longest,   // Include the longest (strlen) value
46     Metadata_merge_range,     // Store value as a range of lowest-highest
47     Metadata_merge_all        // Just include all elements found
48 };
49
50 enum conf_sortkey_type {
51     Metadata_sortkey_relevance,
52     Metadata_sortkey_numeric,       // Standard numerical sorting
53     Metadata_sortkey_skiparticle,   // Skip leading article when sorting
54     Metadata_sortkey_string         // Flat string
55 };
56
57
58
59 // Describes known metadata elements and how they are to be manipulated
60 // An array of these structure provides a 'map' against which
61 // discovered metadata elements are matched. It also governs storage,
62 // to minimize number of cycles needed at various tages of processing
63 struct conf_metadata 
64 {
65     char *name;  // The field name. Output by normalization stylesheet
66     int brief;   // Is this element to be returned in the brief format?
67     int termlist;// Is this field to be treated as a termlist for browsing?
68     int rank;    // Rank factor. 0 means don't use this field for ranking, 
69                  // 1 is default
70                  // values >1  give additional significance to a field
71     int sortkey_offset; // -1 if it's not a sortkey, otherwise index
72                         // into service/record_cluster->sortkey array
73     enum conf_metadata_type type;
74     enum conf_metadata_merge merge;
75 };
76
77
78
79 struct conf_metadata * conf_metadata_assign(NMEM nmem, 
80                                             struct conf_metadata * metadata,
81                                             const char *name,
82                                             enum conf_metadata_type type,
83                                             enum conf_metadata_merge merge,
84                                             int brief,
85                                             int termlist,
86                                             int rank,
87                                             int sortkey_offset);
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_sortkey * conf_sortkey_assign(NMEM nmem, 
99                                             struct conf_sortkey * sortkey,
100                                             const char *name,
101                                             enum conf_sortkey_type type);
102
103
104
105 // It is conceivable that there will eventually be several 'services'
106 // offered from one server, with separate configuration -- possibly
107 // more than one services associated with the same port. For now,
108 // however, only a single service is possible.
109 struct conf_service
110 {
111     int num_metadata;
112     struct conf_metadata *metadata;
113     int num_sortkeys;
114     struct conf_sortkey *sortkeys;
115
116 };
117
118 struct conf_service * conf_service_create(NMEM nmem, 
119                                           int num_metadata, int num_sortkeys);
120
121 struct conf_metadata* conf_service_add_metadata(NMEM nmem, 
122                                                 struct conf_service *service,
123                                                 int field_id,
124                                                 const char *name,
125                                                 enum conf_metadata_type type,
126                                                 enum conf_metadata_merge merge,
127                                                 int brief,
128                                                 int termlist,
129                                                 int rank,
130                                                 int sortkey_offset);
131
132 struct conf_sortkey * conf_service_add_sortkey(NMEM nmem,
133                                                struct conf_service *service,
134                                                int field_id,
135                                                const char *name,
136                                                enum conf_sortkey_type type);
137
138
139 int conf_service_metadata_field_id(struct conf_service *service, const char * name);
140
141 int conf_service_sortkey_field_id(struct conf_service *service, const char * name);
142
143
144 struct conf_server
145 {
146     char *host;
147     int port;
148     char *proxy_host;
149     int proxy_port;
150     char *myurl;
151     char *zproxy_host;
152     int zproxy_port;
153     char *settings;
154
155 #ifdef HAVE_ICU
156     struct icu_chain * icu_chn;
157 #endif // HAVE_ICU
158
159     struct conf_service *service;
160     struct conf_server *next;
161 };
162
163 struct conf_targetprofiles
164 {
165     enum {
166         Targetprofiles_local
167     } type;
168     char *src;
169 };
170
171 struct conf_config
172 {
173     struct conf_server *servers;
174     struct conf_targetprofiles *targetprofiles;
175 };
176
177 #ifndef CONFIG_NOEXTERNS
178
179 extern struct conf_config *config;
180
181 #endif
182
183 int read_config(const char *fname);
184 xsltStylesheet *conf_load_stylesheet(const char *fname);
185
186 #endif
187
188 /*
189  * Local variables:
190  * c-basic-offset: 4
191  * indent-tabs-mode: nil
192  * End:
193  * vim: shiftwidth=4 tabstop=8 expandtab
194  */