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