Added info.
[yaz-moved-to-github.git] / include / proto.h
1 /*
2  * Copyright (C) 1994, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: proto.h,v $
7  * Revision 1.3  1995-03-30 12:18:09  quinn
8  * Added info.
9  *
10  * Revision 1.2  1995/03/30  10:26:48  quinn
11  * Added Term structure
12  *
13  * Revision 1.1  1995/03/30  09:39:42  quinn
14  * Moved .h files to include directory
15  *
16  * Revision 1.11  1995/03/30  09:08:44  quinn
17  * Added Resource control protocol
18  *
19  * Revision 1.10  1995/03/29  15:39:39  quinn
20  * Adding some resource control elements, and a null-check to getentbyoid
21  *
22  * Revision 1.9  1995/03/29  08:06:18  quinn
23  * Added a few v3 elements
24  *
25  * Revision 1.8  1995/03/22  10:12:49  quinn
26  * Added Z_PRES constants.
27  *
28  * Revision 1.7  1995/03/20  09:45:12  quinn
29  * Working towards v3
30  *
31  * Revision 1.5  1995/03/07  16:29:34  quinn
32  * Added authentication stuff.
33  *
34  * Revision 1.4  1995/03/07  10:13:00  quinn
35  * Added prototype for z_APDU()
36  *
37  * Revision 1.3  1995/02/14  11:54:23  quinn
38  * Fixing include.
39  *
40  * Revision 1.2  1995/02/09  15:51:40  quinn
41  * Works better now.
42  *
43  * Revision 1.1  1995/02/06  16:44:48  quinn
44  * First hack at Z/SR protocol
45  *
46  */
47
48 #ifndef PROTO_H
49 #define PROTO_H
50
51 #include <odr.h>
52 #include <odr_use.h>
53
54 /* ----------------- GLOBAL AUXILIARY DEFS ----------------*/
55
56 typedef Odr_oct Z_ReferenceId;
57 typedef char Z_DatabaseName;
58 typedef char Z_ResultSetId;
59 typedef Odr_oct Z_ResultsetId;
60 typedef Odr_external Z_UserInformationField;
61
62 /* ----------------- INIT SERVICE  ----------------*/
63
64 typedef struct
65 {
66     char *groupId;       /* OPTIONAL */
67     char *userId;         /* OPTIONAL */
68     char *password;      /* OPTIONAL */
69 } Z_IdPass;
70
71 typedef struct Z_IdAuthentication
72 {
73     enum
74     {
75         Z_IdAuthentication_open,
76         Z_IdAuthentication_idPass,
77         Z_IdAuthentication_anonymous,
78         Z_IdAuthentication_other
79     } which;
80     union
81     {
82         char *open;
83         Z_IdPass *idPass;
84         void *anonymous;         /* NULL */
85         Odr_external *other;
86     } u;
87 } Z_IdAuthentication;
88
89 #define Z_ProtocolVersion_1            0
90 #define Z_ProtocolVersion_2            1
91 #define Z_ProtocolVersion_3            2
92
93 #define Z_Options_search               0
94 #define Z_Options_present              1
95 #define Z_Options_delSet               2
96 #define Z_Options_resourceReport       3
97 #define Z_Options_triggerResourceCtrl  4
98 #define Z_Options_resourceCtrl         5
99 #define Z_Options_accessCtrl           6
100 #define Z_Options_scan                 7
101 #define Z_Options_sort                 8
102 #define Z_Options_reserved             9
103 #define Z_Options_extendedServices    10
104 #define Z_Options_level_1Segmentation 11
105 #define Z_Options_level_2Segmentation 12
106 #define Z_Options_concurrentOperations 13
107 #define Z_Options_namedResultSets     14
108
109 typedef struct Z_InitRequest
110 {
111     Z_ReferenceId *referenceId;                   /* OPTIONAL */
112     Odr_bitmask *options;
113     Odr_bitmask *protocolVersion;
114     int *preferredMessageSize;
115     int *maximumRecordSize;
116     Z_IdAuthentication* idAuthentication;        /* OPTIONAL */
117     char *implementationId;                      /* OPTIONAL */
118     char *implementationName;                    /* OPTIONAL */
119     char *implementationVersion;                 /* OPTIONAL */
120     Z_UserInformationField *userInformationField; /* OPTIONAL */
121 } Z_InitRequest;
122
123 typedef struct Z_InitResponse
124 {
125     Z_ReferenceId *referenceId;    /* OPTIONAL */
126     Odr_bitmask *options;
127     Odr_bitmask *protocolVersion;
128     int *preferredMessageSize;
129     int *maximumRecordSize;
130     bool_t *result;
131     char *implementationId;      /* OPTIONAL */
132     char *implementationName;    /* OPTIONAL */
133     char *implementationVersion; /* OPTIONAL */
134     Z_UserInformationField *userInformationField; /* OPTIONAL */
135 } Z_InitResponse;
136
137 typedef struct Z_NSRAuthentication
138 {
139     char *user;
140     char *password;
141     char *account;
142 } Z_NSRAuthentication;
143
144 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt);
145
146 int z_StrAuthentication(ODR o, char **p, int opt);
147
148
149 /* ------------------ RESOURCE CONTROL ----------------*/
150
151 typedef struct Z_TriggerResourceControlRequest
152 {
153     Z_ReferenceId *referenceId;    /* OPTIONAL */
154     int *requestedAction;
155 #define Z_TriggerResourceCtrl_resourceReport  1
156 #define Z_TriggerResourceCtrl_resourceControl 2
157 #define Z_TriggerResourceCtrl_cancel          3
158     Odr_oid *prefResourceReportFormat;  /* OPTIONAL */
159     bool_t *resultSetWanted;            /* OPTIONAL */
160 } Z_TriggerResourceControlRequest;
161
162 typedef struct Z_ResourceControlRequest
163 {
164     Z_ReferenceId *referenceId;    /* OPTIONAL */
165     bool_t *suspendedFlag;         /* OPTIONAL */
166     Odr_external *resourceReport; /* OPTIONAL */
167     int *partialResultsAvailable;  /* OPTIONAL */
168 #define Z_ResourceControlRequest_subset    1
169 #define Z_ResourceControlRequest_interim   2
170 #define Z_ResourceControlRequest_none      3
171     bool_t *responseRequired;
172     bool_t *triggeredRequestFlag;  /* OPTIONAL */
173 } Z_ResourceControlRequest;
174
175 typedef struct Z_ResourceControlResponse
176 {
177     Z_ReferenceId *referenceId;    /* OPTIONAL */
178     bool_t *continueFlag;
179     bool_t *resultSetWanted;       /* OPTIONAL */
180 } Z_ResourceControlResponse;
181
182 /* ------------------ SEARCH SERVICE ----------------*/
183
184 typedef Odr_oid Z_PreferredRecordSyntax;
185
186 typedef struct Z_DatabaseSpecificUnit
187 {
188     char *databaseName;
189     char *elementSetName;
190 } Z_DatabaseSpecificUnit;
191
192 typedef struct Z_DatabaseSpecific
193 {
194     int num_elements;
195     Z_DatabaseSpecificUnit **elements;
196 } Z_DatabaseSpecific;
197
198 typedef struct Z_ElementSetNames
199 {
200     int which;
201 #define Z_ElementSetNames_generic 0
202 #define Z_ElementSetNames_databaseSpecific 1
203     union
204     {
205         char *generic;
206         Z_DatabaseSpecific *databaseSpecific;
207     } u;
208 } Z_ElementSetNames;
209
210 /* ---------------------- RPN QUERY --------------------------- */
211
212 typedef struct Z_AttributeElement
213 {
214     int *attributeType;
215     int *attributeValue;
216 } Z_AttributeElement;
217
218 #define Z_V3
219 #ifdef Z_V3
220
221 typedef struct Z_Term 
222 {
223     enum
224     {
225         Z_Term_general,
226         Z_Term_numeric,
227         Z_Term_characterString,
228         Z_Term_oid,
229         Z_Term_dateTime,
230         Z_Term_external,
231         Z_Term_integerAndUnit,
232         Z_Term_null
233     } which;
234     union
235     {
236         Odr_oct *general; /* this is required for v2 */
237         int *numeric;
238         char *characterString;
239         Odr_oid *oid;
240         char *dateTime;
241         Odr_external *external;
242         /* Z_IntUnit *integerAndUnit; */
243         void *null;
244     } u;
245 } Z_Term;
246
247 #endif
248
249 typedef struct Z_AttributesPlusTerm
250 {
251     int num_attributes;
252     Z_AttributeElement **attributeList;
253 #ifdef Z_V3
254     Z_Term *term;
255 #else
256     Odr_oct *term;
257 #endif
258 } Z_AttributesPlusTerm;
259
260 typedef struct Z_ProximityOperator
261 {
262     bool_t *exclusion;          /* OPTIONAL */
263     int *distance;
264     bool_t *ordered;
265     int *relationType;
266     enum
267     {
268         Z_ProximityOperator_known,
269         Z_ProximityOperator_private
270     } which;
271     union
272     {
273         int *known;
274         int *private;
275     } u;
276 } Z_ProximityOperator;
277
278 typedef struct Z_Operator
279 {
280     enum
281     {
282         Z_Operator_and,
283         Z_Operator_or,
284         Z_Operator_and_not,
285         Z_Operator_proximity
286     } which;
287     union
288     {
289         void *and;          /* these guys are nulls. */
290         void *or;
291         void *and_not;
292         Z_ProximityOperator *proximity;
293     } u;
294 } Z_Operator;
295
296 typedef struct Z_Operand
297 {
298     int which;
299 #define Z_Operand_APT 0
300 #define Z_Operand_resultSetId 1
301     union
302     {
303         Z_AttributesPlusTerm *attributesPlusTerm;
304         Z_ResultSetId *resultSetId;
305     } u;
306 } Z_Operand;
307
308 typedef struct Z_Complex
309 {
310     struct Z_RPNStructure *s1;
311     struct Z_RPNStructure *s2;
312     Z_Operator *operator;
313 } Z_Complex;
314
315 typedef struct Z_RPNStructure
316 {
317     int which;
318 #define Z_RPNStructure_simple 0
319 #define Z_RPNStructure_complex 1
320     union
321     {
322         Z_Operand *simple;
323         Z_Complex *complex;
324     } u;
325 } Z_RPNStructure;
326
327 typedef struct Z_RPNQuery
328 {
329     Odr_oid *attributeSetId;
330     Z_RPNStructure *RPNStructure;
331 } Z_RPNQuery;
332
333 /* -------------------------- SEARCHREQUEST -------------------------- */
334
335 typedef struct Z_Query
336 {
337     int which;
338 #define Z_Query_type_1 1
339 #define Z_Query_type_2 2
340     union
341     {
342         Z_RPNQuery *type_1;
343         Odr_oct *type_2;
344     } u;
345 } Z_Query;
346
347 typedef struct Z_SearchRequest
348 {
349     Z_ReferenceId *referenceId;   /* OPTIONAL */
350     int *smallSetUpperBound;
351     int *largeSetLowerBound;
352     int *mediumSetPresentNumber;
353     bool_t *replaceIndicator;
354     char *resultSetName;
355     int num_databaseNames;
356     char **databaseNames;
357     Z_ElementSetNames *smallSetElementSetNames;    /* OPTIONAL */
358     Z_ElementSetNames *mediumSetElementSetNames;    /* OPTIONAL */
359     Z_PreferredRecordSyntax *preferredRecordSyntax;  /* OPTIONAL */
360     Z_Query *query;
361 } Z_SearchRequest;
362
363 /* ------------------------ RECORD -------------------------- */
364
365 typedef Odr_external Z_DatabaseRecord;
366
367 typedef struct Z_DiagRec
368 {
369     Odr_oid *diagnosticSetId;
370     int *condition;
371     char *addinfo;
372 } Z_DiagRec;
373
374 typedef struct Z_NamePlusRecord
375 {
376     char *databaseName;      /* OPTIONAL */
377     int which;
378 #define Z_NamePlusRecord_databaseRecord 0
379 #define Z_NamePlusRecord_surrogateDiagnostic 1
380     union
381     {
382         Z_DatabaseRecord *databaseRecord;
383         Z_DiagRec *surrogateDiagnostic;
384     } u;
385 } Z_NamePlusRecord;
386
387 typedef struct Z_NamePlusRecordList
388 {
389     int num_records;
390     Z_NamePlusRecord **records;
391 } Z_NamePlusRecordList;
392
393 typedef struct Z_Records
394 {
395     int which;
396 #define Z_Records_DBOSD 0
397 #define Z_Records_NSD 1
398     union
399     {
400         Z_NamePlusRecordList *databaseOrSurDiagnostics;
401         Z_DiagRec *nonSurrogateDiagnostic;
402     } u;
403 } Z_Records;
404
405 /* ------------------------ SEARCHRESPONSE ------------------ */
406
407 typedef struct Z_SearchResponse
408 {
409     Z_ReferenceId *referenceId;       /* OPTIONAL */
410     int *resultCount;
411     int *numberOfRecordsReturned;
412     int *nextResultSetPosition;
413     bool_t *searchStatus;
414     int *resultSetStatus;              /* OPTIONAL */
415 #define Z_RES_SUBSET        1
416 #define Z_RES_INTERIM       2
417 #define Z_RES_NONE          3
418     int *presentStatus;                /* OPTIONAL */
419 #define Z_PRES_SUCCESS      0
420 #define Z_PRES_PARTIAL_1    1
421 #define Z_PRES_PARTIAL_2    2
422 #define Z_PRES_PARTIAL_3    3
423 #define Z_PRES_PARTIAL_4    4
424 #define Z_PRES_FAILURE      5
425     Z_Records *records;                  /* OPTIONAL */
426 } Z_SearchResponse;
427
428 /* ------------------------- PRESENT SERVICE -----------------*/
429
430 typedef struct Z_PresentRequest
431 {
432     Z_ReferenceId *referenceId;          /* OPTIONAL */
433     Z_ResultSetId *resultSetId;
434     int *resultSetStartPoint;
435     int *numberOfRecordsRequested;
436     Z_ElementSetNames *elementSetNames;  /* OPTIONAL */
437     Z_PreferredRecordSyntax *preferredRecordSyntax;  /* OPTIONAL */
438 } Z_PresentRequest;
439
440 typedef struct Z_PresentResponse
441 {
442     Z_ReferenceId *referenceId;        /* OPTIONAL */
443     int *numberOfRecordsReturned;
444     int *nextResultSetPosition;
445     int *presentStatus;
446     Z_Records *records;
447 } Z_PresentResponse;
448
449 /* ------------------------ APDU ---------------------------- */
450
451 typedef struct Z_APDU
452 {    
453     int which;
454 #define Z_APDU_initRequest 0
455 #define Z_APDU_initResponse 1
456 #define Z_APDU_searchRequest 2
457 #define Z_APDU_searchResponse 3
458 #define Z_APDU_presentRequest 4
459 #define Z_APDU_presentResponse 5
460     union
461     {
462         Z_InitRequest  *initRequest;
463         Z_InitResponse *initResponse;
464         Z_SearchRequest *searchRequest;
465         Z_SearchResponse *searchResponse;
466         Z_PresentRequest *presentRequest;
467         Z_PresentResponse *presentResponse;
468     } u;
469 } Z_APDU;
470
471 int z_APDU(ODR o, Z_APDU **p, int opt);
472
473 #endif