3d05a577037e11127ebbcafdcc60b55a52c301dc
[yaz-moved-to-github.git] / include / proto.h
1 /*
2  * Copyright (c) 1995, Index Data.
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and
5  * its documentation, in whole or in part, for any purpose, is hereby granted,
6  * provided that:
7  *
8  * 1. This copyright and permission notice appear in all copies of the
9  * software and its documentation. Notices of copyright or attribution
10  * which appear at the beginning of any file must remain unchanged.
11  *
12  * 2. The name of Index Data or the individual authors may not be used to
13  * endorse or promote products derived from this software without specific
14  * prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
18  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
19  * IN NO EVENT SHALL INDEX DATA BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
20  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
21  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR
22  * NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24  * OF THIS SOFTWARE.
25  *
26  * $Log: proto.h,v $
27  * Revision 1.16  1995-06-15 07:45:06  quinn
28  * Moving to v3.
29  *
30  * Revision 1.15  1995/06/14  15:26:43  quinn
31  * *** empty log message ***
32  *
33  * Revision 1.14  1995/06/07  14:42:34  quinn
34  * Fixed CLOSE
35  *
36  * Revision 1.13  1995/06/07  14:36:47  quinn
37  * Added CLOSE
38  *
39  * Revision 1.12  1995/06/05  10:53:13  quinn
40  * Smallish.
41  *
42  * Revision 1.11  1995/06/02  09:49:47  quinn
43  * Add access control
44  *
45  * Revision 1.10  1995/05/29  08:11:34  quinn
46  * Moved oid from odr/asn to util.
47  *
48  * Revision 1.9  1995/05/22  11:31:25  quinn
49  * Added PDUs
50  *
51  * Revision 1.8  1995/05/17  08:41:35  quinn
52  * Added delete to proto & other little things.
53  * Relaying auth info to backend.
54  *
55  * Revision 1.7  1995/05/16  08:50:37  quinn
56  * License, documentation, and memory fixes
57  *
58  * Revision 1.6  1995/05/15  11:55:55  quinn
59  * Work on asynchronous activity.
60  *
61  * Revision 1.5  1995/04/17  11:28:18  quinn
62  * Smallish
63  *
64  * Revision 1.4  1995/04/10  10:22:47  quinn
65  * Added SCAN
66  *
67  * Revision 1.3  1995/03/30  12:18:09  quinn
68  * Added info.
69  *
70  * Revision 1.2  1995/03/30  10:26:48  quinn
71  * Added Term structure
72  *
73  * Revision 1.1  1995/03/30  09:39:42  quinn
74  * Moved .h files to include directory
75  *
76  * Revision 1.11  1995/03/30  09:08:44  quinn
77  * Added Resource control protocol
78  *
79  * Revision 1.10  1995/03/29  15:39:39  quinn
80  * Adding some resource control elements, and a null-check to getentbyoid
81  *
82  * Revision 1.9  1995/03/29  08:06:18  quinn
83  * Added a few v3 elements
84  *
85  * Revision 1.8  1995/03/22  10:12:49  quinn
86  * Added Z_PRES constants.
87  *
88  * Revision 1.7  1995/03/20  09:45:12  quinn
89  * Working towards v3
90  *
91  * Revision 1.5  1995/03/07  16:29:34  quinn
92  * Added authentication stuff.
93  *
94  * Revision 1.4  1995/03/07  10:13:00  quinn
95  * Added prototype for z_APDU()
96  *
97  * Revision 1.3  1995/02/14  11:54:23  quinn
98  * Fixing include.
99  *
100  * Revision 1.2  1995/02/09  15:51:40  quinn
101  * Works better now.
102  *
103  * Revision 1.1  1995/02/06  16:44:48  quinn
104  * First hack at Z/SR protocol
105  *
106  */
107
108 #ifndef PROTO_H
109 #define PROTO_H
110
111 #include <odr.h>
112 #include <oid.h>
113 #include <odr_use.h>
114 #include <yaz-version.h>
115
116 /*
117  * Because we didn't have time to put all of the extra v3 elements in here
118  * before the first applications were written, we have to place them
119  * in #ifdefs in places where they would break existing code. If you are
120  * developing new stuff, we urge you to leave them in, even if you don't
121  * intend to use any v3 features. When we are comfortable that the old
122  * apps have been updated, we'll remove the #ifdefs.
123  */
124
125 #define Z_95
126
127 /* ----------------- GLOBAL AUXILIARY DEFS ----------------*/
128
129 typedef Odr_oct Z_ReferenceId;
130 typedef char Z_DatabaseName;
131 typedef char Z_ResultSetId;
132 typedef Odr_oct Z_ResultsetId;
133
134 typedef struct Z_InfoCategory
135 {
136     Odr_oid *categoryTypeId;         /* OPTIONAL */
137     int *categoryValue;
138 } Z_InfoCategory;
139
140 typedef struct Z_OtherInformationUnit
141 {
142     Z_InfoCategory *category;        /* OPTIONAL */
143     enum
144     {
145         Z_OtherInfo_characterInfo,
146         Z_OtherInfo_binaryInfo,
147         Z_OtherInfo_externallyDefinedInfo,
148         Z_OtherInfo_oid
149     } which;
150     union
151     {
152         char *characterInfo; 
153         Odr_oct *binaryInfo;
154         Odr_external *externallyDefinedInfo;
155         Odr_oid *oid;
156     } information;
157 } Z_OtherInformationUnit;
158
159 typedef struct Z_OtherInformation
160 {
161     int num_elements;
162     Z_OtherInformationUnit **list;
163 } Z_OtherInformation;
164
165 typedef struct Z_StringOrNumeric
166 {
167     enum
168     {
169         Z_StringOrNumeric_string,
170         Z_StringOrNumeric_numeric
171     } which;
172     union
173     {
174         char *string;
175         int *numeric;
176     } u;
177 } Z_StringOrNumeric;
178
179 typedef struct Z_Unit
180 {
181     char *unitSystem;               /* OPTIONAL */
182     Z_StringOrNumeric *unitType;    /* OPTIONAL */
183     Z_StringOrNumeric *unit;        /* OPTIONAL */
184     int *scaleFactor;               /* OPTIONAL */
185 } Z_Unit;
186
187 typedef struct Z_IntUnit
188 {
189     int *value;
190     Z_Unit *unitUsed;
191 } Z_IntUnit;
192
193 /* ----------------- INIT SERVICE  ----------------*/
194
195 typedef struct
196 {
197     char *groupId;       /* OPTIONAL */
198     char *userId;         /* OPTIONAL */
199     char *password;      /* OPTIONAL */
200 } Z_IdPass;
201
202 typedef struct Z_IdAuthentication
203 {
204     enum
205     {
206         Z_IdAuthentication_open,
207         Z_IdAuthentication_idPass,
208         Z_IdAuthentication_anonymous,
209         Z_IdAuthentication_other
210     } which;
211     union
212     {
213         char *open;
214         Z_IdPass *idPass;
215         Odr_null *anonymous;
216         Odr_external *other;
217     } u;
218 } Z_IdAuthentication;
219
220 #define Z_ProtocolVersion_1               0
221 #define Z_ProtocolVersion_2               1
222 #define Z_ProtocolVersion_3               2
223
224 #define Z_Options_search                  0
225 #define Z_Options_present                 1
226 #define Z_Options_delSet                  2
227 #define Z_Options_resourceReport          3
228 #define Z_Options_triggerResourceCtrl     4
229 #define Z_Options_resourceCtrl            5
230 #define Z_Options_accessCtrl              6
231 #define Z_Options_scan                    7
232 #define Z_Options_sort                    8
233 #define Z_Options_reserved                9
234 #define Z_Options_extendedServices       10
235 #define Z_Options_level_1Segmentation    11
236 #define Z_Options_level_2Segmentation    12
237 #define Z_Options_concurrentOperations   13
238 #define Z_Options_namedResultSets        14
239
240 typedef struct Z_InitRequest
241 {
242     Z_ReferenceId *referenceId;                   /* OPTIONAL */
243     Odr_bitmask *protocolVersion;
244     Odr_bitmask *options;
245     int *preferredMessageSize;
246     int *maximumRecordSize;
247     Z_IdAuthentication* idAuthentication;        /* OPTIONAL */
248     char *implementationId;                      /* OPTIONAL */
249     char *implementationName;                    /* OPTIONAL */
250     char *implementationVersion;                 /* OPTIONAL */
251     Odr_external *userInformationField;          /* OPTIONAL */
252 #ifdef Z_95
253     Z_OtherInformation *otherInfo;               /* OPTIONAL */
254 #endif
255 } Z_InitRequest;
256
257 typedef struct Z_InitResponse
258 {
259     Z_ReferenceId *referenceId;    /* OPTIONAL */
260     Odr_bitmask *protocolVersion;
261     Odr_bitmask *options;
262     int *preferredMessageSize;
263     int *maximumRecordSize;
264     bool_t *result;
265     char *implementationId;      /* OPTIONAL */
266     char *implementationName;    /* OPTIONAL */
267     char *implementationVersion; /* OPTIONAL */
268     Odr_external *userInformationField; /* OPTIONAL */
269 #ifdef Z_95
270     Z_OtherInformation *otherInfo;    /* OPTIONAL */
271 #endif
272 } Z_InitResponse;
273
274 typedef struct Z_NSRAuthentication
275 {
276     char *user;
277     char *password;
278     char *account;
279 } Z_NSRAuthentication;
280
281 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt);
282
283 int z_StrAuthentication(ODR o, char **p, int opt);
284
285 /* ------------------ SEARCH SERVICE ----------------*/
286
287 typedef struct Z_DatabaseSpecificUnit
288 {
289     char *databaseName;
290     char *elementSetName;
291 } Z_DatabaseSpecificUnit;
292
293 typedef struct Z_DatabaseSpecific
294 {
295     int num_elements;
296     Z_DatabaseSpecificUnit **elements;
297 } Z_DatabaseSpecific;
298
299 typedef struct Z_ElementSetNames
300 {
301     int which;
302 #define Z_ElementSetNames_generic 0
303 #define Z_ElementSetNames_databaseSpecific 1
304     union
305     {
306         char *generic;
307         Z_DatabaseSpecific *databaseSpecific;
308     } u;
309 } Z_ElementSetNames;
310
311 /* ---------------------- RPN QUERY --------------------------- */
312
313 typedef struct Z_ComplexAttribute
314 {
315     int num_list;
316     Z_StringOrNumeric **list;
317     int num_semanticAction;
318     int **semanticAction;           /* OPTIONAL */
319 } Z_ComplexAttribute;
320
321 typedef struct Z_AttributeElement
322 {
323 #ifdef Z_95
324     Odr_oid *attributeSet;           /* OPTIONAL - v3 only */
325 #endif
326     int *attributeType;
327 #ifdef Z_95
328     enum
329     {
330         Z_AttributeValue_numeric,
331         Z_AttributeValue_complex
332     } which;
333     union
334     {
335         int *numeric;
336         Z_ComplexAttribute *complex;
337     } value;
338 #else
339     int *attributeValue;
340 #endif
341 } Z_AttributeElement;
342
343 typedef struct Z_Term 
344 {
345     enum
346     {
347         Z_Term_general,
348         Z_Term_numeric,
349         Z_Term_characterString,
350         Z_Term_oid,
351         Z_Term_dateTime,
352         Z_Term_external,
353         Z_Term_integerAndUnit,
354         Z_Term_null
355     } which;
356     union
357     {
358         Odr_oct *general; /* this is required for v2 */
359         int *numeric;
360         char *characterString;
361         Odr_oid *oid;
362         char *dateTime;
363         Odr_external *external;
364         /* Z_IntUnit *integerAndUnit; */
365         Odr_null *null;
366     } u;
367 } Z_Term;
368
369 typedef struct Z_AttributesPlusTerm
370 {
371     int num_attributes;
372     Z_AttributeElement **attributeList;
373     Z_Term *term;
374 } Z_AttributesPlusTerm;
375
376 typedef struct Z_ResultSetPlusAttributes
377 {
378     char *resultSet;
379     int num_attributes;
380     Z_AttributeElement **attributeList;
381 } Z_ResultSetPlusAttributes;
382
383 typedef struct Z_ProximityOperator
384 {
385     bool_t *exclusion;          /* OPTIONAL */
386     int *distance;
387     bool_t *ordered;
388     int *relationType;
389 #define Z_Prox_lessThan           1
390 #define Z_Prox_lessThanOrEqual    2
391 #define Z_Prox_equal              3
392 #define Z_Prox_greaterThanOrEqual 4
393 #define Z_Prox_greaterThan        5
394 #define Z_Prox_notEqual           6
395     enum
396     {
397         Z_ProxCode_known,
398         Z_ProxCode_private
399     } which;
400     int *proximityUnitCode;
401 #define Z_ProxUnit_character       1
402 #define Z_ProxUnit_word            2
403 #define Z_ProxUnit_sentence        3
404 #define Z_ProxUnit_paragraph       4
405 #define Z_ProxUnit_section         5
406 #define Z_ProxUnit_chapter         6
407 #define Z_ProxUnit_document        7
408 #define Z_ProxUnit_element         8
409 #define Z_ProxUnit_subelement      9
410 #define Z_ProxUnit_elementType    10
411 #define Z_ProxUnit_byte           11   /* v3 only */
412 } Z_ProximityOperator;
413
414 typedef struct Z_Operator
415 {
416     enum
417     {
418         Z_Operator_and,
419         Z_Operator_or,
420         Z_Operator_and_not,
421         Z_Operator_prox
422     } which;
423     union
424     {
425         Odr_null *and;          /* these guys are nulls. */
426         Odr_null *or;
427         Odr_null *and_not;
428         Z_ProximityOperator *prox;
429     } u;
430 } Z_Operator;
431
432 typedef struct Z_Operand
433 {
434     enum
435     {
436         Z_Operand_APT,
437         Z_Operand_resultSetId,
438         Z_Operand_resultAttr             /* v3 only */
439     } which;
440     union
441     {
442         Z_AttributesPlusTerm *attributesPlusTerm;
443         Z_ResultSetId *resultSetId;
444         Z_ResultSetPlusAttributes *resultAttr;
445     } u;
446 } Z_Operand;
447
448 typedef struct Z_Complex
449 {
450     struct Z_RPNStructure *s1;
451     struct Z_RPNStructure *s2;
452     Z_Operator *operator;
453 } Z_Complex;
454
455 typedef struct Z_RPNStructure
456 {
457     enum
458     {
459         Z_RPNStructure_simple,
460         Z_RPNStructure_complex
461     } which;
462     union
463     {
464         Z_Operand *simple;
465         Z_Complex *complex;
466     } u;
467 } Z_RPNStructure;
468
469 typedef struct Z_RPNQuery
470 {
471     Odr_oid *attributeSetId;
472     Z_RPNStructure *RPNStructure;
473 } Z_RPNQuery;
474
475 /* -------------------------- SEARCHREQUEST -------------------------- */
476
477 typedef struct Z_Query
478 {
479     enum
480     {
481         Z_Query_type_1 = 1,
482         Z_Query_type_2,
483         Z_Query_type_101
484     }
485     which;
486     union
487     {
488         Z_RPNQuery *type_1;
489         Odr_oct *type_2;
490         Z_RPNQuery *type_101;
491     } u;
492 } Z_Query;
493
494 typedef struct Z_SearchRequest
495 {
496     Z_ReferenceId *referenceId;   /* OPTIONAL */
497     int *smallSetUpperBound;
498     int *largeSetLowerBound;
499     int *mediumSetPresentNumber;
500     bool_t *replaceIndicator;
501     char *resultSetName;
502     int num_databaseNames;
503     char **databaseNames;
504     Z_ElementSetNames *smallSetElementSetNames;    /* OPTIONAL */
505     Z_ElementSetNames *mediumSetElementSetNames;    /* OPTIONAL */
506     Odr_oid *preferredRecordSyntax;  /* OPTIONAL */
507     Z_Query *query;
508 #ifdef Z_95
509     Z_OtherInformation *additionalSearchInfo;       /* OPTIONAL */
510     Z_OtherInformation *otherInfo;                  /* OPTIONAL */
511 #endif
512 } Z_SearchRequest;
513
514 /* ------------------------ RECORD -------------------------- */
515
516 typedef Odr_external Z_DatabaseRecord;
517
518 #ifdef Z_95
519
520 typedef struct Z_DefaultDiagFormat
521 {
522     Odr_oid *diagnosticSetId; /* This is opt'l to interwork with bad targets */
523     int *condition;
524     char *addinfo;
525 } Z_DefaultDiagFormat;
526
527 typedef struct Z_DiagRec
528 {
529     enum
530     {   
531         Z_DiagRec_defaultFormat,
532         Z_DiagRec_externallyDefined
533     } which;
534     union
535     {
536         Z_DefaultDiagFormat *defaultFormat;
537         Odr_external *externallyDefined;
538     } u;
539 } Z_DiagRec;
540
541 #else
542
543 typedef struct Z_DiagRec
544 {
545     Odr_oid *diagnosticSetId; /* This is opt'l to interwork with bad targets */
546     int *condition;
547     char *addinfo;
548 } Z_DiagRec;
549
550 #endif
551
552 typedef struct Z_DiagRecList
553 {
554     int num;
555     Z_DiagRec **list;
556 } Z_DiagRecList;
557
558 typedef struct Z_NamePlusRecord
559 {
560     char *databaseName;      /* OPTIONAL */
561     enum
562     {
563         Z_NamePlusRecord_databaseRecord,
564         Z_NamePlusRecord_surrogateDiagnostic,
565         Z_NamePlusRecord_multipleNonSurDiagnostics
566     }
567     which;
568     union
569     {
570         Z_DatabaseRecord *databaseRecord;
571         Z_DiagRec *surrogateDiagnostic;
572         Z_DiagRecList *multipleNonSurDiagnostics;
573     } u;
574 } Z_NamePlusRecord;
575
576 typedef struct Z_NamePlusRecordList
577 {
578     int num_records;
579     Z_NamePlusRecord **records;
580 } Z_NamePlusRecordList;
581
582 typedef struct Z_Records
583 {
584     enum
585     {
586         Z_Records_DBOSD,
587         Z_Records_NSD,
588         Z_Records_multipleNSD
589     } which;
590     union
591     {
592         Z_NamePlusRecordList *databaseOrSurDiagnostics;
593         Z_DiagRec *nonSurrogateDiagnostic;
594         Z_DiagRecList *multipleNonSurDiagnostics;
595     } u;
596 } Z_Records;
597
598 /* ------------------------ SEARCHRESPONSE ------------------ */
599
600 typedef struct Z_SearchResponse
601 {
602     Z_ReferenceId *referenceId;       /* OPTIONAL */
603     int *resultCount;
604     int *numberOfRecordsReturned;
605     int *nextResultSetPosition;
606     bool_t *searchStatus;
607     int *resultSetStatus;              /* OPTIONAL */
608 #define Z_RES_SUBSET        1
609 #define Z_RES_INTERIM       2
610 #define Z_RES_NONE          3
611     int *presentStatus;                /* OPTIONAL */
612 #define Z_PRES_SUCCESS      0
613 #define Z_PRES_PARTIAL_1    1
614 #define Z_PRES_PARTIAL_2    2
615 #define Z_PRES_PARTIAL_3    3
616 #define Z_PRES_PARTIAL_4    4
617 #define Z_PRES_FAILURE      5
618     Z_Records *records;                  /* OPTIONAL */
619 #ifdef Z_95
620     Z_OtherInformation *additionalSearchInfo;
621     Z_OtherInformation *otherInfo;
622 #endif
623 } Z_SearchResponse;
624
625 /* ------------------------- PRESENT SERVICE -----------------*/
626
627 typedef struct Z_ElementSpec
628 {
629     enum
630     {
631         Z_ElementSpec_elementSetName,
632         Z_ElementSpec_externalSpec
633     } which;
634     union
635     {
636         char *elementSetName;
637         Odr_external *externalSpec;
638     } u;
639 } Z_ElementSpec;
640
641 typedef struct Z_Specification
642 {
643     Odr_oid *schema;                  /* OPTIONAL */
644     Z_ElementSpec *elementSpec;       /* OPTIONAL */
645 } Z_Specification;
646
647 typedef struct Z_DbSpecific
648 {
649     char *databaseName;
650     Z_Specification *spec;
651 } Z_DbSpecific;
652
653 typedef struct Z_CompSpec
654 {
655     bool_t *selectAlternativeSyntax;
656     Z_Specification *generic;            /* OPTIONAL */
657     int num_dbSpecific;
658     Z_DbSpecific **dbSpecific;           /* OPTIONAL */
659     int num_recordSyntax;
660     Odr_oid **recordSyntax;              /* OPTIONAL */
661 } Z_CompSpec;
662
663 typedef struct Z_RecordComposition
664 {
665     enum
666     {
667         Z_RecordComp_simple,
668         Z_RecordComp_complex
669     } which;
670     union
671     {
672         Z_ElementSetNames *simple;
673         Z_CompSpec *complex;
674     } u;
675 } Z_RecordComposition;
676
677 typedef struct Z_Range
678 {
679     int *startingPosition;
680     int *numberOfRecords;
681 } Z_Range;
682
683 typedef struct Z_PresentRequest
684 {
685     Z_ReferenceId *referenceId;              /* OPTIONAL */
686     Z_ResultSetId *resultSetId;
687     int *resultSetStartPoint;
688     int *numberOfRecordsRequested;
689 #ifdef Z_95
690     int num_ranges;
691     Z_Range **additionalRanges;              /* OPTIONAL */
692     Z_RecordComposition *recordComposition;  /* OPTIONAL */
693 #else
694     Z_ElementSetNames *elementSetNames;  /* OPTIONAL */
695 #endif
696     Odr_oid *preferredRecordSyntax;  /* OPTIONAL */
697 #ifdef Z_95
698     int *maxSegmentCount;                 /* OPTIONAL */
699     int *maxRecordSize;                   /* OPTIONAL */
700     int *maxSegmentSize;                  /* OPTIONAL */
701     Z_OtherInformation *otherInfo;        /* OPTIONAL */
702 #endif
703 } Z_PresentRequest;
704
705 typedef struct Z_PresentResponse
706 {
707     Z_ReferenceId *referenceId;        /* OPTIONAL */
708     int *numberOfRecordsReturned;
709     int *nextResultSetPosition;
710     int *presentStatus;
711     Z_Records *records;
712 #ifdef Z_95
713     Z_OtherInformation *otherInfo;     /* OPTIONAL */
714 #endif
715 } Z_PresentResponse;
716
717 /* ------------------ RESOURCE CONTROL ----------------*/
718
719 typedef struct Z_TriggerResourceControlRequest
720 {
721     Z_ReferenceId *referenceId;    /* OPTIONAL */
722     int *requestedAction;
723 #define Z_TriggerResourceCtrl_resourceReport  1
724 #define Z_TriggerResourceCtrl_resourceControl 2
725 #define Z_TriggerResourceCtrl_cancel          3
726     Odr_oid *prefResourceReportFormat;  /* OPTIONAL */
727     bool_t *resultSetWanted;            /* OPTIONAL */
728 #ifdef Z_95
729     Z_OtherInformation *otherInfo;
730 #endif
731 } Z_TriggerResourceControlRequest;
732
733 typedef struct Z_ResourceControlRequest
734 {
735     Z_ReferenceId *referenceId;    /* OPTIONAL */
736     bool_t *suspendedFlag;         /* OPTIONAL */
737     Odr_external *resourceReport; /* OPTIONAL */
738     int *partialResultsAvailable;  /* OPTIONAL */
739 #define Z_ResourceControlRequest_subset    1
740 #define Z_ResourceControlRequest_interim   2
741 #define Z_ResourceControlRequest_none      3
742     bool_t *responseRequired;
743     bool_t *triggeredRequestFlag;  /* OPTIONAL */
744 #ifdef Z_95
745     Z_OtherInformation *otherInfo;
746 #endif
747 } Z_ResourceControlRequest;
748
749 typedef struct Z_ResourceControlResponse
750 {
751     Z_ReferenceId *referenceId;    /* OPTIONAL */
752     bool_t *continueFlag;
753     bool_t *resultSetWanted;       /* OPTIONAL */
754 #ifdef Z_95
755     Z_OtherInformation *otherInfo;
756 #endif
757 } Z_ResourceControlResponse;
758
759
760 /* ------------------ ACCESS CTRL SERVICE ----------------*/
761
762 typedef struct Z_AccessControlRequest
763 {
764     Z_ReferenceId *referenceId;           /* OPTIONAL */
765     enum
766     {
767         Z_AccessRequest_simpleForm,
768         Z_AccessRequest_externallyDefined
769     } which;
770     union
771     {
772         Odr_oct *simpleForm;
773         Odr_external *externallyDefined;
774     } u;
775 #ifdef Z_95
776     Z_OtherInformation *otherInfo;           /* OPTIONAL */
777 #endif
778 } Z_AccessControlRequest;
779
780 typedef struct Z_AccessControlResponse
781 {
782     Z_ReferenceId *referenceId;              /* OPTIONAL */
783     enum
784     {
785         Z_AccessResponse_simpleForm,
786         Z_AccessResponse_externallyDefined
787     } which;
788     union
789     {
790         Odr_oct *simpleForm;
791         Odr_external *externallyDefined;
792     } u;
793     Z_DiagRec *diagnostic;                   /* OPTIONAL */
794 #ifdef Z_95
795     Z_OtherInformation *otherInfo;           /* OPTIONAL */
796 #endif
797 } Z_AccessControlResponse;
798
799 /* ------------------------ SCAN SERVICE -------------------- */
800
801 typedef struct Z_AttributeList
802 {
803     int num_attributes;
804     Z_AttributeElement **attributes;
805 } Z_AttributeList;
806
807 typedef struct Z_AlternativeTerm
808 {
809     int num_terms;
810     Z_AttributesPlusTerm **terms;
811 } Z_AlternativeTerm;
812
813 typedef struct Z_OccurrenceByAttributes
814 {
815     Z_AttributeList *attributes;
816 #if 0
817     enum
818     {
819         Z_OByAtt_global,
820         Z_ObyAtt_byDatabase
821     } which;
822     union
823     {
824 #endif
825         int *global;
826 #if 0
827         /* Z_ByDatabase *byDatabase; */
828     } u;
829 #endif
830 } Z_OccurrenceByAttributes;
831
832 typedef struct Z_TermInfo
833 {
834     Z_Term *term;
835     Z_AttributeList *suggestedAttributes;  /* OPTIONAL */
836     Z_AlternativeTerm *alternativeTerm;    /* OPTIONAL */
837     int *globalOccurrences;                /* OPTIONAL */
838     Z_OccurrenceByAttributes *byAttributes; /* OPTIONAL */
839 } Z_TermInfo;
840
841 typedef struct Z_Entry
842 {
843     enum
844     {
845         Z_Entry_termInfo,
846         Z_Entry_surrogateDiagnostic
847     } which;
848     union
849     {
850         Z_TermInfo *termInfo;
851         Z_DiagRec *surrogateDiagnostic;
852     } u;
853 } Z_Entry;
854
855 typedef struct Z_Entries
856 {
857     int num_entries;
858     Z_Entry **entries;
859 } Z_Entries;
860
861 typedef struct Z_DiagRecs
862 {
863     int num_diagRecs;
864     Z_DiagRec **diagRecs;
865 } Z_DiagRecs;
866
867 typedef struct Z_ListEntries
868 {
869     enum
870     {
871         Z_ListEntries_entries,
872         Z_ListEntries_nonSurrogateDiagnostics
873     } which;
874     union
875     {
876         Z_Entries *entries;
877         Z_DiagRecs *nonSurrogateDiagnostics;
878     } u;
879 } Z_ListEntries;
880
881 typedef struct Z_ScanRequest
882 {
883     Z_ReferenceId *referenceId;       /* OPTIONAL */
884     int num_databaseNames;
885     char **databaseNames;
886     Odr_oid *attributeSet;          /* OPTIONAL */
887     Z_AttributesPlusTerm *termListAndStartPoint;
888     int *stepSize;                    /* OPTIONAL */
889     int *numberOfTermsRequested;
890     int *preferredPositionInResponse;   /* OPTIONAL */
891 #ifdef Z_95
892     Z_OtherInformation *otherInfo;
893 #endif
894 } Z_ScanRequest;
895
896 typedef struct Z_ScanResponse
897 {
898     Z_ReferenceId *referenceId;       /* OPTIONAL */
899     int *stepSize;                    /* OPTIONAL */
900     int *scanStatus;
901 #define Z_Scan_success      0
902 #define Z_Scan_partial_1    1
903 #define Z_Scan_partial_2    2
904 #define Z_Scan_partial_3    3
905 #define Z_Scan_partial_4    4
906 #define Z_Scan_partial_5    5
907 #define Z_Scan_failure      6
908     int *numberOfEntriesReturned;
909     int *positionOfTerm;              /* OPTIONAL */
910     Z_ListEntries *entries;           /* OPTIONAL */
911     Odr_oid *attributeSet;            /* OPTIONAL */
912 #ifdef Z_95
913     Z_OtherInformation *otherInfo;
914 #endif
915 } Z_ScanResponse; 
916
917
918 /* ------------------------ DELETE -------------------------- */
919
920 #define Z_DeleteStatus_success                          0
921 #define Z_DeleteStatus_resultSetDidNotExist             1
922 #define Z_DeleteStatus_previouslyDeletedByTarget        2
923 #define Z_DeleteStatus_systemProblemAtTarget            3
924 #define Z_DeleteStatus_accessNotAllowed                 4
925 #define Z_DeleteStatus_resourceControlAtOrigin          5
926 #define Z_DeleteStatus_resourceControlAtTarget          6
927 #define Z_DeleteStatus_bulkDeleteNotSupported           7
928 #define Z_DeleteStatus_notAllRsltSetsDeletedOnBulkDlte  8
929 #define Z_DeleteStatus_notAllRequestedResultSetsDeleted 9
930 #define Z_DeleteStatus_resultSetInUse                  10
931
932 typedef struct Z_ListStatus
933 {
934     Z_ResultSetId *id;
935     int *status;
936 } Z_ListStatus;
937
938 typedef struct Z_DeleteResultSetRequest
939 {
940     Z_ReferenceId *referenceId;        /* OPTIONAL */
941     int *deleteFunction;
942 #define Z_DeleteRequest_list    0
943 #define Z_DeleteRequest_all     1
944     int num_ids;
945     Z_ResultSetId **resultSetList;      /* OPTIONAL */
946 #ifdef Z_95
947     Z_OtherInformation *otherInfo;
948 #endif
949 } Z_DeleteResultSetRequest;
950
951 typedef struct Z_DeleteResultSetResponse
952 {
953     Z_ReferenceId *referenceId;        /* OPTIONAL */
954     int *deleteOperationStatus;
955     int num_statuses;
956     Z_ListStatus *deleteListStatuses;  /* OPTIONAL */
957     int *numberNotDeleted;             /* OPTIONAL */
958     int num_bulkStatuses;
959     Z_ListStatus *bulkStatuses;        /* OPTIONAL */
960     char *deleteMessage;               /* OPTIONAL */
961 #ifdef Z_95
962     Z_OtherInformation *otherInfo;
963 #endif
964 } Z_DeleteResultSetResponse;
965
966 /* ------------------------ CLOSE SERVICE ------------------- */
967
968 typedef struct Z_Close
969 {
970     Z_ReferenceId *referenceId;         /* OPTIONAL */
971     int *closeReason;
972 #define Z_Close_finished           0
973 #define Z_Close_shutdown           1
974 #define Z_Close_systemProblem      2
975 #define Z_Close_costLimit          3
976 #define Z_Close_resources          4
977 #define Z_Close_securityViolation  5
978 #define Z_Close_protocolError      6
979 #define Z_Close_lackOfActivity     7
980 #define Z_Close_peerAbort          8
981 #define Z_Close_unspecified        9
982     char *diagnosticInformation;          /* OPTIONAL */
983     Odr_oid *resourceReportFormat;        /* OPTIONAL */
984     Odr_external *resourceReport;         /* OPTIONAL */
985 #ifdef Z_95
986     Z_OtherInformation *otherInfo;        /* OPTIONAL */
987 #endif
988 } Z_Close;
989
990 /* ------------------------ SEGMENTATION -------------------- */
991
992 typedef struct Z_Segment
993 {
994     Z_ReferenceId *referenceId;   /* OPTIONAL */
995     int *numberOfRecordsReturned;
996     int num_segmentRecords;
997     Z_NamePlusRecord **segmentRecords;
998     Z_OtherInformation *otherInfo;  /* OPTIONAL */
999 } Z_Segment;
1000
1001
1002 /* ------------------------ APDU ---------------------------- */
1003
1004 typedef struct Z_APDU
1005 {    
1006     enum Z_APDU_which
1007     {
1008         Z_APDU_initRequest,
1009         Z_APDU_initResponse,
1010         Z_APDU_searchRequest,
1011         Z_APDU_searchResponse,
1012         Z_APDU_presentRequest,
1013         Z_APDU_presentResponse,
1014         Z_APDU_deleteResultSetRequest,
1015         Z_APDU_deleteResultSetResponse,
1016         Z_APDU_resourceControlRequest,
1017         Z_APDU_resourceControlResponse,
1018         Z_APDU_triggerResourceControlRequest,
1019         Z_APDU_scanRequest,
1020         Z_APDU_scanResponse,
1021         Z_APDU_segmentRequest,
1022         Z_APDU_close
1023     } which;
1024     union
1025     {
1026         Z_InitRequest  *initRequest;
1027         Z_InitResponse *initResponse;
1028         Z_SearchRequest *searchRequest;
1029         Z_SearchResponse *searchResponse;
1030         Z_PresentRequest *presentRequest;
1031         Z_PresentResponse *presentResponse;
1032         Z_DeleteResultSetRequest *deleteResultSetRequest;
1033         Z_DeleteResultSetResponse *deleteResultSetResponse;
1034         Z_ResourceControlRequest *resourceControlRequest;
1035         Z_ResourceControlResponse *resourceControlResponse;
1036         Z_TriggerResourceControlRequest *triggerResourceControlRequest;
1037         Z_ScanRequest *scanRequest;
1038         Z_ScanResponse *scanResponse;
1039         Z_Segment *segmentRequest;
1040         Z_Close *close;
1041     } u;
1042 } Z_APDU;
1043
1044 int z_APDU(ODR o, Z_APDU **p, int opt);
1045
1046 Z_InitRequest *zget_InitRequest(ODR o);
1047 Z_InitResponse *zget_InitResponse(ODR o);
1048 Z_SearchRequest *zget_SearchRequest(ODR o);
1049 Z_SearchResponse *zget_SearchResponse(ODR o);
1050 Z_PresentRequest *zget_PresentRequest(ODR o);
1051 Z_PresentResponse *zget_PresentResponse(ODR o);
1052 Z_DeleteResultSetRequest *zget_DeleteResultSetRequest(ODR o);
1053 Z_DeleteResultSetResponse *zget_DeleteResultSetResponse(ODR o);
1054 Z_ScanRequest *zget_ScanRequest(ODR o);
1055 Z_ScanResponse *zget_ScanResponse(ODR o);
1056 Z_TriggerResourceControlRequest *zget_TriggerResourceControlRequest(ODR o);
1057 Z_ResourceControlRequest *zget_ResourceControlRequest(ODR o);
1058 Z_ResourceControlResponse *zget_ResourceControlResponse(ODR o);
1059 Z_Close *zget_Close(ODR o);
1060 Z_APDU *zget_APDU(ODR o, enum Z_APDU_which which);
1061
1062 #include <prt-rsc.h>
1063 #include <prt-acc.h>
1064
1065 #endif