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