2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.19 1995-04-11 11:58:35 quinn
10 * Revision 1.18 1995/04/11 11:52:02 quinn
11 * Fixed possible buf in proto.c
13 * Revision 1.17 1995/04/10 10:22:22 quinn
16 * Revision 1.16 1995/03/30 10:26:43 quinn
17 * Added Term structure
19 * Revision 1.15 1995/03/30 09:08:39 quinn
20 * Added Resource control protocol
22 * Revision 1.14 1995/03/29 08:06:13 quinn
23 * Added a few v3 elements
25 * Revision 1.13 1995/03/20 11:26:52 quinn
26 * *** empty log message ***
28 * Revision 1.12 1995/03/20 09:45:09 quinn
31 * Revision 1.11 1995/03/17 10:17:25 quinn
32 * Added memory management.
34 * Revision 1.10 1995/03/15 11:17:40 quinn
35 * Fixed some return-checks from choice.. need better ay to handle those..
37 * Revision 1.9 1995/03/15 08:37:06 quinn
38 * Fixed protocol bugs.
40 * Revision 1.8 1995/03/14 16:59:24 quinn
41 * Fixed OPTIONAL flag in attributeelement
43 * Revision 1.7 1995/03/07 16:29:33 quinn
44 * Added authentication stuff.
46 * Revision 1.6 1995/03/01 14:46:03 quinn
47 * Fixed protocol bug in 8777query.
49 * Revision 1.5 1995/02/14 11:54:22 quinn
52 * Revision 1.4 1995/02/10 15:54:30 quinn
55 * Revision 1.3 1995/02/09 15:51:39 quinn
58 * Revision 1.2 1995/02/06 21:26:07 quinn
59 * Repaired this evening's damages..
61 * Revision 1.1 1995/02/06 16:44:47 quinn
62 * First hack at Z/SR protocol
70 /* ---------------------- GLOBAL DEFS ------------------- */
72 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
74 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
77 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
79 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
83 int z_ResultSetId(ODR o, char **p, int opt)
85 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
89 int z_UserInformationField(ODR o, Z_UserInformationField **p, int opt)
91 return odr_explicit(o, odr_external, (Odr_external **)p, ODR_CONTEXT,
95 /* ---------------------- INITIALIZE SERVICE ------------------- */
97 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
99 if (!odr_sequence_begin(o, p, sizeof(**p)))
102 odr_visiblestring(o, &(*p)->user, 0) &&
103 odr_visiblestring(o, &(*p)->password, 0) &&
104 odr_visiblestring(o, &(*p)->account, 0) &&
108 int z_IdPass(ODR o, Z_IdPass **p, int opt)
110 if (!odr_sequence_begin(o, p, sizeof(**p)))
113 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 0) &&
114 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 0) &&
115 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
120 int z_StrAuthentication(ODR o, char **p, int opt)
122 return odr_visiblestring(o, p, opt);
125 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
127 static Odr_arm arm[] =
129 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
130 {-1, -1, -1, Z_IdAuthentication_idPass, z_NSRAuthentication},
131 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
132 {-1, -1, -1, Z_IdAuthentication_other, odr_external},
136 if (o->direction == ODR_DECODE)
137 *p = odr_malloc(o, sizeof(**p));
139 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
142 return opt && !o->error;
145 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
149 if (!odr_sequence_begin(o, p, sizeof(**p)))
153 z_ReferenceId(o, &pp->referenceId, 1) &&
154 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
156 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
157 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
159 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
161 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
163 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
165 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
167 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
168 ODR_CONTEXT, 112, 1) &&
169 z_UserInformationField(o, &pp->userInformationField, 1) &&
173 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
177 if (!odr_sequence_begin(o, p, sizeof(**p)))
181 z_ReferenceId(o, &pp->referenceId, 1) &&
182 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
184 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
185 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
187 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
189 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
190 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
192 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
194 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
195 ODR_CONTEXT, 112, 1) &&
196 z_UserInformationField(o, &pp->userInformationField, 1) &&
200 /* ------------------ RESOURCE CONTROL ----------------*/
202 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
205 if (!odr_sequence_begin(o, p, sizeof(**p)))
208 z_ReferenceId(o, &(*p)->referenceId, 1) &&
209 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
211 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
212 ODR_CONTEXT, 47, 1) &&
213 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
218 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
220 if (!odr_sequence_begin(o, p, sizeof(**p)))
223 z_ReferenceId(o, &(*p)->referenceId, 1) &&
224 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
225 odr_explicit(o, odr_external, &(*p)->resourceReport, ODR_CONTEXT,
227 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
228 ODR_CONTEXT, 41, 1) &&
229 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
231 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
232 ODR_CONTEXT, 43, 1) &&
236 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
238 if (!odr_sequence_begin(o, p, sizeof(**p)))
241 z_ReferenceId(o, &(*p)->referenceId, 1) &&
242 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
243 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
248 /* ------------------------ SEARCH SERVICE ----------------------- */
250 int z_ElementSetName(ODR o, char **p, int opt)
252 return odr_implicit(o, odr_visiblestring, (char**) p, ODR_CONTEXT, 103,
256 int z_PreferredRecordSyntax(ODR o, Z_PreferredRecordSyntax **p, int opt)
258 return odr_implicit(o, odr_oid, (Odr_oid**) p, ODR_CONTEXT, 104, opt);
261 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
263 if (!odr_sequence_begin(o, p, sizeof(**p)))
266 z_DatabaseName(o, &(*p)->databaseName, 0) &&
267 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
271 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
273 if (o->direction == ODR_DECODE)
274 *p = odr_malloc(o, sizeof(**p));
278 odr_implicit_settag(o, ODR_CONTEXT, 1);
279 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
280 &(*p)->num_elements))
286 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
288 static Odr_arm arm[] =
290 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
292 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
297 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 19))
300 if (o->direction == ODR_DECODE)
301 *p = odr_malloc(o, sizeof(**p));
303 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
304 odr_constructed_end(o))
310 /* ----------------------- RPN QUERY -----------------------*/
312 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
314 if (!odr_sequence_begin(o, p, sizeof(**p)))
317 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
319 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
326 int z_Term(ODR o, Z_Term **p, int opt)
328 static Odr_arm arm[] =
330 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
331 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
332 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
334 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
335 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
336 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, odr_external},
337 /* add intUnit here */
338 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
342 if (o->direction ==ODR_DECODE)
343 *p = odr_malloc(o, sizeof(**p));
346 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
349 return opt && !o->error;
354 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
356 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
357 odr_sequence_begin(o, p, sizeof(**p))))
360 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
361 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
362 &(*p)->num_attributes) &&
364 z_Term(o, &(*p)->term, 0) &&
366 odr_implicit(o, odr_octetstring, &(*p)->term, ODR_CONTEXT, 45, 0) &&
371 int z_Operator(ODR o, Z_Operator **p, int opt)
373 static Odr_arm arm[] =
375 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
376 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
377 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
382 if (!*p && o->direction != ODR_DECODE)
384 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
386 if (o->direction == ODR_DECODE)
387 *p = odr_malloc(o, sizeof(**p));
389 (*p)->u.and = &dummy;
391 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
392 odr_constructed_end(o))
395 return opt && !o->error;
398 int z_Operand(ODR o, Z_Operand **p, int opt)
400 static Odr_arm arm[] =
402 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
403 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
407 if (o->direction ==ODR_DECODE)
408 *p = odr_malloc(o, sizeof(**p));
411 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
414 return opt && !o->error;
417 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
419 int z_Complex(ODR o, Z_Complex **p, int opt)
421 if (!odr_sequence_begin(o, p, sizeof(**p)))
424 z_RPNStructure(o, &(*p)->s1, 0) &&
425 z_RPNStructure(o, &(*p)->s2, 0) &&
426 z_Operator(o, &(*p)->operator, 0) &&
430 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
432 static Odr_arm arm[] =
434 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
435 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
439 if (o->direction == ODR_DECODE)
440 *p = odr_malloc(o, sizeof(**p));
443 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
446 return opt && !o->error;
449 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
451 if (!odr_sequence_begin(o, p, sizeof(**p)))
454 odr_oid(o, &(*p)->attributeSetId, 0) &&
455 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
459 /* -----------------------END RPN QUERY ----------------------- */
461 int z_Query(ODR o, Z_Query **p, int opt)
463 static Odr_arm arm[] =
465 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
466 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
470 if (o->direction == ODR_DECODE)
471 *p = odr_malloc(o, sizeof(**p));
474 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
477 return opt && !o->error;
480 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
484 if (!odr_sequence_begin(o, p, sizeof(**p)))
488 z_ReferenceId(o, &pp->referenceId, 1) &&
489 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
491 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
493 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
495 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
496 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
498 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
499 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
500 &pp->num_databaseNames) &&
501 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
502 ODR_CONTEXT, 100, 1) &&
503 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
504 ODR_CONTEXT, 101, 1) &&
505 z_PreferredRecordSyntax(o, &pp->preferredRecordSyntax, 1) &&
506 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
510 /* ------------------------ RECORD ------------------------- */
512 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
514 return odr_external(o, (Odr_external **) p, opt);
517 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
519 if (!odr_sequence_begin(o, p, sizeof(**p)))
522 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT */
523 odr_integer(o, &(*p)->condition, 0) &&
524 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
525 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT, ODR_VISIBLESTRING, 1)) &&
529 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
531 static Odr_arm arm[] =
533 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
535 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
540 if (!odr_sequence_begin(o, p, sizeof(**p)))
543 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
545 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
546 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
547 odr_constructed_end(o) &&
551 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
553 if (o->direction == ODR_DECODE)
554 *p = odr_malloc(o, sizeof(**p));
555 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
562 int z_Records(ODR o, Z_Records **p, int opt)
566 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
567 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
571 if (o->direction == ODR_DECODE)
572 *p = odr_malloc(o, sizeof(**p));
575 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
578 return opt && !o->error;
581 /* ------------------------ SCAN SERVICE -------------------- */
583 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
585 if (o->direction == ODR_DECODE)
586 *p = odr_malloc(o, sizeof(**p));
590 odr_implicit_settag(o, ODR_CONTEXT, 44);
591 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
592 &(*p)->num_attributes))
595 return opt && !o->error;
599 * This is a temporary hack. We don't know just *what* old version of the
600 * protocol willow uses, so we'll just patiently wait for them to update
602 static int willow_scan = 0;
604 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
606 if (!*p && o->direction != ODR_DECODE)
608 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
613 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
615 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
617 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
619 if (o->direction == ODR_DECODE)
620 *p = odr_malloc(o, sizeof(**p));
621 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
622 &(*p)->num_attributes))
624 if (!odr_sequence_end(o) || !odr_sequence_end(o))
626 if (!z_Term(o, &(*p)->term, 0))
628 if (!odr_constructed_end(o))
634 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
636 if (o->direction == ODR_DECODE)
637 *p = odr_malloc(o, sizeof(**p));
644 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
648 return opt && !o->error;
651 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
653 if (!odr_sequence_begin(o, p, sizeof(**p)))
656 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
657 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
661 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
663 if (!odr_sequence_begin(o, p, sizeof(**p)))
667 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
668 z_Term(o, &(*p)->term, 0)) &&
669 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
670 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
671 ODR_CONTEXT, 4, 1) &&
672 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
674 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
675 ODR_CONTEXT, 3, 1) &&
679 int z_Entry(ODR o, Z_Entry **p, int opt)
681 static Odr_arm arm[] =
683 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
684 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
689 if (o->direction == ODR_DECODE)
690 *p = odr_malloc(o, sizeof(**p));
692 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
695 return opt && !o->error;
698 int z_Entries(ODR o, Z_Entries **p, int opt)
700 if (o->direction == ODR_DECODE)
701 *p = odr_malloc(o, sizeof(**p));
705 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
712 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
714 if (o->direction == ODR_DECODE)
715 *p = odr_malloc(o, sizeof(**p));
719 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
720 &(*p)->num_diagRecs))
726 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
728 static Odr_arm arm[] =
730 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
731 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
736 if (o->direction == ODR_DECODE)
737 *p = odr_malloc(o, sizeof(**p));
739 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
742 return opt && !o->error;
745 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
747 if (!odr_sequence_begin(o, p, sizeof(**p)))
751 z_ReferenceId(o, &(*p)->referenceId, 1) &&
752 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
753 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
754 &(*p)->num_databaseNames) &&
755 odr_oid(o, &(*p)->attributeSet, 1) &&
756 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
757 ((*p)->termListAndStartPoint ? 1 :
758 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
759 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
760 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
761 ODR_CONTEXT, 6, 0) &&
762 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
763 ODR_CONTEXT, 7, 1) &&
767 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
769 if (!odr_sequence_begin(o, p, sizeof(**p)))
772 z_ReferenceId(o, &(*p)->referenceId, 1) &&
773 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
774 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
775 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
776 ODR_CONTEXT, 5, 0) &&
777 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
778 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
779 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
783 /* ------------------------ SEARCHRESPONSE ----------------*/
785 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
787 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
790 int z_NextResultSetPosition(ODR o, int **p, int opt)
792 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
795 int z_PresentStatus(ODR o, int **p, int opt)
797 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
800 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
802 Z_SearchResponse *pp;
804 if (!odr_sequence_begin(o, p, sizeof(**p)))
808 z_ReferenceId(o, &pp->referenceId, 1) &&
809 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
810 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
811 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
812 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
813 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26, 1) &&
814 z_PresentStatus(o, &pp->presentStatus, 1) &&
815 z_Records(o, &pp->records, 1) &&
819 /* --------------------- PRESENT SERVICE ---------------------- */
821 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
823 Z_PresentRequest *pp;
825 if (!odr_sequence_begin(o, p, sizeof(**p)))
829 z_ReferenceId(o, &pp->referenceId, 1) &&
830 z_ResultSetId(o, &pp->resultSetId, 0) &&
831 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
833 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
835 z_ElementSetNames(o, &pp->elementSetNames, 1) &&
836 z_PreferredRecordSyntax(o, &pp->preferredRecordSyntax, 1) &&
840 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
842 Z_PresentResponse *pp;
844 if (!odr_sequence_begin(o, p, sizeof(**p)))
848 z_ReferenceId(o, &pp->referenceId, 1) &&
849 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
850 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
851 z_PresentStatus(o, &pp->presentStatus, 0) &&
852 z_Records(o, &pp->records, 1) &&
856 /* ------------------------ APDU ------------------------- */
858 int z_APDU(ODR o, Z_APDU **p, int opt)
860 static Odr_arm arm[] =
862 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
863 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
864 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
865 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse, z_SearchResponse},
866 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest, z_PresentRequest},
867 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse, z_PresentResponse},
868 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
869 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
874 if (o->direction == ODR_DECODE)
875 *p = odr_malloc(o, sizeof(**p));
876 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
878 if (o->direction == ODR_DECODE)
880 return opt && !o->error;