splitting record specific definition out from pazpar2.h header to record.h header...
[pazpar2-moved-to-github.git] / src / config.h
1 /* $Id: config.h,v 1.19 2007-04-19 19:42:30 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 enum conf_metadata_type {
32     Metadata_type_generic,    // Generic text field
33     Metadata_type_number,     // A number
34     Metadata_type_year        // 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
53
54 // Describes known metadata elements and how they are to be manipulated
55 // An array of these structure provides a 'map' against which
56 // discovered metadata elements are matched. It also governs storage,
57 // to minimize number of cycles needed at various tages of processing
58 struct conf_metadata 
59 {
60     char *name;  // The field name. Output by normalization stylesheet
61     int brief;   // Is this element to be returned in the brief format?
62     int termlist;// Is this field to be treated as a termlist for browsing?
63     int rank;    // Rank factor. 0 means don't use this field for ranking, 
64                  // 1 is default
65                  // values >1  give additional significance to a field
66     int sortkey_offset; // -1 if it's not a sortkey, otherwise index
67                         // into service/record_cluster->sortkey array
68     enum conf_metadata_type type;
69     enum conf_metadata_merge merge;
70 };
71
72
73
74 struct conf_metadata * conf_metadata_assign(NMEM nmem, 
75                                             struct conf_metadata * metadata,
76                                             const char *name,
77                                             enum conf_metadata_type type,
78                                             enum conf_metadata_merge merge,
79                                             int brief,
80                                             int termlist,
81                                             int rank,
82                                             int sortkey_offset);
83
84
85
86 // Controls sorting
87 struct conf_sortkey
88 {
89     char *name;
90     enum conf_sortkey_type type;
91 };
92
93 struct conf_sortkey * conf_sortkey_assign(NMEM nmem, 
94                                             struct conf_sortkey * sortkey,
95                                             const char *name,
96                                             enum conf_sortkey_type type);
97
98
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     int num_metadata;
107     struct conf_metadata *metadata;
108     int num_sortkeys;
109     struct conf_sortkey *sortkeys;
110 };
111
112 struct conf_service * conf_service_create(NMEM nmem, 
113                                           int num_metadata, int num_sortkeys);
114
115 struct conf_metadata* conf_service_add_metadata(NMEM nmem, 
116                                                 struct conf_service *service,
117                                                 int position,
118                                                 const char *name,
119                                                 enum conf_metadata_type type,
120                                                 enum conf_metadata_merge merge,
121                                                 int brief,
122                                                 int termlist,
123                                                 int rank,
124                                                 int sortkey_offset);
125
126 struct conf_sortkey * conf_service_add_sortkey(NMEM nmem,
127                                                struct conf_service *service,
128                                                int position,
129                                                const char *name,
130                                                enum conf_sortkey_type type);
131
132
133
134 struct conf_server
135 {
136     char *host;
137     int port;
138     char *proxy_host;
139     int proxy_port;
140     char *myurl;
141     char *zproxy_host;
142     int zproxy_port;
143     char *settings;
144     struct conf_service *service;
145     struct conf_server *next;
146 };
147
148 struct conf_targetprofiles
149 {
150     enum {
151         Targetprofiles_local
152     } type;
153     char *src;
154 };
155
156 struct conf_config
157 {
158     struct conf_server *servers;
159     struct conf_targetprofiles *targetprofiles;
160 };
161
162 #ifndef CONFIG_NOEXTERNS
163
164 extern struct conf_config *config;
165
166 #endif
167
168 int read_config(const char *fname);
169 xsltStylesheet *conf_load_stylesheet(const char *fname);
170
171 #endif
172
173 /*
174  * Local variables:
175  * c-basic-offset: 4
176  * indent-tabs-mode: nil
177  * End:
178  * vim: shiftwidth=4 tabstop=8 expandtab
179  */