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