2 * IR toolkit for tcl/tk
3 * (c) Index Data 1995-1998
4 * See the file LICENSE for details.
5 * Sebastian Hammer, Adam Dickmeiss
8 * Revision 1.38 1999-03-22 06:51:34 adam
11 * Revision 1.37 1998/04/02 14:31:08 adam
12 * This version works with compiled ASN.1 code.
14 * Revision 1.36 1997/11/19 11:22:09 adam
15 * Object identifiers can be accessed in GRS-1 records.
17 * Revision 1.35 1997/09/09 10:19:54 adam
18 * New MSV5.0 port with fewer warnings.
20 * Revision 1.34 1996/08/16 15:07:47 adam
21 * First work on Explain.
23 * Revision 1.33 1996/07/03 13:31:13 adam
24 * The xmalloc/xfree functions from YAZ are used to manage memory.
26 * Revision 1.32 1996/03/20 13:54:05 adam
27 * The Tcl_File structure is only manipulated in the Tk-event interface
30 * Revision 1.31 1996/03/05 09:21:19 adam
31 * Bug fix: memory used by GRS records wasn't freed.
32 * Rewrote some of the error handling code - the connection is always
33 * closed before failback is called.
34 * If failback is defined the send APDU methods (init, search, ...) will
35 * return OK but invoke failback (as is the case if the write operation
37 * Bug fix: ref_count in assoc object could grow if fraction of PDU was
40 * Revision 1.30 1996/02/29 15:30:23 adam
41 * Export of IrTcl functionality to extensions.
43 * Revision 1.29 1996/02/26 18:38:33 adam
44 * Work on export of set methods.
46 * Revision 1.28 1996/02/23 17:31:41 adam
47 * More functions made available to the wais tcl extension.
49 * Revision 1.27 1996/02/23 13:41:41 adam
50 * Work on public access to simple ir class system.
52 * Revision 1.26 1996/02/21 10:16:20 adam
53 * Simplified select handling. Only one function ir_tcl_select_set has
54 * to be externally defined.
56 * Revision 1.25 1996/02/05 17:58:04 adam
57 * Ported ir-tcl to use the beta releases of tcl7.5/tk4.1.
59 * Revision 1.24 1996/01/29 11:35:27 adam
60 * Bug fix: cs_type member renamed to comstackType to avoid conflict with
61 * cs_type macro defined by YAZ.
63 * Revision 1.23 1996/01/19 16:22:40 adam
64 * New method: apduDump - returns information about last incoming APDU.
66 * Revision 1.22 1996/01/10 09:18:44 adam
67 * PDU specific callbacks implemented: initRespnse, searchResponse,
68 * presentResponse and scanResponse.
69 * Bug fix in the command line shell (tclmain.c) - discovered on OSF/1.
71 * Revision 1.21 1996/01/04 16:12:14 adam
72 * Setting PDUType renamed to eventType.
74 * Revision 1.20 1996/01/04 11:05:23 adam
75 * New setting: PDUType - returns type of last PDU returned from the target.
76 * Fixed a bug in configure/Makefile.
78 * Revision 1.19 1995/11/13 09:55:46 adam
79 * Multiple records at a position in a result-set with differnt
82 * Revision 1.18 1995/10/18 16:42:44 adam
83 * New settings: smallSetElementSetNames and mediumSetElementSetNames.
85 * Revision 1.17 1995/10/16 17:00:56 adam
86 * New setting: elementSetNames.
87 * Various client improvements. Medium presentation format looks better.
89 * Revision 1.16 1995/09/20 11:37:01 adam
90 * Configure searches for tk4.1 and tk7.5.
93 * Revision 1.15 1995/08/29 15:30:15 adam
94 * Work on GRS records.
96 * Revision 1.14 1995/08/04 11:32:40 adam
97 * More work on output queue. Memory related routines moved
100 * Revision 1.13 1995/08/03 13:23:00 adam
103 * Revision 1.12 1995/07/28 10:28:38 adam
104 * First work on request queue.
106 * Revision 1.11 1995/06/20 08:07:35 adam
107 * New setting: failInfo.
108 * Working on better cancel mechanism.
110 * Revision 1.10 1995/06/16 12:28:20 adam
111 * Implemented preferredRecordSyntax.
112 * Minor changes in diagnostic handling.
113 * Record list deleted when connection closes.
115 * Revision 1.9 1995/06/14 15:08:01 adam
116 * Bug fix in cascade-target-list. Uses yaz-version.h.
118 * Revision 1.8 1995/06/14 13:37:18 adam
119 * Setting recordType implemented.
120 * Setting implementationVersion implemented.
121 * Settings implementationId / implementationName edited.
123 * Revision 1.7 1995/06/01 07:31:28 adam
124 * Rename of many typedefs -> IrTcl_...
126 * Revision 1.6 1995/05/31 08:36:40 adam
127 * Bug fix in client.tcl: didn't save options on clientrc.tcl.
128 * New method: referenceId. More work on scan.
130 * Revision 1.5 1995/05/29 08:44:25 adam
131 * Work on delete of objects.
133 * Revision 1.4 1995/05/26 11:44:10 adam
134 * Bugs fixed. More work on MARC utilities and queries. Test
135 * client is up-to-date again.
137 * Revision 1.3 1995/05/26 08:54:17 adam
138 * New MARC utilities. Uses prefix query.
140 * Revision 1.2 1995/05/24 14:10:23 adam
141 * Work on idAuthentication, protocolVersion and options.
143 * Revision 1.1 1995/05/23 15:34:49 adam
144 * Many new settings, userInformationField, smallSetUpperBound, etc.
145 * A number of settings are inherited when ir-set is executed.
146 * This version is incompatible with the graphical test client (client.tcl).
161 #include <comstack.h>
168 #include <yaz-version.h>
172 #include <diagbib1.h>
179 int (*method) (void *obj, Tcl_Interp *interp, int argc, char **argv);
189 char **databaseNames;
190 int num_databaseNames;
192 enum oid_value *preferredRecordSyntax;
193 int replaceIndicator;
196 char *elementSetNames;
197 char *smallSetElementSetNames;
198 char *mediumSetElementSetNames;
200 int smallSetUpperBound;
201 int largeSetLowerBound;
202 int mediumSetPresentNumber;
215 int preferredMessageSize;
216 int maximumRecordSize;
218 Odr_bitmask protocolVersion;
220 char *idAuthenticationOpen;
221 char *idAuthenticationGroupId;
222 char *idAuthenticationUserId;
223 char *idAuthenticationPassword;
225 char *implementationName;
226 char *implementationId;
227 char *implementationVersion;
229 char *targetImplementationName;
230 char *targetImplementationId;
231 char *targetImplementationVersion;
232 char *userInformationField;
254 struct IrTcl_Request_ *request_queue;
256 IrTcl_SetCObj set_inher;
259 typedef struct IrTcl_Request_ {
260 struct IrTcl_Request_ *next;
275 struct GRS_Record_entry {
284 struct IrTcl_GRS_Record_ *sub;
296 typedef struct IrTcl_GRS_Record_ {
298 struct GRS_Record_entry *entries;
301 typedef struct IrTcl_RecordList_ {
310 IrTcl_GRS_Record *grs1;
319 IrTcl_Diagnostic *list;
320 } surrogateDiagnostics;
322 struct IrTcl_RecordList_ *next;
325 typedef struct IrTcl_SetObj_ {
331 int nextResultSetPosition;
334 int numberOfRecordsReturned;
336 char *recordElements;
339 int nonSurrogateDiagnosticNum;
340 char *searchResponse;
341 char *presentResponse;
343 IrTcl_Diagnostic *nonSurrogateDiagnosticList;
344 IrTcl_RecordList *record_list;
345 IrTcl_SetCObj set_inher;
348 typedef struct IrTcl_ScanEntry_ {
353 int globalOccurrences;
356 IrTcl_Diagnostic *list;
362 typedef struct IrTcl_ScanObj_ {
365 int numberOfTermsRequested;
366 int preferredPositionInResponse;
369 int numberOfEntriesReturned;
381 IrTcl_ScanEntry *entries;
382 IrTcl_Diagnostic *nonSurrogateDiagnosticList;
383 int nonSurrogateDiagnosticNum;
386 struct ir_named_entry {
391 int ir_tcl_get_marc (Tcl_Interp *interp, const char *buf,
392 int argc, char **argv);
393 int ir_tcl_send_APDU (Tcl_Interp *interp, IrTcl_Obj *p, Z_APDU *apdu,
394 const char *msg, const char *object_name);
395 int ir_tcl_send_q (IrTcl_Obj *p, IrTcl_Request *rq, const char *msg);
396 void ir_tcl_del_q (IrTcl_Obj *p);
397 int ir_tcl_strdup (Tcl_Interp *interp, char** p, const char *s);
398 int ir_tcl_strdel (Tcl_Interp *interp, char **p);
400 char *ir_tcl_fread_marc (FILE *inf, size_t *size);
401 void ir_tcl_grs_mk (Z_GenericRecord *r, IrTcl_GRS_Record **grs_record);
402 void ir_tcl_grs_del (IrTcl_GRS_Record **grs_record);
403 int ir_tcl_get_grs (Tcl_Interp *interp, IrTcl_GRS_Record *grs_record,
404 int argc, char **argv);
406 int ir_tcl_get_explain (Tcl_Interp *interp, Z_ExplainRecord *rec,
407 int argc, char **argv);
409 int ir_tcl_method (Tcl_Interp *interp, int argc, char **argv,
410 IrTcl_Methods *tab, int *ret);
411 int ir_tcl_get_set_int (int *val, Tcl_Interp *interp, int argc, char **argv);
415 int (*ir_init) (ClientData clientData, Tcl_Interp *interp,
416 int argc, char **argv, ClientData *subData,
417 ClientData parentData);
418 int (*ir_method) (ClientData clientData, Tcl_Interp *interp,
419 int argc, char **argv);
420 void (*ir_delete)(ClientData clientData);
423 extern IrTcl_Class ir_obj_class;
424 extern IrTcl_Class ir_set_obj_class;
426 void ir_select_add (int fd, void *obj);
427 void ir_select_add_write (int fd, void *obj);
428 void ir_select_remove (int fd, void *obj);
429 void ir_select_remove_write (int fd, void *obj);
431 int ir_tcl_eval (Tcl_Interp *interp, const char *command);
432 void ir_tcl_disconnect (IrTcl_Obj *p);
434 #define IR_TCL_FAIL_CONNECT 1
435 #define IR_TCL_FAIL_READ 2
436 #define IR_TCL_FAIL_WRITE 3
437 #define IR_TCL_FAIL_IN_APDU 4
438 #define IR_TCL_FAIL_UNKNOWN_APDU 5
440 #define IR_TCL_R_Idle 0
441 #define IR_TCL_R_Writing 1
442 #define IR_TCL_R_Waiting 2
443 #define IR_TCL_R_Reading 3
444 #define IR_TCL_R_Connecting 4