2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.21 1995-05-16 08:50:24 quinn
8 * License, documentation, and memory fixes
10 * Revision 1.20 1995/05/15 11:55:25 quinn
13 * Revision 1.19 1995/04/11 11:58:35 quinn
16 * Revision 1.18 1995/04/11 11:52:02 quinn
17 * Fixed possible buf in proto.c
19 * Revision 1.17 1995/04/10 10:22:22 quinn
22 * Revision 1.16 1995/03/30 10:26:43 quinn
23 * Added Term structure
25 * Revision 1.15 1995/03/30 09:08:39 quinn
26 * Added Resource control protocol
28 * Revision 1.14 1995/03/29 08:06:13 quinn
29 * Added a few v3 elements
31 * Revision 1.13 1995/03/20 11:26:52 quinn
32 * *** empty log message ***
34 * Revision 1.12 1995/03/20 09:45:09 quinn
37 * Revision 1.11 1995/03/17 10:17:25 quinn
38 * Added memory management.
40 * Revision 1.10 1995/03/15 11:17:40 quinn
41 * Fixed some return-checks from choice.. need better ay to handle those..
43 * Revision 1.9 1995/03/15 08:37:06 quinn
44 * Fixed protocol bugs.
46 * Revision 1.8 1995/03/14 16:59:24 quinn
47 * Fixed OPTIONAL flag in attributeelement
49 * Revision 1.7 1995/03/07 16:29:33 quinn
50 * Added authentication stuff.
52 * Revision 1.6 1995/03/01 14:46:03 quinn
53 * Fixed protocol bug in 8777query.
55 * Revision 1.5 1995/02/14 11:54:22 quinn
58 * Revision 1.4 1995/02/10 15:54:30 quinn
61 * Revision 1.3 1995/02/09 15:51:39 quinn
64 * Revision 1.2 1995/02/06 21:26:07 quinn
65 * Repaired this evening's damages..
67 * Revision 1.1 1995/02/06 16:44:47 quinn
68 * First hack at Z/SR protocol
76 /* ---------------------- GLOBAL DEFS ------------------- */
78 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
80 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
83 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
85 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
89 int z_ResultSetId(ODR o, char **p, int opt)
91 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
95 int z_UserInformationField(ODR o, Z_UserInformationField **p, int opt)
97 return odr_explicit(o, odr_external, (Odr_external **)p, ODR_CONTEXT,
101 /* ---------------------- INITIALIZE SERVICE ------------------- */
103 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
105 if (!odr_sequence_begin(o, p, sizeof(**p)))
106 return opt && odr_ok(o);
108 odr_visiblestring(o, &(*p)->user, 0) &&
109 odr_visiblestring(o, &(*p)->password, 0) &&
110 odr_visiblestring(o, &(*p)->account, 0) &&
114 int z_IdPass(ODR o, Z_IdPass **p, int opt)
116 if (!odr_sequence_begin(o, p, sizeof(**p)))
117 return opt && odr_ok(o);
119 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 0) &&
120 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 0) &&
121 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
126 int z_StrAuthentication(ODR o, char **p, int opt)
128 return odr_visiblestring(o, p, opt);
131 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
133 static Odr_arm arm[] =
135 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
136 {-1, -1, -1, Z_IdAuthentication_idPass, z_NSRAuthentication},
137 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
138 {-1, -1, -1, Z_IdAuthentication_other, odr_external},
142 if (o->direction == ODR_DECODE)
143 *p = odr_malloc(o, sizeof(**p));
145 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
148 return opt && !o->error;
151 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
155 if (!odr_sequence_begin(o, p, sizeof(**p)))
159 z_ReferenceId(o, &pp->referenceId, 1) &&
160 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
162 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
163 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
165 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
167 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
169 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
171 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
173 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
174 ODR_CONTEXT, 112, 1) &&
175 z_UserInformationField(o, &pp->userInformationField, 1) &&
179 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
183 if (!odr_sequence_begin(o, p, sizeof(**p)))
187 z_ReferenceId(o, &pp->referenceId, 1) &&
188 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
190 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
191 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
193 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
195 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
196 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
198 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
200 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
201 ODR_CONTEXT, 112, 1) &&
202 z_UserInformationField(o, &pp->userInformationField, 1) &&
206 /* ------------------ RESOURCE CONTROL ----------------*/
208 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
211 if (!odr_sequence_begin(o, p, sizeof(**p)))
214 z_ReferenceId(o, &(*p)->referenceId, 1) &&
215 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
217 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
218 ODR_CONTEXT, 47, 1) &&
219 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
224 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
226 if (!odr_sequence_begin(o, p, sizeof(**p)))
229 z_ReferenceId(o, &(*p)->referenceId, 1) &&
230 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
231 odr_explicit(o, odr_external, &(*p)->resourceReport, ODR_CONTEXT,
233 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
234 ODR_CONTEXT, 41, 1) &&
235 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
237 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
238 ODR_CONTEXT, 43, 1) &&
242 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
244 if (!odr_sequence_begin(o, p, sizeof(**p)))
247 z_ReferenceId(o, &(*p)->referenceId, 1) &&
248 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
249 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
254 /* ------------------------ SEARCH SERVICE ----------------------- */
256 int z_ElementSetName(ODR o, char **p, int opt)
258 return odr_implicit(o, odr_visiblestring, (char**) p, ODR_CONTEXT, 103,
262 int z_PreferredRecordSyntax(ODR o, Z_PreferredRecordSyntax **p, int opt)
264 return odr_implicit(o, odr_oid, (Odr_oid**) p, ODR_CONTEXT, 104, opt);
267 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
269 if (!odr_sequence_begin(o, p, sizeof(**p)))
272 z_DatabaseName(o, &(*p)->databaseName, 0) &&
273 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
277 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
279 if (o->direction == ODR_DECODE)
280 *p = odr_malloc(o, sizeof(**p));
284 odr_implicit_settag(o, ODR_CONTEXT, 1);
285 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
286 &(*p)->num_elements))
292 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
294 static Odr_arm arm[] =
296 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
298 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
303 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 19))
306 if (o->direction == ODR_DECODE)
307 *p = odr_malloc(o, sizeof(**p));
309 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
310 odr_constructed_end(o))
316 /* ----------------------- RPN QUERY -----------------------*/
318 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
320 if (!odr_sequence_begin(o, p, sizeof(**p)))
323 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
325 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
332 int z_Term(ODR o, Z_Term **p, int opt)
334 static Odr_arm arm[] =
336 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
337 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
338 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
340 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
341 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
342 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, odr_external},
343 /* add intUnit here */
344 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
348 if (o->direction ==ODR_DECODE)
349 *p = odr_malloc(o, sizeof(**p));
352 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
355 return opt && !o->error;
360 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
362 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
363 odr_sequence_begin(o, p, sizeof(**p))))
366 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
367 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
368 &(*p)->num_attributes) &&
370 z_Term(o, &(*p)->term, 0) &&
372 odr_implicit(o, odr_octetstring, &(*p)->term, ODR_CONTEXT, 45, 0) &&
377 int z_Operator(ODR o, Z_Operator **p, int opt)
379 static Odr_arm arm[] =
381 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
382 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
383 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
388 if (!*p && o->direction != ODR_DECODE)
390 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
392 if (o->direction == ODR_DECODE)
393 *p = odr_malloc(o, sizeof(**p));
395 (*p)->u.and = &dummy;
397 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
398 odr_constructed_end(o))
401 return opt && odr_ok(o);
404 int z_Operand(ODR o, Z_Operand **p, int opt)
406 static Odr_arm arm[] =
408 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
409 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
413 if (o->direction ==ODR_DECODE)
414 *p = odr_malloc(o, sizeof(**p));
417 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
420 return opt && odr_ok(o);
423 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
425 int z_Complex(ODR o, Z_Complex **p, int opt)
427 if (!odr_sequence_begin(o, p, sizeof(**p)))
428 return opt && odr_ok(o);
430 z_RPNStructure(o, &(*p)->s1, 0) &&
431 z_RPNStructure(o, &(*p)->s2, 0) &&
432 z_Operator(o, &(*p)->operator, 0) &&
436 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
438 static Odr_arm arm[] =
440 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
441 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
445 if (o->direction == ODR_DECODE)
446 *p = odr_malloc(o, sizeof(**p));
449 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
452 return opt && odr_ok(o);
455 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
457 if (!odr_sequence_begin(o, p, sizeof(**p)))
458 return opt && odr_ok(o);
460 odr_oid(o, &(*p)->attributeSetId, 0) &&
461 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
465 /* -----------------------END RPN QUERY ----------------------- */
467 int z_Query(ODR o, Z_Query **p, int opt)
469 static Odr_arm arm[] =
471 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
472 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
476 if (o->direction == ODR_DECODE)
477 *p = odr_malloc(o, sizeof(**p));
480 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
483 return opt && odr_ok(o);
486 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
490 if (!odr_sequence_begin(o, p, sizeof(**p)))
491 return opt && odr_ok(o);
494 z_ReferenceId(o, &pp->referenceId, 1) &&
495 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
497 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
499 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
501 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
502 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
504 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
505 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
506 &pp->num_databaseNames) &&
507 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
508 ODR_CONTEXT, 100, 1) &&
509 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
510 ODR_CONTEXT, 101, 1) &&
511 z_PreferredRecordSyntax(o, &pp->preferredRecordSyntax, 1) &&
512 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
516 /* ------------------------ RECORD ------------------------- */
518 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
520 return odr_external(o, (Odr_external **) p, opt);
523 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
525 if (!odr_sequence_begin(o, p, sizeof(**p)))
526 return opt && odr_ok(o);
528 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT */
529 odr_integer(o, &(*p)->condition, 0) &&
530 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
531 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT, ODR_VISIBLESTRING, 1)) &&
535 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
537 static Odr_arm arm[] =
539 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
541 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
546 if (!odr_sequence_begin(o, p, sizeof(**p)))
547 return opt && odr_ok(o);
549 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
551 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
552 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
553 odr_constructed_end(o) &&
557 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
559 if (o->direction == ODR_DECODE)
560 *p = odr_malloc(o, sizeof(**p));
561 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
568 int z_Records(ODR o, Z_Records **p, int opt)
572 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
573 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
577 if (o->direction == ODR_DECODE)
578 *p = odr_malloc(o, sizeof(**p));
581 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
584 return opt && odr_ok(o);
587 /* ------------------------ SCAN SERVICE -------------------- */
589 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
591 if (o->direction == ODR_DECODE)
592 *p = odr_malloc(o, sizeof(**p));
596 odr_implicit_settag(o, ODR_CONTEXT, 44);
597 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
598 &(*p)->num_attributes))
601 return opt && odr_ok(o);
605 * This is a temporary hack. We don't know just *what* old version of the
606 * protocol willow uses, so we'll just patiently wait for them to update
608 static int willow_scan = 0;
610 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
612 if (!*p && o->direction != ODR_DECODE)
614 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
617 return opt && odr_ok(o);
619 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
621 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
623 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
625 if (o->direction == ODR_DECODE)
626 *p = odr_malloc(o, sizeof(**p));
627 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
628 &(*p)->num_attributes))
630 if (!odr_sequence_end(o) || !odr_sequence_end(o))
632 if (!z_Term(o, &(*p)->term, 0))
634 if (!odr_constructed_end(o))
640 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
642 if (o->direction == ODR_DECODE)
643 *p = odr_malloc(o, sizeof(**p));
647 return opt && odr_ok(o);
650 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
654 return opt && !o->error;
657 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
659 if (!odr_sequence_begin(o, p, sizeof(**p)))
660 return opt && odr_ok(o);
662 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
663 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
667 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
669 if (!odr_sequence_begin(o, p, sizeof(**p)))
670 return opt && odr_ok(o);
673 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
674 z_Term(o, &(*p)->term, 0)) &&
675 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
676 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
677 ODR_CONTEXT, 4, 1) &&
678 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
680 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
681 ODR_CONTEXT, 3, 1) &&
685 int z_Entry(ODR o, Z_Entry **p, int opt)
687 static Odr_arm arm[] =
689 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
690 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
695 if (o->direction == ODR_DECODE)
696 *p = odr_malloc(o, sizeof(**p));
698 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
701 return opt && odr_ok(o);
704 int z_Entries(ODR o, Z_Entries **p, int opt)
706 if (o->direction == ODR_DECODE)
707 *p = odr_malloc(o, sizeof(**p));
711 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
718 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
720 if (o->direction == ODR_DECODE)
721 *p = odr_malloc(o, sizeof(**p));
725 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
726 &(*p)->num_diagRecs))
732 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
734 static Odr_arm arm[] =
736 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
737 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
742 if (o->direction == ODR_DECODE)
743 *p = odr_malloc(o, sizeof(**p));
745 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
748 return opt && odr_ok(o);
751 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
753 if (!odr_sequence_begin(o, p, sizeof(**p)))
754 return opt && odr_ok(o);
757 z_ReferenceId(o, &(*p)->referenceId, 1) &&
758 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
759 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
760 &(*p)->num_databaseNames) &&
761 odr_oid(o, &(*p)->attributeSet, 1) &&
762 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
763 ((*p)->termListAndStartPoint ? 1 :
764 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
765 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
766 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
767 ODR_CONTEXT, 6, 0) &&
768 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
769 ODR_CONTEXT, 7, 1) &&
773 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
775 if (!odr_sequence_begin(o, p, sizeof(**p)))
776 return opt && odr_ok(o);
778 z_ReferenceId(o, &(*p)->referenceId, 1) &&
779 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
780 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
781 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
782 ODR_CONTEXT, 5, 0) &&
783 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
784 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
785 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
789 /* ------------------------ SEARCHRESPONSE ----------------*/
791 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
793 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
796 int z_NextResultSetPosition(ODR o, int **p, int opt)
798 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
801 int z_PresentStatus(ODR o, int **p, int opt)
803 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
806 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
808 Z_SearchResponse *pp;
810 if (!odr_sequence_begin(o, p, sizeof(**p)))
811 return opt && odr_ok(o);
814 z_ReferenceId(o, &pp->referenceId, 1) &&
815 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
816 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
817 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
818 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
819 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26, 1) &&
820 z_PresentStatus(o, &pp->presentStatus, 1) &&
821 z_Records(o, &pp->records, 1) &&
825 /* --------------------- PRESENT SERVICE ---------------------- */
827 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
829 Z_PresentRequest *pp;
831 if (!odr_sequence_begin(o, p, sizeof(**p)))
832 return opt && odr_ok(o);
835 z_ReferenceId(o, &pp->referenceId, 1) &&
836 z_ResultSetId(o, &pp->resultSetId, 0) &&
837 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
839 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
841 z_ElementSetNames(o, &pp->elementSetNames, 1) &&
842 z_PreferredRecordSyntax(o, &pp->preferredRecordSyntax, 1) &&
846 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
848 Z_PresentResponse *pp;
850 if (!odr_sequence_begin(o, p, sizeof(**p)))
851 return opt && odr_ok(o);
854 z_ReferenceId(o, &pp->referenceId, 1) &&
855 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
856 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
857 z_PresentStatus(o, &pp->presentStatus, 0) &&
858 z_Records(o, &pp->records, 1) &&
862 /* ------------------------ APDU ------------------------- */
864 int z_APDU(ODR o, Z_APDU **p, int opt)
866 static Odr_arm arm[] =
868 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
869 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
870 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
871 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
873 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
875 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
877 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
878 z_ResourceControlRequest},
879 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
880 z_ResourceControlResponse},
881 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
882 z_TriggerResourceControlRequest},
883 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
884 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
889 if (o->direction == ODR_DECODE)
890 *p = odr_malloc(o, sizeof(**p));
891 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
893 if (o->direction == ODR_DECODE)
895 return opt && odr_ok(o);