2 * Copyright (c) 1995-2006, Index Data
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of Index Data nor the names of its contributors
13 * may be used to endorse or promote products derived from this
14 * software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 /* $Id: backend.h,v 1.40 2006-12-06 21:35:58 adam Exp $ */
31 * \brief Header for GFS
33 * This header includes all public definitions for the
34 * Generic Frontend Server (GFS).
40 #include <yaz/yconfig.h>
41 #include <yaz/proto.h>
46 typedef struct request *bend_request;
47 typedef struct association *bend_association;
49 /* extended search handler (rr = request response) */
51 char *setname; /* name to give to this set */
52 int replace_set; /* replace set, if it already exists */
53 int num_bases; /* number of databases in list */
54 char **basenames; /* databases to search */
55 Z_ReferenceId *referenceId;/* reference ID */
56 Z_Query *query; /* query structure */
57 ODR stream; /* encode stream */
58 ODR decode; /* decode stream */
59 ODR print; /* print stream */
62 bend_association association;
64 int hits; /* number of hits */
65 int errcode; /* 0==OK */
66 char *errstring; /* system error string or NULL */
67 Z_OtherInformation *search_info; /* additional search info */
68 char *srw_sortKeys; /* holds SRU/SRW sortKeys info */
69 char *srw_setname; /* holds SRU/SRW generated resultsetID */
70 int *srw_setnameIdleTime; /* holds SRU/SRW life-time */
73 /* extended present handler. Does not replace bend_fetch. */
75 char *setname; /* set name */
77 int number; /* record number */
78 oid_value format; /* One of the CLASS_RECSYN members */
79 Z_ReferenceId *referenceId;/* reference ID */
80 Z_RecordComposition *comp; /* Formatting instructions */
81 ODR stream; /* encoding stream - memory source if required */
82 ODR print; /* printing stream */
84 bend_association association;
86 int hits; /* number of hits */
87 int errcode; /* 0==OK */
88 char *errstring; /* system error string or NULL */
91 typedef struct bend_fetch_rr {
92 char *setname; /* set name */
93 int number; /* record number */
94 Z_ReferenceId *referenceId;/* reference ID */
95 oid_value request_format; /* One of the CLASS_RECSYN members */
96 int *request_format_raw; /* same as above (raw OID) */
97 Z_RecordComposition *comp; /* Formatting instructions */
98 ODR stream; /* encoding stream - memory source if req */
99 ODR print; /* printing stream */
101 char *basename; /* name of database that provided record */
102 int len; /* length of record or -1 if structured */
103 char *record; /* record */
104 int last_in_set; /* is it? */
105 oid_value output_format; /* format */
106 int *output_format_raw; /* used instead of above if not-null */
107 int errcode; /* 0==success */
108 char *errstring; /* system error string or NULL */
109 int surrogate_flag; /* surrogate diagnostic */
110 char *schema; /* string record schema input/output */
114 char *term; /* the returned scan term */
115 int occurrences; /* no of occurrences or -1 if error (see below) */
116 int errcode; /* Bib-1 diagnostic code; only used when occur.= -1 */
117 char *errstring; /* Additional string */
122 BEND_SCAN_SUCCESS, /* ok */
123 BEND_SCAN_PARTIAL /* not all entries could be found */
126 typedef struct bend_scan_rr {
127 int num_bases; /* number of elements in databaselist */
128 char **basenames; /* databases to search */
129 oid_value attributeset;
130 Z_ReferenceId *referenceId; /* reference ID */
131 Z_AttributesPlusTerm *term;
132 ODR stream; /* encoding stream - memory source if required */
133 ODR print; /* printing stream */
135 int *step_size; /* step size */
136 int term_position; /* desired index of term in result list/returned */
137 int num_entries; /* number of entries requested/returned */
139 /* scan term entries. The called handler does not have
140 to allocate this. Size of entries is num_entries (see above) */
141 struct scan_entry *entries;
142 bend_scan_status status;
145 char *scanClause; /* CQL scan clause */
148 typedef struct bend_update_rr {
149 int num_bases; /* number of elements in databaselist */
150 char **basenames; /* databases to search */
151 Z_ReferenceId *referenceId; /* reference ID */
152 ODR stream; /* encoding stream - memory source if required */
153 ODR print; /* printing stream */
155 char *operation_status;
157 Z_SRW_recordVersion *record_versions;
159 char *record_packing;
162 char *extra_record_data;
163 char *extra_request_data;
164 char *extra_response_data;
171 typedef struct bend_delete_rr {
175 Z_ReferenceId *referenceId;
176 int delete_status; /* status for the whole operation */
177 int *statuses; /* status each set - indexed as setnames */
183 typedef struct bend_sort_rr
185 int num_input_setnames;
186 char **input_setnames;
187 char *output_setname;
188 Z_SortKeySpecList *sort_sequence;
191 Z_ReferenceId *referenceId;/* reference ID */
198 typedef struct bend_esrequest_rr
201 Z_ExtendedServicesRequest *esr;
203 ODR stream; /* encoding stream */
204 ODR decode; /* decoding stream */
205 ODR print; /* printing stream */
206 Z_ReferenceId *referenceId;/* reference ID */
207 bend_request request;
208 bend_association association;
209 int errcode; /* 0==success, -1==accepted, >0 = failure */
210 char *errstring; /* system error string or NULL */
211 Z_TaskPackage *taskPackage;
214 typedef struct bend_segment_rr {
219 bend_request request;
220 bend_association association;
230 void *server_node_ptr;
233 typedef struct bend_initrequest
235 Z_IdAuthentication *auth;
236 ODR stream; /* encoding stream */
237 ODR print; /* printing stream */
238 Z_ReferenceId *referenceId;/* reference ID */
239 char *peer_name; /* dns host of peer (client) */
241 char *implementation_id;
242 char *implementation_name;
243 char *implementation_version;
244 int (*bend_sort) (void *handle, bend_sort_rr *rr);
245 int (*bend_search) (void *handle, bend_search_rr *rr);
246 int (*bend_fetch) (void *handle, bend_fetch_rr *rr);
247 int (*bend_present) (void *handle, bend_present_rr *rr);
248 int (*bend_esrequest) (void *handle, bend_esrequest_rr *rr);
249 int (*bend_delete)(void *handle, bend_delete_rr *rr);
250 int (*bend_scan)(void *handle, bend_scan_rr *rr);
251 int (*bend_segment)(void *handle, bend_segment_rr *rr);
253 ODR decode; /* decoding stream */
254 /* character set and language negotiation - see include/yaz/z-charneg.h */
255 Z_CharSetandLanguageNegotiation *charneg_request;
256 Z_External *charneg_response;
257 int (*bend_explain)(void *handle, bend_explain_rr *rr);
258 int (*bend_srw_scan)(void *handle, bend_scan_rr *rr);
259 int (*bend_srw_update)(void *handle, bend_update_rr *rr);
262 typedef struct bend_initresult
264 int errcode; /* 0==OK */
265 char *errstring; /* system error string or NULL */
266 void *handle; /* private handle to the backend module */
269 YAZ_EXPORT void bend_request_send (bend_association a, bend_request req,
272 YAZ_EXPORT bend_request bend_request_mk (bend_association a);
274 YAZ_EXPORT void bend_request_destroy (bend_request *req);
276 YAZ_EXPORT Z_ReferenceId *bend_request_getid (ODR odr, bend_request req);
277 YAZ_EXPORT int bend_backend_respond (bend_association a, bend_request req);
278 YAZ_EXPORT void bend_request_setdata(bend_request r, void *p);
279 YAZ_EXPORT void *bend_request_getdata(bend_request r);
281 typedef struct statserv_options_block
283 int dynamic; /* fork on incoming requests */
284 int threads; /* use threads */
285 int one_shot; /* one session then exit(1) */
286 int __UNUSED__loglevel; /* desired logging-level */
287 char apdufile[ODR_MAXNAME+1]; /* file for pretty-printed PDUs */
288 char logfile[ODR_MAXNAME+1]; /* file for diagnostic output */
289 char default_listen[1024]; /* 0 == no default listen */
290 enum oid_proto default_proto; /* PROTO_SR or PROTO_Z3950 */
291 int idle_timeout; /* how many minutes to wait before closing */
292 int maxrecordsize; /* maximum value for negotiation */
293 char configname[ODR_MAXNAME+1]; /* given to the backend in bend_init */
294 char setuid[ODR_MAXNAME+1]; /* setuid to this user after binding */
295 void (*bend_start)(struct statserv_options_block *p);
296 void (*bend_stop)(struct statserv_options_block *p);
297 int (*options_func)(int argc, char **argv);
298 int (*check_ip)(void *cd, const char *addr, int len, int type);
299 char daemon_name[128];
300 int inetd; /* Do we use the inet deamon or not */
302 void *handle; /* Handle */
303 bend_initresult *(*bend_init)(bend_initrequest *r);
304 void (*bend_close)(void *handle);
306 /* We only have these members for the windows version */
307 /* They seemed a bit large to have them there in general */
308 char service_name[128]; /* NT Service Name */
309 char app_name[128]; /* Application Name */
310 char service_dependencies[128]; /* The services we are dependent on */
311 char service_display_name[128]; /* The service display name */
313 struct bend_soap_handler *soap_handlers;
314 char pid_fname[128]; /* pid fname */
315 int background; /* auto daemon */
316 char cert_fname[128]; /* SSL certificate fname */
317 char xml_config[128]; /* XML config filename */
318 } statserv_options_block;
320 YAZ_EXPORT int statserv_main(
321 int argc, char **argv,
322 bend_initresult *(*bend_init)(bend_initrequest *r),
323 void (*bend_close)(void *handle));
324 YAZ_EXPORT int statserv_start(int argc, char **argv);
325 YAZ_EXPORT void statserv_closedown(void);
326 YAZ_EXPORT statserv_options_block *statserv_getcontrol(void);
327 YAZ_EXPORT void statserv_setcontrol(statserv_options_block *block);
328 YAZ_EXPORT int check_ip_tcpd(void *cd, const char *addr, int len, int type);
330 YAZ_EXPORT int bend_assoc_is_alive(bend_association assoc);
338 * indent-tabs-mode: nil
340 * vim: shiftwidth=4 tabstop=8 expandtab