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.9 1995-05-22 11:31:25 quinn
30 * Revision 1.8 1995/05/17 08:41:35 quinn
31 * Added delete to proto & other little things.
32 * Relaying auth info to backend.
34 * Revision 1.7 1995/05/16 08:50:37 quinn
35 * License, documentation, and memory fixes
37 * Revision 1.6 1995/05/15 11:55:55 quinn
38 * Work on asynchronous activity.
40 * Revision 1.5 1995/04/17 11:28:18 quinn
43 * Revision 1.4 1995/04/10 10:22:47 quinn
46 * Revision 1.3 1995/03/30 12:18:09 quinn
49 * Revision 1.2 1995/03/30 10:26:48 quinn
50 * Added Term structure
52 * Revision 1.1 1995/03/30 09:39:42 quinn
53 * Moved .h files to include directory
55 * Revision 1.11 1995/03/30 09:08:44 quinn
56 * Added Resource control protocol
58 * Revision 1.10 1995/03/29 15:39:39 quinn
59 * Adding some resource control elements, and a null-check to getentbyoid
61 * Revision 1.9 1995/03/29 08:06:18 quinn
62 * Added a few v3 elements
64 * Revision 1.8 1995/03/22 10:12:49 quinn
65 * Added Z_PRES constants.
67 * Revision 1.7 1995/03/20 09:45:12 quinn
70 * Revision 1.5 1995/03/07 16:29:34 quinn
71 * Added authentication stuff.
73 * Revision 1.4 1995/03/07 10:13:00 quinn
74 * Added prototype for z_APDU()
76 * Revision 1.3 1995/02/14 11:54:23 quinn
79 * Revision 1.2 1995/02/09 15:51:40 quinn
82 * Revision 1.1 1995/02/06 16:44:48 quinn
83 * First hack at Z/SR protocol
93 /* ----------------- GLOBAL AUXILIARY DEFS ----------------*/
95 typedef Odr_oct Z_ReferenceId;
96 typedef char Z_DatabaseName;
97 typedef char Z_ResultSetId;
98 typedef Odr_oct Z_ResultsetId;
99 typedef Odr_external Z_UserInformationField;
101 typedef struct Z_InfoCategory
103 Odr_oid *categoryTypeId; /* OPTIONAL */
107 typedef struct Z_OtherInformationUnit
109 Z_InfoCategory *category; /* OPTIONAL */
112 Z_OtherInfo_characterInfo,
113 Z_OtherInfo_binaryInfo,
114 Z_OtherInfo_externallyDefinedInfo,
121 Odr_external *externallyDefinedInfo;
124 } Z_OtherInformationUnit;
126 typedef struct Z_OtherInformation
129 Z_OtherInformationUnit **list;
130 } Z_OtherInformation;
132 /* ----------------- INIT SERVICE ----------------*/
136 char *groupId; /* OPTIONAL */
137 char *userId; /* OPTIONAL */
138 char *password; /* OPTIONAL */
141 typedef struct Z_IdAuthentication
145 Z_IdAuthentication_open,
146 Z_IdAuthentication_idPass,
147 Z_IdAuthentication_anonymous,
148 Z_IdAuthentication_other
157 } Z_IdAuthentication;
159 #define Z_ProtocolVersion_1 0
160 #define Z_ProtocolVersion_2 1
161 #define Z_ProtocolVersion_3 2
163 #define Z_Options_search 0
164 #define Z_Options_present 1
165 #define Z_Options_delSet 2
166 #define Z_Options_resourceReport 3
167 #define Z_Options_triggerResourceCtrl 4
168 #define Z_Options_resourceCtrl 5
169 #define Z_Options_accessCtrl 6
170 #define Z_Options_scan 7
171 #define Z_Options_sort 8
172 #define Z_Options_reserved 9
173 #define Z_Options_extendedServices 10
174 #define Z_Options_level_1Segmentation 11
175 #define Z_Options_level_2Segmentation 12
176 #define Z_Options_concurrentOperations 13
177 #define Z_Options_namedResultSets 14
179 typedef struct Z_InitRequest
181 Z_ReferenceId *referenceId; /* OPTIONAL */
182 Odr_bitmask *options;
183 Odr_bitmask *protocolVersion;
184 int *preferredMessageSize;
185 int *maximumRecordSize;
186 Z_IdAuthentication* idAuthentication; /* OPTIONAL */
187 char *implementationId; /* OPTIONAL */
188 char *implementationName; /* OPTIONAL */
189 char *implementationVersion; /* OPTIONAL */
190 Z_UserInformationField *userInformationField; /* OPTIONAL */
193 typedef struct Z_InitResponse
195 Z_ReferenceId *referenceId; /* OPTIONAL */
196 Odr_bitmask *options;
197 Odr_bitmask *protocolVersion;
198 int *preferredMessageSize;
199 int *maximumRecordSize;
201 char *implementationId; /* OPTIONAL */
202 char *implementationName; /* OPTIONAL */
203 char *implementationVersion; /* OPTIONAL */
204 Z_UserInformationField *userInformationField; /* OPTIONAL */
207 typedef struct Z_NSRAuthentication
212 } Z_NSRAuthentication;
214 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt);
216 int z_StrAuthentication(ODR o, char **p, int opt);
219 /* ------------------ RESOURCE CONTROL ----------------*/
221 typedef struct Z_TriggerResourceControlRequest
223 Z_ReferenceId *referenceId; /* OPTIONAL */
224 int *requestedAction;
225 #define Z_TriggerResourceCtrl_resourceReport 1
226 #define Z_TriggerResourceCtrl_resourceControl 2
227 #define Z_TriggerResourceCtrl_cancel 3
228 Odr_oid *prefResourceReportFormat; /* OPTIONAL */
229 bool_t *resultSetWanted; /* OPTIONAL */
230 } Z_TriggerResourceControlRequest;
232 typedef struct Z_ResourceControlRequest
234 Z_ReferenceId *referenceId; /* OPTIONAL */
235 bool_t *suspendedFlag; /* OPTIONAL */
236 Odr_external *resourceReport; /* OPTIONAL */
237 int *partialResultsAvailable; /* OPTIONAL */
238 #define Z_ResourceControlRequest_subset 1
239 #define Z_ResourceControlRequest_interim 2
240 #define Z_ResourceControlRequest_none 3
241 bool_t *responseRequired;
242 bool_t *triggeredRequestFlag; /* OPTIONAL */
243 } Z_ResourceControlRequest;
245 typedef struct Z_ResourceControlResponse
247 Z_ReferenceId *referenceId; /* OPTIONAL */
248 bool_t *continueFlag;
249 bool_t *resultSetWanted; /* OPTIONAL */
250 } Z_ResourceControlResponse;
252 /* ------------------ SEARCH SERVICE ----------------*/
254 typedef Odr_oid Z_PreferredRecordSyntax;
256 typedef struct Z_DatabaseSpecificUnit
259 char *elementSetName;
260 } Z_DatabaseSpecificUnit;
262 typedef struct Z_DatabaseSpecific
265 Z_DatabaseSpecificUnit **elements;
266 } Z_DatabaseSpecific;
268 typedef struct Z_ElementSetNames
271 #define Z_ElementSetNames_generic 0
272 #define Z_ElementSetNames_databaseSpecific 1
276 Z_DatabaseSpecific *databaseSpecific;
280 /* ---------------------- RPN QUERY --------------------------- */
282 typedef struct Z_AttributeElement
286 } Z_AttributeElement;
291 typedef struct Z_Term
297 Z_Term_characterString,
301 Z_Term_integerAndUnit,
306 Odr_oct *general; /* this is required for v2 */
308 char *characterString;
311 Odr_external *external;
312 /* Z_IntUnit *integerAndUnit; */
319 typedef struct Z_AttributesPlusTerm
322 Z_AttributeElement **attributeList;
328 } Z_AttributesPlusTerm;
330 typedef struct Z_ProximityOperator
332 bool_t *exclusion; /* OPTIONAL */
336 #define Z_Prox_lessThan 1
337 #define Z_Prox_lessThanOrEqual 2
338 #define Z_Prox_equal 3
339 #define Z_Prox_greaterThanOrEqual 4
340 #define Z_Prox_greaterThan 5
341 #define Z_Prox_notEqual 6
347 int *proximityUnitCode;
348 #define Z_ProxUnit_character 1
349 #define Z_ProxUnit_word 2
350 #define Z_ProxUnit_sentence 3
351 #define Z_ProxUnit_paragraph 4
352 #define Z_ProxUnit_section 5
353 #define Z_ProxUnit_chapter 6
354 #define Z_ProxUnit_document 7
355 #define Z_ProxUnit_element 8
356 #define Z_ProxUnit_subelement 9
357 #define Z_ProxUnit_elementType 10
358 #define Z_ProxUnit_byte 11 /* v3 only */
359 } Z_ProximityOperator;
361 typedef struct Z_Operator
372 Odr_null *and; /* these guys are nulls. */
375 Z_ProximityOperator *prox;
379 typedef struct Z_Operand
382 #define Z_Operand_APT 0
383 #define Z_Operand_resultSetId 1
386 Z_AttributesPlusTerm *attributesPlusTerm;
387 Z_ResultSetId *resultSetId;
391 typedef struct Z_Complex
393 struct Z_RPNStructure *s1;
394 struct Z_RPNStructure *s2;
395 Z_Operator *operator;
398 typedef struct Z_RPNStructure
401 #define Z_RPNStructure_simple 0
402 #define Z_RPNStructure_complex 1
410 typedef struct Z_RPNQuery
412 Odr_oid *attributeSetId;
413 Z_RPNStructure *RPNStructure;
416 /* -------------------------- SEARCHREQUEST -------------------------- */
418 typedef struct Z_Query
421 #define Z_Query_type_1 1
422 #define Z_Query_type_2 2
430 typedef struct Z_SearchRequest
432 Z_ReferenceId *referenceId; /* OPTIONAL */
433 int *smallSetUpperBound;
434 int *largeSetLowerBound;
435 int *mediumSetPresentNumber;
436 bool_t *replaceIndicator;
438 int num_databaseNames;
439 char **databaseNames;
440 Z_ElementSetNames *smallSetElementSetNames; /* OPTIONAL */
441 Z_ElementSetNames *mediumSetElementSetNames; /* OPTIONAL */
442 Z_PreferredRecordSyntax *preferredRecordSyntax; /* OPTIONAL */
446 /* ------------------------ RECORD -------------------------- */
448 typedef Odr_external Z_DatabaseRecord;
450 typedef struct Z_DiagRec
452 Odr_oid *diagnosticSetId;
457 typedef struct Z_NamePlusRecord
459 char *databaseName; /* OPTIONAL */
461 #define Z_NamePlusRecord_databaseRecord 0
462 #define Z_NamePlusRecord_surrogateDiagnostic 1
465 Z_DatabaseRecord *databaseRecord;
466 Z_DiagRec *surrogateDiagnostic;
470 typedef struct Z_NamePlusRecordList
473 Z_NamePlusRecord **records;
474 } Z_NamePlusRecordList;
476 typedef struct Z_Records
479 #define Z_Records_DBOSD 0
480 #define Z_Records_NSD 1
483 Z_NamePlusRecordList *databaseOrSurDiagnostics;
484 Z_DiagRec *nonSurrogateDiagnostic;
488 /* ------------------ ACCESS CTRL SERVICE ----------------*/
490 typedef struct Z_AccessControlRequest
492 Z_ReferenceId *referenceId; /* OPTIONAL */
495 Z_AccessRequest_simpleForm,
496 Z_AccessRequest_externallyDefined
501 Odr_external *externallyDefined;
504 Z_OtherInformation *otherInfo; /* OPTIONAL */
506 } Z_AccessControlRequest;
508 typedef struct Z_AccessControlResponse
510 Z_ReferenceId *referenceId; /* OPTIONAL */
513 Z_AccessResponse_simpleForm,
514 Z_AccessResponse_externallyDefined
519 Odr_external *externallyDefined;
521 Z_DiagRec *diagnostic; /* OPTIONAL */
523 Z_OtherInformation *otherInfo; /* OPTIONAL */
525 } Z_AccessControlResponse;
527 /* ------------------------ SCAN SERVICE -------------------- */
529 typedef struct Z_AttributeList
532 Z_AttributeElement **attributes;
535 typedef struct Z_AlternativeTerm
538 Z_AttributesPlusTerm **terms;
541 typedef struct Z_OccurrenceByAttributes
543 Z_AttributeList *attributes;
555 /* Z_ByDatabase *byDatabase; */
558 } Z_OccurrenceByAttributes;
560 typedef struct Z_TermInfo
563 Z_AttributeList *suggestedAttributes; /* OPTIONAL */
564 Z_AlternativeTerm *alternativeTerm; /* OPTIONAL */
565 int *globalOccurrences; /* OPTIONAL */
566 Z_OccurrenceByAttributes *byAttributes; /* OPTIONAL */
569 typedef struct Z_Entry
574 Z_Entry_surrogateDiagnostic
578 Z_TermInfo *termInfo;
579 Z_DiagRec *surrogateDiagnostic;
583 typedef struct Z_Entries
589 typedef struct Z_DiagRecs
592 Z_DiagRec **diagRecs;
595 typedef struct Z_ListEntries
599 Z_ListEntries_entries,
600 Z_ListEntries_nonSurrogateDiagnostics
605 Z_DiagRecs *nonSurrogateDiagnostics;
609 typedef struct Z_ScanRequest
611 Z_ReferenceId *referenceId; /* OPTIONAL */
612 int num_databaseNames;
613 char **databaseNames;
614 Odr_oid *attributeSet; /* OPTIONAL */
616 Z_AttributesPlusTerm *termListAndStartPoint;
617 int *stepSize; /* OPTIONAL */
618 int *numberOfTermsRequested;
619 int *preferredPositionInResponse; /* OPTIONAL */
622 typedef struct Z_ScanResponse
624 Z_ReferenceId *referenceId; /* OPTIONAL */
625 int *stepSize; /* OPTIONAL */
627 #define Z_Scan_success 0
628 #define Z_Scan_partial_1 1
629 #define Z_Scan_partial_2 2
630 #define Z_Scan_partial_3 3
631 #define Z_Scan_partial_4 4
632 #define Z_Scan_partial_5 5
633 #define Z_Scan_failure 6
634 int *numberOfEntriesReturned;
635 int *positionOfTerm; /* OPTIONAL */
636 Z_ListEntries *entries; /* OPTIONAL */
637 Odr_oid *attributeSet; /* OPTIONAL */
640 /* ------------------------ SEARCHRESPONSE ------------------ */
642 typedef struct Z_SearchResponse
644 Z_ReferenceId *referenceId; /* OPTIONAL */
646 int *numberOfRecordsReturned;
647 int *nextResultSetPosition;
648 bool_t *searchStatus;
649 int *resultSetStatus; /* OPTIONAL */
650 #define Z_RES_SUBSET 1
651 #define Z_RES_INTERIM 2
653 int *presentStatus; /* OPTIONAL */
654 #define Z_PRES_SUCCESS 0
655 #define Z_PRES_PARTIAL_1 1
656 #define Z_PRES_PARTIAL_2 2
657 #define Z_PRES_PARTIAL_3 3
658 #define Z_PRES_PARTIAL_4 4
659 #define Z_PRES_FAILURE 5
660 Z_Records *records; /* OPTIONAL */
663 /* ------------------------- PRESENT SERVICE -----------------*/
665 typedef struct Z_PresentRequest
667 Z_ReferenceId *referenceId; /* OPTIONAL */
668 Z_ResultSetId *resultSetId;
669 int *resultSetStartPoint;
670 int *numberOfRecordsRequested;
671 Z_ElementSetNames *elementSetNames; /* OPTIONAL */
672 Z_PreferredRecordSyntax *preferredRecordSyntax; /* OPTIONAL */
675 typedef struct Z_PresentResponse
677 Z_ReferenceId *referenceId; /* OPTIONAL */
678 int *numberOfRecordsReturned;
679 int *nextResultSetPosition;
684 /* ------------------------ DELETE -------------------------- */
686 #define Z_DeleteStatus_success 0
687 #define Z_DeleteStatus_resultSetDidNotExist 1
688 #define Z_DeleteStatus_previouslyDeletedByTarget 2
689 #define Z_DeleteStatus_systemProblemAtTarget 3
690 #define Z_DeleteStatus_accessNotAllowed 4
691 #define Z_DeleteStatus_resourceControlAtOrigin 5
692 #define Z_DeleteStatus_resourceControlAtTarget 6
693 #define Z_DeleteStatus_bulkDeleteNotSupported 7
694 #define Z_DeleteStatus_notAllRsltSetsDeletedOnBulkDlte 8
695 #define Z_DeleteStatus_notAllRequestedResultSetsDeleted 9
696 #define Z_DeleteStatus_resultSetInUse 10
698 typedef struct Z_ListStatus
704 typedef struct Z_DeleteResultSetRequest
706 Z_ReferenceId *referenceId; /* OPTIONAL */
708 #define Z_DeleteRequest_list 0
709 #define Z_DeleteRequest_all 1
711 Z_ResultSetId **resultSetList; /* OPTIONAL */
713 Z_OtherInformation *otherInfo;
715 } Z_DeleteResultSetRequest;
717 typedef struct Z_DeleteResultSetResponse
719 Z_ReferenceId *referenceId; /* OPTIONAL */
720 int *deleteOperationStatus;
722 Z_ListStatus *deleteListStatuses; /* OPTIONAL */
723 int *numberNotDeleted; /* OPTIONAL */
724 int num_bulkStatuses;
725 Z_ListStatus *bulkStatuses; /* OPTIONAL */
726 char *deleteMessage; /* OPTIONAL */
728 Z_OtherInformation *otherInfo;
730 } Z_DeleteResultSetResponse;
732 /* ------------------------ APDU ---------------------------- */
734 typedef struct Z_APDU
740 Z_APDU_searchRequest,
741 Z_APDU_searchResponse,
742 Z_APDU_presentRequest,
743 Z_APDU_presentResponse,
744 Z_APDU_deleteResultSetRequest,
745 Z_APDU_deleteResultSetResponse,
746 Z_APDU_resourceControlRequest,
747 Z_APDU_resourceControlResponse,
748 Z_APDU_triggerResourceControlRequest,
754 Z_InitRequest *initRequest;
755 Z_InitResponse *initResponse;
756 Z_SearchRequest *searchRequest;
757 Z_SearchResponse *searchResponse;
758 Z_PresentRequest *presentRequest;
759 Z_PresentResponse *presentResponse;
760 Z_DeleteResultSetRequest *deleteResultSetRequest;
761 Z_DeleteResultSetResponse *deleteResultSetResponse;
762 Z_ResourceControlRequest *resourceControlRequest;
763 Z_ResourceControlResponse *resourceControlResponse;
764 Z_TriggerResourceControlRequest *triggerResourceControlRequest;
765 Z_ScanRequest *scanRequest;
766 Z_ScanResponse *scanResponse;
770 int z_APDU(ODR o, Z_APDU **p, int opt);
772 Z_InitRequest *zget_InitRequest(ODR o);
773 Z_InitResponse *zget_InitResponse(ODR o);
774 Z_SearchRequest *zget_SearchRequest(ODR o);
775 Z_SearchResponse *zget_SearchResponse(ODR o);
776 Z_PresentRequest *zget_PresentRequest(ODR o);
777 Z_PresentResponse *zget_PresentResponse(ODR o);
778 Z_DeleteResultSetRequest *zget_DeleteResultSetRequest(ODR o);
779 Z_DeleteResultSetResponse *zget_DeleteResultSetResponse(ODR o);
780 Z_ScanRequest *zget_ScanRequest(ODR o);
781 Z_ScanResponse *zget_ScanResponse(ODR o);
782 Z_TriggerResourceControlRequest *zget_TriggerResourceControlRequest(ODR o);
783 Z_ResourceControlRequest *zget_ResourceControlRequest(ODR o);
784 Z_ResourceControlResponse *zget_ResourceControlResponse(ODR o);
785 Z_APDU *zget_APDU(ODR o, enum Z_APDU_which which);