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.14 1995-06-07 14:42:34 quinn
30 * Revision 1.13 1995/06/07 14:36:47 quinn
33 * Revision 1.12 1995/06/05 10:53:13 quinn
36 * Revision 1.11 1995/06/02 09:49:47 quinn
39 * Revision 1.10 1995/05/29 08:11:34 quinn
40 * Moved oid from odr/asn to util.
42 * Revision 1.9 1995/05/22 11:31:25 quinn
45 * Revision 1.8 1995/05/17 08:41:35 quinn
46 * Added delete to proto & other little things.
47 * Relaying auth info to backend.
49 * Revision 1.7 1995/05/16 08:50:37 quinn
50 * License, documentation, and memory fixes
52 * Revision 1.6 1995/05/15 11:55:55 quinn
53 * Work on asynchronous activity.
55 * Revision 1.5 1995/04/17 11:28:18 quinn
58 * Revision 1.4 1995/04/10 10:22:47 quinn
61 * Revision 1.3 1995/03/30 12:18:09 quinn
64 * Revision 1.2 1995/03/30 10:26:48 quinn
65 * Added Term structure
67 * Revision 1.1 1995/03/30 09:39:42 quinn
68 * Moved .h files to include directory
70 * Revision 1.11 1995/03/30 09:08:44 quinn
71 * Added Resource control protocol
73 * Revision 1.10 1995/03/29 15:39:39 quinn
74 * Adding some resource control elements, and a null-check to getentbyoid
76 * Revision 1.9 1995/03/29 08:06:18 quinn
77 * Added a few v3 elements
79 * Revision 1.8 1995/03/22 10:12:49 quinn
80 * Added Z_PRES constants.
82 * Revision 1.7 1995/03/20 09:45:12 quinn
85 * Revision 1.5 1995/03/07 16:29:34 quinn
86 * Added authentication stuff.
88 * Revision 1.4 1995/03/07 10:13:00 quinn
89 * Added prototype for z_APDU()
91 * Revision 1.3 1995/02/14 11:54:23 quinn
94 * Revision 1.2 1995/02/09 15:51:40 quinn
97 * Revision 1.1 1995/02/06 16:44:48 quinn
98 * First hack at Z/SR protocol
109 /* ----------------- GLOBAL AUXILIARY DEFS ----------------*/
111 typedef Odr_oct Z_ReferenceId;
112 typedef char Z_DatabaseName;
113 typedef char Z_ResultSetId;
114 typedef Odr_oct Z_ResultsetId;
115 typedef Odr_external Z_UserInformationField;
117 typedef struct Z_InfoCategory
119 Odr_oid *categoryTypeId; /* OPTIONAL */
123 typedef struct Z_OtherInformationUnit
125 Z_InfoCategory *category; /* OPTIONAL */
128 Z_OtherInfo_characterInfo,
129 Z_OtherInfo_binaryInfo,
130 Z_OtherInfo_externallyDefinedInfo,
137 Odr_external *externallyDefinedInfo;
140 } Z_OtherInformationUnit;
142 typedef struct Z_OtherInformation
145 Z_OtherInformationUnit **list;
146 } Z_OtherInformation;
148 typedef struct Z_StringOrNumeric
152 Z_StringOrNumeric_string,
153 Z_StringOrNumeric_numeric
162 typedef struct Z_Unit
164 char *unitSystem; /* OPTIONAL */
165 Z_StringOrNumeric *unitType; /* OPTIONAL */
166 Z_StringOrNumeric *unit; /* OPTIONAL */
167 int *scaleFactor; /* OPTIONAL */
170 typedef struct Z_IntUnit
176 /* ----------------- INIT SERVICE ----------------*/
180 char *groupId; /* OPTIONAL */
181 char *userId; /* OPTIONAL */
182 char *password; /* OPTIONAL */
185 typedef struct Z_IdAuthentication
189 Z_IdAuthentication_open,
190 Z_IdAuthentication_idPass,
191 Z_IdAuthentication_anonymous,
192 Z_IdAuthentication_other
201 } Z_IdAuthentication;
203 #define Z_ProtocolVersion_1 0
204 #define Z_ProtocolVersion_2 1
205 #define Z_ProtocolVersion_3 2
207 #define Z_Options_search 0
208 #define Z_Options_present 1
209 #define Z_Options_delSet 2
210 #define Z_Options_resourceReport 3
211 #define Z_Options_triggerResourceCtrl 4
212 #define Z_Options_resourceCtrl 5
213 #define Z_Options_accessCtrl 6
214 #define Z_Options_scan 7
215 #define Z_Options_sort 8
216 #define Z_Options_reserved 9
217 #define Z_Options_extendedServices 10
218 #define Z_Options_level_1Segmentation 11
219 #define Z_Options_level_2Segmentation 12
220 #define Z_Options_concurrentOperations 13
221 #define Z_Options_namedResultSets 14
223 typedef struct Z_InitRequest
225 Z_ReferenceId *referenceId; /* OPTIONAL */
226 Odr_bitmask *options;
227 Odr_bitmask *protocolVersion;
228 int *preferredMessageSize;
229 int *maximumRecordSize;
230 Z_IdAuthentication* idAuthentication; /* OPTIONAL */
231 char *implementationId; /* OPTIONAL */
232 char *implementationName; /* OPTIONAL */
233 char *implementationVersion; /* OPTIONAL */
234 Z_UserInformationField *userInformationField; /* OPTIONAL */
237 typedef struct Z_InitResponse
239 Z_ReferenceId *referenceId; /* OPTIONAL */
240 Odr_bitmask *options;
241 Odr_bitmask *protocolVersion;
242 int *preferredMessageSize;
243 int *maximumRecordSize;
245 char *implementationId; /* OPTIONAL */
246 char *implementationName; /* OPTIONAL */
247 char *implementationVersion; /* OPTIONAL */
248 Z_UserInformationField *userInformationField; /* OPTIONAL */
251 typedef struct Z_NSRAuthentication
256 } Z_NSRAuthentication;
258 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt);
260 int z_StrAuthentication(ODR o, char **p, int opt);
263 /* ------------------ RESOURCE CONTROL ----------------*/
265 typedef struct Z_TriggerResourceControlRequest
267 Z_ReferenceId *referenceId; /* OPTIONAL */
268 int *requestedAction;
269 #define Z_TriggerResourceCtrl_resourceReport 1
270 #define Z_TriggerResourceCtrl_resourceControl 2
271 #define Z_TriggerResourceCtrl_cancel 3
272 Odr_oid *prefResourceReportFormat; /* OPTIONAL */
273 bool_t *resultSetWanted; /* OPTIONAL */
274 } Z_TriggerResourceControlRequest;
276 typedef struct Z_ResourceControlRequest
278 Z_ReferenceId *referenceId; /* OPTIONAL */
279 bool_t *suspendedFlag; /* OPTIONAL */
280 Odr_external *resourceReport; /* OPTIONAL */
281 int *partialResultsAvailable; /* OPTIONAL */
282 #define Z_ResourceControlRequest_subset 1
283 #define Z_ResourceControlRequest_interim 2
284 #define Z_ResourceControlRequest_none 3
285 bool_t *responseRequired;
286 bool_t *triggeredRequestFlag; /* OPTIONAL */
287 } Z_ResourceControlRequest;
289 typedef struct Z_ResourceControlResponse
291 Z_ReferenceId *referenceId; /* OPTIONAL */
292 bool_t *continueFlag;
293 bool_t *resultSetWanted; /* OPTIONAL */
294 } Z_ResourceControlResponse;
296 /* ------------------ SEARCH SERVICE ----------------*/
298 typedef Odr_oid Z_PreferredRecordSyntax;
300 typedef struct Z_DatabaseSpecificUnit
303 char *elementSetName;
304 } Z_DatabaseSpecificUnit;
306 typedef struct Z_DatabaseSpecific
309 Z_DatabaseSpecificUnit **elements;
310 } Z_DatabaseSpecific;
312 typedef struct Z_ElementSetNames
315 #define Z_ElementSetNames_generic 0
316 #define Z_ElementSetNames_databaseSpecific 1
320 Z_DatabaseSpecific *databaseSpecific;
324 /* ---------------------- RPN QUERY --------------------------- */
326 typedef struct Z_AttributeElement
330 } Z_AttributeElement;
335 typedef struct Z_Term
341 Z_Term_characterString,
345 Z_Term_integerAndUnit,
350 Odr_oct *general; /* this is required for v2 */
352 char *characterString;
355 Odr_external *external;
356 /* Z_IntUnit *integerAndUnit; */
363 typedef struct Z_AttributesPlusTerm
366 Z_AttributeElement **attributeList;
372 } Z_AttributesPlusTerm;
374 typedef struct Z_ProximityOperator
376 bool_t *exclusion; /* OPTIONAL */
380 #define Z_Prox_lessThan 1
381 #define Z_Prox_lessThanOrEqual 2
382 #define Z_Prox_equal 3
383 #define Z_Prox_greaterThanOrEqual 4
384 #define Z_Prox_greaterThan 5
385 #define Z_Prox_notEqual 6
391 int *proximityUnitCode;
392 #define Z_ProxUnit_character 1
393 #define Z_ProxUnit_word 2
394 #define Z_ProxUnit_sentence 3
395 #define Z_ProxUnit_paragraph 4
396 #define Z_ProxUnit_section 5
397 #define Z_ProxUnit_chapter 6
398 #define Z_ProxUnit_document 7
399 #define Z_ProxUnit_element 8
400 #define Z_ProxUnit_subelement 9
401 #define Z_ProxUnit_elementType 10
402 #define Z_ProxUnit_byte 11 /* v3 only */
403 } Z_ProximityOperator;
405 typedef struct Z_Operator
416 Odr_null *and; /* these guys are nulls. */
419 Z_ProximityOperator *prox;
423 typedef struct Z_Operand
426 #define Z_Operand_APT 0
427 #define Z_Operand_resultSetId 1
430 Z_AttributesPlusTerm *attributesPlusTerm;
431 Z_ResultSetId *resultSetId;
435 typedef struct Z_Complex
437 struct Z_RPNStructure *s1;
438 struct Z_RPNStructure *s2;
439 Z_Operator *operator;
442 typedef struct Z_RPNStructure
445 #define Z_RPNStructure_simple 0
446 #define Z_RPNStructure_complex 1
454 typedef struct Z_RPNQuery
456 Odr_oid *attributeSetId;
457 Z_RPNStructure *RPNStructure;
460 /* -------------------------- SEARCHREQUEST -------------------------- */
462 typedef struct Z_Query
465 #define Z_Query_type_1 1
466 #define Z_Query_type_2 2
474 typedef struct Z_SearchRequest
476 Z_ReferenceId *referenceId; /* OPTIONAL */
477 int *smallSetUpperBound;
478 int *largeSetLowerBound;
479 int *mediumSetPresentNumber;
480 bool_t *replaceIndicator;
482 int num_databaseNames;
483 char **databaseNames;
484 Z_ElementSetNames *smallSetElementSetNames; /* OPTIONAL */
485 Z_ElementSetNames *mediumSetElementSetNames; /* OPTIONAL */
486 Z_PreferredRecordSyntax *preferredRecordSyntax; /* OPTIONAL */
490 /* ------------------------ RECORD -------------------------- */
492 typedef Odr_external Z_DatabaseRecord;
494 typedef struct Z_DiagRec
496 Odr_oid *diagnosticSetId;
501 typedef struct Z_NamePlusRecord
503 char *databaseName; /* OPTIONAL */
505 #define Z_NamePlusRecord_databaseRecord 0
506 #define Z_NamePlusRecord_surrogateDiagnostic 1
509 Z_DatabaseRecord *databaseRecord;
510 Z_DiagRec *surrogateDiagnostic;
514 typedef struct Z_NamePlusRecordList
517 Z_NamePlusRecord **records;
518 } Z_NamePlusRecordList;
520 typedef struct Z_Records
523 #define Z_Records_DBOSD 0
524 #define Z_Records_NSD 1
527 Z_NamePlusRecordList *databaseOrSurDiagnostics;
528 Z_DiagRec *nonSurrogateDiagnostic;
532 /* ------------------ ACCESS CTRL SERVICE ----------------*/
534 typedef struct Z_AccessControlRequest
536 Z_ReferenceId *referenceId; /* OPTIONAL */
539 Z_AccessRequest_simpleForm,
540 Z_AccessRequest_externallyDefined
545 Odr_external *externallyDefined;
548 Z_OtherInformation *otherInfo; /* OPTIONAL */
550 } Z_AccessControlRequest;
552 typedef struct Z_AccessControlResponse
554 Z_ReferenceId *referenceId; /* OPTIONAL */
557 Z_AccessResponse_simpleForm,
558 Z_AccessResponse_externallyDefined
563 Odr_external *externallyDefined;
565 Z_DiagRec *diagnostic; /* OPTIONAL */
567 Z_OtherInformation *otherInfo; /* OPTIONAL */
569 } Z_AccessControlResponse;
571 /* ------------------------ SCAN SERVICE -------------------- */
573 typedef struct Z_AttributeList
576 Z_AttributeElement **attributes;
579 typedef struct Z_AlternativeTerm
582 Z_AttributesPlusTerm **terms;
585 typedef struct Z_OccurrenceByAttributes
587 Z_AttributeList *attributes;
599 /* Z_ByDatabase *byDatabase; */
602 } Z_OccurrenceByAttributes;
604 typedef struct Z_TermInfo
607 Z_AttributeList *suggestedAttributes; /* OPTIONAL */
608 Z_AlternativeTerm *alternativeTerm; /* OPTIONAL */
609 int *globalOccurrences; /* OPTIONAL */
610 Z_OccurrenceByAttributes *byAttributes; /* OPTIONAL */
613 typedef struct Z_Entry
618 Z_Entry_surrogateDiagnostic
622 Z_TermInfo *termInfo;
623 Z_DiagRec *surrogateDiagnostic;
627 typedef struct Z_Entries
633 typedef struct Z_DiagRecs
636 Z_DiagRec **diagRecs;
639 typedef struct Z_ListEntries
643 Z_ListEntries_entries,
644 Z_ListEntries_nonSurrogateDiagnostics
649 Z_DiagRecs *nonSurrogateDiagnostics;
653 typedef struct Z_ScanRequest
655 Z_ReferenceId *referenceId; /* OPTIONAL */
656 int num_databaseNames;
657 char **databaseNames;
658 Odr_oid *attributeSet; /* OPTIONAL */
659 Z_AttributesPlusTerm *termListAndStartPoint;
660 int *stepSize; /* OPTIONAL */
661 int *numberOfTermsRequested;
662 int *preferredPositionInResponse; /* OPTIONAL */
665 typedef struct Z_ScanResponse
667 Z_ReferenceId *referenceId; /* OPTIONAL */
668 int *stepSize; /* OPTIONAL */
670 #define Z_Scan_success 0
671 #define Z_Scan_partial_1 1
672 #define Z_Scan_partial_2 2
673 #define Z_Scan_partial_3 3
674 #define Z_Scan_partial_4 4
675 #define Z_Scan_partial_5 5
676 #define Z_Scan_failure 6
677 int *numberOfEntriesReturned;
678 int *positionOfTerm; /* OPTIONAL */
679 Z_ListEntries *entries; /* OPTIONAL */
680 Odr_oid *attributeSet; /* OPTIONAL */
683 /* ------------------------ SEARCHRESPONSE ------------------ */
685 typedef struct Z_SearchResponse
687 Z_ReferenceId *referenceId; /* OPTIONAL */
689 int *numberOfRecordsReturned;
690 int *nextResultSetPosition;
691 bool_t *searchStatus;
692 int *resultSetStatus; /* OPTIONAL */
693 #define Z_RES_SUBSET 1
694 #define Z_RES_INTERIM 2
696 int *presentStatus; /* OPTIONAL */
697 #define Z_PRES_SUCCESS 0
698 #define Z_PRES_PARTIAL_1 1
699 #define Z_PRES_PARTIAL_2 2
700 #define Z_PRES_PARTIAL_3 3
701 #define Z_PRES_PARTIAL_4 4
702 #define Z_PRES_FAILURE 5
703 Z_Records *records; /* OPTIONAL */
706 /* ------------------------- PRESENT SERVICE -----------------*/
708 typedef struct Z_PresentRequest
710 Z_ReferenceId *referenceId; /* OPTIONAL */
711 Z_ResultSetId *resultSetId;
712 int *resultSetStartPoint;
713 int *numberOfRecordsRequested;
714 Z_ElementSetNames *elementSetNames; /* OPTIONAL */
715 Z_PreferredRecordSyntax *preferredRecordSyntax; /* OPTIONAL */
718 typedef struct Z_PresentResponse
720 Z_ReferenceId *referenceId; /* OPTIONAL */
721 int *numberOfRecordsReturned;
722 int *nextResultSetPosition;
727 /* ------------------------ DELETE -------------------------- */
729 #define Z_DeleteStatus_success 0
730 #define Z_DeleteStatus_resultSetDidNotExist 1
731 #define Z_DeleteStatus_previouslyDeletedByTarget 2
732 #define Z_DeleteStatus_systemProblemAtTarget 3
733 #define Z_DeleteStatus_accessNotAllowed 4
734 #define Z_DeleteStatus_resourceControlAtOrigin 5
735 #define Z_DeleteStatus_resourceControlAtTarget 6
736 #define Z_DeleteStatus_bulkDeleteNotSupported 7
737 #define Z_DeleteStatus_notAllRsltSetsDeletedOnBulkDlte 8
738 #define Z_DeleteStatus_notAllRequestedResultSetsDeleted 9
739 #define Z_DeleteStatus_resultSetInUse 10
741 typedef struct Z_ListStatus
747 typedef struct Z_DeleteResultSetRequest
749 Z_ReferenceId *referenceId; /* OPTIONAL */
751 #define Z_DeleteRequest_list 0
752 #define Z_DeleteRequest_all 1
754 Z_ResultSetId **resultSetList; /* OPTIONAL */
756 Z_OtherInformation *otherInfo;
758 } Z_DeleteResultSetRequest;
760 typedef struct Z_DeleteResultSetResponse
762 Z_ReferenceId *referenceId; /* OPTIONAL */
763 int *deleteOperationStatus;
765 Z_ListStatus *deleteListStatuses; /* OPTIONAL */
766 int *numberNotDeleted; /* OPTIONAL */
767 int num_bulkStatuses;
768 Z_ListStatus *bulkStatuses; /* OPTIONAL */
769 char *deleteMessage; /* OPTIONAL */
771 Z_OtherInformation *otherInfo;
773 } Z_DeleteResultSetResponse;
775 /* ------------------------ CLOSE SERVICE ------------------- */
777 typedef struct Z_Close
779 Z_ReferenceId *referenceId; /* OPTIONAL */
781 #define Z_Close_finished 0
782 #define Z_Close_shutdown 1
783 #define Z_Close_systemProblem 2
784 #define Z_Close_costLimit 3
785 #define Z_Close_resources 4
786 #define Z_Close_securityViolation 5
787 #define Z_Close_protocolError 6
788 #define Z_Close_lackOfActivity 7
789 #define Z_Close_peerAbort 8
790 #define Z_Close_unspecified 9
791 char *diagnosticInformation; /* OPTIONAL */
792 Odr_oid *resourceReportFormat; /* OPTIONAL */
793 Odr_external *resourceReport; /* OPTIONAL */
795 Z_OtherInformation *otherInfo; /* OPTIONAL */
799 /* ------------------------ APDU ---------------------------- */
801 typedef struct Z_APDU
807 Z_APDU_searchRequest,
808 Z_APDU_searchResponse,
809 Z_APDU_presentRequest,
810 Z_APDU_presentResponse,
811 Z_APDU_deleteResultSetRequest,
812 Z_APDU_deleteResultSetResponse,
813 Z_APDU_resourceControlRequest,
814 Z_APDU_resourceControlResponse,
815 Z_APDU_triggerResourceControlRequest,
822 Z_InitRequest *initRequest;
823 Z_InitResponse *initResponse;
824 Z_SearchRequest *searchRequest;
825 Z_SearchResponse *searchResponse;
826 Z_PresentRequest *presentRequest;
827 Z_PresentResponse *presentResponse;
828 Z_DeleteResultSetRequest *deleteResultSetRequest;
829 Z_DeleteResultSetResponse *deleteResultSetResponse;
830 Z_ResourceControlRequest *resourceControlRequest;
831 Z_ResourceControlResponse *resourceControlResponse;
832 Z_TriggerResourceControlRequest *triggerResourceControlRequest;
833 Z_ScanRequest *scanRequest;
834 Z_ScanResponse *scanResponse;
839 int z_APDU(ODR o, Z_APDU **p, int opt);
841 Z_InitRequest *zget_InitRequest(ODR o);
842 Z_InitResponse *zget_InitResponse(ODR o);
843 Z_SearchRequest *zget_SearchRequest(ODR o);
844 Z_SearchResponse *zget_SearchResponse(ODR o);
845 Z_PresentRequest *zget_PresentRequest(ODR o);
846 Z_PresentResponse *zget_PresentResponse(ODR o);
847 Z_DeleteResultSetRequest *zget_DeleteResultSetRequest(ODR o);
848 Z_DeleteResultSetResponse *zget_DeleteResultSetResponse(ODR o);
849 Z_ScanRequest *zget_ScanRequest(ODR o);
850 Z_ScanResponse *zget_ScanResponse(ODR o);
851 Z_TriggerResourceControlRequest *zget_TriggerResourceControlRequest(ODR o);
852 Z_ResourceControlRequest *zget_ResourceControlRequest(ODR o);
853 Z_ResourceControlResponse *zget_ResourceControlResponse(ODR o);
854 Z_Close *zget_Close(ODR o);
855 Z_APDU *zget_APDU(ODR o, enum Z_APDU_which which);