Configure searches for tk4.1 and tk7.5.
[ir-tcl-moved-to-github.git] / ir-tclp.h
1 /*
2  * IR toolkit for tcl/tk
3  * (c) Index Data 1995
4  * See the file LICENSE for details.
5  * Sebastian Hammer, Adam Dickmeiss
6  *
7  * $Log: ir-tclp.h,v $
8  * Revision 1.16  1995-09-20 11:37:01  adam
9  * Configure searches for tk4.1 and tk7.5.
10  * Work on GRS.
11  *
12  * Revision 1.15  1995/08/29  15:30:15  adam
13  * Work on GRS records.
14  *
15  * Revision 1.14  1995/08/04  11:32:40  adam
16  * More work on output queue. Memory related routines moved
17  * to mem.c
18  *
19  * Revision 1.13  1995/08/03  13:23:00  adam
20  * Request queue.
21  *
22  * Revision 1.12  1995/07/28  10:28:38  adam
23  * First work on request queue.
24  *
25  * Revision 1.11  1995/06/20  08:07:35  adam
26  * New setting: failInfo.
27  * Working on better cancel mechanism.
28  *
29  * Revision 1.10  1995/06/16  12:28:20  adam
30  * Implemented preferredRecordSyntax.
31  * Minor changes in diagnostic handling.
32  * Record list deleted when connection closes.
33  *
34  * Revision 1.9  1995/06/14  15:08:01  adam
35  * Bug fix in cascade-target-list. Uses yaz-version.h.
36  *
37  * Revision 1.8  1995/06/14  13:37:18  adam
38  * Setting recordType implemented.
39  * Setting implementationVersion implemented.
40  * Settings implementationId / implementationName edited.
41  *
42  * Revision 1.7  1995/06/01  07:31:28  adam
43  * Rename of many typedefs -> IrTcl_...
44  *
45  * Revision 1.6  1995/05/31  08:36:40  adam
46  * Bug fix in client.tcl: didn't save options on clientrc.tcl.
47  * New method: referenceId. More work on scan.
48  *
49  * Revision 1.5  1995/05/29  08:44:25  adam
50  * Work on delete of objects.
51  *
52  * Revision 1.4  1995/05/26  11:44:10  adam
53  * Bugs fixed. More work on MARC utilities and queries. Test
54  * client is up-to-date again.
55  *
56  * Revision 1.3  1995/05/26  08:54:17  adam
57  * New MARC utilities. Uses prefix query.
58  *
59  * Revision 1.2  1995/05/24  14:10:23  adam
60  * Work on idAuthentication, protocolVersion and options.
61  *
62  * Revision 1.1  1995/05/23  15:34:49  adam
63  * Many new settings, userInformationField, smallSetUpperBound, etc.
64  * A number of settings are inherited when ir-set is executed.
65  * This version is incompatible with the graphical test client (client.tcl).
66  *
67  */
68
69 #ifndef IR_TCLP_H
70 #define IR_TCLP_H
71
72 #include <tcl.h>
73
74 #include <log.h>
75 #include <pquery.h>
76 #if CCL2RPN
77 #include <yaz-ccl.h>
78 #endif
79
80 #include <comstack.h>
81 #include <tcpip.h>
82
83 #if MOSI
84 #include <xmosi.h>
85 #endif
86
87 #include <yaz-version.h>
88 #include <odr.h>
89 #include <proto.h>
90 #include <oid.h>
91 #include <diagbib1.h>
92
93 #include "ir-tcl.h"
94
95 typedef struct {
96     char      **databaseNames;
97     int         num_databaseNames;
98     char       *queryType;
99     enum oid_value *preferredRecordSyntax;
100     int         replaceIndicator;
101     char       *referenceId;
102
103     int         smallSetUpperBound;
104     int         largeSetLowerBound;
105     int         mediumSetPresentNumber;
106 } IrTcl_SetCObj;
107     
108 typedef struct {
109     int         ref_count;
110
111     char       *cs_type;
112     int         protocol_type;
113     int         failInfo;
114     COMSTACK    cs_link;
115     
116     int         state;
117
118     int         preferredMessageSize;
119     int         maximumRecordSize;
120     Odr_bitmask options;
121     Odr_bitmask protocolVersion;
122
123     char       *idAuthenticationOpen;
124     char       *idAuthenticationGroupId;
125     char       *idAuthenticationUserId;
126     char       *idAuthenticationPassword;
127
128     char       *implementationName;
129     char       *implementationId;
130     char       *implementationVersion;
131     int        initResult;
132     char       *targetImplementationName;
133     char       *targetImplementationId;
134     char       *targetImplementationVersion;
135     char       *userInformationField;
136
137     char       *hostname;
138    
139     char       *buf_in;
140     int         len_in;
141     ODR         odr_in;
142     ODR         odr_out;
143     ODR         odr_pr;
144
145     Tcl_Interp *interp;
146     char       *callback;
147     char       *failback;
148
149 #if CCL2RPN
150     CCL_bibset  bibset;
151 #endif
152     struct IrTcl_Request_ *request_queue;
153
154     IrTcl_SetCObj   set_inher;
155 } IrTcl_Obj;
156
157 typedef struct IrTcl_Request_ {
158     struct IrTcl_Request_ *next; 
159
160     char       *object_name;
161     
162     char       *buf_out;
163     int         len_out;
164
165     char       *callback;
166 } IrTcl_Request;
167
168 typedef struct {
169     int condition;
170     char *addinfo;
171 } IrTcl_Diagnostic;
172
173 struct GRS_Record_entry {
174     int tagType;
175     int tagWhich;
176     union {
177         int num;
178         char *str;
179     } tagVal;
180     int dataWhich;
181     union {
182         struct IrTcl_GRS_Record_ *sub;
183         char *str;
184         struct {
185             int len;
186             char *buf;
187         } octets;
188         int num;
189         int bool;
190     } tagData;
191 };
192
193 typedef struct IrTcl_GRS_Record_ {
194     int noTags;
195     struct GRS_Record_entry *entries;
196 } IrTcl_GRS_Record;
197
198 typedef struct IrTcl_RecordList_ {
199     int no;
200     int which;
201     union {
202         struct {
203             char *buf;
204             size_t size;
205             union {
206                 IrTcl_GRS_Record *grs1;
207             } u;
208             enum oid_value type;
209         } dbrec;
210         struct {
211             int num;
212             IrTcl_Diagnostic *list;
213         } surrogateDiagnostics;
214     } u;
215     struct IrTcl_RecordList_ *next;
216 } IrTcl_RecordList;
217
218 typedef struct IrTcl_SetObj_ {
219     IrTcl_Obj  *parent;
220     int         searchStatus;
221     int         presentStatus;
222     int         resultCount;
223     int         nextResultSetPosition;
224     int         start;
225     int         number;
226     int         numberOfRecordsReturned;
227     char       *setName;
228     int         recordFlag;
229     int         which;
230     int         nonSurrogateDiagnosticNum;
231     IrTcl_Diagnostic *nonSurrogateDiagnosticList;
232     IrTcl_RecordList *record_list;
233     IrTcl_SetCObj set_inher;
234 } IrTcl_SetObj;
235
236 typedef struct IrTcl_ScanEntry_ {
237     int         which;
238     union {
239         struct {
240             char *buf;
241             int  globalOccurrences;
242         } term;
243         struct {
244             IrTcl_Diagnostic *list;
245             int num;
246         } diag;
247     } u;
248 } IrTcl_ScanEntry;
249
250 typedef struct IrTcl_ScanObj_ {
251     IrTcl_Obj   *parent;
252     int         stepSize;
253     int         numberOfTermsRequested;
254     int         preferredPositionInResponse;
255
256     int         scanStatus;
257     int         numberOfEntriesReturned;
258     int         positionOfTerm;
259
260     int         entries_flag;
261     int         which;
262
263     int         num_entries;
264     int         num_diagRecs;
265
266     IrTcl_ScanEntry *entries;
267     IrTcl_Diagnostic  *nonSurrogateDiagnosticList;
268     int         nonSurrogateDiagnosticNum;
269 } IrTcl_ScanObj;
270
271 struct ir_named_entry {
272     char *name;
273     int  pos;
274 };
275
276 int ir_tcl_get_marc (Tcl_Interp *interp, const char *buf,
277                      int argc, char **argv);
278 int ir_tcl_send_APDU (Tcl_Interp *interp, IrTcl_Obj *p, Z_APDU *apdu,
279                       const char *msg, const char *object_name);
280 int ir_tcl_send_q (IrTcl_Obj *p, IrTcl_Request *rq, const char *msg);
281 void ir_tcl_del_q (IrTcl_Obj *p);
282 void *ir_tcl_malloc (size_t size);
283 int ir_tcl_strdup (Tcl_Interp *interp, char** p, const char *s);
284 int ir_tcl_strdel (Tcl_Interp *interp, char **p);
285
286 char *ir_tcl_fread_marc (FILE *inf, size_t *size);
287 void ir_tcl_read_grs (Z_GenericRecord *r, IrTcl_GRS_Record **grs_record);
288 int ir_tcl_get_grs (Tcl_Interp *interp, IrTcl_GRS_Record *grs_record, 
289                      int argc, char **argv);
290
291 #define IR_TCL_FAIL_CONNECT      1
292 #define IR_TCL_FAIL_READ         2
293 #define IR_TCL_FAIL_WRITE        3
294 #define IR_TCL_FAIL_IN_APDU      4
295 #define IR_TCL_FAIL_UNKNOWN_APDU 5
296
297 #define IR_TCL_R_Idle            0
298 #define IR_TCL_R_Writing         1
299 #define IR_TCL_R_Waiting         2
300 #define IR_TCL_R_Reading         3
301 #define IR_TCL_R_Connecting      4
302 #endif