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