2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.20 1995-05-15 11:55:25 quinn
10 * Revision 1.19 1995/04/11 11:58:35 quinn
13 * Revision 1.18 1995/04/11 11:52:02 quinn
14 * Fixed possible buf in proto.c
16 * Revision 1.17 1995/04/10 10:22:22 quinn
19 * Revision 1.16 1995/03/30 10:26:43 quinn
20 * Added Term structure
22 * Revision 1.15 1995/03/30 09:08:39 quinn
23 * Added Resource control protocol
25 * Revision 1.14 1995/03/29 08:06:13 quinn
26 * Added a few v3 elements
28 * Revision 1.13 1995/03/20 11:26:52 quinn
29 * *** empty log message ***
31 * Revision 1.12 1995/03/20 09:45:09 quinn
34 * Revision 1.11 1995/03/17 10:17:25 quinn
35 * Added memory management.
37 * Revision 1.10 1995/03/15 11:17:40 quinn
38 * Fixed some return-checks from choice.. need better ay to handle those..
40 * Revision 1.9 1995/03/15 08:37:06 quinn
41 * Fixed protocol bugs.
43 * Revision 1.8 1995/03/14 16:59:24 quinn
44 * Fixed OPTIONAL flag in attributeelement
46 * Revision 1.7 1995/03/07 16:29:33 quinn
47 * Added authentication stuff.
49 * Revision 1.6 1995/03/01 14:46:03 quinn
50 * Fixed protocol bug in 8777query.
52 * Revision 1.5 1995/02/14 11:54:22 quinn
55 * Revision 1.4 1995/02/10 15:54:30 quinn
58 * Revision 1.3 1995/02/09 15:51:39 quinn
61 * Revision 1.2 1995/02/06 21:26:07 quinn
62 * Repaired this evening's damages..
64 * Revision 1.1 1995/02/06 16:44:47 quinn
65 * First hack at Z/SR protocol
73 /* ---------------------- GLOBAL DEFS ------------------- */
75 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
77 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
80 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
82 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
86 int z_ResultSetId(ODR o, char **p, int opt)
88 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
92 int z_UserInformationField(ODR o, Z_UserInformationField **p, int opt)
94 return odr_explicit(o, odr_external, (Odr_external **)p, ODR_CONTEXT,
98 /* ---------------------- INITIALIZE SERVICE ------------------- */
100 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
102 if (!odr_sequence_begin(o, p, sizeof(**p)))
105 odr_visiblestring(o, &(*p)->user, 0) &&
106 odr_visiblestring(o, &(*p)->password, 0) &&
107 odr_visiblestring(o, &(*p)->account, 0) &&
111 int z_IdPass(ODR o, Z_IdPass **p, int opt)
113 if (!odr_sequence_begin(o, p, sizeof(**p)))
116 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 0) &&
117 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 0) &&
118 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
123 int z_StrAuthentication(ODR o, char **p, int opt)
125 return odr_visiblestring(o, p, opt);
128 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
130 static Odr_arm arm[] =
132 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
133 {-1, -1, -1, Z_IdAuthentication_idPass, z_NSRAuthentication},
134 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
135 {-1, -1, -1, Z_IdAuthentication_other, odr_external},
139 if (o->direction == ODR_DECODE)
140 *p = odr_malloc(o, sizeof(**p));
142 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
145 return opt && !o->error;
148 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
152 if (!odr_sequence_begin(o, p, sizeof(**p)))
156 z_ReferenceId(o, &pp->referenceId, 1) &&
157 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
159 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
160 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
162 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
164 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
166 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
168 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
170 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
171 ODR_CONTEXT, 112, 1) &&
172 z_UserInformationField(o, &pp->userInformationField, 1) &&
176 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
180 if (!odr_sequence_begin(o, p, sizeof(**p)))
184 z_ReferenceId(o, &pp->referenceId, 1) &&
185 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
187 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
188 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
190 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
192 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
193 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
195 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
197 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
198 ODR_CONTEXT, 112, 1) &&
199 z_UserInformationField(o, &pp->userInformationField, 1) &&
203 /* ------------------ RESOURCE CONTROL ----------------*/
205 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
208 if (!odr_sequence_begin(o, p, sizeof(**p)))
211 z_ReferenceId(o, &(*p)->referenceId, 1) &&
212 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
214 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
215 ODR_CONTEXT, 47, 1) &&
216 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
221 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
223 if (!odr_sequence_begin(o, p, sizeof(**p)))
226 z_ReferenceId(o, &(*p)->referenceId, 1) &&
227 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
228 odr_explicit(o, odr_external, &(*p)->resourceReport, ODR_CONTEXT,
230 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
231 ODR_CONTEXT, 41, 1) &&
232 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
234 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
235 ODR_CONTEXT, 43, 1) &&
239 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
241 if (!odr_sequence_begin(o, p, sizeof(**p)))
244 z_ReferenceId(o, &(*p)->referenceId, 1) &&
245 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
246 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
251 /* ------------------------ SEARCH SERVICE ----------------------- */
253 int z_ElementSetName(ODR o, char **p, int opt)
255 return odr_implicit(o, odr_visiblestring, (char**) p, ODR_CONTEXT, 103,
259 int z_PreferredRecordSyntax(ODR o, Z_PreferredRecordSyntax **p, int opt)
261 return odr_implicit(o, odr_oid, (Odr_oid**) p, ODR_CONTEXT, 104, opt);
264 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
266 if (!odr_sequence_begin(o, p, sizeof(**p)))
269 z_DatabaseName(o, &(*p)->databaseName, 0) &&
270 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
274 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
276 if (o->direction == ODR_DECODE)
277 *p = odr_malloc(o, sizeof(**p));
281 odr_implicit_settag(o, ODR_CONTEXT, 1);
282 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
283 &(*p)->num_elements))
289 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
291 static Odr_arm arm[] =
293 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
295 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
300 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 19))
303 if (o->direction == ODR_DECODE)
304 *p = odr_malloc(o, sizeof(**p));
306 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
307 odr_constructed_end(o))
313 /* ----------------------- RPN QUERY -----------------------*/
315 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
317 if (!odr_sequence_begin(o, p, sizeof(**p)))
320 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
322 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
329 int z_Term(ODR o, Z_Term **p, int opt)
331 static Odr_arm arm[] =
333 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
334 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
335 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
337 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
338 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
339 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, odr_external},
340 /* add intUnit here */
341 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
345 if (o->direction ==ODR_DECODE)
346 *p = odr_malloc(o, sizeof(**p));
349 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
352 return opt && !o->error;
357 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
359 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
360 odr_sequence_begin(o, p, sizeof(**p))))
363 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
364 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
365 &(*p)->num_attributes) &&
367 z_Term(o, &(*p)->term, 0) &&
369 odr_implicit(o, odr_octetstring, &(*p)->term, ODR_CONTEXT, 45, 0) &&
374 int z_Operator(ODR o, Z_Operator **p, int opt)
376 static Odr_arm arm[] =
378 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
379 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
380 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
385 if (!*p && o->direction != ODR_DECODE)
387 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
389 if (o->direction == ODR_DECODE)
390 *p = odr_malloc(o, sizeof(**p));
392 (*p)->u.and = &dummy;
394 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
395 odr_constructed_end(o))
398 return opt && !o->error;
401 int z_Operand(ODR o, Z_Operand **p, int opt)
403 static Odr_arm arm[] =
405 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
406 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
410 if (o->direction ==ODR_DECODE)
411 *p = odr_malloc(o, sizeof(**p));
414 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
417 return opt && !o->error;
420 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
422 int z_Complex(ODR o, Z_Complex **p, int opt)
424 if (!odr_sequence_begin(o, p, sizeof(**p)))
427 z_RPNStructure(o, &(*p)->s1, 0) &&
428 z_RPNStructure(o, &(*p)->s2, 0) &&
429 z_Operator(o, &(*p)->operator, 0) &&
433 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
435 static Odr_arm arm[] =
437 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
438 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
442 if (o->direction == ODR_DECODE)
443 *p = odr_malloc(o, sizeof(**p));
446 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
449 return opt && !o->error;
452 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
454 if (!odr_sequence_begin(o, p, sizeof(**p)))
457 odr_oid(o, &(*p)->attributeSetId, 0) &&
458 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
462 /* -----------------------END RPN QUERY ----------------------- */
464 int z_Query(ODR o, Z_Query **p, int opt)
466 static Odr_arm arm[] =
468 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
469 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
473 if (o->direction == ODR_DECODE)
474 *p = odr_malloc(o, sizeof(**p));
477 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
480 return opt && !o->error;
483 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
487 if (!odr_sequence_begin(o, p, sizeof(**p)))
491 z_ReferenceId(o, &pp->referenceId, 1) &&
492 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
494 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
496 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
498 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
499 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
501 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
502 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
503 &pp->num_databaseNames) &&
504 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
505 ODR_CONTEXT, 100, 1) &&
506 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
507 ODR_CONTEXT, 101, 1) &&
508 z_PreferredRecordSyntax(o, &pp->preferredRecordSyntax, 1) &&
509 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
513 /* ------------------------ RECORD ------------------------- */
515 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
517 return odr_external(o, (Odr_external **) p, opt);
520 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
522 if (!odr_sequence_begin(o, p, sizeof(**p)))
525 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT */
526 odr_integer(o, &(*p)->condition, 0) &&
527 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
528 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT, ODR_VISIBLESTRING, 1)) &&
532 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
534 static Odr_arm arm[] =
536 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
538 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
543 if (!odr_sequence_begin(o, p, sizeof(**p)))
546 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
548 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
549 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
550 odr_constructed_end(o) &&
554 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
556 if (o->direction == ODR_DECODE)
557 *p = odr_malloc(o, sizeof(**p));
558 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
565 int z_Records(ODR o, Z_Records **p, int opt)
569 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
570 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
574 if (o->direction == ODR_DECODE)
575 *p = odr_malloc(o, sizeof(**p));
578 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
581 return opt && !o->error;
584 /* ------------------------ SCAN SERVICE -------------------- */
586 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
588 if (o->direction == ODR_DECODE)
589 *p = odr_malloc(o, sizeof(**p));
593 odr_implicit_settag(o, ODR_CONTEXT, 44);
594 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
595 &(*p)->num_attributes))
598 return opt && !o->error;
602 * This is a temporary hack. We don't know just *what* old version of the
603 * protocol willow uses, so we'll just patiently wait for them to update
605 static int willow_scan = 0;
607 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
609 if (!*p && o->direction != ODR_DECODE)
611 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
616 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
618 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
620 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
622 if (o->direction == ODR_DECODE)
623 *p = odr_malloc(o, sizeof(**p));
624 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
625 &(*p)->num_attributes))
627 if (!odr_sequence_end(o) || !odr_sequence_end(o))
629 if (!z_Term(o, &(*p)->term, 0))
631 if (!odr_constructed_end(o))
637 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
639 if (o->direction == ODR_DECODE)
640 *p = odr_malloc(o, sizeof(**p));
647 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
651 return opt && !o->error;
654 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
656 if (!odr_sequence_begin(o, p, sizeof(**p)))
659 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
660 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
664 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
666 if (!odr_sequence_begin(o, p, sizeof(**p)))
670 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
671 z_Term(o, &(*p)->term, 0)) &&
672 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
673 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
674 ODR_CONTEXT, 4, 1) &&
675 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
677 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
678 ODR_CONTEXT, 3, 1) &&
682 int z_Entry(ODR o, Z_Entry **p, int opt)
684 static Odr_arm arm[] =
686 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
687 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
692 if (o->direction == ODR_DECODE)
693 *p = odr_malloc(o, sizeof(**p));
695 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
698 return opt && !o->error;
701 int z_Entries(ODR o, Z_Entries **p, int opt)
703 if (o->direction == ODR_DECODE)
704 *p = odr_malloc(o, sizeof(**p));
708 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
715 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
717 if (o->direction == ODR_DECODE)
718 *p = odr_malloc(o, sizeof(**p));
722 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
723 &(*p)->num_diagRecs))
729 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
731 static Odr_arm arm[] =
733 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
734 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
739 if (o->direction == ODR_DECODE)
740 *p = odr_malloc(o, sizeof(**p));
742 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
745 return opt && !o->error;
748 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
750 if (!odr_sequence_begin(o, p, sizeof(**p)))
754 z_ReferenceId(o, &(*p)->referenceId, 1) &&
755 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
756 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
757 &(*p)->num_databaseNames) &&
758 odr_oid(o, &(*p)->attributeSet, 1) &&
759 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
760 ((*p)->termListAndStartPoint ? 1 :
761 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
762 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
763 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
764 ODR_CONTEXT, 6, 0) &&
765 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
766 ODR_CONTEXT, 7, 1) &&
770 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
772 if (!odr_sequence_begin(o, p, sizeof(**p)))
775 z_ReferenceId(o, &(*p)->referenceId, 1) &&
776 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
777 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
778 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
779 ODR_CONTEXT, 5, 0) &&
780 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
781 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
782 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
786 /* ------------------------ SEARCHRESPONSE ----------------*/
788 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
790 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
793 int z_NextResultSetPosition(ODR o, int **p, int opt)
795 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
798 int z_PresentStatus(ODR o, int **p, int opt)
800 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
803 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
805 Z_SearchResponse *pp;
807 if (!odr_sequence_begin(o, p, sizeof(**p)))
811 z_ReferenceId(o, &pp->referenceId, 1) &&
812 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
813 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
814 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
815 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
816 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26, 1) &&
817 z_PresentStatus(o, &pp->presentStatus, 1) &&
818 z_Records(o, &pp->records, 1) &&
822 /* --------------------- PRESENT SERVICE ---------------------- */
824 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
826 Z_PresentRequest *pp;
828 if (!odr_sequence_begin(o, p, sizeof(**p)))
832 z_ReferenceId(o, &pp->referenceId, 1) &&
833 z_ResultSetId(o, &pp->resultSetId, 0) &&
834 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
836 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
838 z_ElementSetNames(o, &pp->elementSetNames, 1) &&
839 z_PreferredRecordSyntax(o, &pp->preferredRecordSyntax, 1) &&
843 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
845 Z_PresentResponse *pp;
847 if (!odr_sequence_begin(o, p, sizeof(**p)))
851 z_ReferenceId(o, &pp->referenceId, 1) &&
852 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
853 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
854 z_PresentStatus(o, &pp->presentStatus, 0) &&
855 z_Records(o, &pp->records, 1) &&
859 /* ------------------------ APDU ------------------------- */
861 int z_APDU(ODR o, Z_APDU **p, int opt)
863 static Odr_arm arm[] =
865 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
866 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
867 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
868 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
870 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
872 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
874 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
875 z_ResourceControlRequest},
876 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
877 z_ResourceControlResponse},
878 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
879 z_TriggerResourceControlRequest},
880 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
881 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
886 if (o->direction == ODR_DECODE)
887 *p = odr_malloc(o, sizeof(**p));
888 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
890 if (o->direction == ODR_DECODE)
892 return opt && !o->error;