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