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