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