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