2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.36 1995-08-15 11:59:39 quinn
10 * Revision 1.35 1995/08/10 08:53:59 quinn
13 * Revision 1.34 1995/06/19 17:01:48 quinn
14 * This should bring us in sync with the version distributed as 1.0b
16 * Revision 1.33 1995/06/19 13:39:56 quinn
17 * *** empty log message ***
19 * Revision 1.32 1995/06/19 12:37:28 quinn
20 * Fixed a bug in the compspec.
22 * Revision 1.31 1995/06/16 13:15:56 quinn
23 * Fixed Defaultdiagformat.
25 * Revision 1.30 1995/06/15 15:42:01 quinn
28 * Revision 1.29 1995/06/15 07:44:49 quinn
31 * Revision 1.28 1995/06/14 15:26:35 quinn
32 * *** empty log message ***
34 * Revision 1.27 1995/06/07 14:36:22 quinn
37 * Revision 1.26 1995/06/02 09:49:13 quinn
38 * Adding access control
40 * Revision 1.25 1995/05/25 11:00:08 quinn
41 * *** empty log message ***
43 * Revision 1.24 1995/05/22 13:58:18 quinn
44 * Fixed an ODR_NULLVAL.
46 * Revision 1.23 1995/05/22 11:30:18 quinn
47 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
49 * Revision 1.22 1995/05/17 08:40:56 quinn
50 * Added delete. Fixed some sequence_begins. Smallish.
52 * Revision 1.21 1995/05/16 08:50:24 quinn
53 * License, documentation, and memory fixes
55 * Revision 1.20 1995/05/15 11:55:25 quinn
58 * Revision 1.19 1995/04/11 11:58:35 quinn
61 * Revision 1.18 1995/04/11 11:52:02 quinn
62 * Fixed possible buf in proto.c
64 * Revision 1.17 1995/04/10 10:22:22 quinn
67 * Revision 1.16 1995/03/30 10:26:43 quinn
68 * Added Term structure
70 * Revision 1.15 1995/03/30 09:08:39 quinn
71 * Added Resource control protocol
73 * Revision 1.14 1995/03/29 08:06:13 quinn
74 * Added a few v3 elements
76 * Revision 1.13 1995/03/20 11:26:52 quinn
77 * *** empty log message ***
79 * Revision 1.12 1995/03/20 09:45:09 quinn
82 * Revision 1.11 1995/03/17 10:17:25 quinn
83 * Added memory management.
85 * Revision 1.10 1995/03/15 11:17:40 quinn
86 * Fixed some return-checks from choice.. need better ay to handle those..
88 * Revision 1.9 1995/03/15 08:37:06 quinn
89 * Fixed protocol bugs.
91 * Revision 1.8 1995/03/14 16:59:24 quinn
92 * Fixed OPTIONAL flag in attributeelement
94 * Revision 1.7 1995/03/07 16:29:33 quinn
95 * Added authentication stuff.
97 * Revision 1.6 1995/03/01 14:46:03 quinn
98 * Fixed protocol bug in 8777query.
100 * Revision 1.5 1995/02/14 11:54:22 quinn
103 * Revision 1.4 1995/02/10 15:54:30 quinn
106 * Revision 1.3 1995/02/09 15:51:39 quinn
109 * Revision 1.2 1995/02/06 21:26:07 quinn
110 * Repaired this evening's damages..
112 * Revision 1.1 1995/02/06 16:44:47 quinn
113 * First hack at Z/SR protocol
121 /* ---------------------- GLOBAL DEFS ------------------- */
124 * We'll use a general octetstring here, since string operations are
125 * clumsy on long strings.
127 int z_SUTRS(ODR o, Odr_oct **p, int opt)
129 return odr_implicit(o, odr_octetstring, p, ODR_UNIVERSAL,
130 ODR_GENERALSTRING, opt);
133 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
135 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
138 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
140 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
144 int z_ResultSetId(ODR o, char **p, int opt)
146 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
150 int z_ElementSetName(ODR o, char **p, int opt)
152 return odr_implicit(o, odr_visiblestring, p, ODR_CONTEXT, 103, opt);
155 int z_UserInformationField(ODR o, Z_External **p, int opt)
157 return odr_explicit(o, z_External, (Z_External **)p, ODR_CONTEXT,
161 int z_InternationalString(ODR o, char **p, int opt)
163 return odr_generalstring(o, p, opt);
166 int z_InfoCategory(ODR o, Z_InfoCategory **p, int opt)
168 if (!odr_sequence_begin(o, p, sizeof(**p)))
169 return opt && odr_ok(o);
171 odr_implicit(o, odr_oid, &(*p)->categoryTypeId, ODR_CONTEXT, 1, 1) &&
172 odr_implicit(o, odr_integer, &(*p)->categoryValue, ODR_CONTEXT, 2, 0) &&
176 int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt)
178 static Odr_arm arm[] =
180 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_OtherInfo_characterInfo,
182 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_OtherInfo_binaryInfo,
184 {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_OtherInfo_externallyDefinedInfo,
186 {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_OtherInfo_oid, odr_oid},
190 if (!odr_sequence_begin(o, p, sizeof(**p)))
191 return opt && odr_ok(o);
193 odr_implicit(o, z_InfoCategory, &(*p)->category, ODR_CONTEXT, 1, 1) &&
194 odr_choice(o, arm, &(*p)->which, &(*p)->information) &&
198 int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt)
200 if (o->direction == ODR_DECODE)
201 *p = odr_malloc(o, sizeof(**p));
204 odr_implicit_settag(o, ODR_CONTEXT, 201);
205 if (odr_sequence_of(o, z_OtherInformationUnit, &(*p)->list,
206 &(*p)->num_elements))
209 return opt && odr_ok(o);
212 int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt)
214 static Odr_arm arm[] =
216 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_StringOrNumeric_string,
218 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_StringOrNumeric_numeric,
223 if (o->direction == ODR_DECODE)
224 *p = odr_malloc(o, sizeof(**p));
227 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
230 return opt && odr_ok(o);
236 int z_Unit(ODR o, Z_Unit **p, int opt)
238 if (!odr_sequence_begin(o, p, sizeof(**p)))
239 return opt && odr_ok(o);
241 odr_implicit(o, odr_visiblestring, &(*p)->unitSystem, ODR_CONTEXT,
243 odr_explicit(o, z_StringOrNumeric, &(*p)->unitType, ODR_CONTEXT,
245 odr_explicit(o, z_StringOrNumeric, &(*p)->unit, ODR_CONTEXT, 3, 1) &&
246 odr_implicit(o, odr_integer, &(*p)->scaleFactor, ODR_CONTEXT, 4, 1) &&
250 int z_IntUnit(ODR o, Z_IntUnit **p, int opt)
252 if (!odr_sequence_begin(o, p, sizeof(**p)))
253 return opt && odr_ok(o);
255 odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 1, 0) &&
256 odr_implicit(o, z_Unit, &(*p)->unitUsed, ODR_CONTEXT, 2, 0) &&
260 /* ---------------------- INITIALIZE SERVICE ------------------- */
263 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
265 if (!odr_sequence_begin(o, p, sizeof(**p)))
266 return opt && odr_ok(o);
268 odr_visiblestring(o, &(*p)->user, 0) &&
269 odr_visiblestring(o, &(*p)->password, 0) &&
270 odr_visiblestring(o, &(*p)->account, 0) &&
275 int z_IdPass(ODR o, Z_IdPass **p, int opt)
277 if (!odr_sequence_begin(o, p, sizeof(**p)))
278 return opt && odr_ok(o);
280 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 1) &&
281 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 1) &&
282 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
287 int z_StrAuthentication(ODR o, char **p, int opt)
289 return odr_visiblestring(o, p, opt);
292 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
294 static Odr_arm arm[] =
296 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
297 {-1, -1, -1, Z_IdAuthentication_idPass, z_IdPass},
298 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
299 {-1, -1, -1, Z_IdAuthentication_other, z_External},
303 if (o->direction == ODR_DECODE)
304 *p = odr_malloc(o, sizeof(**p));
308 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
311 return opt && odr_ok(o);
314 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
318 if (!odr_sequence_begin(o, p, sizeof(**p)))
319 return opt && odr_ok(o);
322 z_ReferenceId(o, &pp->referenceId, 1) &&
323 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
325 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
326 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
328 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
330 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
332 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
334 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
336 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
337 ODR_CONTEXT, 112, 1) &&
338 z_UserInformationField(o, &pp->userInformationField, 1) &&
340 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
345 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
349 if (!odr_sequence_begin(o, p, sizeof(**p)))
350 return opt && odr_ok(o);
353 z_ReferenceId(o, &pp->referenceId, 1) &&
354 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
356 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
357 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
359 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
361 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
362 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
364 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
366 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
367 ODR_CONTEXT, 112, 1) &&
368 z_UserInformationField(o, &pp->userInformationField, 1) &&
370 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
375 /* ------------------ RESOURCE CONTROL ----------------*/
377 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
380 if (!odr_sequence_begin(o, p, sizeof(**p)))
381 return opt && odr_ok(o);
383 z_ReferenceId(o, &(*p)->referenceId, 1) &&
384 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
386 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
387 ODR_CONTEXT, 47, 1) &&
388 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
391 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
396 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
398 if (!odr_sequence_begin(o, p, sizeof(**p)))
399 return opt && odr_ok(o);
401 z_ReferenceId(o, &(*p)->referenceId, 1) &&
402 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
403 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
405 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
406 ODR_CONTEXT, 41, 1) &&
407 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
409 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
410 ODR_CONTEXT, 43, 1) &&
412 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
417 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
419 if (!odr_sequence_begin(o, p, sizeof(**p)))
420 return opt && odr_ok(o);
422 z_ReferenceId(o, &(*p)->referenceId, 1) &&
423 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
424 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
427 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
432 /* ------------------------ SEARCH SERVICE ----------------------- */
434 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
436 if (!odr_sequence_begin(o, p, sizeof(**p)))
437 return opt && odr_ok(o);
439 z_DatabaseName(o, &(*p)->databaseName, 0) &&
440 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
444 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
446 if (o->direction == ODR_DECODE)
447 *p = odr_malloc(o, sizeof(**p));
451 odr_implicit_settag(o, ODR_CONTEXT, 1);
452 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
453 &(*p)->num_elements))
459 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
461 static Odr_arm arm[] =
463 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
465 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
470 if (o->direction == ODR_DECODE)
471 *p = odr_malloc(o, sizeof(**p));
473 return opt && odr_ok(o);
475 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
481 /* ----------------------- RPN QUERY -----------------------*/
483 int z_ComplexAttribute(ODR o, Z_ComplexAttribute **p, int opt)
485 if (!odr_sequence_begin(o, p, sizeof(**p)))
486 return opt && odr_ok(o);
488 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
489 odr_sequence_of(o, z_StringOrNumeric, &(*p)->list,
491 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
492 (odr_sequence_of(o, odr_integer, &(*p)->semanticAction,
493 &(*p)->num_semanticAction) || odr_ok(o)) &&
497 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
500 static Odr_arm arm[] =
502 {ODR_IMPLICIT, ODR_CONTEXT, 121, Z_AttributeValue_numeric,
504 {ODR_IMPLICIT, ODR_CONTEXT, 224, Z_AttributeValue_complex,
510 if (!odr_sequence_begin(o, p, sizeof(**p)))
511 return opt && odr_ok(o);
514 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 1, 1) &&
516 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
519 odr_choice(o, arm, &(*p)->value, &(*p)->which) &&
521 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
527 int z_Term(ODR o, Z_Term **p, int opt)
529 static Odr_arm arm[] =
531 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
532 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
533 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
535 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
536 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
537 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, z_External},
538 /* add intUnit here */
539 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
543 if (o->direction ==ODR_DECODE)
544 *p = odr_malloc(o, sizeof(**p));
547 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
550 return opt && odr_ok(o);
553 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
555 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
556 odr_sequence_begin(o, p, sizeof(**p))))
557 return opt && odr_ok(o);
559 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
560 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
561 &(*p)->num_attributes) &&
562 z_Term(o, &(*p)->term, 0) &&
566 int z_ResultSetPlusAttributes(ODR o, Z_ResultSetPlusAttributes **p, int opt)
568 if (!(odr_implicit_settag(o, ODR_CONTEXT, 214) &&
569 odr_sequence_begin(o, p, sizeof(**p))))
570 return opt && odr_ok(o);
572 z_ResultSetId(o, &(*p)->resultSet, 0) &&
573 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
574 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
575 &(*p)->num_attributes) &&
579 int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
581 static Odr_arm arm[] =
583 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, odr_integer},
584 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_private, odr_integer},
588 if (!odr_sequence_begin(o, p, sizeof(**p)))
589 return opt && odr_ok(o);
591 odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
592 odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
593 odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
594 odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
595 odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
596 odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
597 odr_constructed_end(o) &&
601 int z_Operator(ODR o, Z_Operator **p, int opt)
603 static Odr_arm arm[] =
605 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
606 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
607 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
608 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, z_ProximityOperator},
612 if (!*p && o->direction != ODR_DECODE)
614 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
615 return opt && odr_ok(o);
616 if (o->direction == ODR_DECODE)
617 *p = odr_malloc(o, sizeof(**p));
619 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
620 odr_constructed_end(o))
623 return opt && odr_ok(o);
626 int z_Operand(ODR o, Z_Operand **p, int opt)
628 static Odr_arm arm[] =
630 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
631 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
632 {-1, -1, -1, Z_Operand_resultAttr, z_ResultSetPlusAttributes},
636 if (o->direction == ODR_DECODE)
637 *p = odr_malloc(o, sizeof(**p));
640 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
643 return opt && odr_ok(o);
646 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
648 int z_Complex(ODR o, Z_Complex **p, int opt)
650 if (!odr_sequence_begin(o, p, sizeof(**p)))
651 return opt && odr_ok(o);
653 z_RPNStructure(o, &(*p)->s1, 0) &&
654 z_RPNStructure(o, &(*p)->s2, 0) &&
655 z_Operator(o, &(*p)->operator, 0) &&
659 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
661 static Odr_arm arm[] =
663 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
664 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
668 if (o->direction == ODR_DECODE)
669 *p = odr_malloc(o, sizeof(**p));
672 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
675 return opt && odr_ok(o);
678 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
680 if (!odr_sequence_begin(o, p, sizeof(**p)))
681 return opt && odr_ok(o);
683 odr_oid(o, &(*p)->attributeSetId, 0) &&
684 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
688 /* -----------------------END RPN QUERY ----------------------- */
690 int z_Query(ODR o, Z_Query **p, int opt)
692 static Odr_arm arm[] =
694 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
695 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
696 {ODR_EXPLICIT, ODR_CONTEXT, 101, Z_Query_type_101, z_RPNQuery},
700 if (o->direction == ODR_DECODE)
701 *p = odr_malloc(o, sizeof(**p));
704 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
707 return opt && odr_ok(o);
710 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
714 if (!odr_sequence_begin(o, p, sizeof(**p)))
715 return opt && odr_ok(o);
718 z_ReferenceId(o, &pp->referenceId, 1) &&
719 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
721 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
723 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
725 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
726 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
728 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
729 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
730 &pp->num_databaseNames) &&
731 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
732 ODR_CONTEXT, 100, 1) &&
733 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
734 ODR_CONTEXT, 101, 1) &&
735 odr_implicit(o, odr_oid, &pp->preferredRecordSyntax,
736 ODR_CONTEXT, 104, 1) &&
737 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
739 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
740 ODR_CONTEXT, 203, 1) &&
741 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
746 /* ------------------------ RECORD ------------------------- */
748 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
750 return z_External(o, (Z_External **) p, opt);
755 int z_DefaultDiagFormat(ODR o, Z_DefaultDiagFormat **p, int opt)
757 static Odr_arm arm[] =
759 {-1, -1, -1, Z_DiagForm_v2AddInfo, odr_visiblestring},
760 {-1, -1, -1, Z_DiagForm_v3AddInfo, z_InternationalString},
761 {ODR_IMPLICIT, ODR_CONTEXT, ODR_VISIBLESTRING, Z_DiagForm_v2AddInfo,
762 odr_visiblestring}, /* To cater to a bug in the CNIDR servers */
765 if (!odr_sequence_begin(o, p, sizeof(**p)))
766 return opt && odr_ok(o);
768 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
769 odr_integer(o, &(*p)->condition, 0) &&
771 * I no longer recall what server tagged the addinfo.. but it isn't
772 * hurting anyone, so...
773 * We need to turn it into a choice, or something, because of
774 * that damn generalstring in v3.
776 odr_choice(o, arm, &(*p)->addinfo, &(*p)->which) &&
780 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
782 static Odr_arm arm[] =
784 {-1, -1, -1, Z_DiagRec_defaultFormat, z_DefaultDiagFormat},
785 {-1, -1, -1, Z_DiagRec_externallyDefined, z_External},
789 if (o->direction == ODR_DECODE)
790 *p = odr_malloc(o, sizeof(**p));
793 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
796 return opt && odr_ok(o);
801 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
803 if (!odr_sequence_begin(o, p, sizeof(**p)))
804 return opt && odr_ok(o);
806 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
807 odr_integer(o, &(*p)->condition, 0) &&
809 * I no longer recall what server tagged the addinfo.. but it isn't
810 * hurting anyone, so...
811 * We need to turn it into a choice, or something, because of
812 * that damn generalstring in v3.
814 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
815 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT,
816 ODR_VISIBLESTRING, 1)) &&
822 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
824 if (o->direction == ODR_DECODE)
825 *p = odr_malloc(o, sizeof(**p));
829 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
830 &(*p)->num_diagRecs))
836 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
838 static Odr_arm arm[] =
840 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
842 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
847 if (!odr_sequence_begin(o, p, sizeof(**p)))
848 return opt && odr_ok(o);
850 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
852 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
853 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
854 odr_constructed_end(o) &&
858 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
860 if (o->direction == ODR_DECODE)
861 *p = odr_malloc(o, sizeof(**p));
864 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
871 int z_Records(ODR o, Z_Records **p, int opt)
873 static Odr_arm arm[] =
875 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
876 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
877 {ODR_IMPLICIT, ODR_CONTEXT, 205, Z_Records_multipleNSD,
882 if (o->direction == ODR_DECODE)
883 *p = odr_malloc(o, sizeof(**p));
886 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
889 return opt && odr_ok(o);
892 /* ------------------------ ACCESS CTRL SERVICE ----------------------- */
894 int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
896 static Odr_arm arm[] =
898 {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
900 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
904 if (!odr_sequence_begin(o, p, sizeof(**p)))
905 return opt && odr_ok(o);
907 z_ReferenceId(o, &(*p)->referenceId, 1) &&
908 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
910 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
915 int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
917 static Odr_arm arm[] =
919 {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
921 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
925 if (!odr_sequence_begin(o, p, sizeof(**p)))
926 return opt && odr_ok(o);
928 z_ReferenceId(o, &(*p)->referenceId, 1) &&
929 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
930 odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
932 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
937 /* ------------------------ SCAN SERVICE -------------------- */
939 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
941 if (o->direction == ODR_DECODE)
942 *p = odr_malloc(o, sizeof(**p));
946 odr_implicit_settag(o, ODR_CONTEXT, 44);
947 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
948 &(*p)->num_attributes))
951 return opt && odr_ok(o);
955 * This is a temporary hack. We don't know just *what* old version of the
956 * protocol willow uses, so we'll just patiently wait for them to update
958 static int willow_scan = 0;
960 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
962 if (!*p && o->direction != ODR_DECODE)
964 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
967 return opt && odr_ok(o);
969 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
971 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
973 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
975 if (o->direction == ODR_DECODE)
976 *p = odr_malloc(o, sizeof(**p));
977 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
978 &(*p)->num_attributes))
980 if (!odr_sequence_end(o) || !odr_sequence_end(o))
982 if (!z_Term(o, &(*p)->term, 0))
984 if (!odr_constructed_end(o))
990 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
992 if (o->direction == ODR_DECODE)
993 *p = odr_malloc(o, sizeof(**p));
997 return opt && odr_ok(o);
1000 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
1004 return opt && !o->error;
1007 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1009 if (!odr_sequence_begin(o, p, sizeof(**p)))
1010 return opt && odr_ok(o);
1012 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
1013 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
1014 odr_sequence_end(o);
1017 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
1019 if (!odr_sequence_begin(o, p, sizeof(**p)))
1020 return opt && odr_ok(o);
1023 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
1024 z_Term(o, &(*p)->term, 0)) &&
1025 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
1026 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
1027 ODR_CONTEXT, 4, 1) &&
1028 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
1030 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
1031 ODR_CONTEXT, 3, 1) &&
1032 odr_sequence_end(o);
1035 int z_Entry(ODR o, Z_Entry **p, int opt)
1037 static Odr_arm arm[] =
1039 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
1040 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
1045 if (o->direction == ODR_DECODE)
1046 *p = odr_malloc(o, sizeof(**p));
1050 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1053 return opt && odr_ok(o);
1056 int z_Entries(ODR o, Z_Entries **p, int opt)
1058 if (o->direction == ODR_DECODE)
1059 *p = odr_malloc(o, sizeof(**p));
1063 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
1064 &(*p)->num_entries))
1070 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
1072 static Odr_arm arm[] =
1074 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
1075 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
1080 if (o->direction == ODR_DECODE)
1081 *p = odr_malloc(o, sizeof(**p));
1085 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1088 return opt && odr_ok(o);
1091 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
1093 if (!odr_sequence_begin(o, p, sizeof(**p)))
1094 return opt && odr_ok(o);
1097 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1098 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1099 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
1100 &(*p)->num_databaseNames) &&
1101 odr_oid(o, &(*p)->attributeSet, 1) &&
1102 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
1103 ((*p)->termListAndStartPoint ? 1 :
1104 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
1105 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
1106 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
1107 ODR_CONTEXT, 6, 0) &&
1108 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
1109 ODR_CONTEXT, 7, 1) &&
1110 odr_sequence_end(o);
1113 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
1115 if (!odr_sequence_begin(o, p, sizeof(**p)))
1116 return opt && odr_ok(o);
1118 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1119 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
1120 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
1121 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
1122 ODR_CONTEXT, 5, 0) &&
1123 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
1124 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
1125 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
1126 odr_sequence_end(o);
1129 /* ------------------------ SEARCHRESPONSE ----------------*/
1131 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
1133 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
1136 int z_NextResultSetPosition(ODR o, int **p, int opt)
1138 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
1141 int z_PresentStatus(ODR o, int **p, int opt)
1143 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
1146 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
1148 Z_SearchResponse *pp;
1150 if (!odr_sequence_begin(o, p, sizeof(**p)))
1151 return opt && odr_ok(o);
1154 z_ReferenceId(o, &pp->referenceId, 1) &&
1155 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
1156 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1157 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1158 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
1159 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26,
1161 z_PresentStatus(o, &pp->presentStatus, 1) &&
1162 z_Records(o, &pp->records, 1) &&
1164 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
1165 ODR_CONTEXT, 203, 1) &&
1166 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1168 odr_sequence_end(o);
1171 /* --------------------- PRESENT SERVICE ---------------------- */
1173 int z_ElementSpec(ODR o, Z_ElementSpec **p, int opt)
1175 static Odr_arm arm[] =
1177 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSpec_elementSetName,
1179 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ElementSpec_externalSpec,
1184 if (o->direction == ODR_DECODE)
1185 *p = odr_malloc(o, sizeof(**p));
1189 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1192 return opt && odr_ok(o);
1195 int z_Specification(ODR o, Z_Specification **p, int opt)
1197 if (!odr_sequence_begin(o, p, sizeof(**p)))
1198 return opt && odr_ok(o);
1200 odr_implicit(o, odr_oid, &(*p)->schema, ODR_CONTEXT, 1, 1) &&
1201 z_ElementSpec(o, &(*p)->elementSpec, 1) &&
1202 odr_sequence_end(o);
1205 int z_DbSpecific(ODR o, Z_DbSpecific **p, int opt)
1207 if (!odr_sequence_begin(o, p, sizeof(**p)))
1208 return opt && odr_ok(o);
1210 odr_explicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
1212 odr_implicit(o, z_Specification, &(*p)->spec, ODR_CONTEXT, 2, 0) &&
1213 odr_sequence_end(o);
1216 int z_CompSpec(ODR o, Z_CompSpec **p, int opt)
1218 if (!odr_sequence_begin(o, p, sizeof(**p)))
1219 return opt && odr_ok(o);
1221 odr_implicit(o, odr_bool, &(*p)->selectAlternativeSyntax, ODR_CONTEXT,
1223 odr_implicit(o, z_Specification, &(*p)->generic, ODR_CONTEXT, 2, 1) &&
1224 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1225 (odr_sequence_of(o, z_DbSpecific, &(*p)->dbSpecific,
1226 &(*p)->num_dbSpecific) || odr_ok(o)) &&
1227 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1228 (odr_sequence_of(o, odr_oid, &(*p)->recordSyntax,
1229 &(*p)->num_recordSyntax) || odr_ok(o)) &&
1230 odr_sequence_end(o);
1233 int z_RecordComposition(ODR o, Z_RecordComposition **p, int opt)
1235 static Odr_arm arm[] =
1237 {ODR_EXPLICIT, ODR_CONTEXT, 19, Z_RecordComp_simple,
1239 {ODR_IMPLICIT, ODR_CONTEXT, 209, Z_RecordComp_complex,
1244 if (o->direction == ODR_DECODE)
1245 *p = odr_malloc(o, sizeof(**p));
1249 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1252 return opt && odr_ok(o);
1255 int z_Range(ODR o, Z_Range **p, int opt)
1257 if (!odr_sequence_begin(o, p, sizeof(**p)))
1258 return opt && odr_ok(o);
1260 odr_implicit(o, odr_integer, &(*p)->startingPosition, ODR_CONTEXT,
1262 odr_implicit(o, odr_integer, &(*p)->numberOfRecords, ODR_CONTEXT,
1264 odr_sequence_end(o);
1267 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
1269 Z_PresentRequest *pp;
1271 if (!odr_sequence_begin(o, p, sizeof(**p)))
1272 return opt && odr_ok(o);
1275 z_ReferenceId(o, &pp->referenceId, 1) &&
1276 z_ResultSetId(o, &pp->resultSetId, 0) &&
1277 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
1279 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
1282 odr_implicit_settag(o, ODR_CONTEXT, 212) &&
1283 (odr_sequence_of(o, z_Range, &(*p)->additionalRanges,
1284 &(*p)->num_ranges) || odr_ok(o)) &&
1285 z_RecordComposition(o, &(*p)->recordComposition, 1) &&
1287 odr_explicit(o, z_ElementSetNames, &pp->elementSetNames, ODR_CONTEXT,
1290 odr_implicit(o, odr_oid, &(*p)->preferredRecordSyntax, ODR_CONTEXT,
1293 odr_implicit(o, odr_integer, &(*p)->maxSegmentCount, ODR_CONTEXT,
1295 odr_implicit(o, odr_integer, &(*p)->maxRecordSize, ODR_CONTEXT,
1297 odr_implicit(o, odr_integer, &(*p)->maxSegmentSize, ODR_CONTEXT,
1299 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1301 odr_sequence_end(o);
1304 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
1306 Z_PresentResponse *pp;
1308 if (!odr_sequence_begin(o, p, sizeof(**p)))
1309 return opt && odr_ok(o);
1312 z_ReferenceId(o, &pp->referenceId, 1) &&
1313 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1314 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1315 z_PresentStatus(o, &pp->presentStatus, 0) &&
1316 z_Records(o, &pp->records, 1) &&
1318 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1320 odr_sequence_end(o);
1323 /* ----------------------DELETE -------------------------- */
1325 int z_DeleteSetStatus(ODR o, int **p, int opt)
1327 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
1330 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
1332 if (!odr_sequence_begin(o, p, sizeof(**p)))
1333 return opt && odr_ok(o);
1335 z_ResultSetId(o, &(*p)->id, 0) &&
1336 z_DeleteSetStatus(o, &(*p)->status, 0) &&
1337 odr_sequence_end(o);
1340 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
1342 if (!odr_sequence_begin(o, p, sizeof(**p)))
1343 return opt && odr_ok(o);
1345 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1346 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
1348 (odr_sequence_of(o, z_ListStatus, &(*p)->resultSetList,
1349 &(*p)->num_ids) || odr_ok(o)) &&
1351 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1353 odr_sequence_end(o);
1356 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
1358 if (!odr_sequence_begin(o, p, sizeof(**p)))
1359 return opt && odr_ok(o);
1361 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1362 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
1363 ODR_CONTEXT, 0, 1) &&
1364 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
1365 (odr_sequence_of(o, z_ListStatus, &(*p)->deleteListStatuses,
1366 &(*p)->num_statuses) || odr_ok(o)) &&
1367 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
1369 odr_implicit_settag(o, ODR_CONTEXT, 35) &&
1370 (odr_sequence_of(o, z_ListStatus, &(*p)->bulkStatuses,
1371 &(*p)->num_bulkStatuses) || odr_ok(o)) &&
1372 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
1375 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1377 odr_sequence_end(o);
1380 /* ------------------------ SEGMENT SERVICE -------------- */
1382 int z_Segment(ODR o, Z_Segment **p, int opt)
1384 if (!odr_sequence_begin(o, p, sizeof(**p)))
1385 return opt && odr_ok(o);
1387 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1388 odr_implicit(o, odr_integer, &(*p)->numberOfRecordsReturned,
1389 ODR_CONTEXT, 24, 0) &&
1390 odr_implicit_settag(o, ODR_CONTEXT, 0) &&
1391 odr_sequence_of(o, z_NamePlusRecord, &(*p)->segmentRecords,
1392 &(*p)->num_segmentRecords) &&
1393 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1394 odr_sequence_end(o);
1397 /* ------------------------ CLOSE SERVICE ---------------- */
1399 int z_Close(ODR o, Z_Close **p, int opt)
1401 if (!odr_sequence_begin(o, p, sizeof(**p)))
1402 return opt && odr_ok(o);
1404 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1405 odr_implicit(o, odr_integer, &(*p)->closeReason, ODR_CONTEXT, 211, 0) &&
1406 odr_implicit(o, odr_visiblestring, &(*p)->diagnosticInformation,
1407 ODR_CONTEXT, 3, 1) &&
1408 odr_implicit(o, odr_oid, &(*p)->resourceReportFormat, ODR_CONTEXT,
1410 odr_implicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1413 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1415 odr_sequence_end(o);
1418 /* ------------------------ APDU ------------------------- */
1420 int z_APDU(ODR o, Z_APDU **p, int opt)
1422 static Odr_arm arm[] =
1424 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
1425 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
1426 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
1427 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
1429 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
1431 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
1433 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
1434 z_DeleteResultSetRequest},
1435 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
1436 z_DeleteResultSetResponse},
1437 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
1438 z_ResourceControlRequest},
1439 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
1440 z_ResourceControlResponse},
1441 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
1442 z_TriggerResourceControlRequest},
1443 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
1444 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
1445 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_APDU_segmentRequest, z_Segment},
1446 {ODR_IMPLICIT, ODR_CONTEXT, 48, Z_APDU_close, z_Close},
1451 if (o->direction == ODR_DECODE)
1452 *p = odr_malloc(o, sizeof(**p));
1453 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
1455 if (o->direction == ODR_DECODE)
1457 return opt && odr_ok(o);