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