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