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.10 1995-05-29 08:11:34 quinn
28 * Moved oid from odr/asn to util.
30 * Revision 1.9 1995/05/22 11:31:25 quinn
33 * Revision 1.8 1995/05/17 08:41:35 quinn
34 * Added delete to proto & other little things.
35 * Relaying auth info to backend.
37 * Revision 1.7 1995/05/16 08:50:37 quinn
38 * License, documentation, and memory fixes
40 * Revision 1.6 1995/05/15 11:55:55 quinn
41 * Work on asynchronous activity.
43 * Revision 1.5 1995/04/17 11:28:18 quinn
46 * Revision 1.4 1995/04/10 10:22:47 quinn
49 * Revision 1.3 1995/03/30 12:18:09 quinn
52 * Revision 1.2 1995/03/30 10:26:48 quinn
53 * Added Term structure
55 * Revision 1.1 1995/03/30 09:39:42 quinn
56 * Moved .h files to include directory
58 * Revision 1.11 1995/03/30 09:08:44 quinn
59 * Added Resource control protocol
61 * Revision 1.10 1995/03/29 15:39:39 quinn
62 * Adding some resource control elements, and a null-check to getentbyoid
64 * Revision 1.9 1995/03/29 08:06:18 quinn
65 * Added a few v3 elements
67 * Revision 1.8 1995/03/22 10:12:49 quinn
68 * Added Z_PRES constants.
70 * Revision 1.7 1995/03/20 09:45:12 quinn
73 * Revision 1.5 1995/03/07 16:29:34 quinn
74 * Added authentication stuff.
76 * Revision 1.4 1995/03/07 10:13:00 quinn
77 * Added prototype for z_APDU()
79 * Revision 1.3 1995/02/14 11:54:23 quinn
82 * Revision 1.2 1995/02/09 15:51:40 quinn
85 * Revision 1.1 1995/02/06 16:44:48 quinn
86 * First hack at Z/SR protocol
97 /* ----------------- GLOBAL AUXILIARY DEFS ----------------*/
99 typedef Odr_oct Z_ReferenceId;
100 typedef char Z_DatabaseName;
101 typedef char Z_ResultSetId;
102 typedef Odr_oct Z_ResultsetId;
103 typedef Odr_external Z_UserInformationField;
105 typedef struct Z_InfoCategory
107 Odr_oid *categoryTypeId; /* OPTIONAL */
111 typedef struct Z_OtherInformationUnit
113 Z_InfoCategory *category; /* OPTIONAL */
116 Z_OtherInfo_characterInfo,
117 Z_OtherInfo_binaryInfo,
118 Z_OtherInfo_externallyDefinedInfo,
125 Odr_external *externallyDefinedInfo;
128 } Z_OtherInformationUnit;
130 typedef struct Z_OtherInformation
133 Z_OtherInformationUnit **list;
134 } Z_OtherInformation;
136 /* ----------------- INIT SERVICE ----------------*/
140 char *groupId; /* OPTIONAL */
141 char *userId; /* OPTIONAL */
142 char *password; /* OPTIONAL */
145 typedef struct Z_IdAuthentication
149 Z_IdAuthentication_open,
150 Z_IdAuthentication_idPass,
151 Z_IdAuthentication_anonymous,
152 Z_IdAuthentication_other
161 } Z_IdAuthentication;
163 #define Z_ProtocolVersion_1 0
164 #define Z_ProtocolVersion_2 1
165 #define Z_ProtocolVersion_3 2
167 #define Z_Options_search 0
168 #define Z_Options_present 1
169 #define Z_Options_delSet 2
170 #define Z_Options_resourceReport 3
171 #define Z_Options_triggerResourceCtrl 4
172 #define Z_Options_resourceCtrl 5
173 #define Z_Options_accessCtrl 6
174 #define Z_Options_scan 7
175 #define Z_Options_sort 8
176 #define Z_Options_reserved 9
177 #define Z_Options_extendedServices 10
178 #define Z_Options_level_1Segmentation 11
179 #define Z_Options_level_2Segmentation 12
180 #define Z_Options_concurrentOperations 13
181 #define Z_Options_namedResultSets 14
183 typedef struct Z_InitRequest
185 Z_ReferenceId *referenceId; /* OPTIONAL */
186 Odr_bitmask *options;
187 Odr_bitmask *protocolVersion;
188 int *preferredMessageSize;
189 int *maximumRecordSize;
190 Z_IdAuthentication* idAuthentication; /* OPTIONAL */
191 char *implementationId; /* OPTIONAL */
192 char *implementationName; /* OPTIONAL */
193 char *implementationVersion; /* OPTIONAL */
194 Z_UserInformationField *userInformationField; /* OPTIONAL */
197 typedef struct Z_InitResponse
199 Z_ReferenceId *referenceId; /* OPTIONAL */
200 Odr_bitmask *options;
201 Odr_bitmask *protocolVersion;
202 int *preferredMessageSize;
203 int *maximumRecordSize;
205 char *implementationId; /* OPTIONAL */
206 char *implementationName; /* OPTIONAL */
207 char *implementationVersion; /* OPTIONAL */
208 Z_UserInformationField *userInformationField; /* OPTIONAL */
211 typedef struct Z_NSRAuthentication
216 } Z_NSRAuthentication;
218 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt);
220 int z_StrAuthentication(ODR o, char **p, int opt);
223 /* ------------------ RESOURCE CONTROL ----------------*/
225 typedef struct Z_TriggerResourceControlRequest
227 Z_ReferenceId *referenceId; /* OPTIONAL */
228 int *requestedAction;
229 #define Z_TriggerResourceCtrl_resourceReport 1
230 #define Z_TriggerResourceCtrl_resourceControl 2
231 #define Z_TriggerResourceCtrl_cancel 3
232 Odr_oid *prefResourceReportFormat; /* OPTIONAL */
233 bool_t *resultSetWanted; /* OPTIONAL */
234 } Z_TriggerResourceControlRequest;
236 typedef struct Z_ResourceControlRequest
238 Z_ReferenceId *referenceId; /* OPTIONAL */
239 bool_t *suspendedFlag; /* OPTIONAL */
240 Odr_external *resourceReport; /* OPTIONAL */
241 int *partialResultsAvailable; /* OPTIONAL */
242 #define Z_ResourceControlRequest_subset 1
243 #define Z_ResourceControlRequest_interim 2
244 #define Z_ResourceControlRequest_none 3
245 bool_t *responseRequired;
246 bool_t *triggeredRequestFlag; /* OPTIONAL */
247 } Z_ResourceControlRequest;
249 typedef struct Z_ResourceControlResponse
251 Z_ReferenceId *referenceId; /* OPTIONAL */
252 bool_t *continueFlag;
253 bool_t *resultSetWanted; /* OPTIONAL */
254 } Z_ResourceControlResponse;
256 /* ------------------ SEARCH SERVICE ----------------*/
258 typedef Odr_oid Z_PreferredRecordSyntax;
260 typedef struct Z_DatabaseSpecificUnit
263 char *elementSetName;
264 } Z_DatabaseSpecificUnit;
266 typedef struct Z_DatabaseSpecific
269 Z_DatabaseSpecificUnit **elements;
270 } Z_DatabaseSpecific;
272 typedef struct Z_ElementSetNames
275 #define Z_ElementSetNames_generic 0
276 #define Z_ElementSetNames_databaseSpecific 1
280 Z_DatabaseSpecific *databaseSpecific;
284 /* ---------------------- RPN QUERY --------------------------- */
286 typedef struct Z_AttributeElement
290 } Z_AttributeElement;
295 typedef struct Z_Term
301 Z_Term_characterString,
305 Z_Term_integerAndUnit,
310 Odr_oct *general; /* this is required for v2 */
312 char *characterString;
315 Odr_external *external;
316 /* Z_IntUnit *integerAndUnit; */
323 typedef struct Z_AttributesPlusTerm
326 Z_AttributeElement **attributeList;
332 } Z_AttributesPlusTerm;
334 typedef struct Z_ProximityOperator
336 bool_t *exclusion; /* OPTIONAL */
340 #define Z_Prox_lessThan 1
341 #define Z_Prox_lessThanOrEqual 2
342 #define Z_Prox_equal 3
343 #define Z_Prox_greaterThanOrEqual 4
344 #define Z_Prox_greaterThan 5
345 #define Z_Prox_notEqual 6
351 int *proximityUnitCode;
352 #define Z_ProxUnit_character 1
353 #define Z_ProxUnit_word 2
354 #define Z_ProxUnit_sentence 3
355 #define Z_ProxUnit_paragraph 4
356 #define Z_ProxUnit_section 5
357 #define Z_ProxUnit_chapter 6
358 #define Z_ProxUnit_document 7
359 #define Z_ProxUnit_element 8
360 #define Z_ProxUnit_subelement 9
361 #define Z_ProxUnit_elementType 10
362 #define Z_ProxUnit_byte 11 /* v3 only */
363 } Z_ProximityOperator;
365 typedef struct Z_Operator
376 Odr_null *and; /* these guys are nulls. */
379 Z_ProximityOperator *prox;
383 typedef struct Z_Operand
386 #define Z_Operand_APT 0
387 #define Z_Operand_resultSetId 1
390 Z_AttributesPlusTerm *attributesPlusTerm;
391 Z_ResultSetId *resultSetId;
395 typedef struct Z_Complex
397 struct Z_RPNStructure *s1;
398 struct Z_RPNStructure *s2;
399 Z_Operator *operator;
402 typedef struct Z_RPNStructure
405 #define Z_RPNStructure_simple 0
406 #define Z_RPNStructure_complex 1
414 typedef struct Z_RPNQuery
416 Odr_oid *attributeSetId;
417 Z_RPNStructure *RPNStructure;
420 /* -------------------------- SEARCHREQUEST -------------------------- */
422 typedef struct Z_Query
425 #define Z_Query_type_1 1
426 #define Z_Query_type_2 2
434 typedef struct Z_SearchRequest
436 Z_ReferenceId *referenceId; /* OPTIONAL */
437 int *smallSetUpperBound;
438 int *largeSetLowerBound;
439 int *mediumSetPresentNumber;
440 bool_t *replaceIndicator;
442 int num_databaseNames;
443 char **databaseNames;
444 Z_ElementSetNames *smallSetElementSetNames; /* OPTIONAL */
445 Z_ElementSetNames *mediumSetElementSetNames; /* OPTIONAL */
446 Z_PreferredRecordSyntax *preferredRecordSyntax; /* OPTIONAL */
450 /* ------------------------ RECORD -------------------------- */
452 typedef Odr_external Z_DatabaseRecord;
454 typedef struct Z_DiagRec
456 Odr_oid *diagnosticSetId;
461 typedef struct Z_NamePlusRecord
463 char *databaseName; /* OPTIONAL */
465 #define Z_NamePlusRecord_databaseRecord 0
466 #define Z_NamePlusRecord_surrogateDiagnostic 1
469 Z_DatabaseRecord *databaseRecord;
470 Z_DiagRec *surrogateDiagnostic;
474 typedef struct Z_NamePlusRecordList
477 Z_NamePlusRecord **records;
478 } Z_NamePlusRecordList;
480 typedef struct Z_Records
483 #define Z_Records_DBOSD 0
484 #define Z_Records_NSD 1
487 Z_NamePlusRecordList *databaseOrSurDiagnostics;
488 Z_DiagRec *nonSurrogateDiagnostic;
492 /* ------------------ ACCESS CTRL SERVICE ----------------*/
494 typedef struct Z_AccessControlRequest
496 Z_ReferenceId *referenceId; /* OPTIONAL */
499 Z_AccessRequest_simpleForm,
500 Z_AccessRequest_externallyDefined
505 Odr_external *externallyDefined;
508 Z_OtherInformation *otherInfo; /* OPTIONAL */
510 } Z_AccessControlRequest;
512 typedef struct Z_AccessControlResponse
514 Z_ReferenceId *referenceId; /* OPTIONAL */
517 Z_AccessResponse_simpleForm,
518 Z_AccessResponse_externallyDefined
523 Odr_external *externallyDefined;
525 Z_DiagRec *diagnostic; /* OPTIONAL */
527 Z_OtherInformation *otherInfo; /* OPTIONAL */
529 } Z_AccessControlResponse;
531 /* ------------------------ SCAN SERVICE -------------------- */
533 typedef struct Z_AttributeList
536 Z_AttributeElement **attributes;
539 typedef struct Z_AlternativeTerm
542 Z_AttributesPlusTerm **terms;
545 typedef struct Z_OccurrenceByAttributes
547 Z_AttributeList *attributes;
559 /* Z_ByDatabase *byDatabase; */
562 } Z_OccurrenceByAttributes;
564 typedef struct Z_TermInfo
567 Z_AttributeList *suggestedAttributes; /* OPTIONAL */
568 Z_AlternativeTerm *alternativeTerm; /* OPTIONAL */
569 int *globalOccurrences; /* OPTIONAL */
570 Z_OccurrenceByAttributes *byAttributes; /* OPTIONAL */
573 typedef struct Z_Entry
578 Z_Entry_surrogateDiagnostic
582 Z_TermInfo *termInfo;
583 Z_DiagRec *surrogateDiagnostic;
587 typedef struct Z_Entries
593 typedef struct Z_DiagRecs
596 Z_DiagRec **diagRecs;
599 typedef struct Z_ListEntries
603 Z_ListEntries_entries,
604 Z_ListEntries_nonSurrogateDiagnostics
609 Z_DiagRecs *nonSurrogateDiagnostics;
613 typedef struct Z_ScanRequest
615 Z_ReferenceId *referenceId; /* OPTIONAL */
616 int num_databaseNames;
617 char **databaseNames;
618 Odr_oid *attributeSet; /* OPTIONAL */
620 Z_AttributesPlusTerm *termListAndStartPoint;
621 int *stepSize; /* OPTIONAL */
622 int *numberOfTermsRequested;
623 int *preferredPositionInResponse; /* OPTIONAL */
626 typedef struct Z_ScanResponse
628 Z_ReferenceId *referenceId; /* OPTIONAL */
629 int *stepSize; /* OPTIONAL */
631 #define Z_Scan_success 0
632 #define Z_Scan_partial_1 1
633 #define Z_Scan_partial_2 2
634 #define Z_Scan_partial_3 3
635 #define Z_Scan_partial_4 4
636 #define Z_Scan_partial_5 5
637 #define Z_Scan_failure 6
638 int *numberOfEntriesReturned;
639 int *positionOfTerm; /* OPTIONAL */
640 Z_ListEntries *entries; /* OPTIONAL */
641 Odr_oid *attributeSet; /* OPTIONAL */
644 /* ------------------------ SEARCHRESPONSE ------------------ */
646 typedef struct Z_SearchResponse
648 Z_ReferenceId *referenceId; /* OPTIONAL */
650 int *numberOfRecordsReturned;
651 int *nextResultSetPosition;
652 bool_t *searchStatus;
653 int *resultSetStatus; /* OPTIONAL */
654 #define Z_RES_SUBSET 1
655 #define Z_RES_INTERIM 2
657 int *presentStatus; /* OPTIONAL */
658 #define Z_PRES_SUCCESS 0
659 #define Z_PRES_PARTIAL_1 1
660 #define Z_PRES_PARTIAL_2 2
661 #define Z_PRES_PARTIAL_3 3
662 #define Z_PRES_PARTIAL_4 4
663 #define Z_PRES_FAILURE 5
664 Z_Records *records; /* OPTIONAL */
667 /* ------------------------- PRESENT SERVICE -----------------*/
669 typedef struct Z_PresentRequest
671 Z_ReferenceId *referenceId; /* OPTIONAL */
672 Z_ResultSetId *resultSetId;
673 int *resultSetStartPoint;
674 int *numberOfRecordsRequested;
675 Z_ElementSetNames *elementSetNames; /* OPTIONAL */
676 Z_PreferredRecordSyntax *preferredRecordSyntax; /* OPTIONAL */
679 typedef struct Z_PresentResponse
681 Z_ReferenceId *referenceId; /* OPTIONAL */
682 int *numberOfRecordsReturned;
683 int *nextResultSetPosition;
688 /* ------------------------ DELETE -------------------------- */
690 #define Z_DeleteStatus_success 0
691 #define Z_DeleteStatus_resultSetDidNotExist 1
692 #define Z_DeleteStatus_previouslyDeletedByTarget 2
693 #define Z_DeleteStatus_systemProblemAtTarget 3
694 #define Z_DeleteStatus_accessNotAllowed 4
695 #define Z_DeleteStatus_resourceControlAtOrigin 5
696 #define Z_DeleteStatus_resourceControlAtTarget 6
697 #define Z_DeleteStatus_bulkDeleteNotSupported 7
698 #define Z_DeleteStatus_notAllRsltSetsDeletedOnBulkDlte 8
699 #define Z_DeleteStatus_notAllRequestedResultSetsDeleted 9
700 #define Z_DeleteStatus_resultSetInUse 10
702 typedef struct Z_ListStatus
708 typedef struct Z_DeleteResultSetRequest
710 Z_ReferenceId *referenceId; /* OPTIONAL */
712 #define Z_DeleteRequest_list 0
713 #define Z_DeleteRequest_all 1
715 Z_ResultSetId **resultSetList; /* OPTIONAL */
717 Z_OtherInformation *otherInfo;
719 } Z_DeleteResultSetRequest;
721 typedef struct Z_DeleteResultSetResponse
723 Z_ReferenceId *referenceId; /* OPTIONAL */
724 int *deleteOperationStatus;
726 Z_ListStatus *deleteListStatuses; /* OPTIONAL */
727 int *numberNotDeleted; /* OPTIONAL */
728 int num_bulkStatuses;
729 Z_ListStatus *bulkStatuses; /* OPTIONAL */
730 char *deleteMessage; /* OPTIONAL */
732 Z_OtherInformation *otherInfo;
734 } Z_DeleteResultSetResponse;
736 /* ------------------------ APDU ---------------------------- */
738 typedef struct Z_APDU
744 Z_APDU_searchRequest,
745 Z_APDU_searchResponse,
746 Z_APDU_presentRequest,
747 Z_APDU_presentResponse,
748 Z_APDU_deleteResultSetRequest,
749 Z_APDU_deleteResultSetResponse,
750 Z_APDU_resourceControlRequest,
751 Z_APDU_resourceControlResponse,
752 Z_APDU_triggerResourceControlRequest,
758 Z_InitRequest *initRequest;
759 Z_InitResponse *initResponse;
760 Z_SearchRequest *searchRequest;
761 Z_SearchResponse *searchResponse;
762 Z_PresentRequest *presentRequest;
763 Z_PresentResponse *presentResponse;
764 Z_DeleteResultSetRequest *deleteResultSetRequest;
765 Z_DeleteResultSetResponse *deleteResultSetResponse;
766 Z_ResourceControlRequest *resourceControlRequest;
767 Z_ResourceControlResponse *resourceControlResponse;
768 Z_TriggerResourceControlRequest *triggerResourceControlRequest;
769 Z_ScanRequest *scanRequest;
770 Z_ScanResponse *scanResponse;
774 int z_APDU(ODR o, Z_APDU **p, int opt);
776 Z_InitRequest *zget_InitRequest(ODR o);
777 Z_InitResponse *zget_InitResponse(ODR o);
778 Z_SearchRequest *zget_SearchRequest(ODR o);
779 Z_SearchResponse *zget_SearchResponse(ODR o);
780 Z_PresentRequest *zget_PresentRequest(ODR o);
781 Z_PresentResponse *zget_PresentResponse(ODR o);
782 Z_DeleteResultSetRequest *zget_DeleteResultSetRequest(ODR o);
783 Z_DeleteResultSetResponse *zget_DeleteResultSetResponse(ODR o);
784 Z_ScanRequest *zget_ScanRequest(ODR o);
785 Z_ScanResponse *zget_ScanResponse(ODR o);
786 Z_TriggerResourceControlRequest *zget_TriggerResourceControlRequest(ODR o);
787 Z_ResourceControlRequest *zget_ResourceControlRequest(ODR o);
788 Z_ResourceControlResponse *zget_ResourceControlResponse(ODR o);
789 Z_APDU *zget_APDU(ODR o, enum Z_APDU_which which);