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