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