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