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