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.17 2003-01-06 08:20:27 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 */
101 char *term; /* the returned scan term */
102 int occurrences; /* no of occurrences or -1 if error (see below) */
103 int errcode; /* Bib-1 diagnostic code; only used when occur.= -1 */
104 char *errstring; /* Additional string */
108 BEND_SCAN_SUCCESS, /* ok */
109 BEND_SCAN_PARTIAL /* not all entries could be found */
112 typedef struct bend_scan_rr {
113 int num_bases; /* number of elements in databaselist */
114 char **basenames; /* databases to search */
115 oid_value attributeset;
116 Z_ReferenceId *referenceId; /* reference ID */
117 Z_AttributesPlusTerm *term;
118 ODR stream; /* encoding stream - memory source if required */
119 ODR print; /* printing stream */
121 int *step_size; /* step size */
122 int term_position; /* desired index of term in result list/returned */
123 int num_entries; /* number of entries requested/returned */
125 struct scan_entry *entries;
126 bend_scan_status status;
132 typedef struct bend_delete_rr {
136 Z_ReferenceId *referenceId;
137 int delete_status; /* status for the whole operation */
138 int *statuses; /* status each set - indexed as setnames */
144 typedef struct bend_sort_rr
146 int num_input_setnames;
147 char **input_setnames;
148 char *output_setname;
149 Z_SortKeySpecList *sort_sequence;
152 Z_ReferenceId *referenceId;/* reference ID */
159 typedef struct bend_esrequest_rr
162 Z_ExtendedServicesRequest *esr;
164 ODR stream; /* encoding stream */
165 ODR decode; /* decoding stream */
166 ODR print; /* printing stream */
167 Z_ReferenceId *referenceId;/* reference ID */
168 bend_request request;
169 bend_association association;
170 int errcode; /* 0==success, -1==accepted, >0 = failure */
171 char *errstring; /* system error string or NULL */
172 Z_TaskPackage *taskPackage;
175 typedef struct bend_segment_rr {
180 bend_request request;
181 bend_association association;
184 typedef struct bend_initrequest
186 Z_IdAuthentication *auth;
187 ODR stream; /* encoding stream */
188 ODR print; /* printing stream */
189 Z_ReferenceId *referenceId;/* reference ID */
190 char *peer_name; /* dns host of peer (client) */
192 char *implementation_id;
193 char *implementation_name;
194 char *implementation_version;
195 int (*bend_sort) (void *handle, bend_sort_rr *rr);
196 int (*bend_search) (void *handle, bend_search_rr *rr);
197 int (*bend_fetch) (void *handle, bend_fetch_rr *rr);
198 int (*bend_present) (void *handle, bend_present_rr *rr);
199 int (*bend_esrequest) (void *handle, bend_esrequest_rr *rr);
200 int (*bend_delete)(void *handle, bend_delete_rr *rr);
201 int (*bend_scan)(void *handle, bend_scan_rr *rr);
202 int (*bend_segment)(void *handle, bend_segment_rr *rr);
204 ODR decode; /* decoding stream */
205 /* character set and language negotiation - see include/yaz/z-charneg.h */
206 Z_CharSetandLanguageNegotiation *charneg_request;
207 Z_External *charneg_response;
211 typedef struct bend_initresult
213 int errcode; /* 0==OK */
214 char *errstring; /* system error string or NULL */
215 void *handle; /* private handle to the backend module */
218 YAZ_EXPORT void bend_request_send (bend_association a, bend_request req,
221 YAZ_EXPORT bend_request bend_request_mk (bend_association a);
223 YAZ_EXPORT void bend_request_destroy (bend_request *req);
225 YAZ_EXPORT Z_ReferenceId *bend_request_getid (ODR odr, bend_request req);
226 YAZ_EXPORT int bend_backend_respond (bend_association a, bend_request req);
227 YAZ_EXPORT void bend_request_setdata(bend_request r, void *p);
228 YAZ_EXPORT void *bend_request_getdata(bend_request r);
230 typedef struct statserv_options_block
232 int dynamic; /* fork on incoming requests */
233 int threads; /* use threads */
234 int one_shot; /* one session then exit(1) */
235 int loglevel; /* desired logging-level */
236 char apdufile[ODR_MAXNAME+1]; /* file for pretty-printed PDUs */
237 char logfile[ODR_MAXNAME+1]; /* file for diagnostic output */
238 char default_listen[1024]; /* 0 == no default listen */
239 enum oid_proto default_proto; /* PROTO_SR or PROTO_Z3950 */
240 int idle_timeout; /* how many minutes to wait before closing */
241 int maxrecordsize; /* maximum value for negotiation */
242 char configname[ODR_MAXNAME+1]; /* given to the backend in bend_init */
243 char setuid[ODR_MAXNAME+1]; /* setuid to this user after binding */
244 void (*bend_start)(struct statserv_options_block *p);
245 void (*bend_stop)(struct statserv_options_block *p);
246 int (*options_func)(int argc, char **argv);
247 int (*check_ip)(void *cd, const char *addr, int len, int type);
248 char daemon_name[128];
249 int inetd; /* Do we use the inet deamon or not */
251 void *handle; /* Handle */
252 bend_initresult *(*bend_init)(bend_initrequest *r);
253 void (*bend_close)(void *handle);
255 /* We only have these members for the windows version */
256 /* They seemed a bit large to have them there in general */
257 char service_name[128]; /* NT Service Name */
258 char app_name[128]; /* Application Name */
259 char service_dependencies[128]; /* The services we are dependent on */
260 char service_display_name[128]; /* The service display name */
262 } statserv_options_block;
264 YAZ_EXPORT int statserv_main(
265 int argc, char **argv,
266 bend_initresult *(*bend_init)(bend_initrequest *r),
267 void (*bend_close)(void *handle));
268 YAZ_EXPORT int statserv_start(int argc, char **argv);
269 YAZ_EXPORT void statserv_closedown(void);
270 YAZ_EXPORT statserv_options_block *statserv_getcontrol(void);
271 YAZ_EXPORT void statserv_setcontrol(statserv_options_block *block);
272 YAZ_EXPORT int check_ip_tcpd(void *cd, const char *addr, int len, int type);