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.13 1995-06-07 14:36:47 quinn
30 * Revision 1.12 1995/06/05 10:53:13 quinn
33 * Revision 1.11 1995/06/02 09:49:47 quinn
36 * Revision 1.10 1995/05/29 08:11:34 quinn
37 * Moved oid from odr/asn to util.
39 * Revision 1.9 1995/05/22 11:31:25 quinn
42 * Revision 1.8 1995/05/17 08:41:35 quinn
43 * Added delete to proto & other little things.
44 * Relaying auth info to backend.
46 * Revision 1.7 1995/05/16 08:50:37 quinn
47 * License, documentation, and memory fixes
49 * Revision 1.6 1995/05/15 11:55:55 quinn
50 * Work on asynchronous activity.
52 * Revision 1.5 1995/04/17 11:28:18 quinn
55 * Revision 1.4 1995/04/10 10:22:47 quinn
58 * Revision 1.3 1995/03/30 12:18:09 quinn
61 * Revision 1.2 1995/03/30 10:26:48 quinn
62 * Added Term structure
64 * Revision 1.1 1995/03/30 09:39:42 quinn
65 * Moved .h files to include directory
67 * Revision 1.11 1995/03/30 09:08:44 quinn
68 * Added Resource control protocol
70 * Revision 1.10 1995/03/29 15:39:39 quinn
71 * Adding some resource control elements, and a null-check to getentbyoid
73 * Revision 1.9 1995/03/29 08:06:18 quinn
74 * Added a few v3 elements
76 * Revision 1.8 1995/03/22 10:12:49 quinn
77 * Added Z_PRES constants.
79 * Revision 1.7 1995/03/20 09:45:12 quinn
82 * Revision 1.5 1995/03/07 16:29:34 quinn
83 * Added authentication stuff.
85 * Revision 1.4 1995/03/07 10:13:00 quinn
86 * Added prototype for z_APDU()
88 * Revision 1.3 1995/02/14 11:54:23 quinn
91 * Revision 1.2 1995/02/09 15:51:40 quinn
94 * Revision 1.1 1995/02/06 16:44:48 quinn
95 * First hack at Z/SR protocol
106 /* ----------------- GLOBAL AUXILIARY DEFS ----------------*/
108 typedef Odr_oct Z_ReferenceId;
109 typedef char Z_DatabaseName;
110 typedef char Z_ResultSetId;
111 typedef Odr_oct Z_ResultsetId;
112 typedef Odr_external Z_UserInformationField;
114 typedef struct Z_InfoCategory
116 Odr_oid *categoryTypeId; /* OPTIONAL */
120 typedef struct Z_OtherInformationUnit
122 Z_InfoCategory *category; /* OPTIONAL */
125 Z_OtherInfo_characterInfo,
126 Z_OtherInfo_binaryInfo,
127 Z_OtherInfo_externallyDefinedInfo,
134 Odr_external *externallyDefinedInfo;
137 } Z_OtherInformationUnit;
139 typedef struct Z_OtherInformation
142 Z_OtherInformationUnit **list;
143 } Z_OtherInformation;
145 typedef struct Z_StringOrNumeric
149 Z_StringOrNumeric_string,
150 Z_StringOrNumeric_numeric
159 typedef struct Z_Unit
161 char *unitSystem; /* OPTIONAL */
162 Z_StringOrNumeric *unitType; /* OPTIONAL */
163 Z_StringOrNumeric *unit; /* OPTIONAL */
164 int *scaleFactor; /* OPTIONAL */
167 typedef struct Z_IntUnit
173 /* ----------------- INIT SERVICE ----------------*/
177 char *groupId; /* OPTIONAL */
178 char *userId; /* OPTIONAL */
179 char *password; /* OPTIONAL */
182 typedef struct Z_IdAuthentication
186 Z_IdAuthentication_open,
187 Z_IdAuthentication_idPass,
188 Z_IdAuthentication_anonymous,
189 Z_IdAuthentication_other
198 } Z_IdAuthentication;
200 #define Z_ProtocolVersion_1 0
201 #define Z_ProtocolVersion_2 1
202 #define Z_ProtocolVersion_3 2
204 #define Z_Options_search 0
205 #define Z_Options_present 1
206 #define Z_Options_delSet 2
207 #define Z_Options_resourceReport 3
208 #define Z_Options_triggerResourceCtrl 4
209 #define Z_Options_resourceCtrl 5
210 #define Z_Options_accessCtrl 6
211 #define Z_Options_scan 7
212 #define Z_Options_sort 8
213 #define Z_Options_reserved 9
214 #define Z_Options_extendedServices 10
215 #define Z_Options_level_1Segmentation 11
216 #define Z_Options_level_2Segmentation 12
217 #define Z_Options_concurrentOperations 13
218 #define Z_Options_namedResultSets 14
220 typedef struct Z_InitRequest
222 Z_ReferenceId *referenceId; /* OPTIONAL */
223 Odr_bitmask *options;
224 Odr_bitmask *protocolVersion;
225 int *preferredMessageSize;
226 int *maximumRecordSize;
227 Z_IdAuthentication* idAuthentication; /* OPTIONAL */
228 char *implementationId; /* OPTIONAL */
229 char *implementationName; /* OPTIONAL */
230 char *implementationVersion; /* OPTIONAL */
231 Z_UserInformationField *userInformationField; /* OPTIONAL */
234 typedef struct Z_InitResponse
236 Z_ReferenceId *referenceId; /* OPTIONAL */
237 Odr_bitmask *options;
238 Odr_bitmask *protocolVersion;
239 int *preferredMessageSize;
240 int *maximumRecordSize;
242 char *implementationId; /* OPTIONAL */
243 char *implementationName; /* OPTIONAL */
244 char *implementationVersion; /* OPTIONAL */
245 Z_UserInformationField *userInformationField; /* OPTIONAL */
248 typedef struct Z_NSRAuthentication
253 } Z_NSRAuthentication;
255 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt);
257 int z_StrAuthentication(ODR o, char **p, int opt);
260 /* ------------------ RESOURCE CONTROL ----------------*/
262 typedef struct Z_TriggerResourceControlRequest
264 Z_ReferenceId *referenceId; /* OPTIONAL */
265 int *requestedAction;
266 #define Z_TriggerResourceCtrl_resourceReport 1
267 #define Z_TriggerResourceCtrl_resourceControl 2
268 #define Z_TriggerResourceCtrl_cancel 3
269 Odr_oid *prefResourceReportFormat; /* OPTIONAL */
270 bool_t *resultSetWanted; /* OPTIONAL */
271 } Z_TriggerResourceControlRequest;
273 typedef struct Z_ResourceControlRequest
275 Z_ReferenceId *referenceId; /* OPTIONAL */
276 bool_t *suspendedFlag; /* OPTIONAL */
277 Odr_external *resourceReport; /* OPTIONAL */
278 int *partialResultsAvailable; /* OPTIONAL */
279 #define Z_ResourceControlRequest_subset 1
280 #define Z_ResourceControlRequest_interim 2
281 #define Z_ResourceControlRequest_none 3
282 bool_t *responseRequired;
283 bool_t *triggeredRequestFlag; /* OPTIONAL */
284 } Z_ResourceControlRequest;
286 typedef struct Z_ResourceControlResponse
288 Z_ReferenceId *referenceId; /* OPTIONAL */
289 bool_t *continueFlag;
290 bool_t *resultSetWanted; /* OPTIONAL */
291 } Z_ResourceControlResponse;
293 /* ------------------ SEARCH SERVICE ----------------*/
295 typedef Odr_oid Z_PreferredRecordSyntax;
297 typedef struct Z_DatabaseSpecificUnit
300 char *elementSetName;
301 } Z_DatabaseSpecificUnit;
303 typedef struct Z_DatabaseSpecific
306 Z_DatabaseSpecificUnit **elements;
307 } Z_DatabaseSpecific;
309 typedef struct Z_ElementSetNames
312 #define Z_ElementSetNames_generic 0
313 #define Z_ElementSetNames_databaseSpecific 1
317 Z_DatabaseSpecific *databaseSpecific;
321 /* ---------------------- RPN QUERY --------------------------- */
323 typedef struct Z_AttributeElement
327 } Z_AttributeElement;
332 typedef struct Z_Term
338 Z_Term_characterString,
342 Z_Term_integerAndUnit,
347 Odr_oct *general; /* this is required for v2 */
349 char *characterString;
352 Odr_external *external;
353 /* Z_IntUnit *integerAndUnit; */
360 typedef struct Z_AttributesPlusTerm
363 Z_AttributeElement **attributeList;
369 } Z_AttributesPlusTerm;
371 typedef struct Z_ProximityOperator
373 bool_t *exclusion; /* OPTIONAL */
377 #define Z_Prox_lessThan 1
378 #define Z_Prox_lessThanOrEqual 2
379 #define Z_Prox_equal 3
380 #define Z_Prox_greaterThanOrEqual 4
381 #define Z_Prox_greaterThan 5
382 #define Z_Prox_notEqual 6
388 int *proximityUnitCode;
389 #define Z_ProxUnit_character 1
390 #define Z_ProxUnit_word 2
391 #define Z_ProxUnit_sentence 3
392 #define Z_ProxUnit_paragraph 4
393 #define Z_ProxUnit_section 5
394 #define Z_ProxUnit_chapter 6
395 #define Z_ProxUnit_document 7
396 #define Z_ProxUnit_element 8
397 #define Z_ProxUnit_subelement 9
398 #define Z_ProxUnit_elementType 10
399 #define Z_ProxUnit_byte 11 /* v3 only */
400 } Z_ProximityOperator;
402 typedef struct Z_Operator
413 Odr_null *and; /* these guys are nulls. */
416 Z_ProximityOperator *prox;
420 typedef struct Z_Operand
423 #define Z_Operand_APT 0
424 #define Z_Operand_resultSetId 1
427 Z_AttributesPlusTerm *attributesPlusTerm;
428 Z_ResultSetId *resultSetId;
432 typedef struct Z_Complex
434 struct Z_RPNStructure *s1;
435 struct Z_RPNStructure *s2;
436 Z_Operator *operator;
439 typedef struct Z_RPNStructure
442 #define Z_RPNStructure_simple 0
443 #define Z_RPNStructure_complex 1
451 typedef struct Z_RPNQuery
453 Odr_oid *attributeSetId;
454 Z_RPNStructure *RPNStructure;
457 /* -------------------------- SEARCHREQUEST -------------------------- */
459 typedef struct Z_Query
462 #define Z_Query_type_1 1
463 #define Z_Query_type_2 2
471 typedef struct Z_SearchRequest
473 Z_ReferenceId *referenceId; /* OPTIONAL */
474 int *smallSetUpperBound;
475 int *largeSetLowerBound;
476 int *mediumSetPresentNumber;
477 bool_t *replaceIndicator;
479 int num_databaseNames;
480 char **databaseNames;
481 Z_ElementSetNames *smallSetElementSetNames; /* OPTIONAL */
482 Z_ElementSetNames *mediumSetElementSetNames; /* OPTIONAL */
483 Z_PreferredRecordSyntax *preferredRecordSyntax; /* OPTIONAL */
487 /* ------------------------ RECORD -------------------------- */
489 typedef Odr_external Z_DatabaseRecord;
491 typedef struct Z_DiagRec
493 Odr_oid *diagnosticSetId;
498 typedef struct Z_NamePlusRecord
500 char *databaseName; /* OPTIONAL */
502 #define Z_NamePlusRecord_databaseRecord 0
503 #define Z_NamePlusRecord_surrogateDiagnostic 1
506 Z_DatabaseRecord *databaseRecord;
507 Z_DiagRec *surrogateDiagnostic;
511 typedef struct Z_NamePlusRecordList
514 Z_NamePlusRecord **records;
515 } Z_NamePlusRecordList;
517 typedef struct Z_Records
520 #define Z_Records_DBOSD 0
521 #define Z_Records_NSD 1
524 Z_NamePlusRecordList *databaseOrSurDiagnostics;
525 Z_DiagRec *nonSurrogateDiagnostic;
529 /* ------------------ ACCESS CTRL SERVICE ----------------*/
531 typedef struct Z_AccessControlRequest
533 Z_ReferenceId *referenceId; /* OPTIONAL */
536 Z_AccessRequest_simpleForm,
537 Z_AccessRequest_externallyDefined
542 Odr_external *externallyDefined;
545 Z_OtherInformation *otherInfo; /* OPTIONAL */
547 } Z_AccessControlRequest;
549 typedef struct Z_AccessControlResponse
551 Z_ReferenceId *referenceId; /* OPTIONAL */
554 Z_AccessResponse_simpleForm,
555 Z_AccessResponse_externallyDefined
560 Odr_external *externallyDefined;
562 Z_DiagRec *diagnostic; /* OPTIONAL */
564 Z_OtherInformation *otherInfo; /* OPTIONAL */
566 } Z_AccessControlResponse;
568 /* ------------------------ SCAN SERVICE -------------------- */
570 typedef struct Z_AttributeList
573 Z_AttributeElement **attributes;
576 typedef struct Z_AlternativeTerm
579 Z_AttributesPlusTerm **terms;
582 typedef struct Z_OccurrenceByAttributes
584 Z_AttributeList *attributes;
596 /* Z_ByDatabase *byDatabase; */
599 } Z_OccurrenceByAttributes;
601 typedef struct Z_TermInfo
604 Z_AttributeList *suggestedAttributes; /* OPTIONAL */
605 Z_AlternativeTerm *alternativeTerm; /* OPTIONAL */
606 int *globalOccurrences; /* OPTIONAL */
607 Z_OccurrenceByAttributes *byAttributes; /* OPTIONAL */
610 typedef struct Z_Entry
615 Z_Entry_surrogateDiagnostic
619 Z_TermInfo *termInfo;
620 Z_DiagRec *surrogateDiagnostic;
624 typedef struct Z_Entries
630 typedef struct Z_DiagRecs
633 Z_DiagRec **diagRecs;
636 typedef struct Z_ListEntries
640 Z_ListEntries_entries,
641 Z_ListEntries_nonSurrogateDiagnostics
646 Z_DiagRecs *nonSurrogateDiagnostics;
650 typedef struct Z_ScanRequest
652 Z_ReferenceId *referenceId; /* OPTIONAL */
653 int num_databaseNames;
654 char **databaseNames;
655 Odr_oid *attributeSet; /* OPTIONAL */
656 Z_AttributesPlusTerm *termListAndStartPoint;
657 int *stepSize; /* OPTIONAL */
658 int *numberOfTermsRequested;
659 int *preferredPositionInResponse; /* OPTIONAL */
662 typedef struct Z_ScanResponse
664 Z_ReferenceId *referenceId; /* OPTIONAL */
665 int *stepSize; /* OPTIONAL */
667 #define Z_Scan_success 0
668 #define Z_Scan_partial_1 1
669 #define Z_Scan_partial_2 2
670 #define Z_Scan_partial_3 3
671 #define Z_Scan_partial_4 4
672 #define Z_Scan_partial_5 5
673 #define Z_Scan_failure 6
674 int *numberOfEntriesReturned;
675 int *positionOfTerm; /* OPTIONAL */
676 Z_ListEntries *entries; /* OPTIONAL */
677 Odr_oid *attributeSet; /* OPTIONAL */
680 /* ------------------------ SEARCHRESPONSE ------------------ */
682 typedef struct Z_SearchResponse
684 Z_ReferenceId *referenceId; /* OPTIONAL */
686 int *numberOfRecordsReturned;
687 int *nextResultSetPosition;
688 bool_t *searchStatus;
689 int *resultSetStatus; /* OPTIONAL */
690 #define Z_RES_SUBSET 1
691 #define Z_RES_INTERIM 2
693 int *presentStatus; /* OPTIONAL */
694 #define Z_PRES_SUCCESS 0
695 #define Z_PRES_PARTIAL_1 1
696 #define Z_PRES_PARTIAL_2 2
697 #define Z_PRES_PARTIAL_3 3
698 #define Z_PRES_PARTIAL_4 4
699 #define Z_PRES_FAILURE 5
700 Z_Records *records; /* OPTIONAL */
703 /* ------------------------- PRESENT SERVICE -----------------*/
705 typedef struct Z_PresentRequest
707 Z_ReferenceId *referenceId; /* OPTIONAL */
708 Z_ResultSetId *resultSetId;
709 int *resultSetStartPoint;
710 int *numberOfRecordsRequested;
711 Z_ElementSetNames *elementSetNames; /* OPTIONAL */
712 Z_PreferredRecordSyntax *preferredRecordSyntax; /* OPTIONAL */
715 typedef struct Z_PresentResponse
717 Z_ReferenceId *referenceId; /* OPTIONAL */
718 int *numberOfRecordsReturned;
719 int *nextResultSetPosition;
724 /* ------------------------ DELETE -------------------------- */
726 #define Z_DeleteStatus_success 0
727 #define Z_DeleteStatus_resultSetDidNotExist 1
728 #define Z_DeleteStatus_previouslyDeletedByTarget 2
729 #define Z_DeleteStatus_systemProblemAtTarget 3
730 #define Z_DeleteStatus_accessNotAllowed 4
731 #define Z_DeleteStatus_resourceControlAtOrigin 5
732 #define Z_DeleteStatus_resourceControlAtTarget 6
733 #define Z_DeleteStatus_bulkDeleteNotSupported 7
734 #define Z_DeleteStatus_notAllRsltSetsDeletedOnBulkDlte 8
735 #define Z_DeleteStatus_notAllRequestedResultSetsDeleted 9
736 #define Z_DeleteStatus_resultSetInUse 10
738 typedef struct Z_ListStatus
744 typedef struct Z_DeleteResultSetRequest
746 Z_ReferenceId *referenceId; /* OPTIONAL */
748 #define Z_DeleteRequest_list 0
749 #define Z_DeleteRequest_all 1
751 Z_ResultSetId **resultSetList; /* OPTIONAL */
753 Z_OtherInformation *otherInfo;
755 } Z_DeleteResultSetRequest;
757 typedef struct Z_DeleteResultSetResponse
759 Z_ReferenceId *referenceId; /* OPTIONAL */
760 int *deleteOperationStatus;
762 Z_ListStatus *deleteListStatuses; /* OPTIONAL */
763 int *numberNotDeleted; /* OPTIONAL */
764 int num_bulkStatuses;
765 Z_ListStatus *bulkStatuses; /* OPTIONAL */
766 char *deleteMessage; /* OPTIONAL */
768 Z_OtherInformation *otherInfo;
770 } Z_DeleteResultSetResponse;
772 /* ------------------------ CLOSE SERVICE ------------------- */
774 typedef struct Z_Close
776 Z_ReferenceId *referenceId; /* OPTIONAL */
778 #define Z_Close_finished 0
779 #define Z_Close_shutdown 1
780 #define Z_Close_systemProblem 2
781 #define Z_Close_costLimit 3
782 #define Z_Close_resources 4
783 #define Z_Close_securityViolation 5
784 #define Z_Close_protocolError 6
785 #define Z_Close_lackOfActivity 7
786 #define Z_Close_peerAbort 8
787 #define Z_Close_unspecified 9
788 char *diagnosticInformation; /* OPTIONAL */
789 Odr_oid *resourceReportFormat; /* OPTIONAL */
790 Odr_external *resourceReport; /* OPTIONAL */
792 Z_OtherInformation *otherInfo; /* OPTIONAL */
796 /* ------------------------ APDU ---------------------------- */
798 typedef struct Z_APDU
804 Z_APDU_searchRequest,
805 Z_APDU_searchResponse,
806 Z_APDU_presentRequest,
807 Z_APDU_presentResponse,
808 Z_APDU_deleteResultSetRequest,
809 Z_APDU_deleteResultSetResponse,
810 Z_APDU_resourceControlRequest,
811 Z_APDU_resourceControlResponse,
812 Z_APDU_triggerResourceControlRequest,
819 Z_InitRequest *initRequest;
820 Z_InitResponse *initResponse;
821 Z_SearchRequest *searchRequest;
822 Z_SearchResponse *searchResponse;
823 Z_PresentRequest *presentRequest;
824 Z_PresentResponse *presentResponse;
825 Z_DeleteResultSetRequest *deleteResultSetRequest;
826 Z_DeleteResultSetResponse *deleteResultSetResponse;
827 Z_ResourceControlRequest *resourceControlRequest;
828 Z_ResourceControlResponse *resourceControlResponse;
829 Z_TriggerResourceControlRequest *triggerResourceControlRequest;
830 Z_ScanRequest *scanRequest;
831 Z_ScanResponse *scanResponse;
836 int z_APDU(ODR o, Z_APDU **p, int opt);
838 Z_InitRequest *zget_InitRequest(ODR o);
839 Z_InitResponse *zget_InitResponse(ODR o);
840 Z_SearchRequest *zget_SearchRequest(ODR o);
841 Z_SearchResponse *zget_SearchResponse(ODR o);
842 Z_PresentRequest *zget_PresentRequest(ODR o);
843 Z_PresentResponse *zget_PresentResponse(ODR o);
844 Z_DeleteResultSetRequest *zget_DeleteResultSetRequest(ODR o);
845 Z_DeleteResultSetResponse *zget_DeleteResultSetResponse(ODR o);
846 Z_ScanRequest *zget_ScanRequest(ODR o);
847 Z_ScanResponse *zget_ScanResponse(ODR o);
848 Z_TriggerResourceControlRequest *zget_TriggerResourceControlRequest(ODR o);
849 Z_ResourceControlRequest *zget_ResourceControlRequest(ODR o);
850 Z_ResourceControlResponse *zget_ResourceControlResponse(ODR o);
851 Z_Close *zet_Close(ODR o);
852 Z_APDU *zget_APDU(ODR o, enum Z_APDU_which which);