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.11 1995-06-02 09:49:47 quinn
30 * Revision 1.10 1995/05/29 08:11:34 quinn
31 * Moved oid from odr/asn to util.
33 * Revision 1.9 1995/05/22 11:31:25 quinn
36 * Revision 1.8 1995/05/17 08:41:35 quinn
37 * Added delete to proto & other little things.
38 * Relaying auth info to backend.
40 * Revision 1.7 1995/05/16 08:50:37 quinn
41 * License, documentation, and memory fixes
43 * Revision 1.6 1995/05/15 11:55:55 quinn
44 * Work on asynchronous activity.
46 * Revision 1.5 1995/04/17 11:28:18 quinn
49 * Revision 1.4 1995/04/10 10:22:47 quinn
52 * Revision 1.3 1995/03/30 12:18:09 quinn
55 * Revision 1.2 1995/03/30 10:26:48 quinn
56 * Added Term structure
58 * Revision 1.1 1995/03/30 09:39:42 quinn
59 * Moved .h files to include directory
61 * Revision 1.11 1995/03/30 09:08:44 quinn
62 * Added Resource control protocol
64 * Revision 1.10 1995/03/29 15:39:39 quinn
65 * Adding some resource control elements, and a null-check to getentbyoid
67 * Revision 1.9 1995/03/29 08:06:18 quinn
68 * Added a few v3 elements
70 * Revision 1.8 1995/03/22 10:12:49 quinn
71 * Added Z_PRES constants.
73 * Revision 1.7 1995/03/20 09:45:12 quinn
76 * Revision 1.5 1995/03/07 16:29:34 quinn
77 * Added authentication stuff.
79 * Revision 1.4 1995/03/07 10:13:00 quinn
80 * Added prototype for z_APDU()
82 * Revision 1.3 1995/02/14 11:54:23 quinn
85 * Revision 1.2 1995/02/09 15:51:40 quinn
88 * Revision 1.1 1995/02/06 16:44:48 quinn
89 * First hack at Z/SR protocol
100 /* ----------------- GLOBAL AUXILIARY DEFS ----------------*/
102 typedef Odr_oct Z_ReferenceId;
103 typedef char Z_DatabaseName;
104 typedef char Z_ResultSetId;
105 typedef Odr_oct Z_ResultsetId;
106 typedef Odr_external Z_UserInformationField;
108 typedef struct Z_InfoCategory
110 Odr_oid *categoryTypeId; /* OPTIONAL */
114 typedef struct Z_OtherInformationUnit
116 Z_InfoCategory *category; /* OPTIONAL */
119 Z_OtherInfo_characterInfo,
120 Z_OtherInfo_binaryInfo,
121 Z_OtherInfo_externallyDefinedInfo,
128 Odr_external *externallyDefinedInfo;
131 } Z_OtherInformationUnit;
133 typedef struct Z_OtherInformation
136 Z_OtherInformationUnit **list;
137 } Z_OtherInformation;
139 typedef struct Z_StringOrNumeric
143 Z_StringOrNumeric_string,
144 Z_StringOrNumeric_numeric
153 typedef struct Z_Unit
155 char *unitSystem; /* OPTIONAL */
156 Z_StringOrNumeric *unitType; /* OPTIONAL */
157 Z_StringOrNumeric *unit; /* OPTIONAL */
158 int *scaleFactor; /* OPTIONAL */
161 typedef struct Z_IntUnit
167 /* ----------------- INIT SERVICE ----------------*/
171 char *groupId; /* OPTIONAL */
172 char *userId; /* OPTIONAL */
173 char *password; /* OPTIONAL */
176 typedef struct Z_IdAuthentication
180 Z_IdAuthentication_open,
181 Z_IdAuthentication_idPass,
182 Z_IdAuthentication_anonymous,
183 Z_IdAuthentication_other
192 } Z_IdAuthentication;
194 #define Z_ProtocolVersion_1 0
195 #define Z_ProtocolVersion_2 1
196 #define Z_ProtocolVersion_3 2
198 #define Z_Options_search 0
199 #define Z_Options_present 1
200 #define Z_Options_delSet 2
201 #define Z_Options_resourceReport 3
202 #define Z_Options_triggerResourceCtrl 4
203 #define Z_Options_resourceCtrl 5
204 #define Z_Options_accessCtrl 6
205 #define Z_Options_scan 7
206 #define Z_Options_sort 8
207 #define Z_Options_reserved 9
208 #define Z_Options_extendedServices 10
209 #define Z_Options_level_1Segmentation 11
210 #define Z_Options_level_2Segmentation 12
211 #define Z_Options_concurrentOperations 13
212 #define Z_Options_namedResultSets 14
214 typedef struct Z_InitRequest
216 Z_ReferenceId *referenceId; /* OPTIONAL */
217 Odr_bitmask *options;
218 Odr_bitmask *protocolVersion;
219 int *preferredMessageSize;
220 int *maximumRecordSize;
221 Z_IdAuthentication* idAuthentication; /* OPTIONAL */
222 char *implementationId; /* OPTIONAL */
223 char *implementationName; /* OPTIONAL */
224 char *implementationVersion; /* OPTIONAL */
225 Z_UserInformationField *userInformationField; /* OPTIONAL */
228 typedef struct Z_InitResponse
230 Z_ReferenceId *referenceId; /* OPTIONAL */
231 Odr_bitmask *options;
232 Odr_bitmask *protocolVersion;
233 int *preferredMessageSize;
234 int *maximumRecordSize;
236 char *implementationId; /* OPTIONAL */
237 char *implementationName; /* OPTIONAL */
238 char *implementationVersion; /* OPTIONAL */
239 Z_UserInformationField *userInformationField; /* OPTIONAL */
242 typedef struct Z_NSRAuthentication
247 } Z_NSRAuthentication;
249 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt);
251 int z_StrAuthentication(ODR o, char **p, int opt);
254 /* ------------------ RESOURCE CONTROL ----------------*/
256 typedef struct Z_TriggerResourceControlRequest
258 Z_ReferenceId *referenceId; /* OPTIONAL */
259 int *requestedAction;
260 #define Z_TriggerResourceCtrl_resourceReport 1
261 #define Z_TriggerResourceCtrl_resourceControl 2
262 #define Z_TriggerResourceCtrl_cancel 3
263 Odr_oid *prefResourceReportFormat; /* OPTIONAL */
264 bool_t *resultSetWanted; /* OPTIONAL */
265 } Z_TriggerResourceControlRequest;
267 typedef struct Z_ResourceControlRequest
269 Z_ReferenceId *referenceId; /* OPTIONAL */
270 bool_t *suspendedFlag; /* OPTIONAL */
271 Odr_external *resourceReport; /* OPTIONAL */
272 int *partialResultsAvailable; /* OPTIONAL */
273 #define Z_ResourceControlRequest_subset 1
274 #define Z_ResourceControlRequest_interim 2
275 #define Z_ResourceControlRequest_none 3
276 bool_t *responseRequired;
277 bool_t *triggeredRequestFlag; /* OPTIONAL */
278 } Z_ResourceControlRequest;
280 typedef struct Z_ResourceControlResponse
282 Z_ReferenceId *referenceId; /* OPTIONAL */
283 bool_t *continueFlag;
284 bool_t *resultSetWanted; /* OPTIONAL */
285 } Z_ResourceControlResponse;
287 /* ------------------ SEARCH SERVICE ----------------*/
289 typedef Odr_oid Z_PreferredRecordSyntax;
291 typedef struct Z_DatabaseSpecificUnit
294 char *elementSetName;
295 } Z_DatabaseSpecificUnit;
297 typedef struct Z_DatabaseSpecific
300 Z_DatabaseSpecificUnit **elements;
301 } Z_DatabaseSpecific;
303 typedef struct Z_ElementSetNames
306 #define Z_ElementSetNames_generic 0
307 #define Z_ElementSetNames_databaseSpecific 1
311 Z_DatabaseSpecific *databaseSpecific;
315 /* ---------------------- RPN QUERY --------------------------- */
317 typedef struct Z_AttributeElement
321 } Z_AttributeElement;
326 typedef struct Z_Term
332 Z_Term_characterString,
336 Z_Term_integerAndUnit,
341 Odr_oct *general; /* this is required for v2 */
343 char *characterString;
346 Odr_external *external;
347 /* Z_IntUnit *integerAndUnit; */
354 typedef struct Z_AttributesPlusTerm
357 Z_AttributeElement **attributeList;
363 } Z_AttributesPlusTerm;
365 typedef struct Z_ProximityOperator
367 bool_t *exclusion; /* OPTIONAL */
371 #define Z_Prox_lessThan 1
372 #define Z_Prox_lessThanOrEqual 2
373 #define Z_Prox_equal 3
374 #define Z_Prox_greaterThanOrEqual 4
375 #define Z_Prox_greaterThan 5
376 #define Z_Prox_notEqual 6
382 int *proximityUnitCode;
383 #define Z_ProxUnit_character 1
384 #define Z_ProxUnit_word 2
385 #define Z_ProxUnit_sentence 3
386 #define Z_ProxUnit_paragraph 4
387 #define Z_ProxUnit_section 5
388 #define Z_ProxUnit_chapter 6
389 #define Z_ProxUnit_document 7
390 #define Z_ProxUnit_element 8
391 #define Z_ProxUnit_subelement 9
392 #define Z_ProxUnit_elementType 10
393 #define Z_ProxUnit_byte 11 /* v3 only */
394 } Z_ProximityOperator;
396 typedef struct Z_Operator
407 Odr_null *and; /* these guys are nulls. */
410 Z_ProximityOperator *prox;
414 typedef struct Z_Operand
417 #define Z_Operand_APT 0
418 #define Z_Operand_resultSetId 1
421 Z_AttributesPlusTerm *attributesPlusTerm;
422 Z_ResultSetId *resultSetId;
426 typedef struct Z_Complex
428 struct Z_RPNStructure *s1;
429 struct Z_RPNStructure *s2;
430 Z_Operator *operator;
433 typedef struct Z_RPNStructure
436 #define Z_RPNStructure_simple 0
437 #define Z_RPNStructure_complex 1
445 typedef struct Z_RPNQuery
447 Odr_oid *attributeSetId;
448 Z_RPNStructure *RPNStructure;
451 /* -------------------------- SEARCHREQUEST -------------------------- */
453 typedef struct Z_Query
456 #define Z_Query_type_1 1
457 #define Z_Query_type_2 2
465 typedef struct Z_SearchRequest
467 Z_ReferenceId *referenceId; /* OPTIONAL */
468 int *smallSetUpperBound;
469 int *largeSetLowerBound;
470 int *mediumSetPresentNumber;
471 bool_t *replaceIndicator;
473 int num_databaseNames;
474 char **databaseNames;
475 Z_ElementSetNames *smallSetElementSetNames; /* OPTIONAL */
476 Z_ElementSetNames *mediumSetElementSetNames; /* OPTIONAL */
477 Z_PreferredRecordSyntax *preferredRecordSyntax; /* OPTIONAL */
481 /* ------------------------ RECORD -------------------------- */
483 typedef Odr_external Z_DatabaseRecord;
485 typedef struct Z_DiagRec
487 Odr_oid *diagnosticSetId;
492 typedef struct Z_NamePlusRecord
494 char *databaseName; /* OPTIONAL */
496 #define Z_NamePlusRecord_databaseRecord 0
497 #define Z_NamePlusRecord_surrogateDiagnostic 1
500 Z_DatabaseRecord *databaseRecord;
501 Z_DiagRec *surrogateDiagnostic;
505 typedef struct Z_NamePlusRecordList
508 Z_NamePlusRecord **records;
509 } Z_NamePlusRecordList;
511 typedef struct Z_Records
514 #define Z_Records_DBOSD 0
515 #define Z_Records_NSD 1
518 Z_NamePlusRecordList *databaseOrSurDiagnostics;
519 Z_DiagRec *nonSurrogateDiagnostic;
523 /* ------------------ ACCESS CTRL SERVICE ----------------*/
525 typedef struct Z_AccessControlRequest
527 Z_ReferenceId *referenceId; /* OPTIONAL */
530 Z_AccessRequest_simpleForm,
531 Z_AccessRequest_externallyDefined
536 Odr_external *externallyDefined;
539 Z_OtherInformation *otherInfo; /* OPTIONAL */
541 } Z_AccessControlRequest;
543 typedef struct Z_AccessControlResponse
545 Z_ReferenceId *referenceId; /* OPTIONAL */
548 Z_AccessResponse_simpleForm,
549 Z_AccessResponse_externallyDefined
554 Odr_external *externallyDefined;
556 Z_DiagRec *diagnostic; /* OPTIONAL */
558 Z_OtherInformation *otherInfo; /* OPTIONAL */
560 } Z_AccessControlResponse;
562 /* ------------------------ SCAN SERVICE -------------------- */
564 typedef struct Z_AttributeList
567 Z_AttributeElement **attributes;
570 typedef struct Z_AlternativeTerm
573 Z_AttributesPlusTerm **terms;
576 typedef struct Z_OccurrenceByAttributes
578 Z_AttributeList *attributes;
590 /* Z_ByDatabase *byDatabase; */
593 } Z_OccurrenceByAttributes;
595 typedef struct Z_TermInfo
598 Z_AttributeList *suggestedAttributes; /* OPTIONAL */
599 Z_AlternativeTerm *alternativeTerm; /* OPTIONAL */
600 int *globalOccurrences; /* OPTIONAL */
601 Z_OccurrenceByAttributes *byAttributes; /* OPTIONAL */
604 typedef struct Z_Entry
609 Z_Entry_surrogateDiagnostic
613 Z_TermInfo *termInfo;
614 Z_DiagRec *surrogateDiagnostic;
618 typedef struct Z_Entries
624 typedef struct Z_DiagRecs
627 Z_DiagRec **diagRecs;
630 typedef struct Z_ListEntries
634 Z_ListEntries_entries,
635 Z_ListEntries_nonSurrogateDiagnostics
640 Z_DiagRecs *nonSurrogateDiagnostics;
644 typedef struct Z_ScanRequest
646 Z_ReferenceId *referenceId; /* OPTIONAL */
647 int num_databaseNames;
648 char **databaseNames;
649 Odr_oid *attributeSet; /* OPTIONAL */
651 Z_AttributesPlusTerm *termListAndStartPoint;
652 int *stepSize; /* OPTIONAL */
653 int *numberOfTermsRequested;
654 int *preferredPositionInResponse; /* OPTIONAL */
657 typedef struct Z_ScanResponse
659 Z_ReferenceId *referenceId; /* OPTIONAL */
660 int *stepSize; /* OPTIONAL */
662 #define Z_Scan_success 0
663 #define Z_Scan_partial_1 1
664 #define Z_Scan_partial_2 2
665 #define Z_Scan_partial_3 3
666 #define Z_Scan_partial_4 4
667 #define Z_Scan_partial_5 5
668 #define Z_Scan_failure 6
669 int *numberOfEntriesReturned;
670 int *positionOfTerm; /* OPTIONAL */
671 Z_ListEntries *entries; /* OPTIONAL */
672 Odr_oid *attributeSet; /* OPTIONAL */
675 /* ------------------------ SEARCHRESPONSE ------------------ */
677 typedef struct Z_SearchResponse
679 Z_ReferenceId *referenceId; /* OPTIONAL */
681 int *numberOfRecordsReturned;
682 int *nextResultSetPosition;
683 bool_t *searchStatus;
684 int *resultSetStatus; /* OPTIONAL */
685 #define Z_RES_SUBSET 1
686 #define Z_RES_INTERIM 2
688 int *presentStatus; /* OPTIONAL */
689 #define Z_PRES_SUCCESS 0
690 #define Z_PRES_PARTIAL_1 1
691 #define Z_PRES_PARTIAL_2 2
692 #define Z_PRES_PARTIAL_3 3
693 #define Z_PRES_PARTIAL_4 4
694 #define Z_PRES_FAILURE 5
695 Z_Records *records; /* OPTIONAL */
698 /* ------------------------- PRESENT SERVICE -----------------*/
700 typedef struct Z_PresentRequest
702 Z_ReferenceId *referenceId; /* OPTIONAL */
703 Z_ResultSetId *resultSetId;
704 int *resultSetStartPoint;
705 int *numberOfRecordsRequested;
706 Z_ElementSetNames *elementSetNames; /* OPTIONAL */
707 Z_PreferredRecordSyntax *preferredRecordSyntax; /* OPTIONAL */
710 typedef struct Z_PresentResponse
712 Z_ReferenceId *referenceId; /* OPTIONAL */
713 int *numberOfRecordsReturned;
714 int *nextResultSetPosition;
719 /* ------------------------ DELETE -------------------------- */
721 #define Z_DeleteStatus_success 0
722 #define Z_DeleteStatus_resultSetDidNotExist 1
723 #define Z_DeleteStatus_previouslyDeletedByTarget 2
724 #define Z_DeleteStatus_systemProblemAtTarget 3
725 #define Z_DeleteStatus_accessNotAllowed 4
726 #define Z_DeleteStatus_resourceControlAtOrigin 5
727 #define Z_DeleteStatus_resourceControlAtTarget 6
728 #define Z_DeleteStatus_bulkDeleteNotSupported 7
729 #define Z_DeleteStatus_notAllRsltSetsDeletedOnBulkDlte 8
730 #define Z_DeleteStatus_notAllRequestedResultSetsDeleted 9
731 #define Z_DeleteStatus_resultSetInUse 10
733 typedef struct Z_ListStatus
739 typedef struct Z_DeleteResultSetRequest
741 Z_ReferenceId *referenceId; /* OPTIONAL */
743 #define Z_DeleteRequest_list 0
744 #define Z_DeleteRequest_all 1
746 Z_ResultSetId **resultSetList; /* OPTIONAL */
748 Z_OtherInformation *otherInfo;
750 } Z_DeleteResultSetRequest;
752 typedef struct Z_DeleteResultSetResponse
754 Z_ReferenceId *referenceId; /* OPTIONAL */
755 int *deleteOperationStatus;
757 Z_ListStatus *deleteListStatuses; /* OPTIONAL */
758 int *numberNotDeleted; /* OPTIONAL */
759 int num_bulkStatuses;
760 Z_ListStatus *bulkStatuses; /* OPTIONAL */
761 char *deleteMessage; /* OPTIONAL */
763 Z_OtherInformation *otherInfo;
765 } Z_DeleteResultSetResponse;
767 /* ------------------------ APDU ---------------------------- */
769 typedef struct Z_APDU
775 Z_APDU_searchRequest,
776 Z_APDU_searchResponse,
777 Z_APDU_presentRequest,
778 Z_APDU_presentResponse,
779 Z_APDU_deleteResultSetRequest,
780 Z_APDU_deleteResultSetResponse,
781 Z_APDU_resourceControlRequest,
782 Z_APDU_resourceControlResponse,
783 Z_APDU_triggerResourceControlRequest,
789 Z_InitRequest *initRequest;
790 Z_InitResponse *initResponse;
791 Z_SearchRequest *searchRequest;
792 Z_SearchResponse *searchResponse;
793 Z_PresentRequest *presentRequest;
794 Z_PresentResponse *presentResponse;
795 Z_DeleteResultSetRequest *deleteResultSetRequest;
796 Z_DeleteResultSetResponse *deleteResultSetResponse;
797 Z_ResourceControlRequest *resourceControlRequest;
798 Z_ResourceControlResponse *resourceControlResponse;
799 Z_TriggerResourceControlRequest *triggerResourceControlRequest;
800 Z_ScanRequest *scanRequest;
801 Z_ScanResponse *scanResponse;
805 int z_APDU(ODR o, Z_APDU **p, int opt);
807 Z_InitRequest *zget_InitRequest(ODR o);
808 Z_InitResponse *zget_InitResponse(ODR o);
809 Z_SearchRequest *zget_SearchRequest(ODR o);
810 Z_SearchResponse *zget_SearchResponse(ODR o);
811 Z_PresentRequest *zget_PresentRequest(ODR o);
812 Z_PresentResponse *zget_PresentResponse(ODR o);
813 Z_DeleteResultSetRequest *zget_DeleteResultSetRequest(ODR o);
814 Z_DeleteResultSetResponse *zget_DeleteResultSetResponse(ODR o);
815 Z_ScanRequest *zget_ScanRequest(ODR o);
816 Z_ScanResponse *zget_ScanResponse(ODR o);
817 Z_TriggerResourceControlRequest *zget_TriggerResourceControlRequest(ODR o);
818 Z_ResourceControlRequest *zget_ResourceControlRequest(ODR o);
819 Z_ResourceControlResponse *zget_ResourceControlResponse(ODR o);
820 Z_APDU *zget_APDU(ODR o, enum Z_APDU_which which);