2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.33 1995-06-19 13:39:56 quinn
8 * *** empty log message ***
10 * Revision 1.32 1995/06/19 12:37:28 quinn
11 * Fixed a bug in the compspec.
13 * Revision 1.31 1995/06/16 13:15:56 quinn
14 * Fixed Defaultdiagformat.
16 * Revision 1.30 1995/06/15 15:42:01 quinn
19 * Revision 1.29 1995/06/15 07:44:49 quinn
22 * Revision 1.28 1995/06/14 15:26:35 quinn
23 * *** empty log message ***
25 * Revision 1.27 1995/06/07 14:36:22 quinn
28 * Revision 1.26 1995/06/02 09:49:13 quinn
29 * Adding access control
31 * Revision 1.25 1995/05/25 11:00:08 quinn
32 * *** empty log message ***
34 * Revision 1.24 1995/05/22 13:58:18 quinn
35 * Fixed an ODR_NULLVAL.
37 * Revision 1.23 1995/05/22 11:30:18 quinn
38 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
40 * Revision 1.22 1995/05/17 08:40:56 quinn
41 * Added delete. Fixed some sequence_begins. Smallish.
43 * Revision 1.21 1995/05/16 08:50:24 quinn
44 * License, documentation, and memory fixes
46 * Revision 1.20 1995/05/15 11:55:25 quinn
49 * Revision 1.19 1995/04/11 11:58:35 quinn
52 * Revision 1.18 1995/04/11 11:52:02 quinn
53 * Fixed possible buf in proto.c
55 * Revision 1.17 1995/04/10 10:22:22 quinn
58 * Revision 1.16 1995/03/30 10:26:43 quinn
59 * Added Term structure
61 * Revision 1.15 1995/03/30 09:08:39 quinn
62 * Added Resource control protocol
64 * Revision 1.14 1995/03/29 08:06:13 quinn
65 * Added a few v3 elements
67 * Revision 1.13 1995/03/20 11:26:52 quinn
68 * *** empty log message ***
70 * Revision 1.12 1995/03/20 09:45:09 quinn
73 * Revision 1.11 1995/03/17 10:17:25 quinn
74 * Added memory management.
76 * Revision 1.10 1995/03/15 11:17:40 quinn
77 * Fixed some return-checks from choice.. need better ay to handle those..
79 * Revision 1.9 1995/03/15 08:37:06 quinn
80 * Fixed protocol bugs.
82 * Revision 1.8 1995/03/14 16:59:24 quinn
83 * Fixed OPTIONAL flag in attributeelement
85 * Revision 1.7 1995/03/07 16:29:33 quinn
86 * Added authentication stuff.
88 * Revision 1.6 1995/03/01 14:46:03 quinn
89 * Fixed protocol bug in 8777query.
91 * Revision 1.5 1995/02/14 11:54:22 quinn
94 * Revision 1.4 1995/02/10 15:54:30 quinn
97 * Revision 1.3 1995/02/09 15:51:39 quinn
100 * Revision 1.2 1995/02/06 21:26:07 quinn
101 * Repaired this evening's damages..
103 * Revision 1.1 1995/02/06 16:44:47 quinn
104 * First hack at Z/SR protocol
112 /* ---------------------- GLOBAL DEFS ------------------- */
115 * We'll use a general octetstring here, since string operations are
116 * clumsy on long strings.
118 int z_SUTRS(ODR o, Odr_oct **p, int opt)
120 return odr_implicit(o, odr_octetstring, p, ODR_UNIVERSAL,
121 ODR_GENERALSTRING, opt);
124 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
126 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
129 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
131 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
135 int z_ResultSetId(ODR o, char **p, int opt)
137 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
141 int z_UserInformationField(ODR o, Odr_external **p, int opt)
143 return odr_explicit(o, odr_external, (Odr_external **)p, ODR_CONTEXT,
147 int z_InternationalString(ODR o, char **p, int opt)
149 return odr_generalstring(o, p, opt);
152 int z_InfoCategory(ODR o, Z_InfoCategory **p, int opt)
154 if (!odr_sequence_begin(o, p, sizeof(**p)))
155 return opt && odr_ok(o);
157 odr_implicit(o, odr_oid, &(*p)->categoryTypeId, ODR_CONTEXT, 1, 1) &&
158 odr_implicit(o, odr_integer, &(*p)->categoryValue, ODR_CONTEXT, 2, 0) &&
162 int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt)
164 static Odr_arm arm[] =
166 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_OtherInfo_characterInfo,
168 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_OtherInfo_binaryInfo,
170 {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_OtherInfo_externallyDefinedInfo,
172 {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_OtherInfo_oid, odr_oid},
176 if (!odr_sequence_begin(o, p, sizeof(**p)))
177 return opt && odr_ok(o);
179 odr_implicit(o, z_InfoCategory, &(*p)->category, ODR_CONTEXT, 1, 1) &&
180 odr_choice(o, arm, &(*p)->which, &(*p)->information) &&
184 int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt)
186 if (o->direction == ODR_DECODE)
187 *p = odr_malloc(o, sizeof(**p));
190 odr_implicit_settag(o, ODR_CONTEXT, 201);
191 if (odr_sequence_of(o, z_OtherInformationUnit, &(*p)->list,
192 &(*p)->num_elements))
195 return opt && odr_ok(o);
198 int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt)
200 static Odr_arm arm[] =
202 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_StringOrNumeric_string,
204 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_StringOrNumeric_numeric,
209 if (o->direction == ODR_DECODE)
210 *p = odr_malloc(o, sizeof(**p));
213 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
216 return opt && odr_ok(o);
222 int z_Unit(ODR o, Z_Unit **p, int opt)
224 if (!odr_sequence_begin(o, p, sizeof(**p)))
225 return opt && odr_ok(o);
227 odr_implicit(o, odr_visiblestring, &(*p)->unitSystem, ODR_CONTEXT,
229 odr_explicit(o, z_StringOrNumeric, &(*p)->unitType, ODR_CONTEXT,
231 odr_explicit(o, z_StringOrNumeric, &(*p)->unit, ODR_CONTEXT, 3, 1) &&
232 odr_implicit(o, odr_integer, &(*p)->scaleFactor, ODR_CONTEXT, 4, 1) &&
236 int z_IntUnit(ODR o, Z_IntUnit **p, int opt)
238 if (!odr_sequence_begin(o, p, sizeof(**p)))
239 return opt && odr_ok(o);
241 odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 1, 0) &&
242 odr_implicit(o, z_Unit, &(*p)->unitUsed, ODR_CONTEXT, 2, 0) &&
246 /* ---------------------- INITIALIZE SERVICE ------------------- */
249 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
251 if (!odr_sequence_begin(o, p, sizeof(**p)))
252 return opt && odr_ok(o);
254 odr_visiblestring(o, &(*p)->user, 0) &&
255 odr_visiblestring(o, &(*p)->password, 0) &&
256 odr_visiblestring(o, &(*p)->account, 0) &&
261 int z_IdPass(ODR o, Z_IdPass **p, int opt)
263 if (!odr_sequence_begin(o, p, sizeof(**p)))
264 return opt && odr_ok(o);
266 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 1) &&
267 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 1) &&
268 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
273 int z_StrAuthentication(ODR o, char **p, int opt)
275 return odr_visiblestring(o, p, opt);
278 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
280 static Odr_arm arm[] =
282 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
283 {-1, -1, -1, Z_IdAuthentication_idPass, z_IdPass},
284 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
285 {-1, -1, -1, Z_IdAuthentication_other, odr_external},
289 if (o->direction == ODR_DECODE)
290 *p = odr_malloc(o, sizeof(**p));
294 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
297 return opt && odr_ok(o);
300 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
304 if (!odr_sequence_begin(o, p, sizeof(**p)))
305 return opt && odr_ok(o);
308 z_ReferenceId(o, &pp->referenceId, 1) &&
309 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
311 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
312 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
314 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
316 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
318 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
320 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
322 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
323 ODR_CONTEXT, 112, 1) &&
324 z_UserInformationField(o, &pp->userInformationField, 1) &&
326 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
331 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
335 if (!odr_sequence_begin(o, p, sizeof(**p)))
336 return opt && odr_ok(o);
339 z_ReferenceId(o, &pp->referenceId, 1) &&
340 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
342 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
343 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
345 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
347 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
348 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
350 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
352 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
353 ODR_CONTEXT, 112, 1) &&
354 z_UserInformationField(o, &pp->userInformationField, 1) &&
356 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
361 /* ------------------ RESOURCE CONTROL ----------------*/
363 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
366 if (!odr_sequence_begin(o, p, sizeof(**p)))
367 return opt && odr_ok(o);
369 z_ReferenceId(o, &(*p)->referenceId, 1) &&
370 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
372 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
373 ODR_CONTEXT, 47, 1) &&
374 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
377 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
382 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
384 if (!odr_sequence_begin(o, p, sizeof(**p)))
385 return opt && odr_ok(o);
387 z_ReferenceId(o, &(*p)->referenceId, 1) &&
388 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
389 odr_explicit(o, odr_external, &(*p)->resourceReport, ODR_CONTEXT,
391 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
392 ODR_CONTEXT, 41, 1) &&
393 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
395 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
396 ODR_CONTEXT, 43, 1) &&
398 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
403 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
405 if (!odr_sequence_begin(o, p, sizeof(**p)))
406 return opt && odr_ok(o);
408 z_ReferenceId(o, &(*p)->referenceId, 1) &&
409 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
410 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
413 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
418 /* ------------------------ SEARCH SERVICE ----------------------- */
420 int z_ElementSetName(ODR o, char **p, int opt)
422 return odr_implicit(o, odr_visiblestring, (char**) p, ODR_CONTEXT, 103,
426 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
428 if (!odr_sequence_begin(o, p, sizeof(**p)))
429 return opt && odr_ok(o);
431 z_DatabaseName(o, &(*p)->databaseName, 0) &&
432 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
436 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
438 if (o->direction == ODR_DECODE)
439 *p = odr_malloc(o, sizeof(**p));
443 odr_implicit_settag(o, ODR_CONTEXT, 1);
444 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
445 &(*p)->num_elements))
451 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
453 static Odr_arm arm[] =
455 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
457 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
462 if (o->direction == ODR_DECODE)
463 *p = odr_malloc(o, sizeof(**p));
465 return opt && odr_ok(o);
467 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
473 /* ----------------------- RPN QUERY -----------------------*/
475 int z_ComplexAttribute(ODR o, Z_ComplexAttribute **p, int opt)
477 if (!odr_sequence_begin(o, p, sizeof(**p)))
478 return opt && odr_ok(o);
480 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
481 odr_sequence_of(o, z_StringOrNumeric, &(*p)->list,
483 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
484 (odr_sequence_of(o, odr_integer, &(*p)->semanticAction,
485 &(*p)->num_semanticAction) || odr_ok(o)) &&
489 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
492 static Odr_arm arm[] =
494 {ODR_IMPLICIT, ODR_CONTEXT, 121, Z_AttributeValue_numeric,
496 {ODR_IMPLICIT, ODR_CONTEXT, 224, Z_AttributeValue_complex,
502 if (!odr_sequence_begin(o, p, sizeof(**p)))
503 return opt && odr_ok(o);
506 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 1, 1) &&
508 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
511 odr_choice(o, arm, &(*p)->value, &(*p)->which) &&
513 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
519 int z_Term(ODR o, Z_Term **p, int opt)
521 static Odr_arm arm[] =
523 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
524 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
525 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
527 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
528 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
529 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, odr_external},
530 /* add intUnit here */
531 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
535 if (o->direction ==ODR_DECODE)
536 *p = odr_malloc(o, sizeof(**p));
539 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
542 return opt && odr_ok(o);
545 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
547 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
548 odr_sequence_begin(o, p, sizeof(**p))))
549 return opt && odr_ok(o);
551 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
552 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
553 &(*p)->num_attributes) &&
554 z_Term(o, &(*p)->term, 0) &&
558 int z_ResultSetPlusAttributes(ODR o, Z_ResultSetPlusAttributes **p, int opt)
560 if (!(odr_implicit_settag(o, ODR_CONTEXT, 214) &&
561 odr_sequence_begin(o, p, sizeof(**p))))
562 return opt && odr_ok(o);
564 z_ResultSetId(o, &(*p)->resultSet, 0) &&
565 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
566 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
567 &(*p)->num_attributes) &&
571 int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
573 static Odr_arm arm[] =
575 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, odr_integer},
576 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_private, odr_integer},
580 if (!odr_sequence_begin(o, p, sizeof(**p)))
581 return opt && odr_ok(o);
583 odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
584 odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
585 odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
586 odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
587 odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
588 odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
589 odr_constructed_end(o) &&
593 int z_Operator(ODR o, Z_Operator **p, int opt)
595 static Odr_arm arm[] =
597 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
598 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
599 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
600 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, z_ProximityOperator},
604 if (!*p && o->direction != ODR_DECODE)
606 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
607 return opt && odr_ok(o);
608 if (o->direction == ODR_DECODE)
609 *p = odr_malloc(o, sizeof(**p));
611 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
612 odr_constructed_end(o))
615 return opt && odr_ok(o);
618 int z_Operand(ODR o, Z_Operand **p, int opt)
620 static Odr_arm arm[] =
622 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
623 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
624 {-1, -1, -1, Z_Operand_resultAttr, z_ResultSetPlusAttributes},
628 if (o->direction == ODR_DECODE)
629 *p = odr_malloc(o, sizeof(**p));
632 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
635 return opt && odr_ok(o);
638 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
640 int z_Complex(ODR o, Z_Complex **p, int opt)
642 if (!odr_sequence_begin(o, p, sizeof(**p)))
643 return opt && odr_ok(o);
645 z_RPNStructure(o, &(*p)->s1, 0) &&
646 z_RPNStructure(o, &(*p)->s2, 0) &&
647 z_Operator(o, &(*p)->operator, 0) &&
651 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
653 static Odr_arm arm[] =
655 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
656 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
660 if (o->direction == ODR_DECODE)
661 *p = odr_malloc(o, sizeof(**p));
664 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
667 return opt && odr_ok(o);
670 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
672 if (!odr_sequence_begin(o, p, sizeof(**p)))
673 return opt && odr_ok(o);
675 odr_oid(o, &(*p)->attributeSetId, 0) &&
676 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
680 /* -----------------------END RPN QUERY ----------------------- */
682 int z_Query(ODR o, Z_Query **p, int opt)
684 static Odr_arm arm[] =
686 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
687 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
688 {ODR_EXPLICIT, ODR_CONTEXT, 101, Z_Query_type_101, z_RPNQuery},
692 if (o->direction == ODR_DECODE)
693 *p = odr_malloc(o, sizeof(**p));
696 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
699 return opt && odr_ok(o);
702 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
706 if (!odr_sequence_begin(o, p, sizeof(**p)))
707 return opt && odr_ok(o);
710 z_ReferenceId(o, &pp->referenceId, 1) &&
711 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
713 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
715 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
717 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
718 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
720 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
721 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
722 &pp->num_databaseNames) &&
723 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
724 ODR_CONTEXT, 100, 1) &&
725 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
726 ODR_CONTEXT, 101, 1) &&
727 odr_implicit(o, odr_oid, &pp->preferredRecordSyntax,
728 ODR_CONTEXT, 104, 1) &&
729 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
731 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
732 ODR_CONTEXT, 203, 1) &&
733 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
738 /* ------------------------ RECORD ------------------------- */
740 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
742 return odr_external(o, (Odr_external **) p, opt);
747 int z_DefaultDiagFormat(ODR o, Z_DefaultDiagFormat **p, int opt)
749 static Odr_arm arm[] =
751 {-1, -1, -1, Z_DiagForm_v2AddInfo, odr_visiblestring},
752 {-1, -1, -1, Z_DiagForm_v3AddInfo, z_InternationalString},
753 {ODR_IMPLICIT, ODR_CONTEXT, ODR_VISIBLESTRING, Z_DiagForm_v2AddInfo,
754 odr_visiblestring}, /* To cater to a bug in the CNIDR servers */
757 if (!odr_sequence_begin(o, p, sizeof(**p)))
758 return opt && odr_ok(o);
760 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
761 odr_integer(o, &(*p)->condition, 0) &&
763 * I no longer recall what server tagged the addinfo.. but it isn't
764 * hurting anyone, so...
765 * We need to turn it into a choice, or something, because of
766 * that damn generalstring in v3.
768 odr_choice(o, arm, &(*p)->addinfo, &(*p)->which) &&
772 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
774 static Odr_arm arm[] =
776 {-1, -1, -1, Z_DiagRec_defaultFormat, z_DefaultDiagFormat},
777 {-1, -1, -1, Z_DiagRec_externallyDefined, odr_external},
781 if (o->direction == ODR_DECODE)
782 *p = odr_malloc(o, sizeof(**p));
785 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
788 return opt && odr_ok(o);
793 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
795 if (!odr_sequence_begin(o, p, sizeof(**p)))
796 return opt && odr_ok(o);
798 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
799 odr_integer(o, &(*p)->condition, 0) &&
801 * I no longer recall what server tagged the addinfo.. but it isn't
802 * hurting anyone, so...
803 * We need to turn it into a choice, or something, because of
804 * that damn generalstring in v3.
806 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
807 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT,
808 ODR_VISIBLESTRING, 1)) &&
814 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
816 if (o->direction == ODR_DECODE)
817 *p = odr_malloc(o, sizeof(**p));
821 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
822 &(*p)->num_diagRecs))
828 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
830 static Odr_arm arm[] =
832 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
834 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
839 if (!odr_sequence_begin(o, p, sizeof(**p)))
840 return opt && odr_ok(o);
842 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
844 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
845 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
846 odr_constructed_end(o) &&
850 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
852 if (o->direction == ODR_DECODE)
853 *p = odr_malloc(o, sizeof(**p));
856 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
863 int z_Records(ODR o, Z_Records **p, int opt)
865 static Odr_arm arm[] =
867 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
868 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
869 {ODR_IMPLICIT, ODR_CONTEXT, 205, Z_Records_multipleNSD,
874 if (o->direction == ODR_DECODE)
875 *p = odr_malloc(o, sizeof(**p));
878 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
881 return opt && odr_ok(o);
884 /* ------------------------ ACCESS CTRL SERVICE ----------------------- */
886 int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
888 static Odr_arm arm[] =
890 {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
892 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
896 if (!odr_sequence_begin(o, p, sizeof(**p)))
897 return opt && odr_ok(o);
899 z_ReferenceId(o, &(*p)->referenceId, 1) &&
900 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
902 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
907 int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
909 static Odr_arm arm[] =
911 {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
913 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
917 if (!odr_sequence_begin(o, p, sizeof(**p)))
918 return opt && odr_ok(o);
920 z_ReferenceId(o, &(*p)->referenceId, 1) &&
921 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
922 odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
924 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
929 /* ------------------------ SCAN SERVICE -------------------- */
931 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
933 if (o->direction == ODR_DECODE)
934 *p = odr_malloc(o, sizeof(**p));
938 odr_implicit_settag(o, ODR_CONTEXT, 44);
939 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
940 &(*p)->num_attributes))
943 return opt && odr_ok(o);
947 * This is a temporary hack. We don't know just *what* old version of the
948 * protocol willow uses, so we'll just patiently wait for them to update
950 static int willow_scan = 0;
952 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
954 if (!*p && o->direction != ODR_DECODE)
956 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
959 return opt && odr_ok(o);
961 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
963 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
965 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
967 if (o->direction == ODR_DECODE)
968 *p = odr_malloc(o, sizeof(**p));
969 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
970 &(*p)->num_attributes))
972 if (!odr_sequence_end(o) || !odr_sequence_end(o))
974 if (!z_Term(o, &(*p)->term, 0))
976 if (!odr_constructed_end(o))
982 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
984 if (o->direction == ODR_DECODE)
985 *p = odr_malloc(o, sizeof(**p));
989 return opt && odr_ok(o);
992 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
996 return opt && !o->error;
999 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1001 if (!odr_sequence_begin(o, p, sizeof(**p)))
1002 return opt && odr_ok(o);
1004 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
1005 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
1006 odr_sequence_end(o);
1009 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
1011 if (!odr_sequence_begin(o, p, sizeof(**p)))
1012 return opt && odr_ok(o);
1015 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
1016 z_Term(o, &(*p)->term, 0)) &&
1017 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
1018 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
1019 ODR_CONTEXT, 4, 1) &&
1020 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
1022 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
1023 ODR_CONTEXT, 3, 1) &&
1024 odr_sequence_end(o);
1027 int z_Entry(ODR o, Z_Entry **p, int opt)
1029 static Odr_arm arm[] =
1031 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
1032 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
1037 if (o->direction == ODR_DECODE)
1038 *p = odr_malloc(o, sizeof(**p));
1042 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1045 return opt && odr_ok(o);
1048 int z_Entries(ODR o, Z_Entries **p, int opt)
1050 if (o->direction == ODR_DECODE)
1051 *p = odr_malloc(o, sizeof(**p));
1055 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
1056 &(*p)->num_entries))
1062 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
1064 static Odr_arm arm[] =
1066 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
1067 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
1072 if (o->direction == ODR_DECODE)
1073 *p = odr_malloc(o, sizeof(**p));
1077 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1080 return opt && odr_ok(o);
1083 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
1085 if (!odr_sequence_begin(o, p, sizeof(**p)))
1086 return opt && odr_ok(o);
1089 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1090 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1091 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
1092 &(*p)->num_databaseNames) &&
1093 odr_oid(o, &(*p)->attributeSet, 1) &&
1094 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
1095 ((*p)->termListAndStartPoint ? 1 :
1096 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
1097 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
1098 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
1099 ODR_CONTEXT, 6, 0) &&
1100 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
1101 ODR_CONTEXT, 7, 1) &&
1102 odr_sequence_end(o);
1105 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
1107 if (!odr_sequence_begin(o, p, sizeof(**p)))
1108 return opt && odr_ok(o);
1110 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1111 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
1112 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
1113 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
1114 ODR_CONTEXT, 5, 0) &&
1115 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
1116 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
1117 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
1118 odr_sequence_end(o);
1121 /* ------------------------ SEARCHRESPONSE ----------------*/
1123 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
1125 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
1128 int z_NextResultSetPosition(ODR o, int **p, int opt)
1130 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
1133 int z_PresentStatus(ODR o, int **p, int opt)
1135 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
1138 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
1140 Z_SearchResponse *pp;
1142 if (!odr_sequence_begin(o, p, sizeof(**p)))
1143 return opt && odr_ok(o);
1146 z_ReferenceId(o, &pp->referenceId, 1) &&
1147 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
1148 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1149 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1150 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
1151 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26,
1153 z_PresentStatus(o, &pp->presentStatus, 1) &&
1154 z_Records(o, &pp->records, 1) &&
1156 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
1157 ODR_CONTEXT, 203, 1) &&
1158 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1160 odr_sequence_end(o);
1163 /* --------------------- PRESENT SERVICE ---------------------- */
1165 int z_ElementSpec(ODR o, Z_ElementSpec **p, int opt)
1167 static Odr_arm arm[] =
1169 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSpec_elementSetName,
1171 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ElementSpec_externalSpec,
1176 if (o->direction == ODR_DECODE)
1177 *p = odr_malloc(o, sizeof(**p));
1181 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1184 return opt && odr_ok(o);
1187 int z_Specification(ODR o, Z_Specification **p, int opt)
1189 if (!odr_sequence_begin(o, p, sizeof(**p)))
1190 return opt && odr_ok(o);
1192 odr_implicit(o, odr_oid, &(*p)->schema, ODR_CONTEXT, 1, 1) &&
1193 z_ElementSpec(o, &(*p)->elementSpec, 1) &&
1194 odr_sequence_end(o);
1197 int z_DbSpecific(ODR o, Z_DbSpecific **p, int opt)
1199 if (!odr_sequence_begin(o, p, sizeof(**p)))
1200 return opt && odr_ok(o);
1202 odr_explicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
1204 odr_implicit(o, z_Specification, &(*p)->spec, ODR_CONTEXT, 2, 0) &&
1205 odr_sequence_end(o);
1208 int z_CompSpec(ODR o, Z_CompSpec **p, int opt)
1210 if (!odr_sequence_begin(o, p, sizeof(**p)))
1211 return opt && odr_ok(o);
1213 odr_implicit(o, odr_bool, &(*p)->selectAlternativeSyntax, ODR_CONTEXT,
1215 odr_implicit(o, z_Specification, &(*p)->generic, ODR_CONTEXT, 2, 1) &&
1216 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1217 (odr_sequence_of(o, z_DbSpecific, &(*p)->dbSpecific,
1218 &(*p)->num_dbSpecific) || odr_ok(o)) &&
1219 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1220 (odr_sequence_of(o, odr_oid, &(*p)->recordSyntax,
1221 &(*p)->num_recordSyntax) || odr_ok(o)) &&
1222 odr_sequence_end(o);
1225 int z_RecordComposition(ODR o, Z_RecordComposition **p, int opt)
1227 static Odr_arm arm[] =
1229 {ODR_EXPLICIT, ODR_CONTEXT, 19, Z_RecordComp_simple,
1231 {ODR_IMPLICIT, ODR_CONTEXT, 209, Z_RecordComp_complex,
1236 if (o->direction == ODR_DECODE)
1237 *p = odr_malloc(o, sizeof(**p));
1241 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1244 return opt && odr_ok(o);
1247 int z_Range(ODR o, Z_Range **p, int opt)
1249 if (!odr_sequence_begin(o, p, sizeof(**p)))
1250 return opt && odr_ok(o);
1252 odr_implicit(o, odr_integer, &(*p)->startingPosition, ODR_CONTEXT,
1254 odr_implicit(o, odr_integer, &(*p)->numberOfRecords, ODR_CONTEXT,
1256 odr_sequence_end(o);
1259 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
1261 Z_PresentRequest *pp;
1263 if (!odr_sequence_begin(o, p, sizeof(**p)))
1264 return opt && odr_ok(o);
1267 z_ReferenceId(o, &pp->referenceId, 1) &&
1268 z_ResultSetId(o, &pp->resultSetId, 0) &&
1269 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
1271 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
1274 odr_implicit_settag(o, ODR_CONTEXT, 212) &&
1275 (odr_sequence_of(o, z_Range, &(*p)->additionalRanges,
1276 &(*p)->num_ranges) || odr_ok(o)) &&
1277 z_RecordComposition(o, &(*p)->recordComposition, 1) &&
1279 odr_explicit(o, z_ElementSetNames, &pp->elementSetNames, ODR_CONTEXT,
1282 odr_implicit(o, odr_oid, &(*p)->preferredRecordSyntax, ODR_CONTEXT,
1285 odr_implicit(o, odr_integer, &(*p)->maxSegmentCount, ODR_CONTEXT,
1287 odr_implicit(o, odr_integer, &(*p)->maxRecordSize, ODR_CONTEXT,
1289 odr_implicit(o, odr_integer, &(*p)->maxSegmentSize, ODR_CONTEXT,
1291 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1293 odr_sequence_end(o);
1296 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
1298 Z_PresentResponse *pp;
1300 if (!odr_sequence_begin(o, p, sizeof(**p)))
1301 return opt && odr_ok(o);
1304 z_ReferenceId(o, &pp->referenceId, 1) &&
1305 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1306 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1307 z_PresentStatus(o, &pp->presentStatus, 0) &&
1308 z_Records(o, &pp->records, 1) &&
1310 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1312 odr_sequence_end(o);
1315 /* ----------------------DELETE -------------------------- */
1317 int z_DeleteSetStatus(ODR o, int **p, int opt)
1319 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
1322 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
1324 if (!odr_sequence_begin(o, p, sizeof(**p)))
1325 return opt && odr_ok(o);
1327 z_ResultSetId(o, &(*p)->id, 0) &&
1328 z_DeleteSetStatus(o, &(*p)->status, 0) &&
1329 odr_sequence_end(o);
1332 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
1334 if (!odr_sequence_begin(o, p, sizeof(**p)))
1335 return opt && odr_ok(o);
1337 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1338 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
1340 (odr_sequence_of(o, z_ListStatus, &(*p)->resultSetList,
1341 &(*p)->num_ids) || odr_ok(o)) &&
1343 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1345 odr_sequence_end(o);
1348 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
1350 if (!odr_sequence_begin(o, p, sizeof(**p)))
1351 return opt && odr_ok(o);
1353 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1354 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
1355 ODR_CONTEXT, 0, 1) &&
1356 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
1357 (odr_sequence_of(o, z_ListStatus, &(*p)->deleteListStatuses,
1358 &(*p)->num_statuses) || odr_ok(o)) &&
1359 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
1361 odr_implicit_settag(o, ODR_CONTEXT, 35) &&
1362 (odr_sequence_of(o, z_ListStatus, &(*p)->bulkStatuses,
1363 &(*p)->num_bulkStatuses) || odr_ok(o)) &&
1364 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
1367 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1369 odr_sequence_end(o);
1372 /* ------------------------ SEGMENT SERVICE -------------- */
1374 int z_Segment(ODR o, Z_Segment **p, int opt)
1376 if (!odr_sequence_begin(o, p, sizeof(**p)))
1377 return opt && odr_ok(o);
1379 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1380 odr_implicit(o, odr_integer, &(*p)->numberOfRecordsReturned,
1381 ODR_CONTEXT, 24, 0) &&
1382 odr_implicit_settag(o, ODR_CONTEXT, 0) &&
1383 odr_sequence_of(o, z_NamePlusRecord, &(*p)->segmentRecords,
1384 &(*p)->num_segmentRecords) &&
1385 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1386 odr_sequence_end(o);
1389 /* ------------------------ CLOSE SERVICE ---------------- */
1391 int z_Close(ODR o, Z_Close **p, int opt)
1393 if (!odr_sequence_begin(o, p, sizeof(**p)))
1394 return opt && odr_ok(o);
1396 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1397 odr_implicit(o, odr_integer, &(*p)->closeReason, ODR_CONTEXT, 211, 0) &&
1398 odr_implicit(o, odr_visiblestring, &(*p)->diagnosticInformation,
1399 ODR_CONTEXT, 3, 1) &&
1400 odr_implicit(o, odr_oid, &(*p)->resourceReportFormat, ODR_CONTEXT,
1402 odr_implicit(o, odr_external, &(*p)->resourceReport, ODR_CONTEXT,
1405 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1407 odr_sequence_end(o);
1410 /* ------------------------ APDU ------------------------- */
1412 int z_APDU(ODR o, Z_APDU **p, int opt)
1414 static Odr_arm arm[] =
1416 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
1417 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
1418 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
1419 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
1421 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
1423 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
1425 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
1426 z_DeleteResultSetRequest},
1427 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
1428 z_DeleteResultSetResponse},
1429 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
1430 z_ResourceControlRequest},
1431 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
1432 z_ResourceControlResponse},
1433 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
1434 z_TriggerResourceControlRequest},
1435 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
1436 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
1437 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_APDU_segmentRequest, z_Segment},
1438 {ODR_IMPLICIT, ODR_CONTEXT, 48, Z_APDU_close, z_Close},
1443 if (o->direction == ODR_DECODE)
1444 *p = odr_malloc(o, sizeof(**p));
1445 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
1447 if (o->direction == ODR_DECODE)
1449 return opt && odr_ok(o);