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