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