2 * IR toolkit for tcl/tk
4 * See the file LICENSE for details.
5 * Sebastian Hammer, Adam Dickmeiss
8 * Revision 1.28 1996-02-23 17:31:41 adam
9 * More functions made available to the wais tcl extension.
11 * Revision 1.27 1996/02/23 13:41:41 adam
12 * Work on public access to simple ir class system.
14 * Revision 1.26 1996/02/21 10:16:20 adam
15 * Simplified select handling. Only one function ir_tcl_select_set has
16 * to be externally defined.
18 * Revision 1.25 1996/02/05 17:58:04 adam
19 * Ported ir-tcl to use the beta releases of tcl7.5/tk4.1.
21 * Revision 1.24 1996/01/29 11:35:27 adam
22 * Bug fix: cs_type member renamed to comstackType to avoid conflict with
23 * cs_type macro defined by YAZ.
25 * Revision 1.23 1996/01/19 16:22:40 adam
26 * New method: apduDump - returns information about last incoming APDU.
28 * Revision 1.22 1996/01/10 09:18:44 adam
29 * PDU specific callbacks implemented: initRespnse, searchResponse,
30 * presentResponse and scanResponse.
31 * Bug fix in the command line shell (tclmain.c) - discovered on OSF/1.
33 * Revision 1.21 1996/01/04 16:12:14 adam
34 * Setting PDUType renamed to eventType.
36 * Revision 1.20 1996/01/04 11:05:23 adam
37 * New setting: PDUType - returns type of last PDU returned from the target.
38 * Fixed a bug in configure/Makefile.
40 * Revision 1.19 1995/11/13 09:55:46 adam
41 * Multiple records at a position in a result-set with differnt
44 * Revision 1.18 1995/10/18 16:42:44 adam
45 * New settings: smallSetElementSetNames and mediumSetElementSetNames.
47 * Revision 1.17 1995/10/16 17:00:56 adam
48 * New setting: elementSetNames.
49 * Various client improvements. Medium presentation format looks better.
51 * Revision 1.16 1995/09/20 11:37:01 adam
52 * Configure searches for tk4.1 and tk7.5.
55 * Revision 1.15 1995/08/29 15:30:15 adam
56 * Work on GRS records.
58 * Revision 1.14 1995/08/04 11:32:40 adam
59 * More work on output queue. Memory related routines moved
62 * Revision 1.13 1995/08/03 13:23:00 adam
65 * Revision 1.12 1995/07/28 10:28:38 adam
66 * First work on request queue.
68 * Revision 1.11 1995/06/20 08:07:35 adam
69 * New setting: failInfo.
70 * Working on better cancel mechanism.
72 * Revision 1.10 1995/06/16 12:28:20 adam
73 * Implemented preferredRecordSyntax.
74 * Minor changes in diagnostic handling.
75 * Record list deleted when connection closes.
77 * Revision 1.9 1995/06/14 15:08:01 adam
78 * Bug fix in cascade-target-list. Uses yaz-version.h.
80 * Revision 1.8 1995/06/14 13:37:18 adam
81 * Setting recordType implemented.
82 * Setting implementationVersion implemented.
83 * Settings implementationId / implementationName edited.
85 * Revision 1.7 1995/06/01 07:31:28 adam
86 * Rename of many typedefs -> IrTcl_...
88 * Revision 1.6 1995/05/31 08:36:40 adam
89 * Bug fix in client.tcl: didn't save options on clientrc.tcl.
90 * New method: referenceId. More work on scan.
92 * Revision 1.5 1995/05/29 08:44:25 adam
93 * Work on delete of objects.
95 * Revision 1.4 1995/05/26 11:44:10 adam
96 * Bugs fixed. More work on MARC utilities and queries. Test
97 * client is up-to-date again.
99 * Revision 1.3 1995/05/26 08:54:17 adam
100 * New MARC utilities. Uses prefix query.
102 * Revision 1.2 1995/05/24 14:10:23 adam
103 * Work on idAuthentication, protocolVersion and options.
105 * Revision 1.1 1995/05/23 15:34:49 adam
106 * Many new settings, userInformationField, smallSetUpperBound, etc.
107 * A number of settings are inherited when ir-set is executed.
108 * This version is incompatible with the graphical test client (client.tcl).
123 #include <comstack.h>
130 #include <yaz-version.h>
134 #include <diagbib1.h>
140 int (*method) (void *obj, Tcl_Interp *interp, int argc, char **argv);
150 char **databaseNames;
151 int num_databaseNames;
153 enum oid_value *preferredRecordSyntax;
154 int replaceIndicator;
157 char *elementSetNames;
158 char *smallSetElementSetNames;
159 char *mediumSetElementSetNames;
161 int smallSetUpperBound;
162 int largeSetLowerBound;
163 int mediumSetPresentNumber;
173 #if IRTCL_GENERIC_FILES
179 int preferredMessageSize;
180 int maximumRecordSize;
182 Odr_bitmask protocolVersion;
184 char *idAuthenticationOpen;
185 char *idAuthenticationGroupId;
186 char *idAuthenticationUserId;
187 char *idAuthenticationPassword;
189 char *implementationName;
190 char *implementationId;
191 char *implementationVersion;
193 char *targetImplementationName;
194 char *targetImplementationId;
195 char *targetImplementationVersion;
196 char *userInformationField;
218 struct IrTcl_Request_ *request_queue;
220 IrTcl_SetCObj set_inher;
223 typedef struct IrTcl_Request_ {
224 struct IrTcl_Request_ *next;
239 struct GRS_Record_entry {
248 struct IrTcl_GRS_Record_ *sub;
259 typedef struct IrTcl_GRS_Record_ {
261 struct GRS_Record_entry *entries;
264 typedef struct IrTcl_RecordList_ {
273 IrTcl_GRS_Record *grs1;
279 IrTcl_Diagnostic *list;
280 } surrogateDiagnostics;
282 struct IrTcl_RecordList_ *next;
285 typedef struct IrTcl_SetObj_ {
290 int nextResultSetPosition;
293 int numberOfRecordsReturned;
295 char *recordElements;
298 int nonSurrogateDiagnosticNum;
299 char *searchResponse;
300 char *presentResponse;
301 IrTcl_Diagnostic *nonSurrogateDiagnosticList;
302 IrTcl_RecordList *record_list;
303 IrTcl_SetCObj set_inher;
306 typedef struct IrTcl_ScanEntry_ {
311 int globalOccurrences;
314 IrTcl_Diagnostic *list;
320 typedef struct IrTcl_ScanObj_ {
323 int numberOfTermsRequested;
324 int preferredPositionInResponse;
327 int numberOfEntriesReturned;
337 IrTcl_ScanEntry *entries;
338 IrTcl_Diagnostic *nonSurrogateDiagnosticList;
339 int nonSurrogateDiagnosticNum;
342 struct ir_named_entry {
347 int ir_tcl_get_marc (Tcl_Interp *interp, const char *buf,
348 int argc, char **argv);
349 int ir_tcl_send_APDU (Tcl_Interp *interp, IrTcl_Obj *p, Z_APDU *apdu,
350 const char *msg, const char *object_name);
351 int ir_tcl_send_q (IrTcl_Obj *p, IrTcl_Request *rq, const char *msg);
352 void ir_tcl_del_q (IrTcl_Obj *p);
353 int ir_tcl_strdup (Tcl_Interp *interp, char** p, const char *s);
354 int ir_tcl_strdel (Tcl_Interp *interp, char **p);
356 char *ir_tcl_fread_marc (FILE *inf, size_t *size);
357 void ir_tcl_read_grs (Z_GenericRecord *r, IrTcl_GRS_Record **grs_record);
358 int ir_tcl_get_grs (Tcl_Interp *interp, IrTcl_GRS_Record *grs_record,
359 int argc, char **argv);
361 int ir_tcl_method (Tcl_Interp *interp, int argc, char **argv,
366 int (*ir_init) (ClientData clientData, Tcl_Interp *interp,
367 int argc, char **argv, ClientData *subData);
368 int (*ir_method) (ClientData clientData, Tcl_Interp *interp,
369 int argc, char **argv);
370 void (*ir_delete)(ClientData clientData);
373 extern IrTcl_Class ir_obj_class;
375 void ir_select_add (int fd, void *obj);
376 void ir_select_add_write (int fd, void *obj);
377 void ir_select_remove (int fd, void *obj);
378 void ir_select_remove_write (int fd, void *obj);
380 int ir_tcl_eval (Tcl_Interp *interp, const char *command);
382 #define IR_TCL_FAIL_CONNECT 1
383 #define IR_TCL_FAIL_READ 2
384 #define IR_TCL_FAIL_WRITE 3
385 #define IR_TCL_FAIL_IN_APDU 4
386 #define IR_TCL_FAIL_UNKNOWN_APDU 5
388 #define IR_TCL_R_Idle 0
389 #define IR_TCL_R_Writing 1
390 #define IR_TCL_R_Waiting 2
391 #define IR_TCL_R_Reading 3
392 #define IR_TCL_R_Connecting 4