2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.26 1995-06-02 09:49:13 quinn
8 * Adding access control
10 * Revision 1.25 1995/05/25 11:00:08 quinn
11 * *** empty log message ***
13 * Revision 1.24 1995/05/22 13:58:18 quinn
14 * Fixed an ODR_NULLVAL.
16 * Revision 1.23 1995/05/22 11:30:18 quinn
17 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
19 * Revision 1.22 1995/05/17 08:40:56 quinn
20 * Added delete. Fixed some sequence_begins. Smallish.
22 * Revision 1.21 1995/05/16 08:50:24 quinn
23 * License, documentation, and memory fixes
25 * Revision 1.20 1995/05/15 11:55:25 quinn
28 * Revision 1.19 1995/04/11 11:58:35 quinn
31 * Revision 1.18 1995/04/11 11:52:02 quinn
32 * Fixed possible buf in proto.c
34 * Revision 1.17 1995/04/10 10:22:22 quinn
37 * Revision 1.16 1995/03/30 10:26:43 quinn
38 * Added Term structure
40 * Revision 1.15 1995/03/30 09:08:39 quinn
41 * Added Resource control protocol
43 * Revision 1.14 1995/03/29 08:06:13 quinn
44 * Added a few v3 elements
46 * Revision 1.13 1995/03/20 11:26:52 quinn
47 * *** empty log message ***
49 * Revision 1.12 1995/03/20 09:45:09 quinn
52 * Revision 1.11 1995/03/17 10:17:25 quinn
53 * Added memory management.
55 * Revision 1.10 1995/03/15 11:17:40 quinn
56 * Fixed some return-checks from choice.. need better ay to handle those..
58 * Revision 1.9 1995/03/15 08:37:06 quinn
59 * Fixed protocol bugs.
61 * Revision 1.8 1995/03/14 16:59:24 quinn
62 * Fixed OPTIONAL flag in attributeelement
64 * Revision 1.7 1995/03/07 16:29:33 quinn
65 * Added authentication stuff.
67 * Revision 1.6 1995/03/01 14:46:03 quinn
68 * Fixed protocol bug in 8777query.
70 * Revision 1.5 1995/02/14 11:54:22 quinn
73 * Revision 1.4 1995/02/10 15:54:30 quinn
76 * Revision 1.3 1995/02/09 15:51:39 quinn
79 * Revision 1.2 1995/02/06 21:26:07 quinn
80 * Repaired this evening's damages..
82 * Revision 1.1 1995/02/06 16:44:47 quinn
83 * First hack at Z/SR protocol
91 /* ---------------------- GLOBAL DEFS ------------------- */
93 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
95 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
98 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
100 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
104 int z_ResultSetId(ODR o, char **p, int opt)
106 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
110 int z_UserInformationField(ODR o, Z_UserInformationField **p, int opt)
112 return odr_explicit(o, odr_external, (Odr_external **)p, ODR_CONTEXT,
116 int z_InfoCategory(ODR o, Z_InfoCategory **p, int opt)
118 if (!odr_sequence_begin(o, p, sizeof(**p)))
119 return opt && odr_ok(o);
121 odr_implicit(o, odr_oid, &(*p)->categoryTypeId, ODR_CONTEXT, 1, 1) &&
122 odr_implicit(o, odr_integer, &(*p)->categoryValue, ODR_CONTEXT, 2, 0) &&
126 int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt)
128 static Odr_arm arm[] =
130 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_OtherInfo_characterInfo,
132 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_OtherInfo_binaryInfo,
134 {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_OtherInfo_externallyDefinedInfo,
136 {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_OtherInfo_oid, odr_oid},
140 if (!odr_sequence_begin(o, p, sizeof(**p)))
141 return opt && odr_ok(o);
143 odr_implicit(o, z_InfoCategory, &(*p)->category, ODR_CONTEXT, 1, 1) &&
144 odr_choice(o, arm, &(*p)->which, &(*p)->information) &&
148 int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt)
150 if (o->direction == ODR_ENCODE)
151 *p = odr_malloc(o, sizeof(**p));
153 odr_implicit_settag(o, ODR_CONTEXT, 201);
154 if (odr_sequence_of(o, z_OtherInformationUnit, &(*p)->list,
155 &(*p)->num_elements))
158 return opt && odr_ok(o);
161 int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt)
163 static Odr_arm arm[] =
165 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_StringOrNumeric_string,
167 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_StringOrNumeric_numeric,
172 if (o->direction == ODR_DECODE)
173 *p = odr_malloc(o, sizeof(**p));
174 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
177 return opt && odr_ok(o);
183 int z_Unit(ODR o, Z_Unit **p, int opt)
185 if (!odr_sequence_begin(o, p, sizeof(**p)))
186 return opt && odr_ok(o);
188 odr_implicit(o, odr_visiblestring, &(*p)->unitSystem, ODR_CONTEXT,
190 odr_explicit(o, z_StringOrNumeric, &(*p)->unitType, ODR_CONTEXT,
192 odr_explicit(o, z_StringOrNumeric, &(*p)->unit, ODR_CONTEXT, 3, 1) &&
193 odr_implicit(o, odr_integer, &(*p)->scaleFactor, ODR_CONTEXT, 4, 1) &&
197 int z_IntUnit(ODR o, Z_IntUnit **p, int opt)
199 if (!odr_sequence_begin(o, p, sizeof(**p)))
200 return opt && odr_ok(o);
202 odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 1, 0) &&
203 odr_implicit(o, z_Unit, &(*p)->unitUsed, ODR_CONTEXT, 2, 0) &&
207 /* ---------------------- INITIALIZE SERVICE ------------------- */
210 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
212 if (!odr_sequence_begin(o, p, sizeof(**p)))
213 return opt && odr_ok(o);
215 odr_visiblestring(o, &(*p)->user, 0) &&
216 odr_visiblestring(o, &(*p)->password, 0) &&
217 odr_visiblestring(o, &(*p)->account, 0) &&
222 int z_IdPass(ODR o, Z_IdPass **p, int opt)
224 if (!odr_sequence_begin(o, p, sizeof(**p)))
225 return opt && odr_ok(o);
227 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 1) &&
228 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 1) &&
229 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
234 int z_StrAuthentication(ODR o, char **p, int opt)
236 return odr_visiblestring(o, p, opt);
239 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
241 static Odr_arm arm[] =
243 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
244 {-1, -1, -1, Z_IdAuthentication_idPass, z_IdPass},
245 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
246 {-1, -1, -1, Z_IdAuthentication_other, odr_external},
250 if (o->direction == ODR_DECODE)
251 *p = odr_malloc(o, sizeof(**p));
253 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
256 return opt && odr_ok(o);
259 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
263 if (!odr_sequence_begin(o, p, sizeof(**p)))
264 return opt && odr_ok(o);
267 z_ReferenceId(o, &pp->referenceId, 1) &&
268 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
270 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
271 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
273 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
275 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
277 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
279 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
281 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
282 ODR_CONTEXT, 112, 1) &&
283 z_UserInformationField(o, &pp->userInformationField, 1) &&
285 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
290 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
294 if (!odr_sequence_begin(o, p, sizeof(**p)))
295 return opt && odr_ok(o);
298 z_ReferenceId(o, &pp->referenceId, 1) &&
299 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
301 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
302 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
304 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
306 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
307 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
309 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
311 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
312 ODR_CONTEXT, 112, 1) &&
313 z_UserInformationField(o, &pp->userInformationField, 1) &&
315 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
320 /* ------------------ RESOURCE CONTROL ----------------*/
322 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
325 if (!odr_sequence_begin(o, p, sizeof(**p)))
326 return opt && odr_ok(o);
328 z_ReferenceId(o, &(*p)->referenceId, 1) &&
329 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
331 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
332 ODR_CONTEXT, 47, 1) &&
333 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
336 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
341 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
343 if (!odr_sequence_begin(o, p, sizeof(**p)))
344 return opt && odr_ok(o);
346 z_ReferenceId(o, &(*p)->referenceId, 1) &&
347 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
348 odr_explicit(o, odr_external, &(*p)->resourceReport, ODR_CONTEXT,
350 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
351 ODR_CONTEXT, 41, 1) &&
352 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
354 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
355 ODR_CONTEXT, 43, 1) &&
357 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
362 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
364 if (!odr_sequence_begin(o, p, sizeof(**p)))
365 return opt && odr_ok(o);
367 z_ReferenceId(o, &(*p)->referenceId, 1) &&
368 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
369 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
372 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
377 /* ------------------------ SEARCH SERVICE ----------------------- */
379 int z_ElementSetName(ODR o, char **p, int opt)
381 return odr_implicit(o, odr_visiblestring, (char**) p, ODR_CONTEXT, 103,
385 int z_PreferredRecordSyntax(ODR o, Z_PreferredRecordSyntax **p, int opt)
387 return odr_implicit(o, odr_oid, (Odr_oid**) p, ODR_CONTEXT, 104, opt);
390 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
392 if (!odr_sequence_begin(o, p, sizeof(**p)))
393 return opt && odr_ok(o);
395 z_DatabaseName(o, &(*p)->databaseName, 0) &&
396 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
400 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
402 if (o->direction == ODR_DECODE)
403 *p = odr_malloc(o, sizeof(**p));
407 odr_implicit_settag(o, ODR_CONTEXT, 1);
408 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
409 &(*p)->num_elements))
415 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
417 static Odr_arm arm[] =
419 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
421 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
426 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 19))
427 return opt && odr_ok(o);
429 if (o->direction == ODR_DECODE)
430 *p = odr_malloc(o, sizeof(**p));
432 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
433 odr_constructed_end(o))
439 /* ----------------------- RPN QUERY -----------------------*/
441 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
443 if (!odr_sequence_begin(o, p, sizeof(**p)))
444 return opt && odr_ok(o);
446 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
448 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
455 int z_Term(ODR o, Z_Term **p, int opt)
457 static Odr_arm arm[] =
459 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
460 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
461 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
463 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
464 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
465 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, odr_external},
466 /* add intUnit here */
467 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
471 if (o->direction ==ODR_DECODE)
472 *p = odr_malloc(o, sizeof(**p));
475 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
478 return opt && odr_ok(o);
483 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
485 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
486 odr_sequence_begin(o, p, sizeof(**p))))
487 return opt && odr_ok(o);
489 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
490 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
491 &(*p)->num_attributes) &&
492 z_Term(o, &(*p)->term, 0) &&
496 int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
498 static Odr_arm arm[] =
500 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, odr_integer},
501 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_private, odr_integer},
505 if (!odr_sequence_begin(o, p, sizeof(**p)))
506 return opt && odr_ok(o);
508 odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
509 odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
510 odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
511 odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
512 odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
513 odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
514 odr_constructed_end(o) &&
518 int z_Operator(ODR o, Z_Operator **p, int opt)
520 static Odr_arm arm[] =
522 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
523 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
524 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
525 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, z_ProximityOperator},
529 if (!*p && o->direction != ODR_DECODE)
531 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
532 return opt && odr_ok(o);
533 if (o->direction == ODR_DECODE)
534 *p = odr_malloc(o, sizeof(**p));
536 (*p)->u.and = ODR_NULLVAL;
538 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
539 odr_constructed_end(o))
542 return opt && odr_ok(o);
545 int z_Operand(ODR o, Z_Operand **p, int opt)
547 static Odr_arm arm[] =
549 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
550 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
554 if (o->direction ==ODR_DECODE)
555 *p = odr_malloc(o, sizeof(**p));
558 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
561 return opt && odr_ok(o);
564 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
566 int z_Complex(ODR o, Z_Complex **p, int opt)
568 if (!odr_sequence_begin(o, p, sizeof(**p)))
569 return opt && odr_ok(o);
571 z_RPNStructure(o, &(*p)->s1, 0) &&
572 z_RPNStructure(o, &(*p)->s2, 0) &&
573 z_Operator(o, &(*p)->operator, 0) &&
577 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
579 static Odr_arm arm[] =
581 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
582 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
586 if (o->direction == ODR_DECODE)
587 *p = odr_malloc(o, sizeof(**p));
590 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
593 return opt && odr_ok(o);
596 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
598 if (!odr_sequence_begin(o, p, sizeof(**p)))
599 return opt && odr_ok(o);
601 odr_oid(o, &(*p)->attributeSetId, 0) &&
602 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
606 /* -----------------------END RPN QUERY ----------------------- */
608 int z_Query(ODR o, Z_Query **p, int opt)
610 static Odr_arm arm[] =
612 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
613 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
617 if (o->direction == ODR_DECODE)
618 *p = odr_malloc(o, sizeof(**p));
621 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
624 return opt && odr_ok(o);
627 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
631 if (!odr_sequence_begin(o, p, sizeof(**p)))
632 return opt && odr_ok(o);
635 z_ReferenceId(o, &pp->referenceId, 1) &&
636 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
638 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
640 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
642 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
643 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
645 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
646 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
647 &pp->num_databaseNames) &&
648 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
649 ODR_CONTEXT, 100, 1) &&
650 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
651 ODR_CONTEXT, 101, 1) &&
652 odr_implicit(o, z_PreferredRecordSyntax, &pp->preferredRecordSyntax,
653 ODR_CONTEXT, 104, 1) &&
654 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
656 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
657 ODR_CONTEXT, 203, 1) &&
658 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
663 /* ------------------------ RECORD ------------------------- */
665 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
667 return odr_external(o, (Odr_external **) p, opt);
670 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
672 if (!odr_sequence_begin(o, p, sizeof(**p)))
673 return opt && odr_ok(o);
675 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT */
676 odr_integer(o, &(*p)->condition, 0) &&
677 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
678 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT, ODR_VISIBLESTRING, 1)) &&
682 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
684 static Odr_arm arm[] =
686 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
688 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
693 if (!odr_sequence_begin(o, p, sizeof(**p)))
694 return opt && odr_ok(o);
696 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
698 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
699 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
700 odr_constructed_end(o) &&
704 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
706 if (o->direction == ODR_DECODE)
707 *p = odr_malloc(o, sizeof(**p));
708 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
715 int z_Records(ODR o, Z_Records **p, int opt)
719 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
720 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
724 if (o->direction == ODR_DECODE)
725 *p = odr_malloc(o, sizeof(**p));
728 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
731 return opt && odr_ok(o);
734 /* ------------------------ ACCESS CTRL SERVICE ----------------------- */
736 int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
738 static Odr_arm arm[] =
740 {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
742 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
746 if (!odr_sequence_begin(o, p, sizeof(**p)))
747 return opt && odr_ok(o);
749 z_ReferenceId(o, &(*p)->referenceId, 1) &&
750 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
752 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
757 int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
759 static Odr_arm arm[] =
761 {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
763 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
767 if (!odr_sequence_begin(o, p, sizeof(**p)))
768 return opt && odr_ok(o);
770 z_ReferenceId(o, &(*p)->referenceId, 1) &&
771 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
772 odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
774 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
779 /* ------------------------ SCAN SERVICE -------------------- */
781 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
783 if (o->direction == ODR_DECODE)
784 *p = odr_malloc(o, sizeof(**p));
788 odr_implicit_settag(o, ODR_CONTEXT, 44);
789 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
790 &(*p)->num_attributes))
793 return opt && odr_ok(o);
797 * This is a temporary hack. We don't know just *what* old version of the
798 * protocol willow uses, so we'll just patiently wait for them to update
800 static int willow_scan = 0;
802 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
804 if (!*p && o->direction != ODR_DECODE)
806 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
809 return opt && odr_ok(o);
811 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
813 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
815 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
817 if (o->direction == ODR_DECODE)
818 *p = odr_malloc(o, sizeof(**p));
819 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
820 &(*p)->num_attributes))
822 if (!odr_sequence_end(o) || !odr_sequence_end(o))
824 if (!z_Term(o, &(*p)->term, 0))
826 if (!odr_constructed_end(o))
832 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
834 if (o->direction == ODR_DECODE)
835 *p = odr_malloc(o, sizeof(**p));
839 return opt && odr_ok(o);
842 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
846 return opt && !o->error;
849 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
851 if (!odr_sequence_begin(o, p, sizeof(**p)))
852 return opt && odr_ok(o);
854 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
855 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
859 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
861 if (!odr_sequence_begin(o, p, sizeof(**p)))
862 return opt && odr_ok(o);
865 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
866 z_Term(o, &(*p)->term, 0)) &&
867 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
868 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
869 ODR_CONTEXT, 4, 1) &&
870 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
872 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
873 ODR_CONTEXT, 3, 1) &&
877 int z_Entry(ODR o, Z_Entry **p, int opt)
879 static Odr_arm arm[] =
881 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
882 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
887 if (o->direction == ODR_DECODE)
888 *p = odr_malloc(o, sizeof(**p));
890 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
893 return opt && odr_ok(o);
896 int z_Entries(ODR o, Z_Entries **p, int opt)
898 if (o->direction == ODR_DECODE)
899 *p = odr_malloc(o, sizeof(**p));
903 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
910 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
912 if (o->direction == ODR_DECODE)
913 *p = odr_malloc(o, sizeof(**p));
917 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
918 &(*p)->num_diagRecs))
924 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
926 static Odr_arm arm[] =
928 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
929 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
934 if (o->direction == ODR_DECODE)
935 *p = odr_malloc(o, sizeof(**p));
937 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
940 return opt && odr_ok(o);
943 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
945 if (!odr_sequence_begin(o, p, sizeof(**p)))
946 return opt && odr_ok(o);
949 z_ReferenceId(o, &(*p)->referenceId, 1) &&
950 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
951 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
952 &(*p)->num_databaseNames) &&
953 odr_oid(o, &(*p)->attributeSet, 1) &&
954 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
955 ((*p)->termListAndStartPoint ? 1 :
956 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
957 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
958 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
959 ODR_CONTEXT, 6, 0) &&
960 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
961 ODR_CONTEXT, 7, 1) &&
965 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
967 if (!odr_sequence_begin(o, p, sizeof(**p)))
968 return opt && odr_ok(o);
970 z_ReferenceId(o, &(*p)->referenceId, 1) &&
971 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
972 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
973 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
974 ODR_CONTEXT, 5, 0) &&
975 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
976 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
977 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
981 /* ------------------------ SEARCHRESPONSE ----------------*/
983 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
985 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
988 int z_NextResultSetPosition(ODR o, int **p, int opt)
990 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
993 int z_PresentStatus(ODR o, int **p, int opt)
995 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
998 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
1000 Z_SearchResponse *pp;
1002 if (!odr_sequence_begin(o, p, sizeof(**p)))
1003 return opt && odr_ok(o);
1006 z_ReferenceId(o, &pp->referenceId, 1) &&
1007 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
1008 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1009 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1010 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
1011 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26, 1) &&
1012 z_PresentStatus(o, &pp->presentStatus, 1) &&
1013 z_Records(o, &pp->records, 1) &&
1015 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
1016 ODR_CONTEXT, 203, 1) &&
1017 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1019 odr_sequence_end(o);
1022 /* --------------------- PRESENT SERVICE ---------------------- */
1024 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
1026 Z_PresentRequest *pp;
1028 if (!odr_sequence_begin(o, p, sizeof(**p)))
1029 return opt && odr_ok(o);
1032 z_ReferenceId(o, &pp->referenceId, 1) &&
1033 z_ResultSetId(o, &pp->resultSetId, 0) &&
1034 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
1036 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
1038 z_ElementSetNames(o, &pp->elementSetNames, 1) &&
1039 z_PreferredRecordSyntax(o, &pp->preferredRecordSyntax, 1) &&
1040 odr_sequence_end(o);
1043 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
1045 Z_PresentResponse *pp;
1047 if (!odr_sequence_begin(o, p, sizeof(**p)))
1048 return opt && odr_ok(o);
1051 z_ReferenceId(o, &pp->referenceId, 1) &&
1052 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1053 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1054 z_PresentStatus(o, &pp->presentStatus, 0) &&
1055 z_Records(o, &pp->records, 1) &&
1056 odr_sequence_end(o);
1059 /* ----------------------DELETE -------------------------- */
1061 int z_DeleteSetStatus(ODR o, int **p, int opt)
1063 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
1066 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
1068 if (!odr_sequence_begin(o, p, sizeof(**p)))
1069 return opt && odr_ok(o);
1071 z_ResultSetId(o, &(*p)->id, 0) &&
1072 z_DeleteSetStatus(o, &(*p)->status, 0) &&
1073 odr_sequence_end(o);
1076 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
1078 if (!odr_sequence_begin(o, p, sizeof(**p)))
1079 return opt && odr_ok(o);
1081 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1082 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
1084 (odr_sequence_of(o, z_ListStatus, &(*p)->resultSetList,
1085 &(*p)->num_ids) || odr_ok(o)) &&
1087 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1089 odr_sequence_end(o);
1092 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
1094 if (!odr_sequence_begin(o, p, sizeof(**p)))
1095 return opt && odr_ok(o);
1097 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1098 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
1099 ODR_CONTEXT, 0, 1) &&
1100 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
1101 (odr_sequence_of(o, z_ListStatus, &(*p)->deleteListStatuses,
1102 &(*p)->num_statuses) || odr_ok(o)) &&
1103 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
1105 odr_implicit_settag(o, ODR_CONTEXT, 35) &&
1106 (odr_sequence_of(o, z_ListStatus, &(*p)->bulkStatuses,
1107 &(*p)->num_bulkStatuses) || odr_ok(o)) &&
1108 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
1111 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1113 odr_sequence_end(o);
1116 /* ------------------------ APDU ------------------------- */
1118 int z_APDU(ODR o, Z_APDU **p, int opt)
1120 static Odr_arm arm[] =
1122 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
1123 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
1124 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
1125 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
1127 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
1129 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
1131 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
1132 z_DeleteResultSetRequest},
1133 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
1134 z_DeleteResultSetResponse},
1135 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
1136 z_ResourceControlRequest},
1137 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
1138 z_ResourceControlResponse},
1139 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
1140 z_TriggerResourceControlRequest},
1141 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
1142 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
1147 if (o->direction == ODR_DECODE)
1148 *p = odr_malloc(o, sizeof(**p));
1149 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
1151 if (o->direction == ODR_DECODE)
1153 return opt && odr_ok(o);