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.12 1995-06-05 10:53:13 quinn
30 * Revision 1.11 1995/06/02 09:49:47 quinn
33 * Revision 1.10 1995/05/29 08:11:34 quinn
34 * Moved oid from odr/asn to util.
36 * Revision 1.9 1995/05/22 11:31:25 quinn
39 * Revision 1.8 1995/05/17 08:41:35 quinn
40 * Added delete to proto & other little things.
41 * Relaying auth info to backend.
43 * Revision 1.7 1995/05/16 08:50:37 quinn
44 * License, documentation, and memory fixes
46 * Revision 1.6 1995/05/15 11:55:55 quinn
47 * Work on asynchronous activity.
49 * Revision 1.5 1995/04/17 11:28:18 quinn
52 * Revision 1.4 1995/04/10 10:22:47 quinn
55 * Revision 1.3 1995/03/30 12:18:09 quinn
58 * Revision 1.2 1995/03/30 10:26:48 quinn
59 * Added Term structure
61 * Revision 1.1 1995/03/30 09:39:42 quinn
62 * Moved .h files to include directory
64 * Revision 1.11 1995/03/30 09:08:44 quinn
65 * Added Resource control protocol
67 * Revision 1.10 1995/03/29 15:39:39 quinn
68 * Adding some resource control elements, and a null-check to getentbyoid
70 * Revision 1.9 1995/03/29 08:06:18 quinn
71 * Added a few v3 elements
73 * Revision 1.8 1995/03/22 10:12:49 quinn
74 * Added Z_PRES constants.
76 * Revision 1.7 1995/03/20 09:45:12 quinn
79 * Revision 1.5 1995/03/07 16:29:34 quinn
80 * Added authentication stuff.
82 * Revision 1.4 1995/03/07 10:13:00 quinn
83 * Added prototype for z_APDU()
85 * Revision 1.3 1995/02/14 11:54:23 quinn
88 * Revision 1.2 1995/02/09 15:51:40 quinn
91 * Revision 1.1 1995/02/06 16:44:48 quinn
92 * First hack at Z/SR protocol
103 /* ----------------- GLOBAL AUXILIARY DEFS ----------------*/
105 typedef Odr_oct Z_ReferenceId;
106 typedef char Z_DatabaseName;
107 typedef char Z_ResultSetId;
108 typedef Odr_oct Z_ResultsetId;
109 typedef Odr_external Z_UserInformationField;
111 typedef struct Z_InfoCategory
113 Odr_oid *categoryTypeId; /* OPTIONAL */
117 typedef struct Z_OtherInformationUnit
119 Z_InfoCategory *category; /* OPTIONAL */
122 Z_OtherInfo_characterInfo,
123 Z_OtherInfo_binaryInfo,
124 Z_OtherInfo_externallyDefinedInfo,
131 Odr_external *externallyDefinedInfo;
134 } Z_OtherInformationUnit;
136 typedef struct Z_OtherInformation
139 Z_OtherInformationUnit **list;
140 } Z_OtherInformation;
142 typedef struct Z_StringOrNumeric
146 Z_StringOrNumeric_string,
147 Z_StringOrNumeric_numeric
156 typedef struct Z_Unit
158 char *unitSystem; /* OPTIONAL */
159 Z_StringOrNumeric *unitType; /* OPTIONAL */
160 Z_StringOrNumeric *unit; /* OPTIONAL */
161 int *scaleFactor; /* OPTIONAL */
164 typedef struct Z_IntUnit
170 /* ----------------- INIT SERVICE ----------------*/
174 char *groupId; /* OPTIONAL */
175 char *userId; /* OPTIONAL */
176 char *password; /* OPTIONAL */
179 typedef struct Z_IdAuthentication
183 Z_IdAuthentication_open,
184 Z_IdAuthentication_idPass,
185 Z_IdAuthentication_anonymous,
186 Z_IdAuthentication_other
195 } Z_IdAuthentication;
197 #define Z_ProtocolVersion_1 0
198 #define Z_ProtocolVersion_2 1
199 #define Z_ProtocolVersion_3 2
201 #define Z_Options_search 0
202 #define Z_Options_present 1
203 #define Z_Options_delSet 2
204 #define Z_Options_resourceReport 3
205 #define Z_Options_triggerResourceCtrl 4
206 #define Z_Options_resourceCtrl 5
207 #define Z_Options_accessCtrl 6
208 #define Z_Options_scan 7
209 #define Z_Options_sort 8
210 #define Z_Options_reserved 9
211 #define Z_Options_extendedServices 10
212 #define Z_Options_level_1Segmentation 11
213 #define Z_Options_level_2Segmentation 12
214 #define Z_Options_concurrentOperations 13
215 #define Z_Options_namedResultSets 14
217 typedef struct Z_InitRequest
219 Z_ReferenceId *referenceId; /* OPTIONAL */
220 Odr_bitmask *options;
221 Odr_bitmask *protocolVersion;
222 int *preferredMessageSize;
223 int *maximumRecordSize;
224 Z_IdAuthentication* idAuthentication; /* OPTIONAL */
225 char *implementationId; /* OPTIONAL */
226 char *implementationName; /* OPTIONAL */
227 char *implementationVersion; /* OPTIONAL */
228 Z_UserInformationField *userInformationField; /* OPTIONAL */
231 typedef struct Z_InitResponse
233 Z_ReferenceId *referenceId; /* OPTIONAL */
234 Odr_bitmask *options;
235 Odr_bitmask *protocolVersion;
236 int *preferredMessageSize;
237 int *maximumRecordSize;
239 char *implementationId; /* OPTIONAL */
240 char *implementationName; /* OPTIONAL */
241 char *implementationVersion; /* OPTIONAL */
242 Z_UserInformationField *userInformationField; /* OPTIONAL */
245 typedef struct Z_NSRAuthentication
250 } Z_NSRAuthentication;
252 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt);
254 int z_StrAuthentication(ODR o, char **p, int opt);
257 /* ------------------ RESOURCE CONTROL ----------------*/
259 typedef struct Z_TriggerResourceControlRequest
261 Z_ReferenceId *referenceId; /* OPTIONAL */
262 int *requestedAction;
263 #define Z_TriggerResourceCtrl_resourceReport 1
264 #define Z_TriggerResourceCtrl_resourceControl 2
265 #define Z_TriggerResourceCtrl_cancel 3
266 Odr_oid *prefResourceReportFormat; /* OPTIONAL */
267 bool_t *resultSetWanted; /* OPTIONAL */
268 } Z_TriggerResourceControlRequest;
270 typedef struct Z_ResourceControlRequest
272 Z_ReferenceId *referenceId; /* OPTIONAL */
273 bool_t *suspendedFlag; /* OPTIONAL */
274 Odr_external *resourceReport; /* OPTIONAL */
275 int *partialResultsAvailable; /* OPTIONAL */
276 #define Z_ResourceControlRequest_subset 1
277 #define Z_ResourceControlRequest_interim 2
278 #define Z_ResourceControlRequest_none 3
279 bool_t *responseRequired;
280 bool_t *triggeredRequestFlag; /* OPTIONAL */
281 } Z_ResourceControlRequest;
283 typedef struct Z_ResourceControlResponse
285 Z_ReferenceId *referenceId; /* OPTIONAL */
286 bool_t *continueFlag;
287 bool_t *resultSetWanted; /* OPTIONAL */
288 } Z_ResourceControlResponse;
290 /* ------------------ SEARCH SERVICE ----------------*/
292 typedef Odr_oid Z_PreferredRecordSyntax;
294 typedef struct Z_DatabaseSpecificUnit
297 char *elementSetName;
298 } Z_DatabaseSpecificUnit;
300 typedef struct Z_DatabaseSpecific
303 Z_DatabaseSpecificUnit **elements;
304 } Z_DatabaseSpecific;
306 typedef struct Z_ElementSetNames
309 #define Z_ElementSetNames_generic 0
310 #define Z_ElementSetNames_databaseSpecific 1
314 Z_DatabaseSpecific *databaseSpecific;
318 /* ---------------------- RPN QUERY --------------------------- */
320 typedef struct Z_AttributeElement
324 } Z_AttributeElement;
329 typedef struct Z_Term
335 Z_Term_characterString,
339 Z_Term_integerAndUnit,
344 Odr_oct *general; /* this is required for v2 */
346 char *characterString;
349 Odr_external *external;
350 /* Z_IntUnit *integerAndUnit; */
357 typedef struct Z_AttributesPlusTerm
360 Z_AttributeElement **attributeList;
366 } Z_AttributesPlusTerm;
368 typedef struct Z_ProximityOperator
370 bool_t *exclusion; /* OPTIONAL */
374 #define Z_Prox_lessThan 1
375 #define Z_Prox_lessThanOrEqual 2
376 #define Z_Prox_equal 3
377 #define Z_Prox_greaterThanOrEqual 4
378 #define Z_Prox_greaterThan 5
379 #define Z_Prox_notEqual 6
385 int *proximityUnitCode;
386 #define Z_ProxUnit_character 1
387 #define Z_ProxUnit_word 2
388 #define Z_ProxUnit_sentence 3
389 #define Z_ProxUnit_paragraph 4
390 #define Z_ProxUnit_section 5
391 #define Z_ProxUnit_chapter 6
392 #define Z_ProxUnit_document 7
393 #define Z_ProxUnit_element 8
394 #define Z_ProxUnit_subelement 9
395 #define Z_ProxUnit_elementType 10
396 #define Z_ProxUnit_byte 11 /* v3 only */
397 } Z_ProximityOperator;
399 typedef struct Z_Operator
410 Odr_null *and; /* these guys are nulls. */
413 Z_ProximityOperator *prox;
417 typedef struct Z_Operand
420 #define Z_Operand_APT 0
421 #define Z_Operand_resultSetId 1
424 Z_AttributesPlusTerm *attributesPlusTerm;
425 Z_ResultSetId *resultSetId;
429 typedef struct Z_Complex
431 struct Z_RPNStructure *s1;
432 struct Z_RPNStructure *s2;
433 Z_Operator *operator;
436 typedef struct Z_RPNStructure
439 #define Z_RPNStructure_simple 0
440 #define Z_RPNStructure_complex 1
448 typedef struct Z_RPNQuery
450 Odr_oid *attributeSetId;
451 Z_RPNStructure *RPNStructure;
454 /* -------------------------- SEARCHREQUEST -------------------------- */
456 typedef struct Z_Query
459 #define Z_Query_type_1 1
460 #define Z_Query_type_2 2
468 typedef struct Z_SearchRequest
470 Z_ReferenceId *referenceId; /* OPTIONAL */
471 int *smallSetUpperBound;
472 int *largeSetLowerBound;
473 int *mediumSetPresentNumber;
474 bool_t *replaceIndicator;
476 int num_databaseNames;
477 char **databaseNames;
478 Z_ElementSetNames *smallSetElementSetNames; /* OPTIONAL */
479 Z_ElementSetNames *mediumSetElementSetNames; /* OPTIONAL */
480 Z_PreferredRecordSyntax *preferredRecordSyntax; /* OPTIONAL */
484 /* ------------------------ RECORD -------------------------- */
486 typedef Odr_external Z_DatabaseRecord;
488 typedef struct Z_DiagRec
490 Odr_oid *diagnosticSetId;
495 typedef struct Z_NamePlusRecord
497 char *databaseName; /* OPTIONAL */
499 #define Z_NamePlusRecord_databaseRecord 0
500 #define Z_NamePlusRecord_surrogateDiagnostic 1
503 Z_DatabaseRecord *databaseRecord;
504 Z_DiagRec *surrogateDiagnostic;
508 typedef struct Z_NamePlusRecordList
511 Z_NamePlusRecord **records;
512 } Z_NamePlusRecordList;
514 typedef struct Z_Records
517 #define Z_Records_DBOSD 0
518 #define Z_Records_NSD 1
521 Z_NamePlusRecordList *databaseOrSurDiagnostics;
522 Z_DiagRec *nonSurrogateDiagnostic;
526 /* ------------------ ACCESS CTRL SERVICE ----------------*/
528 typedef struct Z_AccessControlRequest
530 Z_ReferenceId *referenceId; /* OPTIONAL */
533 Z_AccessRequest_simpleForm,
534 Z_AccessRequest_externallyDefined
539 Odr_external *externallyDefined;
542 Z_OtherInformation *otherInfo; /* OPTIONAL */
544 } Z_AccessControlRequest;
546 typedef struct Z_AccessControlResponse
548 Z_ReferenceId *referenceId; /* OPTIONAL */
551 Z_AccessResponse_simpleForm,
552 Z_AccessResponse_externallyDefined
557 Odr_external *externallyDefined;
559 Z_DiagRec *diagnostic; /* OPTIONAL */
561 Z_OtherInformation *otherInfo; /* OPTIONAL */
563 } Z_AccessControlResponse;
565 /* ------------------------ SCAN SERVICE -------------------- */
567 typedef struct Z_AttributeList
570 Z_AttributeElement **attributes;
573 typedef struct Z_AlternativeTerm
576 Z_AttributesPlusTerm **terms;
579 typedef struct Z_OccurrenceByAttributes
581 Z_AttributeList *attributes;
593 /* Z_ByDatabase *byDatabase; */
596 } Z_OccurrenceByAttributes;
598 typedef struct Z_TermInfo
601 Z_AttributeList *suggestedAttributes; /* OPTIONAL */
602 Z_AlternativeTerm *alternativeTerm; /* OPTIONAL */
603 int *globalOccurrences; /* OPTIONAL */
604 Z_OccurrenceByAttributes *byAttributes; /* OPTIONAL */
607 typedef struct Z_Entry
612 Z_Entry_surrogateDiagnostic
616 Z_TermInfo *termInfo;
617 Z_DiagRec *surrogateDiagnostic;
621 typedef struct Z_Entries
627 typedef struct Z_DiagRecs
630 Z_DiagRec **diagRecs;
633 typedef struct Z_ListEntries
637 Z_ListEntries_entries,
638 Z_ListEntries_nonSurrogateDiagnostics
643 Z_DiagRecs *nonSurrogateDiagnostics;
647 typedef struct Z_ScanRequest
649 Z_ReferenceId *referenceId; /* OPTIONAL */
650 int num_databaseNames;
651 char **databaseNames;
652 Odr_oid *attributeSet; /* OPTIONAL */
653 Z_AttributesPlusTerm *termListAndStartPoint;
654 int *stepSize; /* OPTIONAL */
655 int *numberOfTermsRequested;
656 int *preferredPositionInResponse; /* OPTIONAL */
659 typedef struct Z_ScanResponse
661 Z_ReferenceId *referenceId; /* OPTIONAL */
662 int *stepSize; /* OPTIONAL */
664 #define Z_Scan_success 0
665 #define Z_Scan_partial_1 1
666 #define Z_Scan_partial_2 2
667 #define Z_Scan_partial_3 3
668 #define Z_Scan_partial_4 4
669 #define Z_Scan_partial_5 5
670 #define Z_Scan_failure 6
671 int *numberOfEntriesReturned;
672 int *positionOfTerm; /* OPTIONAL */
673 Z_ListEntries *entries; /* OPTIONAL */
674 Odr_oid *attributeSet; /* OPTIONAL */
677 /* ------------------------ SEARCHRESPONSE ------------------ */
679 typedef struct Z_SearchResponse
681 Z_ReferenceId *referenceId; /* OPTIONAL */
683 int *numberOfRecordsReturned;
684 int *nextResultSetPosition;
685 bool_t *searchStatus;
686 int *resultSetStatus; /* OPTIONAL */
687 #define Z_RES_SUBSET 1
688 #define Z_RES_INTERIM 2
690 int *presentStatus; /* OPTIONAL */
691 #define Z_PRES_SUCCESS 0
692 #define Z_PRES_PARTIAL_1 1
693 #define Z_PRES_PARTIAL_2 2
694 #define Z_PRES_PARTIAL_3 3
695 #define Z_PRES_PARTIAL_4 4
696 #define Z_PRES_FAILURE 5
697 Z_Records *records; /* OPTIONAL */
700 /* ------------------------- PRESENT SERVICE -----------------*/
702 typedef struct Z_PresentRequest
704 Z_ReferenceId *referenceId; /* OPTIONAL */
705 Z_ResultSetId *resultSetId;
706 int *resultSetStartPoint;
707 int *numberOfRecordsRequested;
708 Z_ElementSetNames *elementSetNames; /* OPTIONAL */
709 Z_PreferredRecordSyntax *preferredRecordSyntax; /* OPTIONAL */
712 typedef struct Z_PresentResponse
714 Z_ReferenceId *referenceId; /* OPTIONAL */
715 int *numberOfRecordsReturned;
716 int *nextResultSetPosition;
721 /* ------------------------ DELETE -------------------------- */
723 #define Z_DeleteStatus_success 0
724 #define Z_DeleteStatus_resultSetDidNotExist 1
725 #define Z_DeleteStatus_previouslyDeletedByTarget 2
726 #define Z_DeleteStatus_systemProblemAtTarget 3
727 #define Z_DeleteStatus_accessNotAllowed 4
728 #define Z_DeleteStatus_resourceControlAtOrigin 5
729 #define Z_DeleteStatus_resourceControlAtTarget 6
730 #define Z_DeleteStatus_bulkDeleteNotSupported 7
731 #define Z_DeleteStatus_notAllRsltSetsDeletedOnBulkDlte 8
732 #define Z_DeleteStatus_notAllRequestedResultSetsDeleted 9
733 #define Z_DeleteStatus_resultSetInUse 10
735 typedef struct Z_ListStatus
741 typedef struct Z_DeleteResultSetRequest
743 Z_ReferenceId *referenceId; /* OPTIONAL */
745 #define Z_DeleteRequest_list 0
746 #define Z_DeleteRequest_all 1
748 Z_ResultSetId **resultSetList; /* OPTIONAL */
750 Z_OtherInformation *otherInfo;
752 } Z_DeleteResultSetRequest;
754 typedef struct Z_DeleteResultSetResponse
756 Z_ReferenceId *referenceId; /* OPTIONAL */
757 int *deleteOperationStatus;
759 Z_ListStatus *deleteListStatuses; /* OPTIONAL */
760 int *numberNotDeleted; /* OPTIONAL */
761 int num_bulkStatuses;
762 Z_ListStatus *bulkStatuses; /* OPTIONAL */
763 char *deleteMessage; /* OPTIONAL */
765 Z_OtherInformation *otherInfo;
767 } Z_DeleteResultSetResponse;
769 /* ------------------------ APDU ---------------------------- */
771 typedef struct Z_APDU
777 Z_APDU_searchRequest,
778 Z_APDU_searchResponse,
779 Z_APDU_presentRequest,
780 Z_APDU_presentResponse,
781 Z_APDU_deleteResultSetRequest,
782 Z_APDU_deleteResultSetResponse,
783 Z_APDU_resourceControlRequest,
784 Z_APDU_resourceControlResponse,
785 Z_APDU_triggerResourceControlRequest,
791 Z_InitRequest *initRequest;
792 Z_InitResponse *initResponse;
793 Z_SearchRequest *searchRequest;
794 Z_SearchResponse *searchResponse;
795 Z_PresentRequest *presentRequest;
796 Z_PresentResponse *presentResponse;
797 Z_DeleteResultSetRequest *deleteResultSetRequest;
798 Z_DeleteResultSetResponse *deleteResultSetResponse;
799 Z_ResourceControlRequest *resourceControlRequest;
800 Z_ResourceControlResponse *resourceControlResponse;
801 Z_TriggerResourceControlRequest *triggerResourceControlRequest;
802 Z_ScanRequest *scanRequest;
803 Z_ScanResponse *scanResponse;
807 int z_APDU(ODR o, Z_APDU **p, int opt);
809 Z_InitRequest *zget_InitRequest(ODR o);
810 Z_InitResponse *zget_InitResponse(ODR o);
811 Z_SearchRequest *zget_SearchRequest(ODR o);
812 Z_SearchResponse *zget_SearchResponse(ODR o);
813 Z_PresentRequest *zget_PresentRequest(ODR o);
814 Z_PresentResponse *zget_PresentResponse(ODR o);
815 Z_DeleteResultSetRequest *zget_DeleteResultSetRequest(ODR o);
816 Z_DeleteResultSetResponse *zget_DeleteResultSetResponse(ODR o);
817 Z_ScanRequest *zget_ScanRequest(ODR o);
818 Z_ScanResponse *zget_ScanResponse(ODR o);
819 Z_TriggerResourceControlRequest *zget_TriggerResourceControlRequest(ODR o);
820 Z_ResourceControlRequest *zget_ResourceControlRequest(ODR o);
821 Z_ResourceControlResponse *zget_ResourceControlResponse(ODR o);
822 Z_APDU *zget_APDU(ODR o, enum Z_APDU_which which);