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.43 2007-04-12 13:52:57 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>
43 #include <yaz/oid_db.h>
47 typedef struct request *bend_request;
48 typedef struct association *bend_association;
50 /* extended search handler (rr = request response) */
52 char *setname; /* name to give to this set */
53 int replace_set; /* replace set, if it already exists */
54 int num_bases; /* number of databases in list */
55 char **basenames; /* databases to search */
56 Z_ReferenceId *referenceId;/* reference ID */
57 Z_Query *query; /* query structure */
58 ODR stream; /* encode stream */
59 ODR decode; /* decode stream */
60 ODR print; /* print stream */
63 bend_association association;
65 int hits; /* number of hits */
66 int errcode; /* 0==OK */
67 char *errstring; /* system error string or NULL */
68 Z_OtherInformation *search_info; /* additional search info */
69 char *srw_sortKeys; /* holds SRU/SRW sortKeys info */
70 char *srw_setname; /* holds SRU/SRW generated resultsetID */
71 int *srw_setnameIdleTime; /* holds SRU/SRW life-time */
72 int estimated_hit_count; /* if hit count is estimated */
73 int partial_resultset; /* if result set is partial */
76 /* extended present handler. Does not replace bend_fetch. */
78 char *setname; /* set name */
80 int number; /* record number */
81 int *format; /* format, transfer syntax (OID) */
82 Z_ReferenceId *referenceId;/* reference ID */
83 Z_RecordComposition *comp; /* Formatting instructions */
84 ODR stream; /* encoding stream - memory source if required */
85 ODR print; /* printing stream */
87 bend_association association;
89 int hits; /* number of hits */
90 int errcode; /* 0==OK */
91 char *errstring; /* system error string or NULL */
94 typedef struct bend_fetch_rr {
95 char *setname; /* set name */
96 int number; /* record number */
97 Z_ReferenceId *referenceId;/* reference ID */
98 int *request_format; /* format, transfer syntax (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 int *output_format; /* response format/syntax (OID) */
108 int errcode; /* 0==success */
109 char *errstring; /* system error string or NULL */
110 int surrogate_flag; /* surrogate diagnostic */
111 char *schema; /* string record schema input/output */
115 char *term; /* the returned scan term */
116 int occurrences; /* no of occurrences or -1 if error (see below) */
117 int errcode; /* Bib-1 diagnostic code; only used when occur.= -1 */
118 char *errstring; /* Additional string */
123 BEND_SCAN_SUCCESS, /* ok */
124 BEND_SCAN_PARTIAL /* not all entries could be found */
127 typedef struct bend_scan_rr {
128 int num_bases; /* number of elements in databaselist */
129 char **basenames; /* databases to search */
131 Z_ReferenceId *referenceId; /* reference ID */
132 Z_AttributesPlusTerm *term;
133 ODR stream; /* encoding stream - memory source if required */
134 ODR print; /* printing stream */
136 int *step_size; /* step size */
137 int term_position; /* desired index of term in result list/returned */
138 int num_entries; /* number of entries requested/returned */
140 /* scan term entries. The called handler does not have
141 to allocate this. Size of entries is num_entries (see above) */
142 struct scan_entry *entries;
143 bend_scan_status status;
146 char *scanClause; /* CQL scan clause */
149 typedef struct bend_update_rr {
150 int num_bases; /* number of elements in databaselist */
151 char **basenames; /* databases to search */
152 Z_ReferenceId *referenceId; /* reference ID */
153 ODR stream; /* encoding stream - memory source if required */
154 ODR print; /* printing stream */
156 char *operation_status;
158 Z_SRW_recordVersion *record_versions;
160 char *record_packing;
163 char *extra_record_data;
164 char *extra_request_data;
165 char *extra_response_data;
172 typedef struct bend_delete_rr {
176 Z_ReferenceId *referenceId;
177 int delete_status; /* status for the whole operation */
178 int *statuses; /* status each set - indexed as setnames */
184 typedef struct bend_sort_rr
186 int num_input_setnames;
187 char **input_setnames;
188 char *output_setname;
189 Z_SortKeySpecList *sort_sequence;
192 Z_ReferenceId *referenceId;/* reference ID */
199 typedef struct bend_esrequest_rr
202 Z_ExtendedServicesRequest *esr;
204 ODR stream; /* encoding stream */
205 ODR decode; /* decoding stream */
206 ODR print; /* printing stream */
207 Z_ReferenceId *referenceId;/* reference ID */
208 bend_request request;
209 bend_association association;
210 int errcode; /* 0==success, -1==accepted, >0 = failure */
211 char *errstring; /* system error string or NULL */
212 Z_TaskPackage *taskPackage;
215 typedef struct bend_segment_rr {
220 bend_request request;
221 bend_association association;
231 void *server_node_ptr;
234 typedef struct bend_initrequest
236 Z_IdAuthentication *auth;
237 ODR stream; /* encoding stream */
238 ODR print; /* printing stream */
239 Z_ReferenceId *referenceId;/* reference ID */
240 char *peer_name; /* dns host of peer (client) */
242 char *implementation_id;
243 char *implementation_name;
244 char *implementation_version;
245 int (*bend_sort) (void *handle, bend_sort_rr *rr);
246 int (*bend_search) (void *handle, bend_search_rr *rr);
247 int (*bend_fetch) (void *handle, bend_fetch_rr *rr);
248 int (*bend_present) (void *handle, bend_present_rr *rr);
249 int (*bend_esrequest) (void *handle, bend_esrequest_rr *rr);
250 int (*bend_delete)(void *handle, bend_delete_rr *rr);
251 int (*bend_scan)(void *handle, bend_scan_rr *rr);
252 int (*bend_segment)(void *handle, bend_segment_rr *rr);
254 ODR decode; /* decoding stream */
255 /* character set and language negotiation - see include/yaz/z-charneg.h */
256 Z_CharSetandLanguageNegotiation *charneg_request;
257 Z_External *charneg_response;
258 int (*bend_explain)(void *handle, bend_explain_rr *rr);
259 int (*bend_srw_scan)(void *handle, bend_scan_rr *rr);
260 int (*bend_srw_update)(void *handle, bend_update_rr *rr);
263 typedef struct bend_initresult
265 int errcode; /* 0==OK */
266 char *errstring; /* system error string or NULL */
267 void *handle; /* private handle to the backend module */
270 YAZ_EXPORT void bend_request_send (bend_association a, bend_request req,
273 YAZ_EXPORT bend_request bend_request_mk (bend_association a);
275 YAZ_EXPORT void bend_request_destroy (bend_request *req);
277 YAZ_EXPORT Z_ReferenceId *bend_request_getid (ODR odr, bend_request req);
278 YAZ_EXPORT int bend_backend_respond (bend_association a, bend_request req);
279 YAZ_EXPORT void bend_request_setdata(bend_request r, void *p);
280 YAZ_EXPORT void *bend_request_getdata(bend_request r);
282 typedef struct statserv_options_block
284 int dynamic; /* fork on incoming requests */
285 int threads; /* use threads */
286 int one_shot; /* one session then exit(1) */
287 int __UNUSED__loglevel; /* desired logging-level */
288 char apdufile[ODR_MAXNAME+1]; /* file for pretty-printed PDUs */
289 char logfile[ODR_MAXNAME+1]; /* file for diagnostic output */
290 char default_listen[1024]; /* 0 == no default listen */
291 enum oid_proto default_proto; /* PROTO_SR or PROTO_Z3950 */
292 int idle_timeout; /* how many minutes to wait before closing */
293 int maxrecordsize; /* maximum value for negotiation */
294 char configname[ODR_MAXNAME+1]; /* given to the backend in bend_init */
295 char setuid[ODR_MAXNAME+1]; /* setuid to this user after binding */
296 void (*bend_start)(struct statserv_options_block *p);
297 void (*bend_stop)(struct statserv_options_block *p);
298 int (*options_func)(int argc, char **argv);
299 int (*check_ip)(void *cd, const char *addr, int len, int type);
300 char daemon_name[128];
301 int inetd; /* Do we use the inet deamon or not */
303 void *handle; /* Handle */
304 bend_initresult *(*bend_init)(bend_initrequest *r);
305 void (*bend_close)(void *handle);
307 /* We only have these members for the windows version */
308 /* They seemed a bit large to have them there in general */
309 char service_name[128]; /* NT Service Name */
310 char app_name[128]; /* Application Name */
311 char service_dependencies[128]; /* The services we are dependent on */
312 char service_display_name[128]; /* The service display name */
314 struct bend_soap_handler *soap_handlers;
315 char pid_fname[128]; /* pid fname */
316 int background; /* auto daemon */
317 char cert_fname[128]; /* SSL certificate fname */
318 char xml_config[128]; /* XML config filename */
319 } statserv_options_block;
321 YAZ_EXPORT int statserv_main(
322 int argc, char **argv,
323 bend_initresult *(*bend_init)(bend_initrequest *r),
324 void (*bend_close)(void *handle));
325 YAZ_EXPORT int statserv_start(int argc, char **argv);
326 YAZ_EXPORT void statserv_closedown(void);
327 YAZ_EXPORT statserv_options_block *statserv_getcontrol(void);
328 YAZ_EXPORT void statserv_setcontrol(statserv_options_block *block);
329 YAZ_EXPORT int check_ip_tcpd(void *cd, const char *addr, int len, int type);
331 YAZ_EXPORT int bend_assoc_is_alive(bend_association assoc);
339 * indent-tabs-mode: nil
341 * vim: shiftwidth=4 tabstop=8 expandtab