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