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