2 * Copyright (c) 1995-2003, Index Data.
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation, in whole or in part, for any purpose, is hereby granted,
8 * 1. This copyright and permission notice appear in all copies of the
9 * software and its documentation. Notices of copyright or attribution
10 * which appear at the beginning of any file must remain unchanged.
12 * 2. The name of Index Data or the individual authors may not be used to
13 * endorse or promote products derived from this software without specific
14 * prior written permission.
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
18 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
19 * IN NO EVENT SHALL INDEX DATA BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
20 * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
21 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR
22 * NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
26 * $Id: backend.h,v 1.21 2003-04-24 13:30:32 adam Exp $
32 #include <yaz/yconfig.h>
33 #include <yaz/proto.h>
37 typedef struct request *bend_request;
38 typedef struct association *bend_association;
40 /* extended search handler (rr = request response) */
42 char *setname; /* name to give to this set */
43 int replace_set; /* replace set, if it already exists */
44 int num_bases; /* number of databases in list */
45 char **basenames; /* databases to search */
46 Z_ReferenceId *referenceId;/* reference ID */
47 Z_Query *query; /* query structure */
48 ODR stream; /* encode stream */
49 ODR decode; /* decode stream */
50 ODR print; /* print stream */
53 bend_association association;
55 int hits; /* number of hits */
56 int errcode; /* 0==OK */
57 char *errstring; /* system error string or NULL */
58 Z_OtherInformation *search_info; /* additional search info */
61 /* extended present handler. Does not replace bend_fetch. */
63 char *setname; /* set name */
65 int number; /* record number */
66 oid_value format; /* One of the CLASS_RECSYN members */
67 Z_ReferenceId *referenceId;/* reference ID */
68 Z_RecordComposition *comp; /* Formatting instructions */
69 ODR stream; /* encoding stream - memory source if required */
70 ODR print; /* printing stream */
72 bend_association association;
74 int hits; /* number of hits */
75 int errcode; /* 0==OK */
76 char *errstring; /* system error string or NULL */
79 typedef struct bend_fetch_rr {
80 char *setname; /* set name */
81 int number; /* record number */
82 Z_ReferenceId *referenceId;/* reference ID */
83 oid_value request_format; /* One of the CLASS_RECSYN members */
84 int *request_format_raw; /* same as above (raw OID) */
85 Z_RecordComposition *comp; /* Formatting instructions */
86 ODR stream; /* encoding stream - memory source if req */
87 ODR print; /* printing stream */
89 char *basename; /* name of database that provided record */
90 int len; /* length of record or -1 if structured */
91 char *record; /* record */
92 int last_in_set; /* is it? */
93 oid_value output_format; /* format */
94 int *output_format_raw; /* used instead of above if not-null */
95 int errcode; /* 0==success */
96 char *errstring; /* system error string or NULL */
97 int surrogate_flag; /* surrogate diagnostic */
98 char *schema; /* string record schema input/output */
102 char *term; /* the returned scan term */
103 int occurrences; /* no of occurrences or -1 if error (see below) */
104 int errcode; /* Bib-1 diagnostic code; only used when occur.= -1 */
105 char *errstring; /* Additional string */
110 BEND_SCAN_SUCCESS, /* ok */
111 BEND_SCAN_PARTIAL /* not all entries could be found */
114 typedef struct bend_scan_rr {
115 int num_bases; /* number of elements in databaselist */
116 char **basenames; /* databases to search */
117 oid_value attributeset;
118 Z_ReferenceId *referenceId; /* reference ID */
119 Z_AttributesPlusTerm *term;
120 ODR stream; /* encoding stream - memory source if required */
121 ODR print; /* printing stream */
123 int *step_size; /* step size */
124 int term_position; /* desired index of term in result list/returned */
125 int num_entries; /* number of entries requested/returned */
127 /* scan term entries. The called handler does not have
128 to allocate this. Size of entries is num_entries (see above) */
129 struct scan_entry *entries;
130 bend_scan_status status;
136 typedef struct bend_delete_rr {
140 Z_ReferenceId *referenceId;
141 int delete_status; /* status for the whole operation */
142 int *statuses; /* status each set - indexed as setnames */
148 typedef struct bend_sort_rr
150 int num_input_setnames;
151 char **input_setnames;
152 char *output_setname;
153 Z_SortKeySpecList *sort_sequence;
156 Z_ReferenceId *referenceId;/* reference ID */
163 typedef struct bend_esrequest_rr
166 Z_ExtendedServicesRequest *esr;
168 ODR stream; /* encoding stream */
169 ODR decode; /* decoding stream */
170 ODR print; /* printing stream */
171 Z_ReferenceId *referenceId;/* reference ID */
172 bend_request request;
173 bend_association association;
174 int errcode; /* 0==success, -1==accepted, >0 = failure */
175 char *errstring; /* system error string or NULL */
176 Z_TaskPackage *taskPackage;
179 typedef struct bend_segment_rr {
184 bend_request request;
185 bend_association association;
195 typedef struct bend_initrequest
197 Z_IdAuthentication *auth;
198 ODR stream; /* encoding stream */
199 ODR print; /* printing stream */
200 Z_ReferenceId *referenceId;/* reference ID */
201 char *peer_name; /* dns host of peer (client) */
203 char *implementation_id;
204 char *implementation_name;
205 char *implementation_version;
206 int (*bend_sort) (void *handle, bend_sort_rr *rr);
207 int (*bend_search) (void *handle, bend_search_rr *rr);
208 int (*bend_fetch) (void *handle, bend_fetch_rr *rr);
209 int (*bend_present) (void *handle, bend_present_rr *rr);
210 int (*bend_esrequest) (void *handle, bend_esrequest_rr *rr);
211 int (*bend_delete)(void *handle, bend_delete_rr *rr);
212 int (*bend_scan)(void *handle, bend_scan_rr *rr);
213 int (*bend_segment)(void *handle, bend_segment_rr *rr);
215 ODR decode; /* decoding stream */
216 /* character set and language negotiation - see include/yaz/z-charneg.h */
217 Z_CharSetandLanguageNegotiation *charneg_request;
218 Z_External *charneg_response;
219 int (*bend_explain)(void *handle, bend_explain_rr *rr);
222 typedef struct bend_initresult
224 int errcode; /* 0==OK */
225 char *errstring; /* system error string or NULL */
226 void *handle; /* private handle to the backend module */
229 YAZ_EXPORT void bend_request_send (bend_association a, bend_request req,
232 YAZ_EXPORT bend_request bend_request_mk (bend_association a);
234 YAZ_EXPORT void bend_request_destroy (bend_request *req);
236 YAZ_EXPORT Z_ReferenceId *bend_request_getid (ODR odr, bend_request req);
237 YAZ_EXPORT int bend_backend_respond (bend_association a, bend_request req);
238 YAZ_EXPORT void bend_request_setdata(bend_request r, void *p);
239 YAZ_EXPORT void *bend_request_getdata(bend_request r);
241 typedef struct statserv_options_block
243 int dynamic; /* fork on incoming requests */
244 int threads; /* use threads */
245 int one_shot; /* one session then exit(1) */
246 int loglevel; /* desired logging-level */
247 char apdufile[ODR_MAXNAME+1]; /* file for pretty-printed PDUs */
248 char logfile[ODR_MAXNAME+1]; /* file for diagnostic output */
249 char default_listen[1024]; /* 0 == no default listen */
250 enum oid_proto default_proto; /* PROTO_SR or PROTO_Z3950 */
251 int idle_timeout; /* how many minutes to wait before closing */
252 int maxrecordsize; /* maximum value for negotiation */
253 char configname[ODR_MAXNAME+1]; /* given to the backend in bend_init */
254 char setuid[ODR_MAXNAME+1]; /* setuid to this user after binding */
255 void (*bend_start)(struct statserv_options_block *p);
256 void (*bend_stop)(struct statserv_options_block *p);
257 int (*options_func)(int argc, char **argv);
258 int (*check_ip)(void *cd, const char *addr, int len, int type);
259 char daemon_name[128];
260 int inetd; /* Do we use the inet deamon or not */
262 void *handle; /* Handle */
263 bend_initresult *(*bend_init)(bend_initrequest *r);
264 void (*bend_close)(void *handle);
266 /* We only have these members for the windows version */
267 /* They seemed a bit large to have them there in general */
268 char service_name[128]; /* NT Service Name */
269 char app_name[128]; /* Application Name */
270 char service_dependencies[128]; /* The services we are dependent on */
271 char service_display_name[128]; /* The service display name */
273 struct bend_soap_handler *soap_handlers;
274 } statserv_options_block;
276 YAZ_EXPORT int statserv_main(
277 int argc, char **argv,
278 bend_initresult *(*bend_init)(bend_initrequest *r),
279 void (*bend_close)(void *handle));
280 YAZ_EXPORT int statserv_start(int argc, char **argv);
281 YAZ_EXPORT void statserv_closedown(void);
282 YAZ_EXPORT statserv_options_block *statserv_getcontrol(void);
283 YAZ_EXPORT void statserv_setcontrol(statserv_options_block *block);
284 YAZ_EXPORT int check_ip_tcpd(void *cd, const char *addr, int len, int type);