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