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.37 1998-04-02 14:31:08 adam
9 * This version works with compiled ASN.1 code.
11 * Revision 1.36 1997/11/19 11:22:09 adam
12 * Object identifiers can be accessed in GRS-1 records.
14 * Revision 1.35 1997/09/09 10:19:54 adam
15 * New MSV5.0 port with fewer warnings.
17 * Revision 1.34 1996/08/16 15:07:47 adam
18 * First work on Explain.
20 * Revision 1.33 1996/07/03 13:31:13 adam
21 * The xmalloc/xfree functions from YAZ are used to manage memory.
23 * Revision 1.32 1996/03/20 13:54:05 adam
24 * The Tcl_File structure is only manipulated in the Tk-event interface
27 * Revision 1.31 1996/03/05 09:21:19 adam
28 * Bug fix: memory used by GRS records wasn't freed.
29 * Rewrote some of the error handling code - the connection is always
30 * closed before failback is called.
31 * If failback is defined the send APDU methods (init, search, ...) will
32 * return OK but invoke failback (as is the case if the write operation
34 * Bug fix: ref_count in assoc object could grow if fraction of PDU was
37 * Revision 1.30 1996/02/29 15:30:23 adam
38 * Export of IrTcl functionality to extensions.
40 * Revision 1.29 1996/02/26 18:38:33 adam
41 * Work on export of set methods.
43 * Revision 1.28 1996/02/23 17:31:41 adam
44 * More functions made available to the wais tcl extension.
46 * Revision 1.27 1996/02/23 13:41:41 adam
47 * Work on public access to simple ir class system.
49 * Revision 1.26 1996/02/21 10:16:20 adam
50 * Simplified select handling. Only one function ir_tcl_select_set has
51 * to be externally defined.
53 * Revision 1.25 1996/02/05 17:58:04 adam
54 * Ported ir-tcl to use the beta releases of tcl7.5/tk4.1.
56 * Revision 1.24 1996/01/29 11:35:27 adam
57 * Bug fix: cs_type member renamed to comstackType to avoid conflict with
58 * cs_type macro defined by YAZ.
60 * Revision 1.23 1996/01/19 16:22:40 adam
61 * New method: apduDump - returns information about last incoming APDU.
63 * Revision 1.22 1996/01/10 09:18:44 adam
64 * PDU specific callbacks implemented: initRespnse, searchResponse,
65 * presentResponse and scanResponse.
66 * Bug fix in the command line shell (tclmain.c) - discovered on OSF/1.
68 * Revision 1.21 1996/01/04 16:12:14 adam
69 * Setting PDUType renamed to eventType.
71 * Revision 1.20 1996/01/04 11:05:23 adam
72 * New setting: PDUType - returns type of last PDU returned from the target.
73 * Fixed a bug in configure/Makefile.
75 * Revision 1.19 1995/11/13 09:55:46 adam
76 * Multiple records at a position in a result-set with differnt
79 * Revision 1.18 1995/10/18 16:42:44 adam
80 * New settings: smallSetElementSetNames and mediumSetElementSetNames.
82 * Revision 1.17 1995/10/16 17:00:56 adam
83 * New setting: elementSetNames.
84 * Various client improvements. Medium presentation format looks better.
86 * Revision 1.16 1995/09/20 11:37:01 adam
87 * Configure searches for tk4.1 and tk7.5.
90 * Revision 1.15 1995/08/29 15:30:15 adam
91 * Work on GRS records.
93 * Revision 1.14 1995/08/04 11:32:40 adam
94 * More work on output queue. Memory related routines moved
97 * Revision 1.13 1995/08/03 13:23:00 adam
100 * Revision 1.12 1995/07/28 10:28:38 adam
101 * First work on request queue.
103 * Revision 1.11 1995/06/20 08:07:35 adam
104 * New setting: failInfo.
105 * Working on better cancel mechanism.
107 * Revision 1.10 1995/06/16 12:28:20 adam
108 * Implemented preferredRecordSyntax.
109 * Minor changes in diagnostic handling.
110 * Record list deleted when connection closes.
112 * Revision 1.9 1995/06/14 15:08:01 adam
113 * Bug fix in cascade-target-list. Uses yaz-version.h.
115 * Revision 1.8 1995/06/14 13:37:18 adam
116 * Setting recordType implemented.
117 * Setting implementationVersion implemented.
118 * Settings implementationId / implementationName edited.
120 * Revision 1.7 1995/06/01 07:31:28 adam
121 * Rename of many typedefs -> IrTcl_...
123 * Revision 1.6 1995/05/31 08:36:40 adam
124 * Bug fix in client.tcl: didn't save options on clientrc.tcl.
125 * New method: referenceId. More work on scan.
127 * Revision 1.5 1995/05/29 08:44:25 adam
128 * Work on delete of objects.
130 * Revision 1.4 1995/05/26 11:44:10 adam
131 * Bugs fixed. More work on MARC utilities and queries. Test
132 * client is up-to-date again.
134 * Revision 1.3 1995/05/26 08:54:17 adam
135 * New MARC utilities. Uses prefix query.
137 * Revision 1.2 1995/05/24 14:10:23 adam
138 * Work on idAuthentication, protocolVersion and options.
140 * Revision 1.1 1995/05/23 15:34:49 adam
141 * Many new settings, userInformationField, smallSetUpperBound, etc.
142 * A number of settings are inherited when ir-set is executed.
143 * This version is incompatible with the graphical test client (client.tcl).
158 #include <comstack.h>
165 #include <yaz-version.h>
169 #include <diagbib1.h>
176 int (*method) (void *obj, Tcl_Interp *interp, int argc, char **argv);
186 char **databaseNames;
187 int num_databaseNames;
189 enum oid_value *preferredRecordSyntax;
190 int replaceIndicator;
193 char *elementSetNames;
194 char *smallSetElementSetNames;
195 char *mediumSetElementSetNames;
197 int smallSetUpperBound;
198 int largeSetLowerBound;
199 int mediumSetPresentNumber;
212 int preferredMessageSize;
213 int maximumRecordSize;
215 Odr_bitmask protocolVersion;
217 char *idAuthenticationOpen;
218 char *idAuthenticationGroupId;
219 char *idAuthenticationUserId;
220 char *idAuthenticationPassword;
222 char *implementationName;
223 char *implementationId;
224 char *implementationVersion;
226 char *targetImplementationName;
227 char *targetImplementationId;
228 char *targetImplementationVersion;
229 char *userInformationField;
251 struct IrTcl_Request_ *request_queue;
253 IrTcl_SetCObj set_inher;
256 typedef struct IrTcl_Request_ {
257 struct IrTcl_Request_ *next;
272 struct GRS_Record_entry {
281 struct IrTcl_GRS_Record_ *sub;
293 typedef struct IrTcl_GRS_Record_ {
295 struct GRS_Record_entry *entries;
298 typedef struct IrTcl_RecordList_ {
307 IrTcl_GRS_Record *grs1;
316 IrTcl_Diagnostic *list;
317 } surrogateDiagnostics;
319 struct IrTcl_RecordList_ *next;
322 typedef struct IrTcl_SetObj_ {
327 int nextResultSetPosition;
330 int numberOfRecordsReturned;
332 char *recordElements;
335 int nonSurrogateDiagnosticNum;
336 char *searchResponse;
337 char *presentResponse;
338 IrTcl_Diagnostic *nonSurrogateDiagnosticList;
339 IrTcl_RecordList *record_list;
340 IrTcl_SetCObj set_inher;
343 typedef struct IrTcl_ScanEntry_ {
348 int globalOccurrences;
351 IrTcl_Diagnostic *list;
357 typedef struct IrTcl_ScanObj_ {
360 int numberOfTermsRequested;
361 int preferredPositionInResponse;
364 int numberOfEntriesReturned;
376 IrTcl_ScanEntry *entries;
377 IrTcl_Diagnostic *nonSurrogateDiagnosticList;
378 int nonSurrogateDiagnosticNum;
381 struct ir_named_entry {
386 int ir_tcl_get_marc (Tcl_Interp *interp, const char *buf,
387 int argc, char **argv);
388 int ir_tcl_send_APDU (Tcl_Interp *interp, IrTcl_Obj *p, Z_APDU *apdu,
389 const char *msg, const char *object_name);
390 int ir_tcl_send_q (IrTcl_Obj *p, IrTcl_Request *rq, const char *msg);
391 void ir_tcl_del_q (IrTcl_Obj *p);
392 int ir_tcl_strdup (Tcl_Interp *interp, char** p, const char *s);
393 int ir_tcl_strdel (Tcl_Interp *interp, char **p);
395 char *ir_tcl_fread_marc (FILE *inf, size_t *size);
396 void ir_tcl_grs_mk (Z_GenericRecord *r, IrTcl_GRS_Record **grs_record);
397 void ir_tcl_grs_del (IrTcl_GRS_Record **grs_record);
398 int ir_tcl_get_grs (Tcl_Interp *interp, IrTcl_GRS_Record *grs_record,
399 int argc, char **argv);
401 int ir_tcl_get_explain (Tcl_Interp *interp, Z_ExplainRecord *rec,
402 int argc, char **argv);
404 int ir_tcl_method (Tcl_Interp *interp, int argc, char **argv,
405 IrTcl_Methods *tab, int *ret);
406 int ir_tcl_get_set_int (int *val, Tcl_Interp *interp, int argc, char **argv);
410 int (*ir_init) (ClientData clientData, Tcl_Interp *interp,
411 int argc, char **argv, ClientData *subData,
412 ClientData parentData);
413 int (*ir_method) (ClientData clientData, Tcl_Interp *interp,
414 int argc, char **argv);
415 void (*ir_delete)(ClientData clientData);
418 extern IrTcl_Class ir_obj_class;
419 extern IrTcl_Class ir_set_obj_class;
421 void ir_select_add (int fd, void *obj);
422 void ir_select_add_write (int fd, void *obj);
423 void ir_select_remove (int fd, void *obj);
424 void ir_select_remove_write (int fd, void *obj);
426 int ir_tcl_eval (Tcl_Interp *interp, const char *command);
427 void ir_tcl_disconnect (IrTcl_Obj *p);
429 #define IR_TCL_FAIL_CONNECT 1
430 #define IR_TCL_FAIL_READ 2
431 #define IR_TCL_FAIL_WRITE 3
432 #define IR_TCL_FAIL_IN_APDU 4
433 #define IR_TCL_FAIL_UNKNOWN_APDU 5
435 #define IR_TCL_R_Idle 0
436 #define IR_TCL_R_Writing 1
437 #define IR_TCL_R_Waiting 2
438 #define IR_TCL_R_Reading 3
439 #define IR_TCL_R_Connecting 4