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