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