Changed 'operator' to 'roperator' to avoid C++ conflict.
[yaz-moved-to-github.git] / include / proto.h
1 /*
2  * Copyright (c) 1995, Index Data.
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and
5  * its documentation, in whole or in part, for any purpose, is hereby granted,
6  * provided that:
7  *
8  * 1. This copyright and permission notice appear in all copies of the
9  * software and its documentation. Notices of copyright or attribution
10  * which appear at the beginning of any file must remain unchanged.
11  *
12  * 2. The name of Index Data or the individual authors may not be used to
13  * endorse or promote products derived from this software without specific
14  * prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
18  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
19  * IN NO EVENT SHALL INDEX DATA BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
20  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
21  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR
22  * NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24  * OF THIS SOFTWARE.
25  *
26  * $Log: proto.h,v $
27  * Revision 1.29  1996-01-02 11:46:49  quinn
28  * Changed 'operator' to 'roperator' to avoid C++ conflict.
29  * Moved to pl3
30  *
31  * Revision 1.28  1996/01/02  08:57:32  quinn
32  * Changed enums in the ASN.1 .h files to #defines. Changed oident.class to oclass
33  *
34  * Revision 1.27  1995/10/12  10:34:46  quinn
35  * Added Espec-1.
36  *
37  * Revision 1.26  1995/09/29  17:12:08  quinn
38  * Smallish
39  *
40  * Revision 1.25  1995/09/27  15:02:49  quinn
41  * Modified function heads & prototypes.
42  *
43  * Revision 1.24  1995/08/29  11:17:43  quinn
44  * *** empty log message ***
45  *
46  * Revision 1.23  1995/08/21  09:10:36  quinn
47  * Smallish fixes to suppport new formats.
48  *
49  * Revision 1.22  1995/08/17  12:45:14  quinn
50  * Fixed minor problems with GRS-1. Added support in c&s.
51  *
52  * Revision 1.21  1995/08/15  12:00:11  quinn
53  * Updated External
54  *
55  * Revision 1.20  1995/08/10  08:54:35  quinn
56  * Added Explain.
57  *
58  * Revision 1.19  1995/06/19  12:38:28  quinn
59  * Reorganized include-files. Added small features.
60  *
61  * Revision 1.18  1995/06/16  13:16:05  quinn
62  * Fixed Defaultdiagformat.
63  *
64  * Revision 1.17  1995/06/15  15:42:05  quinn
65  * Fixed some v3 bugs
66  *
67  * Revision 1.16  1995/06/15  07:45:06  quinn
68  * Moving to v3.
69  *
70  * Revision 1.15  1995/06/14  15:26:43  quinn
71  * *** empty log message ***
72  *
73  * Revision 1.14  1995/06/07  14:42:34  quinn
74  * Fixed CLOSE
75  *
76  * Revision 1.13  1995/06/07  14:36:47  quinn
77  * Added CLOSE
78  *
79  * Revision 1.12  1995/06/05  10:53:13  quinn
80  * Smallish.
81  *
82  * Revision 1.11  1995/06/02  09:49:47  quinn
83  * Add access control
84  *
85  * Revision 1.10  1995/05/29  08:11:34  quinn
86  * Moved oid from odr/asn to util.
87  *
88  * Revision 1.9  1995/05/22  11:31:25  quinn
89  * Added PDUs
90  *
91  * Revision 1.8  1995/05/17  08:41:35  quinn
92  * Added delete to proto & other little things.
93  * Relaying auth info to backend.
94  *
95  * Revision 1.7  1995/05/16  08:50:37  quinn
96  * License, documentation, and memory fixes
97  *
98  * Revision 1.6  1995/05/15  11:55:55  quinn
99  * Work on asynchronous activity.
100  *
101  * Revision 1.5  1995/04/17  11:28:18  quinn
102  * Smallish
103  *
104  * Revision 1.4  1995/04/10  10:22:47  quinn
105  * Added SCAN
106  *
107  * Revision 1.3  1995/03/30  12:18:09  quinn
108  * Added info.
109  *
110  * Revision 1.2  1995/03/30  10:26:48  quinn
111  * Added Term structure
112  *
113  * Revision 1.1  1995/03/30  09:39:42  quinn
114  * Moved .h files to include directory
115  *
116  * Revision 1.11  1995/03/30  09:08:44  quinn
117  * Added Resource control protocol
118  *
119  * Revision 1.10  1995/03/29  15:39:39  quinn
120  * Adding some resource control elements, and a null-check to getentbyoid
121  *
122  * Revision 1.9  1995/03/29  08:06:18  quinn
123  * Added a few v3 elements
124  *
125  * Revision 1.8  1995/03/22  10:12:49  quinn
126  * Added Z_PRES constants.
127  *
128  * Revision 1.7  1995/03/20  09:45:12  quinn
129  * Working towards v3
130  *
131  * Revision 1.5  1995/03/07  16:29:34  quinn
132  * Added authentication stuff.
133  *
134  * Revision 1.4  1995/03/07  10:13:00  quinn
135  * Added prototype for z_APDU()
136  *
137  * Revision 1.3  1995/02/14  11:54:23  quinn
138  * Fixing include.
139  *
140  * Revision 1.2  1995/02/09  15:51:40  quinn
141  * Works better now.
142  *
143  * Revision 1.1  1995/02/06  16:44:48  quinn
144  * First hack at Z/SR protocol
145  *
146  */
147
148 #ifndef PROTO_H
149 #define PROTO_H
150
151 #include <yconfig.h>
152 #include <odr.h>
153 #include <oid.h>
154 #include <odr_use.h>
155 #include <yaz-version.h>
156
157 /*
158  * Because we didn't have time to put all of the extra v3 elements in here
159  * before the first applications were written, we have to place them
160  * in #ifdefs in places where they would break existing code. If you are
161  * developing new stuff, we urge you to leave them in, even if you don't
162  * intend to use any v3 features. When we are comfortable that the old
163  * apps have been updated, we'll remove the #ifdefs.
164  */
165
166 #define Z_95
167
168 /* ----------------- GLOBAL AUXILIARY DEFS ----------------*/
169
170 struct Z_External;
171 typedef struct Z_External Z_External;
172
173 typedef Odr_oct Z_ReferenceId;
174 typedef char Z_DatabaseName;
175 typedef char Z_ResultSetId;
176 typedef Odr_oct Z_ResultsetId;
177
178 typedef struct Z_InfoCategory
179 {
180     Odr_oid *categoryTypeId;         /* OPTIONAL */
181     int *categoryValue;
182 } Z_InfoCategory;
183
184 typedef struct Z_OtherInformationUnit
185 {
186     Z_InfoCategory *category;        /* OPTIONAL */
187     int which;
188 #define Z_OtherInfo_characterInfo 0
189 #define Z_OtherInfo_binaryInfo 1
190 #define Z_OtherInfo_externallyDefinedInfo 2
191 #define Z_OtherInfo_oid 3
192     union
193     {
194         char *characterInfo; 
195         Odr_oct *binaryInfo;
196         Z_External *externallyDefinedInfo;
197         Odr_oid *oid;
198     } information;
199 } Z_OtherInformationUnit;
200
201 typedef struct Z_OtherInformation
202 {
203     int num_elements;
204     Z_OtherInformationUnit **list;
205 } Z_OtherInformation;
206
207 typedef struct Z_StringOrNumeric
208 {
209     int which;
210 #define Z_StringOrNumeric_string 0
211 #define Z_StringOrNumeric_numeric 1
212     union
213     {
214         char *string;
215         int *numeric;
216     } u;
217 } Z_StringOrNumeric;
218
219 typedef struct Z_Unit
220 {
221     char *unitSystem;               /* OPTIONAL */
222     Z_StringOrNumeric *unitType;    /* OPTIONAL */
223     Z_StringOrNumeric *unit;        /* OPTIONAL */
224     int *scaleFactor;               /* OPTIONAL */
225 } Z_Unit;
226
227 typedef struct Z_IntUnit
228 {
229     int *value;
230     Z_Unit *unitUsed;
231 } Z_IntUnit;
232
233 typedef Odr_oct Z_SUTRS;
234
235 /* ----------------- INIT SERVICE  ----------------*/
236
237 typedef struct
238 {
239     char *groupId;       /* OPTIONAL */
240     char *userId;         /* OPTIONAL */
241     char *password;      /* OPTIONAL */
242 } Z_IdPass;
243
244 typedef struct Z_IdAuthentication
245 {
246     int which;
247 #define Z_IdAuthentication_open 0
248 #define Z_IdAuthentication_idPass 1
249 #define Z_IdAuthentication_anonymous 2
250 #define Z_IdAuthentication_other 3
251     union
252     {
253         char *open;
254         Z_IdPass *idPass;
255         Odr_null *anonymous;
256         Z_External *other;
257     } u;
258 } Z_IdAuthentication;
259
260 #define Z_ProtocolVersion_1               0
261 #define Z_ProtocolVersion_2               1
262 #define Z_ProtocolVersion_3               2
263
264 #define Z_Options_search                  0
265 #define Z_Options_present                 1
266 #define Z_Options_delSet                  2
267 #define Z_Options_resourceReport          3
268 #define Z_Options_triggerResourceCtrl     4
269 #define Z_Options_resourceCtrl            5
270 #define Z_Options_accessCtrl              6
271 #define Z_Options_scan                    7
272 #define Z_Options_sort                    8
273 #define Z_Options_reserved                9
274 #define Z_Options_extendedServices       10
275 #define Z_Options_level_1Segmentation    11
276 #define Z_Options_level_2Segmentation    12
277 #define Z_Options_concurrentOperations   13
278 #define Z_Options_namedResultSets        14
279
280 typedef struct Z_InitRequest
281 {
282     Z_ReferenceId *referenceId;                   /* OPTIONAL */
283     Odr_bitmask *protocolVersion;
284     Odr_bitmask *options;
285     int *preferredMessageSize;
286     int *maximumRecordSize;
287     Z_IdAuthentication* idAuthentication;        /* OPTIONAL */
288     char *implementationId;                      /* OPTIONAL */
289     char *implementationName;                    /* OPTIONAL */
290     char *implementationVersion;                 /* OPTIONAL */
291     Z_External *userInformationField;          /* OPTIONAL */
292 #ifdef Z_95
293     Z_OtherInformation *otherInfo;               /* OPTIONAL */
294 #endif
295 } Z_InitRequest;
296
297 typedef struct Z_InitResponse
298 {
299     Z_ReferenceId *referenceId;    /* OPTIONAL */
300     Odr_bitmask *protocolVersion;
301     Odr_bitmask *options;
302     int *preferredMessageSize;
303     int *maximumRecordSize;
304     bool_t *result;
305     char *implementationId;      /* OPTIONAL */
306     char *implementationName;    /* OPTIONAL */
307     char *implementationVersion; /* OPTIONAL */
308     Z_External *userInformationField; /* OPTIONAL */
309 #ifdef Z_95
310     Z_OtherInformation *otherInfo;    /* OPTIONAL */
311 #endif
312 } Z_InitResponse;
313
314 typedef struct Z_NSRAuthentication
315 {
316     char *user;
317     char *password;
318     char *account;
319 } Z_NSRAuthentication;
320
321 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt);
322
323 int z_StrAuthentication(ODR o, char **p, int opt);
324
325 /* ------------------ SEARCH SERVICE ----------------*/
326
327 typedef struct Z_DatabaseSpecificUnit
328 {
329     char *databaseName;
330     char *elementSetName;
331 } Z_DatabaseSpecificUnit;
332
333 typedef struct Z_DatabaseSpecific
334 {
335     int num_elements;
336     Z_DatabaseSpecificUnit **elements;
337 } Z_DatabaseSpecific;
338
339 typedef struct Z_ElementSetNames
340 {
341     int which;
342 #define Z_ElementSetNames_generic 0
343 #define Z_ElementSetNames_databaseSpecific 1
344     union
345     {
346         char *generic;
347         Z_DatabaseSpecific *databaseSpecific;
348     } u;
349 } Z_ElementSetNames;
350
351 /* ---------------------- RPN QUERY --------------------------- */
352
353 typedef struct Z_ComplexAttribute
354 {
355     int num_list;
356     Z_StringOrNumeric **list;
357     int num_semanticAction;
358     int **semanticAction;           /* OPTIONAL */
359 } Z_ComplexAttribute;
360
361 typedef struct Z_AttributeElement
362 {
363 #ifdef Z_95
364     Odr_oid *attributeSet;           /* OPTIONAL - v3 only */
365 #endif
366     int *attributeType;
367 #ifdef Z_95
368     int which;
369 #define Z_AttributeValue_numeric 0
370 #define Z_AttributeValue_complex 1
371     union
372     {
373         int *numeric;
374         Z_ComplexAttribute *complex;
375     } value;
376 #else
377     int *attributeValue;
378 #endif
379 } Z_AttributeElement;
380
381 typedef struct Z_Term 
382 {
383     int which;
384 #define Z_Term_general 0
385 #define Z_Term_numeric 1
386 #define Z_Term_characterString 2
387 #define Z_Term_oid 3
388 #define Z_Term_dateTime 4
389 #define Z_Term_external 5
390 #define Z_Term_integerAndUnit 6
391 #define Z_Term_null 7
392     union
393     {
394         Odr_oct *general; /* this is required for v2 */
395         int *numeric;
396         char *characterString;
397         Odr_oid *oid;
398         char *dateTime;
399         Z_External *external;
400         /* Z_IntUnit *integerAndUnit; */
401         Odr_null *null;
402     } u;
403 } Z_Term;
404
405 typedef struct Z_AttributesPlusTerm
406 {
407     int num_attributes;
408     Z_AttributeElement **attributeList;
409     Z_Term *term;
410 } Z_AttributesPlusTerm;
411
412 typedef struct Z_ResultSetPlusAttributes
413 {
414     char *resultSet;
415     int num_attributes;
416     Z_AttributeElement **attributeList;
417 } Z_ResultSetPlusAttributes;
418
419 typedef struct Z_ProximityOperator
420 {
421     bool_t *exclusion;          /* OPTIONAL */
422     int *distance;
423     bool_t *ordered;
424     int *relationType;
425 #define Z_Prox_lessThan           1
426 #define Z_Prox_lessThanOrEqual    2
427 #define Z_Prox_equal              3
428 #define Z_Prox_greaterThanOrEqual 4
429 #define Z_Prox_greaterThan        5
430 #define Z_Prox_notEqual           6
431     int which;
432 #define Z_ProxCode_known 0
433 #define Z_ProxCode_private 1
434     int *proximityUnitCode;
435 #define Z_ProxUnit_character       1
436 #define Z_ProxUnit_word            2
437 #define Z_ProxUnit_sentence        3
438 #define Z_ProxUnit_paragraph       4
439 #define Z_ProxUnit_section         5
440 #define Z_ProxUnit_chapter         6
441 #define Z_ProxUnit_document        7
442 #define Z_ProxUnit_element         8
443 #define Z_ProxUnit_subelement      9
444 #define Z_ProxUnit_elementType    10
445 #define Z_ProxUnit_byte           11   /* v3 only */
446 } Z_ProximityOperator;
447
448 typedef struct Z_Operator
449 {
450     int which;
451 #define Z_Operator_and 0
452 #define Z_Operator_or 1
453 #define Z_Operator_and_not 2
454 #define Z_Operator_prox 3
455     union
456     {
457         Odr_null *and;          /* these guys are nulls. */
458         Odr_null *or;
459         Odr_null *and_not;
460         Z_ProximityOperator *prox;
461     } u;
462 } Z_Operator;
463
464 typedef struct Z_Operand
465 {
466     int which;
467 #define Z_Operand_APT 0
468 #define Z_Operand_resultSetId 1
469 #define Z_Operand_resultAttr             /* v3 only */ 2
470     union
471     {
472         Z_AttributesPlusTerm *attributesPlusTerm;
473         Z_ResultSetId *resultSetId;
474         Z_ResultSetPlusAttributes *resultAttr;
475     } u;
476 } Z_Operand;
477
478 typedef struct Z_Complex
479 {
480     struct Z_RPNStructure *s1;
481     struct Z_RPNStructure *s2;
482     Z_Operator *roperator;
483 } Z_Complex;
484
485 typedef struct Z_RPNStructure
486 {
487     int which;
488 #define Z_RPNStructure_simple 0
489 #define Z_RPNStructure_complex 1
490     union
491     {
492         Z_Operand *simple;
493         Z_Complex *complex;
494     } u;
495 } Z_RPNStructure;
496
497 typedef struct Z_RPNQuery
498 {
499     Odr_oid *attributeSetId;
500     Z_RPNStructure *RPNStructure;
501 } Z_RPNQuery;
502
503 /* -------------------------- SEARCHREQUEST -------------------------- */
504
505 typedef struct Z_Query
506 {
507     int which;
508 #define Z_Query_type_1 1
509 #define Z_Query_type_2 2
510 #define Z_Query_type_101 3
511     union
512     {
513         Z_RPNQuery *type_1;
514         Odr_oct *type_2;
515         Z_RPNQuery *type_101;
516     } u;
517 } Z_Query;
518
519 typedef struct Z_SearchRequest
520 {
521     Z_ReferenceId *referenceId;   /* OPTIONAL */
522     int *smallSetUpperBound;
523     int *largeSetLowerBound;
524     int *mediumSetPresentNumber;
525     bool_t *replaceIndicator;
526     char *resultSetName;
527     int num_databaseNames;
528     char **databaseNames;
529     Z_ElementSetNames *smallSetElementSetNames;    /* OPTIONAL */
530     Z_ElementSetNames *mediumSetElementSetNames;    /* OPTIONAL */
531     Odr_oid *preferredRecordSyntax;  /* OPTIONAL */
532     Z_Query *query;
533 #ifdef Z_95
534     Z_OtherInformation *additionalSearchInfo;       /* OPTIONAL */
535     Z_OtherInformation *otherInfo;                  /* OPTIONAL */
536 #endif
537 } Z_SearchRequest;
538
539 /* ------------------------ RECORD -------------------------- */
540
541 typedef Z_External Z_DatabaseRecord;
542
543 #ifdef Z_95
544
545 typedef struct Z_DefaultDiagFormat
546 {
547     Odr_oid *diagnosticSetId; /* This is opt'l to interwork with bad targets */
548     int *condition;
549     /* until the whole character set issue becomes more definite,
550      * you can probably ignore this on input. */
551     int which;
552 #define Z_DiagForm_v2AddInfo 0
553 #define Z_DiagForm_v3AddInfo 1
554     char *addinfo;
555 } Z_DefaultDiagFormat;
556
557 typedef struct Z_DiagRec
558 {
559     int which;
560 #define Z_DiagRec_defaultFormat 0
561 #define Z_DiagRec_externallyDefined 1
562     union
563     {
564         Z_DefaultDiagFormat *defaultFormat;
565         Z_External *externallyDefined;
566     } u;
567 } Z_DiagRec;
568
569 #else
570
571 typedef struct Z_DiagRec
572 {
573     Odr_oid *diagnosticSetId; /* This is opt'l to interwork with bad targets */
574     int *condition;
575     char *addinfo;
576 } Z_DiagRec;
577
578 #endif
579
580 typedef struct Z_DiagRecs
581 {
582     int num_diagRecs;
583     Z_DiagRec **diagRecs;
584 } Z_DiagRecs;
585
586 typedef struct Z_NamePlusRecord
587 {
588     char *databaseName;      /* OPTIONAL */
589     int which;
590 #define Z_NamePlusRecord_databaseRecord 0
591 #define Z_NamePlusRecord_surrogateDiagnostic 1
592     union
593     {
594         Z_DatabaseRecord *databaseRecord;
595         Z_DiagRec *surrogateDiagnostic;
596     } u;
597 } Z_NamePlusRecord;
598
599 typedef struct Z_NamePlusRecordList
600 {
601     int num_records;
602     Z_NamePlusRecord **records;
603 } Z_NamePlusRecordList;
604
605 typedef struct Z_Records
606 {
607     int which;
608 #define Z_Records_DBOSD 0
609 #define Z_Records_NSD 1
610 #define Z_Records_multipleNSD 2
611     union
612     {
613         Z_NamePlusRecordList *databaseOrSurDiagnostics;
614         Z_DiagRec *nonSurrogateDiagnostic;
615         Z_DiagRecs *multipleNonSurDiagnostics;
616     } u;
617 } Z_Records;
618
619 /* ------------------------ SEARCHRESPONSE ------------------ */
620
621 typedef struct Z_SearchResponse
622 {
623     Z_ReferenceId *referenceId;       /* OPTIONAL */
624     int *resultCount;
625     int *numberOfRecordsReturned;
626     int *nextResultSetPosition;
627     bool_t *searchStatus;
628     int *resultSetStatus;              /* OPTIONAL */
629 #define Z_RES_SUBSET        1
630 #define Z_RES_INTERIM       2
631 #define Z_RES_NONE          3
632     int *presentStatus;                /* OPTIONAL */
633 #define Z_PRES_SUCCESS      0
634 #define Z_PRES_PARTIAL_1    1
635 #define Z_PRES_PARTIAL_2    2
636 #define Z_PRES_PARTIAL_3    3
637 #define Z_PRES_PARTIAL_4    4
638 #define Z_PRES_FAILURE      5
639     Z_Records *records;                  /* OPTIONAL */
640 #ifdef Z_95
641     Z_OtherInformation *additionalSearchInfo;
642     Z_OtherInformation *otherInfo;
643 #endif
644 } Z_SearchResponse;
645
646 /* ------------------------- PRESENT SERVICE -----------------*/
647
648 typedef struct Z_ElementSpec
649 {
650     int which;
651 #define Z_ElementSpec_elementSetName 0
652 #define Z_ElementSpec_externalSpec 1
653     union
654     {
655         char *elementSetName;
656         Z_External *externalSpec;
657     } u;
658 } Z_ElementSpec;
659
660 typedef struct Z_Specification
661 {
662     Odr_oid *schema;                  /* OPTIONAL */
663     Z_ElementSpec *elementSpec;       /* OPTIONAL */
664 } Z_Specification;
665
666 typedef struct Z_DbSpecific
667 {
668     char *databaseName;
669     Z_Specification *spec;
670 } Z_DbSpecific;
671
672 typedef struct Z_CompSpec
673 {
674     bool_t *selectAlternativeSyntax;
675     Z_Specification *generic;            /* OPTIONAL */
676     int num_dbSpecific;
677     Z_DbSpecific **dbSpecific;           /* OPTIONAL */
678     int num_recordSyntax;
679     Odr_oid **recordSyntax;              /* OPTIONAL */
680 } Z_CompSpec;
681
682 typedef struct Z_RecordComposition
683 {
684     int which;
685 #define Z_RecordComp_simple 0
686 #define Z_RecordComp_complex 1
687     union
688     {
689         Z_ElementSetNames *simple;
690         Z_CompSpec *complex;
691     } u;
692 } Z_RecordComposition;
693
694 typedef struct Z_Range
695 {
696     int *startingPosition;
697     int *numberOfRecords;
698 } Z_Range;
699
700 typedef struct Z_PresentRequest
701 {
702     Z_ReferenceId *referenceId;              /* OPTIONAL */
703     Z_ResultSetId *resultSetId;
704     int *resultSetStartPoint;
705     int *numberOfRecordsRequested;
706 #ifdef Z_95
707     int num_ranges;
708     Z_Range **additionalRanges;              /* OPTIONAL */
709     Z_RecordComposition *recordComposition;  /* OPTIONAL */
710 #else
711     Z_ElementSetNames *elementSetNames;  /* OPTIONAL */
712 #endif
713     Odr_oid *preferredRecordSyntax;  /* OPTIONAL */
714 #ifdef Z_95
715     int *maxSegmentCount;                 /* OPTIONAL */
716     int *maxRecordSize;                   /* OPTIONAL */
717     int *maxSegmentSize;                  /* OPTIONAL */
718     Z_OtherInformation *otherInfo;        /* OPTIONAL */
719 #endif
720 } Z_PresentRequest;
721
722 typedef struct Z_PresentResponse
723 {
724     Z_ReferenceId *referenceId;        /* OPTIONAL */
725     int *numberOfRecordsReturned;
726     int *nextResultSetPosition;
727     int *presentStatus;
728     Z_Records *records;
729 #ifdef Z_95
730     Z_OtherInformation *otherInfo;     /* OPTIONAL */
731 #endif
732 } Z_PresentResponse;
733
734 /* ------------------ RESOURCE CONTROL ----------------*/
735
736 typedef struct Z_TriggerResourceControlRequest
737 {
738     Z_ReferenceId *referenceId;    /* OPTIONAL */
739     int *requestedAction;
740 #define Z_TriggerResourceCtrl_resourceReport  1
741 #define Z_TriggerResourceCtrl_resourceControl 2
742 #define Z_TriggerResourceCtrl_cancel          3
743     Odr_oid *prefResourceReportFormat;  /* OPTIONAL */
744     bool_t *resultSetWanted;            /* OPTIONAL */
745 #ifdef Z_95
746     Z_OtherInformation *otherInfo;
747 #endif
748 } Z_TriggerResourceControlRequest;
749
750 typedef struct Z_ResourceControlRequest
751 {
752     Z_ReferenceId *referenceId;    /* OPTIONAL */
753     bool_t *suspendedFlag;         /* OPTIONAL */
754     Z_External *resourceReport; /* OPTIONAL */
755     int *partialResultsAvailable;  /* OPTIONAL */
756 #define Z_ResourceControlRequest_subset    1
757 #define Z_ResourceControlRequest_interim   2
758 #define Z_ResourceControlRequest_none      3
759     bool_t *responseRequired;
760     bool_t *triggeredRequestFlag;  /* OPTIONAL */
761 #ifdef Z_95
762     Z_OtherInformation *otherInfo;
763 #endif
764 } Z_ResourceControlRequest;
765
766 typedef struct Z_ResourceControlResponse
767 {
768     Z_ReferenceId *referenceId;    /* OPTIONAL */
769     bool_t *continueFlag;
770     bool_t *resultSetWanted;       /* OPTIONAL */
771 #ifdef Z_95
772     Z_OtherInformation *otherInfo;
773 #endif
774 } Z_ResourceControlResponse;
775
776
777 /* ------------------ ACCESS CTRL SERVICE ----------------*/
778
779 typedef struct Z_AccessControlRequest
780 {
781     Z_ReferenceId *referenceId;           /* OPTIONAL */
782     int which;
783 #define Z_AccessRequest_simpleForm 0
784 #define Z_AccessRequest_externallyDefined 1
785     union
786     {
787         Odr_oct *simpleForm;
788         Z_External *externallyDefined;
789     } u;
790 #ifdef Z_95
791     Z_OtherInformation *otherInfo;           /* OPTIONAL */
792 #endif
793 } Z_AccessControlRequest;
794
795 typedef struct Z_AccessControlResponse
796 {
797     Z_ReferenceId *referenceId;              /* OPTIONAL */
798     int which;
799 #define Z_AccessResponse_simpleForm 0
800 #define Z_AccessResponse_externallyDefined 1
801     union
802     {
803         Odr_oct *simpleForm;
804         Z_External *externallyDefined;
805     } u;
806     Z_DiagRec *diagnostic;                   /* OPTIONAL */
807 #ifdef Z_95
808     Z_OtherInformation *otherInfo;           /* OPTIONAL */
809 #endif
810 } Z_AccessControlResponse;
811
812 /* ------------------------ SCAN SERVICE -------------------- */
813
814 typedef struct Z_AttributeList
815 {
816     int num_attributes;
817     Z_AttributeElement **attributes;
818 } Z_AttributeList;
819
820 typedef struct Z_AlternativeTerm
821 {
822     int num_terms;
823     Z_AttributesPlusTerm **terms;
824 } Z_AlternativeTerm;
825
826 typedef struct Z_OccurrenceByAttributes
827 {
828     Z_AttributeList *attributes;
829 #if 0
830     int which;
831 #define Z_OByAtt_global 0
832 #define Z_ObyAtt_byDatabase 1
833     union
834     {
835 #endif
836         int *global;
837 #if 0
838         /* Z_ByDatabase *byDatabase; */
839     } u;
840 #endif
841 } Z_OccurrenceByAttributes;
842
843 typedef struct Z_TermInfo
844 {
845     Z_Term *term;
846     Z_AttributeList *suggestedAttributes;  /* OPTIONAL */
847     Z_AlternativeTerm *alternativeTerm;    /* OPTIONAL */
848     int *globalOccurrences;                /* OPTIONAL */
849     Z_OccurrenceByAttributes *byAttributes; /* OPTIONAL */
850 } Z_TermInfo;
851
852 typedef struct Z_Entry
853 {
854     int which;
855 #define Z_Entry_termInfo 0
856 #define Z_Entry_surrogateDiagnostic 1
857     union
858     {
859         Z_TermInfo *termInfo;
860         Z_DiagRec *surrogateDiagnostic;
861     } u;
862 } Z_Entry;
863
864 typedef struct Z_Entries
865 {
866     int num_entries;
867     Z_Entry **entries;
868 } Z_Entries;
869
870 typedef struct Z_ListEntries
871 {
872     int which;
873 #define Z_ListEntries_entries 0
874 #define Z_ListEntries_nonSurrogateDiagnostics 1
875     union
876     {
877         Z_Entries *entries;
878         Z_DiagRecs *nonSurrogateDiagnostics;
879     } u;
880 } Z_ListEntries;
881
882 typedef struct Z_ScanRequest
883 {
884     Z_ReferenceId *referenceId;       /* OPTIONAL */
885     int num_databaseNames;
886     char **databaseNames;
887     Odr_oid *attributeSet;          /* OPTIONAL */
888     Z_AttributesPlusTerm *termListAndStartPoint;
889     int *stepSize;                    /* OPTIONAL */
890     int *numberOfTermsRequested;
891     int *preferredPositionInResponse;   /* OPTIONAL */
892 #ifdef Z_95
893     Z_OtherInformation *otherInfo;
894 #endif
895 } Z_ScanRequest;
896
897 typedef struct Z_ScanResponse
898 {
899     Z_ReferenceId *referenceId;       /* OPTIONAL */
900     int *stepSize;                    /* OPTIONAL */
901     int *scanStatus;
902 #define Z_Scan_success      0
903 #define Z_Scan_partial_1    1
904 #define Z_Scan_partial_2    2
905 #define Z_Scan_partial_3    3
906 #define Z_Scan_partial_4    4
907 #define Z_Scan_partial_5    5
908 #define Z_Scan_failure      6
909     int *numberOfEntriesReturned;
910     int *positionOfTerm;              /* OPTIONAL */
911     Z_ListEntries *entries;           /* OPTIONAL */
912     Odr_oid *attributeSet;            /* OPTIONAL */
913 #ifdef Z_95
914     Z_OtherInformation *otherInfo;
915 #endif
916 } Z_ScanResponse; 
917
918
919 /* ------------------------ DELETE -------------------------- */
920
921 #define Z_DeleteStatus_success                          0
922 #define Z_DeleteStatus_resultSetDidNotExist             1
923 #define Z_DeleteStatus_previouslyDeletedByTarget        2
924 #define Z_DeleteStatus_systemProblemAtTarget            3
925 #define Z_DeleteStatus_accessNotAllowed                 4
926 #define Z_DeleteStatus_resourceControlAtOrigin          5
927 #define Z_DeleteStatus_resourceControlAtTarget          6
928 #define Z_DeleteStatus_bulkDeleteNotSupported           7
929 #define Z_DeleteStatus_notAllRsltSetsDeletedOnBulkDlte  8
930 #define Z_DeleteStatus_notAllRequestedResultSetsDeleted 9
931 #define Z_DeleteStatus_resultSetInUse                  10
932
933 typedef struct Z_ListStatus
934 {
935     Z_ResultSetId *id;
936     int *status;
937 } Z_ListStatus;
938
939 typedef struct Z_DeleteResultSetRequest
940 {
941     Z_ReferenceId *referenceId;        /* OPTIONAL */
942     int *deleteFunction;
943 #define Z_DeleteRequest_list    0
944 #define Z_DeleteRequest_all     1
945     int num_ids;
946     Z_ResultSetId **resultSetList;      /* OPTIONAL */
947 #ifdef Z_95
948     Z_OtherInformation *otherInfo;
949 #endif
950 } Z_DeleteResultSetRequest;
951
952 typedef struct Z_DeleteResultSetResponse
953 {
954     Z_ReferenceId *referenceId;        /* OPTIONAL */
955     int *deleteOperationStatus;
956     int num_statuses;
957     Z_ListStatus *deleteListStatuses;  /* OPTIONAL */
958     int *numberNotDeleted;             /* OPTIONAL */
959     int num_bulkStatuses;
960     Z_ListStatus *bulkStatuses;        /* OPTIONAL */
961     char *deleteMessage;               /* OPTIONAL */
962 #ifdef Z_95
963     Z_OtherInformation *otherInfo;
964 #endif
965 } Z_DeleteResultSetResponse;
966
967 /* ------------------------ CLOSE SERVICE ------------------- */
968
969 typedef struct Z_Close
970 {
971     Z_ReferenceId *referenceId;         /* OPTIONAL */
972     int *closeReason;
973 #define Z_Close_finished           0
974 #define Z_Close_shutdown           1
975 #define Z_Close_systemProblem      2
976 #define Z_Close_costLimit          3
977 #define Z_Close_resources          4
978 #define Z_Close_securityViolation  5
979 #define Z_Close_protocolError      6
980 #define Z_Close_lackOfActivity     7
981 #define Z_Close_peerAbort          8
982 #define Z_Close_unspecified        9
983     char *diagnosticInformation;          /* OPTIONAL */
984     Odr_oid *resourceReportFormat;        /* OPTIONAL */
985     Z_External *resourceReport;         /* OPTIONAL */
986 #ifdef Z_95
987     Z_OtherInformation *otherInfo;        /* OPTIONAL */
988 #endif
989 } Z_Close;
990
991 /* ------------------------ SEGMENTATION -------------------- */
992
993 typedef struct Z_Segment
994 {
995     Z_ReferenceId *referenceId;   /* OPTIONAL */
996     int *numberOfRecordsReturned;
997     int num_segmentRecords;
998     Z_NamePlusRecord **segmentRecords;
999     Z_OtherInformation *otherInfo;  /* OPTIONAL */
1000 } Z_Segment;
1001
1002 /* ----------------------- Extended Services ---------------- */
1003
1004 typedef struct Z_Permissions
1005 {
1006     char *userId;                         
1007     int num_allowableFunctions;
1008     int **allowableFunctions;             
1009 #define Z_Permissions_delete              1
1010 #define Z_Permissions_modifyContents      2
1011 #define Z_Permissions_modifyPermissions   3
1012 #define Z_Permissions_present             4
1013 #define Z_Permissions_invoke              5
1014 } Z_Permissions;
1015
1016 typedef struct Z_ExtendedServicesRequest
1017 {
1018     Z_ReferenceId *referenceId;             /* OPTIONAL */
1019     int *function;                        
1020 #define Z_ExtendedServicesRequest_create              1
1021 #define Z_ExtendedServicesRequest_delete              2
1022 #define Z_ExtendedServicesRequest_modify              3
1023     Odr_oid *packageType;                 
1024     char *packageName;                      /* OPTIONAL */
1025     char *userId;                           /* OPTIONAL */
1026     Z_IntUnit *retentionTime;               /* OPTIONAL */
1027     Z_Permissions *permissions;             /* OPTIONAL */
1028     char *description;                      /* OPTIONAL */
1029     Z_External *taskSpecificParameters;     /* OPTIONAL */
1030     int *waitAction;                      
1031 #define Z_ExtendedServicesRequest_wait                1
1032 #define Z_ExtendedServicesRequest_waitIfPossible      2
1033 #define Z_ExtendedServicesRequest_dontWait            3
1034 #define Z_ExtendedServicesRequest_dontReturnPackage   4
1035     char *elements;             /* OPTIONAL */
1036     Z_OtherInformation *otherInfo;          /* OPTIONAL */
1037 } Z_ExtendedServicesRequest;
1038
1039 typedef struct Z_ExtendedServicesResponse
1040 {
1041     Z_ReferenceId *referenceId;             /* OPTIONAL */
1042     int *operationStatus;                 
1043 #define Z_ExtendedServicesResponse_done                1
1044 #define Z_ExtendedServicesResponse_accepted            2
1045 #define Z_ExtendedServicesResponse_failure             3
1046     int num_diagnostics;
1047     Z_DiagRec **diagnostics;                /* OPTIONAL */
1048     Z_External *taskPackage;                /* OPTIONAL */
1049     Z_OtherInformation *otherInfo;          /* OPTIONAL */
1050 } Z_ExtendedServicesResponse;
1051
1052 /* ------------------------ APDU ---------------------------- */
1053
1054 typedef struct Z_APDU
1055 {    
1056     int which;
1057 #define Z_APDU_initRequest 0
1058 #define Z_APDU_initResponse 1
1059 #define Z_APDU_searchRequest 2
1060 #define Z_APDU_searchResponse 3
1061 #define Z_APDU_presentRequest 4
1062 #define Z_APDU_presentResponse 5
1063 #define Z_APDU_deleteResultSetRequest 6
1064 #define Z_APDU_deleteResultSetResponse 7
1065 #define Z_APDU_resourceControlRequest 8
1066 #define Z_APDU_resourceControlResponse 9
1067 #define Z_APDU_triggerResourceControlRequest 10
1068 #define Z_APDU_scanRequest 11
1069 #define Z_APDU_scanResponse 12
1070 #define Z_APDU_segmentRequest 13
1071 #define Z_APDU_extendedServicesRequest 14
1072 #define Z_APDU_extendedServicesResponse 15
1073 #define Z_APDU_close 16
1074     union
1075     {
1076         Z_InitRequest  *initRequest;
1077         Z_InitResponse *initResponse;
1078         Z_SearchRequest *searchRequest;
1079         Z_SearchResponse *searchResponse;
1080         Z_PresentRequest *presentRequest;
1081         Z_PresentResponse *presentResponse;
1082         Z_DeleteResultSetRequest *deleteResultSetRequest;
1083         Z_DeleteResultSetResponse *deleteResultSetResponse;
1084         Z_ResourceControlRequest *resourceControlRequest;
1085         Z_ResourceControlResponse *resourceControlResponse;
1086         Z_TriggerResourceControlRequest *triggerResourceControlRequest;
1087         Z_ScanRequest *scanRequest;
1088         Z_ScanResponse *scanResponse;
1089         Z_Segment *segmentRequest;
1090         Z_ExtendedServicesRequest *extendedServicesRequest;
1091         Z_ExtendedServicesResponse *extendedServicesResponse;
1092         Z_Close *close;
1093     } u;
1094 } Z_APDU;
1095
1096 int z_APDU(ODR o, Z_APDU **p, int opt);
1097 int z_SUTRS(ODR o, Odr_oct **p, int opt);
1098
1099 Z_InitRequest *zget_InitRequest(ODR o);
1100 Z_InitResponse *zget_InitResponse(ODR o);
1101 Z_SearchRequest *zget_SearchRequest(ODR o);
1102 Z_SearchResponse *zget_SearchResponse(ODR o);
1103 Z_PresentRequest *zget_PresentRequest(ODR o);
1104 Z_PresentResponse *zget_PresentResponse(ODR o);
1105 Z_DeleteResultSetRequest *zget_DeleteResultSetRequest(ODR o);
1106 Z_DeleteResultSetResponse *zget_DeleteResultSetResponse(ODR o);
1107 Z_ScanRequest *zget_ScanRequest(ODR o);
1108 Z_ScanResponse *zget_ScanResponse(ODR o);
1109 Z_TriggerResourceControlRequest *zget_TriggerResourceControlRequest(ODR o);
1110 Z_ResourceControlRequest *zget_ResourceControlRequest(ODR o);
1111 Z_ResourceControlResponse *zget_ResourceControlResponse(ODR o);
1112 Z_Close *zget_Close(ODR o);
1113 int z_InternationalString(ODR o, char **p, int opt);
1114 int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt);
1115 int z_ElementSetName(ODR o, char **p, int opt);
1116 int z_IntUnit(ODR o, Z_IntUnit **p, int opt);
1117 int z_Unit(ODR o, Z_Unit **p, int opt);
1118 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt);
1119 int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt);
1120 int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt);
1121 int z_Term(ODR o, Z_Term **p, int opt);
1122 int z_Specification(ODR o, Z_Specification **p, int opt);
1123 int z_Permissions(ODR o, Z_Permissions **p, int opt);
1124 int z_DiagRec(ODR o, Z_DiagRec **p, int opt);
1125 int z_AttributeList(ODR o, Z_AttributeList **p, int opt);
1126 int z_DefaultDiagFormat(ODR o, Z_DefaultDiagFormat **p, int opt);
1127 Z_APDU *zget_APDU(ODR o, int which);
1128
1129 #include <prt-rsc.h>
1130 #include <prt-acc.h>
1131 #include <prt-exp.h>
1132 #include <prt-grs.h>
1133 #include <prt-exd.h>
1134 #include <prt-dia.h>
1135 #include <prt-esp.h>
1136
1137 #include <prt-ext.h>
1138
1139 #endif