2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.17 1995-04-10 10:22:22 quinn
10 * Revision 1.16 1995/03/30 10:26:43 quinn
11 * Added Term structure
13 * Revision 1.15 1995/03/30 09:08:39 quinn
14 * Added Resource control protocol
16 * Revision 1.14 1995/03/29 08:06:13 quinn
17 * Added a few v3 elements
19 * Revision 1.13 1995/03/20 11:26:52 quinn
20 * *** empty log message ***
22 * Revision 1.12 1995/03/20 09:45:09 quinn
25 * Revision 1.11 1995/03/17 10:17:25 quinn
26 * Added memory management.
28 * Revision 1.10 1995/03/15 11:17:40 quinn
29 * Fixed some return-checks from choice.. need better ay to handle those..
31 * Revision 1.9 1995/03/15 08:37:06 quinn
32 * Fixed protocol bugs.
34 * Revision 1.8 1995/03/14 16:59:24 quinn
35 * Fixed OPTIONAL flag in attributeelement
37 * Revision 1.7 1995/03/07 16:29:33 quinn
38 * Added authentication stuff.
40 * Revision 1.6 1995/03/01 14:46:03 quinn
41 * Fixed protocol bug in 8777query.
43 * Revision 1.5 1995/02/14 11:54:22 quinn
46 * Revision 1.4 1995/02/10 15:54:30 quinn
49 * Revision 1.3 1995/02/09 15:51:39 quinn
52 * Revision 1.2 1995/02/06 21:26:07 quinn
53 * Repaired this evening's damages..
55 * Revision 1.1 1995/02/06 16:44:47 quinn
56 * First hack at Z/SR protocol
64 /* ---------------------- GLOBAL DEFS ------------------- */
66 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
68 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
71 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
73 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
77 int z_ResultSetId(ODR o, char **p, int opt)
79 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
83 int z_UserInformationField(ODR o, Z_UserInformationField **p, int opt)
85 return odr_explicit(o, odr_external, (Odr_external **)p, ODR_CONTEXT,
89 /* ---------------------- INITIALIZE SERVICE ------------------- */
91 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
93 if (!odr_sequence_begin(o, p, sizeof(**p)))
96 odr_visiblestring(o, &(*p)->user, 0) &&
97 odr_visiblestring(o, &(*p)->password, 0) &&
98 odr_visiblestring(o, &(*p)->account, 0) &&
102 int z_IdPass(ODR o, Z_IdPass **p, int opt)
104 if (!odr_sequence_begin(o, p, sizeof(**p)))
107 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 0) &&
108 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 0) &&
109 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
114 int z_StrAuthentication(ODR o, char **p, int opt)
116 return odr_visiblestring(o, p, opt);
119 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
121 static Odr_arm arm[] =
123 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
124 {-1, -1, -1, Z_IdAuthentication_idPass, z_NSRAuthentication},
125 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
126 {-1, -1, -1, Z_IdAuthentication_other, odr_external},
130 if (o->direction == ODR_DECODE)
131 *p = odr_malloc(o, sizeof(**p));
133 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
136 return opt && !o->error;
139 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
143 if (!odr_sequence_begin(o, p, sizeof(**p)))
147 z_ReferenceId(o, &pp->referenceId, 1) &&
148 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
150 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
151 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
153 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
155 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
157 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
159 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
161 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
162 ODR_CONTEXT, 112, 1) &&
163 z_UserInformationField(o, &pp->userInformationField, 1) &&
167 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
171 if (!odr_sequence_begin(o, p, sizeof(**p)))
175 z_ReferenceId(o, &pp->referenceId, 1) &&
176 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
178 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
179 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
181 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
183 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
184 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
186 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
188 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
189 ODR_CONTEXT, 112, 1) &&
190 z_UserInformationField(o, &pp->userInformationField, 1) &&
194 /* ------------------ RESOURCE CONTROL ----------------*/
196 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
199 if (!odr_sequence_begin(o, p, sizeof(**p)))
202 z_ReferenceId(o, &(*p)->referenceId, 1) &&
203 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
205 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
206 ODR_CONTEXT, 47, 1) &&
207 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
212 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
214 if (!odr_sequence_begin(o, p, sizeof(**p)))
217 z_ReferenceId(o, &(*p)->referenceId, 1) &&
218 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
219 odr_explicit(o, odr_external, &(*p)->resourceReport, ODR_CONTEXT,
221 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
222 ODR_CONTEXT, 41, 1) &&
223 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
225 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
226 ODR_CONTEXT, 43, 1) &&
230 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
232 if (!odr_sequence_begin(o, p, sizeof(**p)))
235 z_ReferenceId(o, &(*p)->referenceId, 1) &&
236 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
237 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
242 /* ------------------------ SEARCH SERVICE ----------------------- */
244 int z_ElementSetName(ODR o, char **p, int opt)
246 return odr_implicit(o, odr_visiblestring, (char**) p, ODR_CONTEXT, 103,
250 int z_PreferredRecordSyntax(ODR o, Z_PreferredRecordSyntax **p, int opt)
252 return odr_implicit(o, odr_oid, (Odr_oid**) p, ODR_CONTEXT, 104, opt);
255 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
257 if (!odr_sequence_begin(o, p, sizeof(**p)))
260 z_DatabaseName(o, &(*p)->databaseName, 0) &&
261 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
265 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
267 if (o->direction == ODR_DECODE)
268 *p = odr_malloc(o, sizeof(**p));
272 odr_implicit_settag(o, ODR_CONTEXT, 1);
273 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
274 &(*p)->num_elements))
280 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
282 static Odr_arm arm[] =
284 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
286 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
291 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 19))
294 if (o->direction == ODR_DECODE)
295 *p = odr_malloc(o, sizeof(**p));
297 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
298 odr_constructed_end(o))
304 /* ----------------------- RPN QUERY -----------------------*/
306 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
308 if (!odr_sequence_begin(o, p, sizeof(**p)))
311 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
313 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
320 int z_Term(ODR o, Z_Term **p, int opt)
322 static Odr_arm arm[] =
324 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
325 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
326 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
328 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
329 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
330 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, odr_external},
331 /* add intUnit here */
332 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
336 if (o->direction ==ODR_DECODE)
337 *p = odr_malloc(o, sizeof(**p));
340 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
343 return opt && !o->error;
348 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
350 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
351 odr_sequence_begin(o, p, sizeof(**p))))
354 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
355 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
356 &(*p)->num_attributes) &&
358 z_Term(o, &(*p)->term, 0) &&
360 odr_implicit(o, odr_octetstring, &(*p)->term, ODR_CONTEXT, 45, 0) &&
365 int z_Operator(ODR o, Z_Operator **p, int opt)
367 static Odr_arm arm[] =
369 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
370 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
371 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
376 if (!*p && o->direction != ODR_DECODE)
378 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
380 if (o->direction == ODR_DECODE)
381 *p = odr_malloc(o, sizeof(**p));
383 (*p)->u.and = &dummy;
385 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
386 odr_constructed_end(o))
389 return opt && !o->error;
392 int z_Operand(ODR o, Z_Operand **p, int opt)
394 static Odr_arm arm[] =
396 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
397 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
401 if (o->direction ==ODR_DECODE)
402 *p = odr_malloc(o, sizeof(**p));
405 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
408 return opt && !o->error;
411 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
413 int z_Complex(ODR o, Z_Complex **p, int opt)
415 if (!odr_sequence_begin(o, p, sizeof(**p)))
418 z_RPNStructure(o, &(*p)->s1, 0) &&
419 z_RPNStructure(o, &(*p)->s2, 0) &&
420 z_Operator(o, &(*p)->operator, 0) &&
424 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
426 static Odr_arm arm[] =
428 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
429 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
433 if (o->direction == ODR_DECODE)
434 *p = odr_malloc(o, sizeof(**p));
437 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
440 return opt && !o->error;
443 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
445 if (!odr_sequence_begin(o, p, sizeof(**p)))
448 odr_oid(o, &(*p)->attributeSetId, 0) &&
449 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
453 /* -----------------------END RPN QUERY ----------------------- */
455 int z_Query(ODR o, Z_Query **p, int opt)
457 static Odr_arm arm[] =
459 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
460 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
464 if (o->direction == ODR_DECODE)
465 *p = odr_malloc(o, sizeof(**p));
468 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
471 return opt && !o->error;
474 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
478 if (!odr_sequence_begin(o, p, sizeof(**p)))
482 z_ReferenceId(o, &pp->referenceId, 1) &&
483 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
485 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
487 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
489 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
490 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
492 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
493 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
494 &pp->num_databaseNames) &&
495 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
496 ODR_CONTEXT, 100, 1) &&
497 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
498 ODR_CONTEXT, 101, 1) &&
499 z_PreferredRecordSyntax(o, &pp->preferredRecordSyntax, 1) &&
500 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
504 /* ------------------------ RECORD ------------------------- */
506 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
508 return odr_external(o, (Odr_external **) p, opt);
511 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
513 if (!odr_sequence_begin(o, p, sizeof(**p)))
516 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT */
517 odr_integer(o, &(*p)->condition, 0) &&
518 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
519 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT, ODR_VISIBLESTRING, 1)) &&
523 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
525 static Odr_arm arm[] =
527 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
529 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
534 if (!odr_sequence_begin(o, p, sizeof(**p)))
537 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
539 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
540 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
541 odr_constructed_end(o) &&
545 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
547 if (o->direction == ODR_DECODE)
548 *p = odr_malloc(o, sizeof(**p));
549 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
556 int z_Records(ODR o, Z_Records **p, int opt)
560 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
561 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
565 if (o->direction == ODR_DECODE)
566 *p = odr_malloc(o, sizeof(**p));
569 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
572 return opt && !o->error;
575 /* ------------------------ SCAN SERVICE -------------------- */
577 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
579 if (o->direction == ODR_DECODE)
580 *p = odr_malloc(o, sizeof(**p));
584 odr_implicit_settag(o, ODR_CONTEXT, 44);
585 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
586 &(*p)->num_attributes))
593 * This is a temporary hack. We don't know just *what* old version of the
594 * protocol willow uses, so we'll just patiently wait for them to update
596 static int willow_scan = 0;
598 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
600 if (!*p && o->direction != ODR_DECODE)
602 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
607 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
609 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
611 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
613 if (o->direction == ODR_DECODE)
614 *p = odr_malloc(o, sizeof(**p));
615 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
616 &(*p)->num_attributes))
618 if (!odr_sequence_end(o) || !odr_sequence_end(o))
620 if (!z_Term(o, &(*p)->term, 0))
622 if (!odr_constructed_end(o))
628 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
630 if (o->direction == ODR_DECODE)
631 *p = odr_malloc(o, sizeof(**p));
638 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
645 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
647 if (!odr_sequence_begin(o, p, sizeof(**p)))
650 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
651 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
655 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
657 if (!odr_sequence_begin(o, p, sizeof(**p)))
661 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
662 z_Term(o, &(*p)->term, 0)) &&
663 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
664 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
665 ODR_CONTEXT, 4, 1) &&
666 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
668 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
669 ODR_CONTEXT, 3, 1) &&
673 int z_Entry(ODR o, Z_Entry **p, int opt)
675 static Odr_arm arm[] =
677 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
678 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
683 if (o->direction == ODR_DECODE)
684 *p = odr_malloc(o, sizeof(**p));
686 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
689 return opt && !o->error;
692 int z_Entries(ODR o, Z_Entries **p, int opt)
694 if (o->direction == ODR_DECODE)
695 *p = odr_malloc(o, sizeof(**p));
699 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
706 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
708 if (o->direction == ODR_DECODE)
709 *p = odr_malloc(o, sizeof(**p));
713 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
714 &(*p)->num_diagRecs))
720 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
722 static Odr_arm arm[] =
724 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
725 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
730 if (o->direction == ODR_DECODE)
731 *p = odr_malloc(o, sizeof(**p));
733 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
736 return opt && !o->error;
739 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
741 if (!odr_sequence_begin(o, p, sizeof(**p)))
745 z_ReferenceId(o, &(*p)->referenceId, 1) &&
746 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
747 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
748 &(*p)->num_databaseNames) &&
749 odr_oid(o, &(*p)->attributeSet, 1) &&
750 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
751 ((*p)->termListAndStartPoint ? 1 :
752 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
753 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
754 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
755 ODR_CONTEXT, 6, 0) &&
756 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
757 ODR_CONTEXT, 7, 1) &&
761 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
763 if (!odr_sequence_begin(o, p, sizeof(**p)))
766 z_ReferenceId(o, &(*p)->referenceId, 1) &&
767 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
768 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
769 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
770 ODR_CONTEXT, 5, 0) &&
771 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
772 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
773 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
777 /* ------------------------ SEARCHRESPONSE ----------------*/
779 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
781 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
784 int z_NextResultSetPosition(ODR o, int **p, int opt)
786 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
789 int z_PresentStatus(ODR o, int **p, int opt)
791 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
794 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
796 Z_SearchResponse *pp;
798 if (!odr_sequence_begin(o, p, sizeof(**p)))
802 z_ReferenceId(o, &pp->referenceId, 1) &&
803 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
804 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
805 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
806 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
807 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26, 1) &&
808 z_PresentStatus(o, &pp->presentStatus, 1) &&
809 z_Records(o, &pp->records, 1) &&
813 /* --------------------- PRESENT SERVICE ---------------------- */
815 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
817 Z_PresentRequest *pp;
819 if (!odr_sequence_begin(o, p, sizeof(**p)))
823 z_ReferenceId(o, &pp->referenceId, 1) &&
824 z_ResultSetId(o, &pp->resultSetId, 0) &&
825 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
827 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
829 z_ElementSetNames(o, &pp->elementSetNames, 1) &&
830 z_PreferredRecordSyntax(o, &pp->preferredRecordSyntax, 1) &&
834 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
836 Z_PresentResponse *pp;
838 if (!odr_sequence_begin(o, p, sizeof(**p)))
842 z_ReferenceId(o, &pp->referenceId, 1) &&
843 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
844 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
845 z_PresentStatus(o, &pp->presentStatus, 0) &&
846 z_Records(o, &pp->records, 1) &&
850 /* ------------------------ APDU ------------------------- */
852 int z_APDU(ODR o, Z_APDU **p, int opt)
854 static Odr_arm arm[] =
856 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
857 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
858 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
859 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse, z_SearchResponse},
860 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest, z_PresentRequest},
861 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse, z_PresentResponse},
862 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
863 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
868 if (o->direction == ODR_DECODE)
869 *p = odr_malloc(o, sizeof(**p));
870 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
872 if (o->direction == ODR_DECODE)
874 return opt && !o->error;