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