2 * Copyright (c) 1995, Index Data.
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,
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.
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.
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
27 * Revision 1.7 1995-05-16 08:50:37 quinn
28 * License, documentation, and memory fixes
30 * Revision 1.6 1995/05/15 11:55:55 quinn
31 * Work on asynchronous activity.
33 * Revision 1.5 1995/04/17 11:28:18 quinn
36 * Revision 1.4 1995/04/10 10:22:47 quinn
39 * Revision 1.3 1995/03/30 12:18:09 quinn
42 * Revision 1.2 1995/03/30 10:26:48 quinn
43 * Added Term structure
45 * Revision 1.1 1995/03/30 09:39:42 quinn
46 * Moved .h files to include directory
48 * Revision 1.11 1995/03/30 09:08:44 quinn
49 * Added Resource control protocol
51 * Revision 1.10 1995/03/29 15:39:39 quinn
52 * Adding some resource control elements, and a null-check to getentbyoid
54 * Revision 1.9 1995/03/29 08:06:18 quinn
55 * Added a few v3 elements
57 * Revision 1.8 1995/03/22 10:12:49 quinn
58 * Added Z_PRES constants.
60 * Revision 1.7 1995/03/20 09:45:12 quinn
63 * Revision 1.5 1995/03/07 16:29:34 quinn
64 * Added authentication stuff.
66 * Revision 1.4 1995/03/07 10:13:00 quinn
67 * Added prototype for z_APDU()
69 * Revision 1.3 1995/02/14 11:54:23 quinn
72 * Revision 1.2 1995/02/09 15:51:40 quinn
75 * Revision 1.1 1995/02/06 16:44:48 quinn
76 * First hack at Z/SR protocol
86 /* ----------------- GLOBAL AUXILIARY DEFS ----------------*/
88 typedef Odr_oct Z_ReferenceId;
89 typedef char Z_DatabaseName;
90 typedef char Z_ResultSetId;
91 typedef Odr_oct Z_ResultsetId;
92 typedef Odr_external Z_UserInformationField;
94 /* ----------------- INIT SERVICE ----------------*/
98 char *groupId; /* OPTIONAL */
99 char *userId; /* OPTIONAL */
100 char *password; /* OPTIONAL */
103 typedef struct Z_IdAuthentication
107 Z_IdAuthentication_open,
108 Z_IdAuthentication_idPass,
109 Z_IdAuthentication_anonymous,
110 Z_IdAuthentication_other
116 void *anonymous; /* NULL */
119 } Z_IdAuthentication;
121 #define Z_ProtocolVersion_1 0
122 #define Z_ProtocolVersion_2 1
123 #define Z_ProtocolVersion_3 2
125 #define Z_Options_search 0
126 #define Z_Options_present 1
127 #define Z_Options_delSet 2
128 #define Z_Options_resourceReport 3
129 #define Z_Options_triggerResourceCtrl 4
130 #define Z_Options_resourceCtrl 5
131 #define Z_Options_accessCtrl 6
132 #define Z_Options_scan 7
133 #define Z_Options_sort 8
134 #define Z_Options_reserved 9
135 #define Z_Options_extendedServices 10
136 #define Z_Options_level_1Segmentation 11
137 #define Z_Options_level_2Segmentation 12
138 #define Z_Options_concurrentOperations 13
139 #define Z_Options_namedResultSets 14
141 typedef struct Z_InitRequest
143 Z_ReferenceId *referenceId; /* OPTIONAL */
144 Odr_bitmask *options;
145 Odr_bitmask *protocolVersion;
146 int *preferredMessageSize;
147 int *maximumRecordSize;
148 Z_IdAuthentication* idAuthentication; /* OPTIONAL */
149 char *implementationId; /* OPTIONAL */
150 char *implementationName; /* OPTIONAL */
151 char *implementationVersion; /* OPTIONAL */
152 Z_UserInformationField *userInformationField; /* OPTIONAL */
155 typedef struct Z_InitResponse
157 Z_ReferenceId *referenceId; /* OPTIONAL */
158 Odr_bitmask *options;
159 Odr_bitmask *protocolVersion;
160 int *preferredMessageSize;
161 int *maximumRecordSize;
163 char *implementationId; /* OPTIONAL */
164 char *implementationName; /* OPTIONAL */
165 char *implementationVersion; /* OPTIONAL */
166 Z_UserInformationField *userInformationField; /* OPTIONAL */
169 typedef struct Z_NSRAuthentication
174 } Z_NSRAuthentication;
176 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt);
178 int z_StrAuthentication(ODR o, char **p, int opt);
181 /* ------------------ RESOURCE CONTROL ----------------*/
183 typedef struct Z_TriggerResourceControlRequest
185 Z_ReferenceId *referenceId; /* OPTIONAL */
186 int *requestedAction;
187 #define Z_TriggerResourceCtrl_resourceReport 1
188 #define Z_TriggerResourceCtrl_resourceControl 2
189 #define Z_TriggerResourceCtrl_cancel 3
190 Odr_oid *prefResourceReportFormat; /* OPTIONAL */
191 bool_t *resultSetWanted; /* OPTIONAL */
192 } Z_TriggerResourceControlRequest;
194 typedef struct Z_ResourceControlRequest
196 Z_ReferenceId *referenceId; /* OPTIONAL */
197 bool_t *suspendedFlag; /* OPTIONAL */
198 Odr_external *resourceReport; /* OPTIONAL */
199 int *partialResultsAvailable; /* OPTIONAL */
200 #define Z_ResourceControlRequest_subset 1
201 #define Z_ResourceControlRequest_interim 2
202 #define Z_ResourceControlRequest_none 3
203 bool_t *responseRequired;
204 bool_t *triggeredRequestFlag; /* OPTIONAL */
205 } Z_ResourceControlRequest;
207 typedef struct Z_ResourceControlResponse
209 Z_ReferenceId *referenceId; /* OPTIONAL */
210 bool_t *continueFlag;
211 bool_t *resultSetWanted; /* OPTIONAL */
212 } Z_ResourceControlResponse;
214 /* ------------------ SEARCH SERVICE ----------------*/
216 typedef Odr_oid Z_PreferredRecordSyntax;
218 typedef struct Z_DatabaseSpecificUnit
221 char *elementSetName;
222 } Z_DatabaseSpecificUnit;
224 typedef struct Z_DatabaseSpecific
227 Z_DatabaseSpecificUnit **elements;
228 } Z_DatabaseSpecific;
230 typedef struct Z_ElementSetNames
233 #define Z_ElementSetNames_generic 0
234 #define Z_ElementSetNames_databaseSpecific 1
238 Z_DatabaseSpecific *databaseSpecific;
242 /* ---------------------- RPN QUERY --------------------------- */
244 typedef struct Z_AttributeElement
248 } Z_AttributeElement;
253 typedef struct Z_Term
259 Z_Term_characterString,
263 Z_Term_integerAndUnit,
268 Odr_oct *general; /* this is required for v2 */
270 char *characterString;
273 Odr_external *external;
274 /* Z_IntUnit *integerAndUnit; */
281 typedef struct Z_AttributesPlusTerm
284 Z_AttributeElement **attributeList;
290 } Z_AttributesPlusTerm;
292 typedef struct Z_ProximityOperator
294 bool_t *exclusion; /* OPTIONAL */
300 Z_ProximityOperator_known,
301 Z_ProximityOperator_private
308 } Z_ProximityOperator;
310 typedef struct Z_Operator
321 void *and; /* these guys are nulls. */
324 Z_ProximityOperator *proximity;
328 typedef struct Z_Operand
331 #define Z_Operand_APT 0
332 #define Z_Operand_resultSetId 1
335 Z_AttributesPlusTerm *attributesPlusTerm;
336 Z_ResultSetId *resultSetId;
340 typedef struct Z_Complex
342 struct Z_RPNStructure *s1;
343 struct Z_RPNStructure *s2;
344 Z_Operator *operator;
347 typedef struct Z_RPNStructure
350 #define Z_RPNStructure_simple 0
351 #define Z_RPNStructure_complex 1
359 typedef struct Z_RPNQuery
361 Odr_oid *attributeSetId;
362 Z_RPNStructure *RPNStructure;
365 /* -------------------------- SEARCHREQUEST -------------------------- */
367 typedef struct Z_Query
370 #define Z_Query_type_1 1
371 #define Z_Query_type_2 2
379 typedef struct Z_SearchRequest
381 Z_ReferenceId *referenceId; /* OPTIONAL */
382 int *smallSetUpperBound;
383 int *largeSetLowerBound;
384 int *mediumSetPresentNumber;
385 bool_t *replaceIndicator;
387 int num_databaseNames;
388 char **databaseNames;
389 Z_ElementSetNames *smallSetElementSetNames; /* OPTIONAL */
390 Z_ElementSetNames *mediumSetElementSetNames; /* OPTIONAL */
391 Z_PreferredRecordSyntax *preferredRecordSyntax; /* OPTIONAL */
395 /* ------------------------ RECORD -------------------------- */
397 typedef Odr_external Z_DatabaseRecord;
399 typedef struct Z_DiagRec
401 Odr_oid *diagnosticSetId;
406 typedef struct Z_NamePlusRecord
408 char *databaseName; /* OPTIONAL */
410 #define Z_NamePlusRecord_databaseRecord 0
411 #define Z_NamePlusRecord_surrogateDiagnostic 1
414 Z_DatabaseRecord *databaseRecord;
415 Z_DiagRec *surrogateDiagnostic;
419 typedef struct Z_NamePlusRecordList
422 Z_NamePlusRecord **records;
423 } Z_NamePlusRecordList;
425 typedef struct Z_Records
428 #define Z_Records_DBOSD 0
429 #define Z_Records_NSD 1
432 Z_NamePlusRecordList *databaseOrSurDiagnostics;
433 Z_DiagRec *nonSurrogateDiagnostic;
437 /* ------------------------ SCAN SERVICE -------------------- */
439 typedef struct Z_AttributeList
442 Z_AttributeElement **attributes;
445 typedef struct Z_AlternativeTerm
448 Z_AttributesPlusTerm **terms;
451 typedef struct Z_OccurrenceByAttributes
453 Z_AttributeList *attributes;
465 /* Z_ByDatabase *byDatabase; */
468 } Z_OccurrenceByAttributes;
470 typedef struct Z_TermInfo
473 Z_AttributeList *suggestedAttributes; /* OPTIONAL */
474 Z_AlternativeTerm *alternativeTerm; /* OPTIONAL */
475 int *globalOccurrences; /* OPTIONAL */
476 Z_OccurrenceByAttributes *byAttributes; /* OPTIONAL */
479 typedef struct Z_Entry
484 Z_Entry_surrogateDiagnostic
488 Z_TermInfo *termInfo;
489 Z_DiagRec *surrogateDiagnostic;
493 typedef struct Z_Entries
499 typedef struct Z_DiagRecs
502 Z_DiagRec **diagRecs;
505 typedef struct Z_ListEntries
509 Z_ListEntries_entries,
510 Z_ListEntries_nonSurrogateDiagnostics
515 Z_DiagRecs *nonSurrogateDiagnostics;
519 typedef struct Z_ScanRequest
521 Z_ReferenceId *referenceId; /* OPTIONAL */
522 int num_databaseNames;
523 char **databaseNames;
524 Odr_oid *attributeSet; /* OPTIONAL */
526 Z_AttributesPlusTerm *termListAndStartPoint;
527 int *stepSize; /* OPTIONAL */
528 int *numberOfTermsRequested;
529 int *preferredPositionInResponse; /* OPTIONAL */
532 typedef struct Z_ScanResponse
534 Z_ReferenceId *referenceId; /* OPTIONAL */
535 int *stepSize; /* OPTIONAL */
537 #define Z_Scan_success 0
538 #define Z_Scan_partial_1 1
539 #define Z_Scan_partial_2 2
540 #define Z_Scan_partial_3 3
541 #define Z_Scan_partial_4 4
542 #define Z_Scan_partial_5 5
543 #define Z_Scan_failure 6
544 int *numberOfEntriesReturned;
545 int *positionOfTerm; /* OPTIONAL */
546 Z_ListEntries *entries; /* OPTIONAL */
547 Odr_oid *attributeSet; /* OPTIONAL */
550 /* ------------------------ SEARCHRESPONSE ------------------ */
552 typedef struct Z_SearchResponse
554 Z_ReferenceId *referenceId; /* OPTIONAL */
556 int *numberOfRecordsReturned;
557 int *nextResultSetPosition;
558 bool_t *searchStatus;
559 int *resultSetStatus; /* OPTIONAL */
560 #define Z_RES_SUBSET 1
561 #define Z_RES_INTERIM 2
563 int *presentStatus; /* OPTIONAL */
564 #define Z_PRES_SUCCESS 0
565 #define Z_PRES_PARTIAL_1 1
566 #define Z_PRES_PARTIAL_2 2
567 #define Z_PRES_PARTIAL_3 3
568 #define Z_PRES_PARTIAL_4 4
569 #define Z_PRES_FAILURE 5
570 Z_Records *records; /* OPTIONAL */
573 /* ------------------------- PRESENT SERVICE -----------------*/
575 typedef struct Z_PresentRequest
577 Z_ReferenceId *referenceId; /* OPTIONAL */
578 Z_ResultSetId *resultSetId;
579 int *resultSetStartPoint;
580 int *numberOfRecordsRequested;
581 Z_ElementSetNames *elementSetNames; /* OPTIONAL */
582 Z_PreferredRecordSyntax *preferredRecordSyntax; /* OPTIONAL */
585 typedef struct Z_PresentResponse
587 Z_ReferenceId *referenceId; /* OPTIONAL */
588 int *numberOfRecordsReturned;
589 int *nextResultSetPosition;
594 /* ------------------------ DELETE -------------------------- */
596 typedef struct Z_ListStatus
602 typedef struct Z_DeleteResultSetRequest
604 Z_ReferenceId *referenceId; /* OPTIONAL */
606 #define Z_DeleteRequest_list 0
607 #define Z_DeleteRequest_all 1
609 Z_ResultSetId *resultSetList; /* OPTIONAL */
610 } Z_DeleteResultSetRequest;
612 typedef enum Z_DeleteSetStatus
614 Z_Delete_success = 0,
615 Z_Delete_resultSetDidNotExist,
616 Z_Delete_previouslyDeletedByTarget,
617 Z_Delete_systemProblemAtTarget,
618 Z_Delete_accessNotAllowed,
619 Z_Delete_resourceControlAtOrigin,
620 Z_Delete_resourceControlAtTarget,
621 Z_Delete_bulkDeleteNotSupported,
622 Z_Delete_notAllRsltSetsDeletedOnBulkDlte,
623 Z_Delete_notAllRequestedResultSetsDeleted,
624 Z_Delete_resultSetInUse
627 typedef struct Z_DeleteResultSetResponse
629 Z_ReferenceId *referenceId; /* OPTIONAL */
630 int *deleteOperationStatus;
632 Z_ListStatus *deleteListStatuses; /* OPTIONAL */
633 int *numberNotDeleted; /* OPTIONAL */
634 int num_bulkstatuses;
635 Z_ListStatus *bulkStatuses; /* OPTIONAL */
636 char *deleteMessage; /* OPTIONAL */
637 } Z_DeleteResultSetResponse;
639 /* ------------------------ APDU ---------------------------- */
641 typedef struct Z_APDU
647 Z_APDU_searchRequest,
648 Z_APDU_searchResponse,
649 Z_APDU_presentRequest,
650 Z_APDU_presentResponse,
651 Z_APDU_resourceControlRequest,
652 Z_APDU_resourceControlResponse,
653 Z_APDU_triggerResourceControlRequest,
659 Z_InitRequest *initRequest;
660 Z_InitResponse *initResponse;
661 Z_SearchRequest *searchRequest;
662 Z_SearchResponse *searchResponse;
663 Z_PresentRequest *presentRequest;
664 Z_PresentResponse *presentResponse;
665 Z_ResourceControlRequest *resourceControlRequest;
666 Z_ResourceControlResponse *resourceControlResponse;
667 Z_TriggerResourceControlRequest *triggerResourceControlRequest;
668 Z_ScanRequest *scanRequest;
669 Z_ScanResponse *scanResponse;
673 int z_APDU(ODR o, Z_APDU **p, int opt);