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