2 * Copyright (c) 1995-2007, 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.42 2007-01-16 14:12:37 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 */
71 int estimated_hit_count; /* if hit count is estimated */
72 int partial_resultset; /* if result set is partial */
75 /* extended present handler. Does not replace bend_fetch. */
77 char *setname; /* set name */
79 int number; /* record number */
80 oid_value format; /* One of the CLASS_RECSYN members */
81 Z_ReferenceId *referenceId;/* reference ID */
82 Z_RecordComposition *comp; /* Formatting instructions */
83 ODR stream; /* encoding stream - memory source if required */
84 ODR print; /* printing stream */
86 bend_association association;
88 int hits; /* number of hits */
89 int errcode; /* 0==OK */
90 char *errstring; /* system error string or NULL */
93 typedef struct bend_fetch_rr {
94 char *setname; /* set name */
95 int number; /* record number */
96 Z_ReferenceId *referenceId;/* reference ID */
97 oid_value request_format; /* One of the CLASS_RECSYN members */
98 int *request_format_raw; /* same as above (raw OID) */
99 Z_RecordComposition *comp; /* Formatting instructions */
100 ODR stream; /* encoding stream - memory source if req */
101 ODR print; /* printing stream */
103 char *basename; /* name of database that provided record */
104 int len; /* length of record or -1 if structured */
105 char *record; /* record */
106 int last_in_set; /* is it? */
107 oid_value output_format; /* format */
108 int *output_format_raw; /* used instead of above if not-null */
109 int errcode; /* 0==success */
110 char *errstring; /* system error string or NULL */
111 int surrogate_flag; /* surrogate diagnostic */
112 char *schema; /* string record schema input/output */
116 char *term; /* the returned scan term */
117 int occurrences; /* no of occurrences or -1 if error (see below) */
118 int errcode; /* Bib-1 diagnostic code; only used when occur.= -1 */
119 char *errstring; /* Additional string */
124 BEND_SCAN_SUCCESS, /* ok */
125 BEND_SCAN_PARTIAL /* not all entries could be found */
128 typedef struct bend_scan_rr {
129 int num_bases; /* number of elements in databaselist */
130 char **basenames; /* databases to search */
131 oid_value attributeset;
132 Z_ReferenceId *referenceId; /* reference ID */
133 Z_AttributesPlusTerm *term;
134 ODR stream; /* encoding stream - memory source if required */
135 ODR print; /* printing stream */
137 int *step_size; /* step size */
138 int term_position; /* desired index of term in result list/returned */
139 int num_entries; /* number of entries requested/returned */
141 /* scan term entries. The called handler does not have
142 to allocate this. Size of entries is num_entries (see above) */
143 struct scan_entry *entries;
144 bend_scan_status status;
147 char *scanClause; /* CQL scan clause */
150 typedef struct bend_update_rr {
151 int num_bases; /* number of elements in databaselist */
152 char **basenames; /* databases to search */
153 Z_ReferenceId *referenceId; /* reference ID */
154 ODR stream; /* encoding stream - memory source if required */
155 ODR print; /* printing stream */
157 char *operation_status;
159 Z_SRW_recordVersion *record_versions;
161 char *record_packing;
164 char *extra_record_data;
165 char *extra_request_data;
166 char *extra_response_data;
173 typedef struct bend_delete_rr {
177 Z_ReferenceId *referenceId;
178 int delete_status; /* status for the whole operation */
179 int *statuses; /* status each set - indexed as setnames */
185 typedef struct bend_sort_rr
187 int num_input_setnames;
188 char **input_setnames;
189 char *output_setname;
190 Z_SortKeySpecList *sort_sequence;
193 Z_ReferenceId *referenceId;/* reference ID */
200 typedef struct bend_esrequest_rr
203 Z_ExtendedServicesRequest *esr;
205 ODR stream; /* encoding stream */
206 ODR decode; /* decoding stream */
207 ODR print; /* printing stream */
208 Z_ReferenceId *referenceId;/* reference ID */
209 bend_request request;
210 bend_association association;
211 int errcode; /* 0==success, -1==accepted, >0 = failure */
212 char *errstring; /* system error string or NULL */
213 Z_TaskPackage *taskPackage;
216 typedef struct bend_segment_rr {
221 bend_request request;
222 bend_association association;
232 void *server_node_ptr;
235 typedef struct bend_initrequest
237 Z_IdAuthentication *auth;
238 ODR stream; /* encoding stream */
239 ODR print; /* printing stream */
240 Z_ReferenceId *referenceId;/* reference ID */
241 char *peer_name; /* dns host of peer (client) */
243 char *implementation_id;
244 char *implementation_name;
245 char *implementation_version;
246 int (*bend_sort) (void *handle, bend_sort_rr *rr);
247 int (*bend_search) (void *handle, bend_search_rr *rr);
248 int (*bend_fetch) (void *handle, bend_fetch_rr *rr);
249 int (*bend_present) (void *handle, bend_present_rr *rr);
250 int (*bend_esrequest) (void *handle, bend_esrequest_rr *rr);
251 int (*bend_delete)(void *handle, bend_delete_rr *rr);
252 int (*bend_scan)(void *handle, bend_scan_rr *rr);
253 int (*bend_segment)(void *handle, bend_segment_rr *rr);
255 ODR decode; /* decoding stream */
256 /* character set and language negotiation - see include/yaz/z-charneg.h */
257 Z_CharSetandLanguageNegotiation *charneg_request;
258 Z_External *charneg_response;
259 int (*bend_explain)(void *handle, bend_explain_rr *rr);
260 int (*bend_srw_scan)(void *handle, bend_scan_rr *rr);
261 int (*bend_srw_update)(void *handle, bend_update_rr *rr);
264 typedef struct bend_initresult
266 int errcode; /* 0==OK */
267 char *errstring; /* system error string or NULL */
268 void *handle; /* private handle to the backend module */
271 YAZ_EXPORT void bend_request_send (bend_association a, bend_request req,
274 YAZ_EXPORT bend_request bend_request_mk (bend_association a);
276 YAZ_EXPORT void bend_request_destroy (bend_request *req);
278 YAZ_EXPORT Z_ReferenceId *bend_request_getid (ODR odr, bend_request req);
279 YAZ_EXPORT int bend_backend_respond (bend_association a, bend_request req);
280 YAZ_EXPORT void bend_request_setdata(bend_request r, void *p);
281 YAZ_EXPORT void *bend_request_getdata(bend_request r);
283 typedef struct statserv_options_block
285 int dynamic; /* fork on incoming requests */
286 int threads; /* use threads */
287 int one_shot; /* one session then exit(1) */
288 int __UNUSED__loglevel; /* desired logging-level */
289 char apdufile[ODR_MAXNAME+1]; /* file for pretty-printed PDUs */
290 char logfile[ODR_MAXNAME+1]; /* file for diagnostic output */
291 char default_listen[1024]; /* 0 == no default listen */
292 enum oid_proto default_proto; /* PROTO_SR or PROTO_Z3950 */
293 int idle_timeout; /* how many minutes to wait before closing */
294 int maxrecordsize; /* maximum value for negotiation */
295 char configname[ODR_MAXNAME+1]; /* given to the backend in bend_init */
296 char setuid[ODR_MAXNAME+1]; /* setuid to this user after binding */
297 void (*bend_start)(struct statserv_options_block *p);
298 void (*bend_stop)(struct statserv_options_block *p);
299 int (*options_func)(int argc, char **argv);
300 int (*check_ip)(void *cd, const char *addr, int len, int type);
301 char daemon_name[128];
302 int inetd; /* Do we use the inet deamon or not */
304 void *handle; /* Handle */
305 bend_initresult *(*bend_init)(bend_initrequest *r);
306 void (*bend_close)(void *handle);
308 /* We only have these members for the windows version */
309 /* They seemed a bit large to have them there in general */
310 char service_name[128]; /* NT Service Name */
311 char app_name[128]; /* Application Name */
312 char service_dependencies[128]; /* The services we are dependent on */
313 char service_display_name[128]; /* The service display name */
315 struct bend_soap_handler *soap_handlers;
316 char pid_fname[128]; /* pid fname */
317 int background; /* auto daemon */
318 char cert_fname[128]; /* SSL certificate fname */
319 char xml_config[128]; /* XML config filename */
320 } statserv_options_block;
322 YAZ_EXPORT int statserv_main(
323 int argc, char **argv,
324 bend_initresult *(*bend_init)(bend_initrequest *r),
325 void (*bend_close)(void *handle));
326 YAZ_EXPORT int statserv_start(int argc, char **argv);
327 YAZ_EXPORT void statserv_closedown(void);
328 YAZ_EXPORT statserv_options_block *statserv_getcontrol(void);
329 YAZ_EXPORT void statserv_setcontrol(statserv_options_block *block);
330 YAZ_EXPORT int check_ip_tcpd(void *cd, const char *addr, int len, int type);
332 YAZ_EXPORT int bend_assoc_is_alive(bend_association assoc);
340 * indent-tabs-mode: nil
342 * vim: shiftwidth=4 tabstop=8 expandtab