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