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