2 * IR toolkit for tcl/tk
4 * See the file LICENSE for details.
5 * Sebastian Hammer, Adam Dickmeiss
8 * Revision 1.30 1996-02-29 15:30:23 adam
9 * Export of IrTcl functionality to extensions.
11 * Revision 1.29 1996/02/26 18:38:33 adam
12 * Work on export of set methods.
14 * Revision 1.28 1996/02/23 17:31:41 adam
15 * More functions made available to the wais tcl extension.
17 * Revision 1.27 1996/02/23 13:41:41 adam
18 * Work on public access to simple ir class system.
20 * Revision 1.26 1996/02/21 10:16:20 adam
21 * Simplified select handling. Only one function ir_tcl_select_set has
22 * to be externally defined.
24 * Revision 1.25 1996/02/05 17:58:04 adam
25 * Ported ir-tcl to use the beta releases of tcl7.5/tk4.1.
27 * Revision 1.24 1996/01/29 11:35:27 adam
28 * Bug fix: cs_type member renamed to comstackType to avoid conflict with
29 * cs_type macro defined by YAZ.
31 * Revision 1.23 1996/01/19 16:22:40 adam
32 * New method: apduDump - returns information about last incoming APDU.
34 * Revision 1.22 1996/01/10 09:18:44 adam
35 * PDU specific callbacks implemented: initRespnse, searchResponse,
36 * presentResponse and scanResponse.
37 * Bug fix in the command line shell (tclmain.c) - discovered on OSF/1.
39 * Revision 1.21 1996/01/04 16:12:14 adam
40 * Setting PDUType renamed to eventType.
42 * Revision 1.20 1996/01/04 11:05:23 adam
43 * New setting: PDUType - returns type of last PDU returned from the target.
44 * Fixed a bug in configure/Makefile.
46 * Revision 1.19 1995/11/13 09:55:46 adam
47 * Multiple records at a position in a result-set with differnt
50 * Revision 1.18 1995/10/18 16:42:44 adam
51 * New settings: smallSetElementSetNames and mediumSetElementSetNames.
53 * Revision 1.17 1995/10/16 17:00:56 adam
54 * New setting: elementSetNames.
55 * Various client improvements. Medium presentation format looks better.
57 * Revision 1.16 1995/09/20 11:37:01 adam
58 * Configure searches for tk4.1 and tk7.5.
61 * Revision 1.15 1995/08/29 15:30:15 adam
62 * Work on GRS records.
64 * Revision 1.14 1995/08/04 11:32:40 adam
65 * More work on output queue. Memory related routines moved
68 * Revision 1.13 1995/08/03 13:23:00 adam
71 * Revision 1.12 1995/07/28 10:28:38 adam
72 * First work on request queue.
74 * Revision 1.11 1995/06/20 08:07:35 adam
75 * New setting: failInfo.
76 * Working on better cancel mechanism.
78 * Revision 1.10 1995/06/16 12:28:20 adam
79 * Implemented preferredRecordSyntax.
80 * Minor changes in diagnostic handling.
81 * Record list deleted when connection closes.
83 * Revision 1.9 1995/06/14 15:08:01 adam
84 * Bug fix in cascade-target-list. Uses yaz-version.h.
86 * Revision 1.8 1995/06/14 13:37:18 adam
87 * Setting recordType implemented.
88 * Setting implementationVersion implemented.
89 * Settings implementationId / implementationName edited.
91 * Revision 1.7 1995/06/01 07:31:28 adam
92 * Rename of many typedefs -> IrTcl_...
94 * Revision 1.6 1995/05/31 08:36:40 adam
95 * Bug fix in client.tcl: didn't save options on clientrc.tcl.
96 * New method: referenceId. More work on scan.
98 * Revision 1.5 1995/05/29 08:44:25 adam
99 * Work on delete of objects.
101 * Revision 1.4 1995/05/26 11:44:10 adam
102 * Bugs fixed. More work on MARC utilities and queries. Test
103 * client is up-to-date again.
105 * Revision 1.3 1995/05/26 08:54:17 adam
106 * New MARC utilities. Uses prefix query.
108 * Revision 1.2 1995/05/24 14:10:23 adam
109 * Work on idAuthentication, protocolVersion and options.
111 * Revision 1.1 1995/05/23 15:34:49 adam
112 * Many new settings, userInformationField, smallSetUpperBound, etc.
113 * A number of settings are inherited when ir-set is executed.
114 * This version is incompatible with the graphical test client (client.tcl).
129 #include <comstack.h>
136 #include <yaz-version.h>
140 #include <diagbib1.h>
146 int (*method) (void *obj, Tcl_Interp *interp, int argc, char **argv);
156 char **databaseNames;
157 int num_databaseNames;
159 enum oid_value *preferredRecordSyntax;
160 int replaceIndicator;
163 char *elementSetNames;
164 char *smallSetElementSetNames;
165 char *mediumSetElementSetNames;
167 int smallSetUpperBound;
168 int largeSetLowerBound;
169 int mediumSetPresentNumber;
179 #if IRTCL_GENERIC_FILES
185 int preferredMessageSize;
186 int maximumRecordSize;
188 Odr_bitmask protocolVersion;
190 char *idAuthenticationOpen;
191 char *idAuthenticationGroupId;
192 char *idAuthenticationUserId;
193 char *idAuthenticationPassword;
195 char *implementationName;
196 char *implementationId;
197 char *implementationVersion;
199 char *targetImplementationName;
200 char *targetImplementationId;
201 char *targetImplementationVersion;
202 char *userInformationField;
224 struct IrTcl_Request_ *request_queue;
226 IrTcl_SetCObj set_inher;
229 typedef struct IrTcl_Request_ {
230 struct IrTcl_Request_ *next;
245 struct GRS_Record_entry {
254 struct IrTcl_GRS_Record_ *sub;
265 typedef struct IrTcl_GRS_Record_ {
267 struct GRS_Record_entry *entries;
270 typedef struct IrTcl_RecordList_ {
279 IrTcl_GRS_Record *grs1;
285 IrTcl_Diagnostic *list;
286 } surrogateDiagnostics;
288 struct IrTcl_RecordList_ *next;
291 typedef struct IrTcl_SetObj_ {
296 int nextResultSetPosition;
299 int numberOfRecordsReturned;
301 char *recordElements;
304 int nonSurrogateDiagnosticNum;
305 char *searchResponse;
306 char *presentResponse;
307 IrTcl_Diagnostic *nonSurrogateDiagnosticList;
308 IrTcl_RecordList *record_list;
309 IrTcl_SetCObj set_inher;
312 typedef struct IrTcl_ScanEntry_ {
317 int globalOccurrences;
320 IrTcl_Diagnostic *list;
326 typedef struct IrTcl_ScanObj_ {
329 int numberOfTermsRequested;
330 int preferredPositionInResponse;
333 int numberOfEntriesReturned;
343 IrTcl_ScanEntry *entries;
344 IrTcl_Diagnostic *nonSurrogateDiagnosticList;
345 int nonSurrogateDiagnosticNum;
348 struct ir_named_entry {
353 int ir_tcl_get_marc (Tcl_Interp *interp, const char *buf,
354 int argc, char **argv);
355 int ir_tcl_send_APDU (Tcl_Interp *interp, IrTcl_Obj *p, Z_APDU *apdu,
356 const char *msg, const char *object_name);
357 int ir_tcl_send_q (IrTcl_Obj *p, IrTcl_Request *rq, const char *msg);
358 void ir_tcl_del_q (IrTcl_Obj *p);
359 int ir_tcl_strdup (Tcl_Interp *interp, char** p, const char *s);
360 int ir_tcl_strdel (Tcl_Interp *interp, char **p);
362 char *ir_tcl_fread_marc (FILE *inf, size_t *size);
363 void ir_tcl_read_grs (Z_GenericRecord *r, IrTcl_GRS_Record **grs_record);
364 int ir_tcl_get_grs (Tcl_Interp *interp, IrTcl_GRS_Record *grs_record,
365 int argc, char **argv);
367 int ir_tcl_method (Tcl_Interp *interp, int argc, char **argv,
368 IrTcl_Methods *tab, int *ret);
369 int ir_tcl_get_set_int (int *val, Tcl_Interp *interp, int argc, char **argv);
373 int (*ir_init) (ClientData clientData, Tcl_Interp *interp,
374 int argc, char **argv, ClientData *subData,
375 ClientData parentData);
376 int (*ir_method) (ClientData clientData, Tcl_Interp *interp,
377 int argc, char **argv);
378 void (*ir_delete)(ClientData clientData);
381 extern IrTcl_Class ir_obj_class;
382 extern IrTcl_Class ir_set_obj_class;
384 void ir_select_add (int fd, void *obj);
385 void ir_select_add_write (int fd, void *obj);
386 void ir_select_remove (int fd, void *obj);
387 void ir_select_remove_write (int fd, void *obj);
389 int ir_tcl_eval (Tcl_Interp *interp, const char *command);
391 #define IR_TCL_FAIL_CONNECT 1
392 #define IR_TCL_FAIL_READ 2
393 #define IR_TCL_FAIL_WRITE 3
394 #define IR_TCL_FAIL_IN_APDU 4
395 #define IR_TCL_FAIL_UNKNOWN_APDU 5
397 #define IR_TCL_R_Idle 0
398 #define IR_TCL_R_Writing 1
399 #define IR_TCL_R_Waiting 2
400 #define IR_TCL_R_Reading 3
401 #define IR_TCL_R_Connecting 4