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