2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.35 1995-08-10 08:53:59 quinn
10 * Revision 1.34 1995/06/19 17:01:48 quinn
11 * This should bring us in sync with the version distributed as 1.0b
13 * Revision 1.33 1995/06/19 13:39:56 quinn
14 * *** empty log message ***
16 * Revision 1.32 1995/06/19 12:37:28 quinn
17 * Fixed a bug in the compspec.
19 * Revision 1.31 1995/06/16 13:15:56 quinn
20 * Fixed Defaultdiagformat.
22 * Revision 1.30 1995/06/15 15:42:01 quinn
25 * Revision 1.29 1995/06/15 07:44:49 quinn
28 * Revision 1.28 1995/06/14 15:26:35 quinn
29 * *** empty log message ***
31 * Revision 1.27 1995/06/07 14:36:22 quinn
34 * Revision 1.26 1995/06/02 09:49:13 quinn
35 * Adding access control
37 * Revision 1.25 1995/05/25 11:00:08 quinn
38 * *** empty log message ***
40 * Revision 1.24 1995/05/22 13:58:18 quinn
41 * Fixed an ODR_NULLVAL.
43 * Revision 1.23 1995/05/22 11:30:18 quinn
44 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
46 * Revision 1.22 1995/05/17 08:40:56 quinn
47 * Added delete. Fixed some sequence_begins. Smallish.
49 * Revision 1.21 1995/05/16 08:50:24 quinn
50 * License, documentation, and memory fixes
52 * Revision 1.20 1995/05/15 11:55:25 quinn
55 * Revision 1.19 1995/04/11 11:58:35 quinn
58 * Revision 1.18 1995/04/11 11:52:02 quinn
59 * Fixed possible buf in proto.c
61 * Revision 1.17 1995/04/10 10:22:22 quinn
64 * Revision 1.16 1995/03/30 10:26:43 quinn
65 * Added Term structure
67 * Revision 1.15 1995/03/30 09:08:39 quinn
68 * Added Resource control protocol
70 * Revision 1.14 1995/03/29 08:06:13 quinn
71 * Added a few v3 elements
73 * Revision 1.13 1995/03/20 11:26:52 quinn
74 * *** empty log message ***
76 * Revision 1.12 1995/03/20 09:45:09 quinn
79 * Revision 1.11 1995/03/17 10:17:25 quinn
80 * Added memory management.
82 * Revision 1.10 1995/03/15 11:17:40 quinn
83 * Fixed some return-checks from choice.. need better ay to handle those..
85 * Revision 1.9 1995/03/15 08:37:06 quinn
86 * Fixed protocol bugs.
88 * Revision 1.8 1995/03/14 16:59:24 quinn
89 * Fixed OPTIONAL flag in attributeelement
91 * Revision 1.7 1995/03/07 16:29:33 quinn
92 * Added authentication stuff.
94 * Revision 1.6 1995/03/01 14:46:03 quinn
95 * Fixed protocol bug in 8777query.
97 * Revision 1.5 1995/02/14 11:54:22 quinn
100 * Revision 1.4 1995/02/10 15:54:30 quinn
103 * Revision 1.3 1995/02/09 15:51:39 quinn
106 * Revision 1.2 1995/02/06 21:26:07 quinn
107 * Repaired this evening's damages..
109 * Revision 1.1 1995/02/06 16:44:47 quinn
110 * First hack at Z/SR protocol
118 /* ---------------------- GLOBAL DEFS ------------------- */
121 * We'll use a general octetstring here, since string operations are
122 * clumsy on long strings.
124 int z_SUTRS(ODR o, Odr_oct **p, int opt)
126 return odr_implicit(o, odr_octetstring, p, ODR_UNIVERSAL,
127 ODR_GENERALSTRING, opt);
130 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
132 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
135 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
137 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
141 int z_ResultSetId(ODR o, char **p, int opt)
143 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
147 int z_ElementSetName(ODR o, char **p, int opt)
149 return odr_implicit(o, odr_visiblestring, p, ODR_CONTEXT, 103, opt);
152 int z_UserInformationField(ODR o, Odr_external **p, int opt)
154 return odr_explicit(o, odr_external, (Odr_external **)p, ODR_CONTEXT,
158 int z_InternationalString(ODR o, char **p, int opt)
160 return odr_generalstring(o, p, opt);
163 int z_InfoCategory(ODR o, Z_InfoCategory **p, int opt)
165 if (!odr_sequence_begin(o, p, sizeof(**p)))
166 return opt && odr_ok(o);
168 odr_implicit(o, odr_oid, &(*p)->categoryTypeId, ODR_CONTEXT, 1, 1) &&
169 odr_implicit(o, odr_integer, &(*p)->categoryValue, ODR_CONTEXT, 2, 0) &&
173 int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt)
175 static Odr_arm arm[] =
177 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_OtherInfo_characterInfo,
179 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_OtherInfo_binaryInfo,
181 {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_OtherInfo_externallyDefinedInfo,
183 {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_OtherInfo_oid, odr_oid},
187 if (!odr_sequence_begin(o, p, sizeof(**p)))
188 return opt && odr_ok(o);
190 odr_implicit(o, z_InfoCategory, &(*p)->category, ODR_CONTEXT, 1, 1) &&
191 odr_choice(o, arm, &(*p)->which, &(*p)->information) &&
195 int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt)
197 if (o->direction == ODR_DECODE)
198 *p = odr_malloc(o, sizeof(**p));
201 odr_implicit_settag(o, ODR_CONTEXT, 201);
202 if (odr_sequence_of(o, z_OtherInformationUnit, &(*p)->list,
203 &(*p)->num_elements))
206 return opt && odr_ok(o);
209 int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt)
211 static Odr_arm arm[] =
213 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_StringOrNumeric_string,
215 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_StringOrNumeric_numeric,
220 if (o->direction == ODR_DECODE)
221 *p = odr_malloc(o, sizeof(**p));
224 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
227 return opt && odr_ok(o);
233 int z_Unit(ODR o, Z_Unit **p, int opt)
235 if (!odr_sequence_begin(o, p, sizeof(**p)))
236 return opt && odr_ok(o);
238 odr_implicit(o, odr_visiblestring, &(*p)->unitSystem, ODR_CONTEXT,
240 odr_explicit(o, z_StringOrNumeric, &(*p)->unitType, ODR_CONTEXT,
242 odr_explicit(o, z_StringOrNumeric, &(*p)->unit, ODR_CONTEXT, 3, 1) &&
243 odr_implicit(o, odr_integer, &(*p)->scaleFactor, ODR_CONTEXT, 4, 1) &&
247 int z_IntUnit(ODR o, Z_IntUnit **p, int opt)
249 if (!odr_sequence_begin(o, p, sizeof(**p)))
250 return opt && odr_ok(o);
252 odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 1, 0) &&
253 odr_implicit(o, z_Unit, &(*p)->unitUsed, ODR_CONTEXT, 2, 0) &&
257 /* ---------------------- INITIALIZE SERVICE ------------------- */
260 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
262 if (!odr_sequence_begin(o, p, sizeof(**p)))
263 return opt && odr_ok(o);
265 odr_visiblestring(o, &(*p)->user, 0) &&
266 odr_visiblestring(o, &(*p)->password, 0) &&
267 odr_visiblestring(o, &(*p)->account, 0) &&
272 int z_IdPass(ODR o, Z_IdPass **p, int opt)
274 if (!odr_sequence_begin(o, p, sizeof(**p)))
275 return opt && odr_ok(o);
277 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 1) &&
278 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 1) &&
279 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
284 int z_StrAuthentication(ODR o, char **p, int opt)
286 return odr_visiblestring(o, p, opt);
289 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
291 static Odr_arm arm[] =
293 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
294 {-1, -1, -1, Z_IdAuthentication_idPass, z_IdPass},
295 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
296 {-1, -1, -1, Z_IdAuthentication_other, odr_external},
300 if (o->direction == ODR_DECODE)
301 *p = odr_malloc(o, sizeof(**p));
305 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
308 return opt && odr_ok(o);
311 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
315 if (!odr_sequence_begin(o, p, sizeof(**p)))
316 return opt && odr_ok(o);
319 z_ReferenceId(o, &pp->referenceId, 1) &&
320 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
322 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
323 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
325 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
327 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
329 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
331 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
333 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
334 ODR_CONTEXT, 112, 1) &&
335 z_UserInformationField(o, &pp->userInformationField, 1) &&
337 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
342 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
346 if (!odr_sequence_begin(o, p, sizeof(**p)))
347 return opt && odr_ok(o);
350 z_ReferenceId(o, &pp->referenceId, 1) &&
351 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
353 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
354 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
356 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
358 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
359 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
361 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
363 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
364 ODR_CONTEXT, 112, 1) &&
365 z_UserInformationField(o, &pp->userInformationField, 1) &&
367 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
372 /* ------------------ RESOURCE CONTROL ----------------*/
374 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
377 if (!odr_sequence_begin(o, p, sizeof(**p)))
378 return opt && odr_ok(o);
380 z_ReferenceId(o, &(*p)->referenceId, 1) &&
381 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
383 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
384 ODR_CONTEXT, 47, 1) &&
385 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
388 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
393 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
395 if (!odr_sequence_begin(o, p, sizeof(**p)))
396 return opt && odr_ok(o);
398 z_ReferenceId(o, &(*p)->referenceId, 1) &&
399 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
400 odr_explicit(o, odr_external, &(*p)->resourceReport, ODR_CONTEXT,
402 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
403 ODR_CONTEXT, 41, 1) &&
404 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
406 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
407 ODR_CONTEXT, 43, 1) &&
409 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
414 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
416 if (!odr_sequence_begin(o, p, sizeof(**p)))
417 return opt && odr_ok(o);
419 z_ReferenceId(o, &(*p)->referenceId, 1) &&
420 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
421 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
424 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
429 /* ------------------------ SEARCH SERVICE ----------------------- */
431 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
433 if (!odr_sequence_begin(o, p, sizeof(**p)))
434 return opt && odr_ok(o);
436 z_DatabaseName(o, &(*p)->databaseName, 0) &&
437 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
441 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
443 if (o->direction == ODR_DECODE)
444 *p = odr_malloc(o, sizeof(**p));
448 odr_implicit_settag(o, ODR_CONTEXT, 1);
449 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
450 &(*p)->num_elements))
456 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
458 static Odr_arm arm[] =
460 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
462 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
467 if (o->direction == ODR_DECODE)
468 *p = odr_malloc(o, sizeof(**p));
470 return opt && odr_ok(o);
472 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
478 /* ----------------------- RPN QUERY -----------------------*/
480 int z_ComplexAttribute(ODR o, Z_ComplexAttribute **p, int opt)
482 if (!odr_sequence_begin(o, p, sizeof(**p)))
483 return opt && odr_ok(o);
485 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
486 odr_sequence_of(o, z_StringOrNumeric, &(*p)->list,
488 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
489 (odr_sequence_of(o, odr_integer, &(*p)->semanticAction,
490 &(*p)->num_semanticAction) || odr_ok(o)) &&
494 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
497 static Odr_arm arm[] =
499 {ODR_IMPLICIT, ODR_CONTEXT, 121, Z_AttributeValue_numeric,
501 {ODR_IMPLICIT, ODR_CONTEXT, 224, Z_AttributeValue_complex,
507 if (!odr_sequence_begin(o, p, sizeof(**p)))
508 return opt && odr_ok(o);
511 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 1, 1) &&
513 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
516 odr_choice(o, arm, &(*p)->value, &(*p)->which) &&
518 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
524 int z_Term(ODR o, Z_Term **p, int opt)
526 static Odr_arm arm[] =
528 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
529 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
530 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
532 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
533 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
534 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, odr_external},
535 /* add intUnit here */
536 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
540 if (o->direction ==ODR_DECODE)
541 *p = odr_malloc(o, sizeof(**p));
544 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
547 return opt && odr_ok(o);
550 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
552 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
553 odr_sequence_begin(o, p, sizeof(**p))))
554 return opt && odr_ok(o);
556 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
557 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
558 &(*p)->num_attributes) &&
559 z_Term(o, &(*p)->term, 0) &&
563 int z_ResultSetPlusAttributes(ODR o, Z_ResultSetPlusAttributes **p, int opt)
565 if (!(odr_implicit_settag(o, ODR_CONTEXT, 214) &&
566 odr_sequence_begin(o, p, sizeof(**p))))
567 return opt && odr_ok(o);
569 z_ResultSetId(o, &(*p)->resultSet, 0) &&
570 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
571 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
572 &(*p)->num_attributes) &&
576 int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
578 static Odr_arm arm[] =
580 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, odr_integer},
581 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_private, odr_integer},
585 if (!odr_sequence_begin(o, p, sizeof(**p)))
586 return opt && odr_ok(o);
588 odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
589 odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
590 odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
591 odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
592 odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
593 odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
594 odr_constructed_end(o) &&
598 int z_Operator(ODR o, Z_Operator **p, int opt)
600 static Odr_arm arm[] =
602 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
603 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
604 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
605 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, z_ProximityOperator},
609 if (!*p && o->direction != ODR_DECODE)
611 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
612 return opt && odr_ok(o);
613 if (o->direction == ODR_DECODE)
614 *p = odr_malloc(o, sizeof(**p));
616 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
617 odr_constructed_end(o))
620 return opt && odr_ok(o);
623 int z_Operand(ODR o, Z_Operand **p, int opt)
625 static Odr_arm arm[] =
627 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
628 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
629 {-1, -1, -1, Z_Operand_resultAttr, z_ResultSetPlusAttributes},
633 if (o->direction == ODR_DECODE)
634 *p = odr_malloc(o, sizeof(**p));
637 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
640 return opt && odr_ok(o);
643 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
645 int z_Complex(ODR o, Z_Complex **p, int opt)
647 if (!odr_sequence_begin(o, p, sizeof(**p)))
648 return opt && odr_ok(o);
650 z_RPNStructure(o, &(*p)->s1, 0) &&
651 z_RPNStructure(o, &(*p)->s2, 0) &&
652 z_Operator(o, &(*p)->operator, 0) &&
656 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
658 static Odr_arm arm[] =
660 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
661 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
665 if (o->direction == ODR_DECODE)
666 *p = odr_malloc(o, sizeof(**p));
669 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
672 return opt && odr_ok(o);
675 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
677 if (!odr_sequence_begin(o, p, sizeof(**p)))
678 return opt && odr_ok(o);
680 odr_oid(o, &(*p)->attributeSetId, 0) &&
681 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
685 /* -----------------------END RPN QUERY ----------------------- */
687 int z_Query(ODR o, Z_Query **p, int opt)
689 static Odr_arm arm[] =
691 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
692 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
693 {ODR_EXPLICIT, ODR_CONTEXT, 101, Z_Query_type_101, z_RPNQuery},
697 if (o->direction == ODR_DECODE)
698 *p = odr_malloc(o, sizeof(**p));
701 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
704 return opt && odr_ok(o);
707 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
711 if (!odr_sequence_begin(o, p, sizeof(**p)))
712 return opt && odr_ok(o);
715 z_ReferenceId(o, &pp->referenceId, 1) &&
716 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
718 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
720 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
722 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
723 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
725 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
726 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
727 &pp->num_databaseNames) &&
728 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
729 ODR_CONTEXT, 100, 1) &&
730 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
731 ODR_CONTEXT, 101, 1) &&
732 odr_implicit(o, odr_oid, &pp->preferredRecordSyntax,
733 ODR_CONTEXT, 104, 1) &&
734 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
736 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
737 ODR_CONTEXT, 203, 1) &&
738 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
743 /* ------------------------ RECORD ------------------------- */
745 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
747 return odr_external(o, (Odr_external **) p, opt);
752 int z_DefaultDiagFormat(ODR o, Z_DefaultDiagFormat **p, int opt)
754 static Odr_arm arm[] =
756 {-1, -1, -1, Z_DiagForm_v2AddInfo, odr_visiblestring},
757 {-1, -1, -1, Z_DiagForm_v3AddInfo, z_InternationalString},
758 {ODR_IMPLICIT, ODR_CONTEXT, ODR_VISIBLESTRING, Z_DiagForm_v2AddInfo,
759 odr_visiblestring}, /* To cater to a bug in the CNIDR servers */
762 if (!odr_sequence_begin(o, p, sizeof(**p)))
763 return opt && odr_ok(o);
765 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
766 odr_integer(o, &(*p)->condition, 0) &&
768 * I no longer recall what server tagged the addinfo.. but it isn't
769 * hurting anyone, so...
770 * We need to turn it into a choice, or something, because of
771 * that damn generalstring in v3.
773 odr_choice(o, arm, &(*p)->addinfo, &(*p)->which) &&
777 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
779 static Odr_arm arm[] =
781 {-1, -1, -1, Z_DiagRec_defaultFormat, z_DefaultDiagFormat},
782 {-1, -1, -1, Z_DiagRec_externallyDefined, odr_external},
786 if (o->direction == ODR_DECODE)
787 *p = odr_malloc(o, sizeof(**p));
790 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
793 return opt && odr_ok(o);
798 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
800 if (!odr_sequence_begin(o, p, sizeof(**p)))
801 return opt && odr_ok(o);
803 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
804 odr_integer(o, &(*p)->condition, 0) &&
806 * I no longer recall what server tagged the addinfo.. but it isn't
807 * hurting anyone, so...
808 * We need to turn it into a choice, or something, because of
809 * that damn generalstring in v3.
811 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
812 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT,
813 ODR_VISIBLESTRING, 1)) &&
819 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
821 if (o->direction == ODR_DECODE)
822 *p = odr_malloc(o, sizeof(**p));
826 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
827 &(*p)->num_diagRecs))
833 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
835 static Odr_arm arm[] =
837 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
839 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
844 if (!odr_sequence_begin(o, p, sizeof(**p)))
845 return opt && odr_ok(o);
847 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
849 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
850 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
851 odr_constructed_end(o) &&
855 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
857 if (o->direction == ODR_DECODE)
858 *p = odr_malloc(o, sizeof(**p));
861 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
868 int z_Records(ODR o, Z_Records **p, int opt)
870 static Odr_arm arm[] =
872 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
873 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
874 {ODR_IMPLICIT, ODR_CONTEXT, 205, Z_Records_multipleNSD,
879 if (o->direction == ODR_DECODE)
880 *p = odr_malloc(o, sizeof(**p));
883 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
886 return opt && odr_ok(o);
889 /* ------------------------ ACCESS CTRL SERVICE ----------------------- */
891 int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
893 static Odr_arm arm[] =
895 {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
897 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
901 if (!odr_sequence_begin(o, p, sizeof(**p)))
902 return opt && odr_ok(o);
904 z_ReferenceId(o, &(*p)->referenceId, 1) &&
905 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
907 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
912 int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
914 static Odr_arm arm[] =
916 {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
918 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
922 if (!odr_sequence_begin(o, p, sizeof(**p)))
923 return opt && odr_ok(o);
925 z_ReferenceId(o, &(*p)->referenceId, 1) &&
926 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
927 odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
929 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
934 /* ------------------------ SCAN SERVICE -------------------- */
936 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
938 if (o->direction == ODR_DECODE)
939 *p = odr_malloc(o, sizeof(**p));
943 odr_implicit_settag(o, ODR_CONTEXT, 44);
944 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
945 &(*p)->num_attributes))
948 return opt && odr_ok(o);
952 * This is a temporary hack. We don't know just *what* old version of the
953 * protocol willow uses, so we'll just patiently wait for them to update
955 static int willow_scan = 0;
957 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
959 if (!*p && o->direction != ODR_DECODE)
961 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
964 return opt && odr_ok(o);
966 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
968 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
970 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
972 if (o->direction == ODR_DECODE)
973 *p = odr_malloc(o, sizeof(**p));
974 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
975 &(*p)->num_attributes))
977 if (!odr_sequence_end(o) || !odr_sequence_end(o))
979 if (!z_Term(o, &(*p)->term, 0))
981 if (!odr_constructed_end(o))
987 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
989 if (o->direction == ODR_DECODE)
990 *p = odr_malloc(o, sizeof(**p));
994 return opt && odr_ok(o);
997 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
1001 return opt && !o->error;
1004 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1006 if (!odr_sequence_begin(o, p, sizeof(**p)))
1007 return opt && odr_ok(o);
1009 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
1010 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
1011 odr_sequence_end(o);
1014 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
1016 if (!odr_sequence_begin(o, p, sizeof(**p)))
1017 return opt && odr_ok(o);
1020 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
1021 z_Term(o, &(*p)->term, 0)) &&
1022 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
1023 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
1024 ODR_CONTEXT, 4, 1) &&
1025 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
1027 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
1028 ODR_CONTEXT, 3, 1) &&
1029 odr_sequence_end(o);
1032 int z_Entry(ODR o, Z_Entry **p, int opt)
1034 static Odr_arm arm[] =
1036 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
1037 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
1042 if (o->direction == ODR_DECODE)
1043 *p = odr_malloc(o, sizeof(**p));
1047 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1050 return opt && odr_ok(o);
1053 int z_Entries(ODR o, Z_Entries **p, int opt)
1055 if (o->direction == ODR_DECODE)
1056 *p = odr_malloc(o, sizeof(**p));
1060 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
1061 &(*p)->num_entries))
1067 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
1069 static Odr_arm arm[] =
1071 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
1072 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
1077 if (o->direction == ODR_DECODE)
1078 *p = odr_malloc(o, sizeof(**p));
1082 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1085 return opt && odr_ok(o);
1088 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
1090 if (!odr_sequence_begin(o, p, sizeof(**p)))
1091 return opt && odr_ok(o);
1094 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1095 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1096 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
1097 &(*p)->num_databaseNames) &&
1098 odr_oid(o, &(*p)->attributeSet, 1) &&
1099 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
1100 ((*p)->termListAndStartPoint ? 1 :
1101 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
1102 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
1103 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
1104 ODR_CONTEXT, 6, 0) &&
1105 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
1106 ODR_CONTEXT, 7, 1) &&
1107 odr_sequence_end(o);
1110 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
1112 if (!odr_sequence_begin(o, p, sizeof(**p)))
1113 return opt && odr_ok(o);
1115 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1116 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
1117 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
1118 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
1119 ODR_CONTEXT, 5, 0) &&
1120 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
1121 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
1122 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
1123 odr_sequence_end(o);
1126 /* ------------------------ SEARCHRESPONSE ----------------*/
1128 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
1130 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
1133 int z_NextResultSetPosition(ODR o, int **p, int opt)
1135 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
1138 int z_PresentStatus(ODR o, int **p, int opt)
1140 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
1143 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
1145 Z_SearchResponse *pp;
1147 if (!odr_sequence_begin(o, p, sizeof(**p)))
1148 return opt && odr_ok(o);
1151 z_ReferenceId(o, &pp->referenceId, 1) &&
1152 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
1153 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1154 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1155 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
1156 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26,
1158 z_PresentStatus(o, &pp->presentStatus, 1) &&
1159 z_Records(o, &pp->records, 1) &&
1161 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
1162 ODR_CONTEXT, 203, 1) &&
1163 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1165 odr_sequence_end(o);
1168 /* --------------------- PRESENT SERVICE ---------------------- */
1170 int z_ElementSpec(ODR o, Z_ElementSpec **p, int opt)
1172 static Odr_arm arm[] =
1174 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSpec_elementSetName,
1176 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ElementSpec_externalSpec,
1181 if (o->direction == ODR_DECODE)
1182 *p = odr_malloc(o, sizeof(**p));
1186 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1189 return opt && odr_ok(o);
1192 int z_Specification(ODR o, Z_Specification **p, int opt)
1194 if (!odr_sequence_begin(o, p, sizeof(**p)))
1195 return opt && odr_ok(o);
1197 odr_implicit(o, odr_oid, &(*p)->schema, ODR_CONTEXT, 1, 1) &&
1198 z_ElementSpec(o, &(*p)->elementSpec, 1) &&
1199 odr_sequence_end(o);
1202 int z_DbSpecific(ODR o, Z_DbSpecific **p, int opt)
1204 if (!odr_sequence_begin(o, p, sizeof(**p)))
1205 return opt && odr_ok(o);
1207 odr_explicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
1209 odr_implicit(o, z_Specification, &(*p)->spec, ODR_CONTEXT, 2, 0) &&
1210 odr_sequence_end(o);
1213 int z_CompSpec(ODR o, Z_CompSpec **p, int opt)
1215 if (!odr_sequence_begin(o, p, sizeof(**p)))
1216 return opt && odr_ok(o);
1218 odr_implicit(o, odr_bool, &(*p)->selectAlternativeSyntax, ODR_CONTEXT,
1220 odr_implicit(o, z_Specification, &(*p)->generic, ODR_CONTEXT, 2, 1) &&
1221 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1222 (odr_sequence_of(o, z_DbSpecific, &(*p)->dbSpecific,
1223 &(*p)->num_dbSpecific) || odr_ok(o)) &&
1224 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1225 (odr_sequence_of(o, odr_oid, &(*p)->recordSyntax,
1226 &(*p)->num_recordSyntax) || odr_ok(o)) &&
1227 odr_sequence_end(o);
1230 int z_RecordComposition(ODR o, Z_RecordComposition **p, int opt)
1232 static Odr_arm arm[] =
1234 {ODR_EXPLICIT, ODR_CONTEXT, 19, Z_RecordComp_simple,
1236 {ODR_IMPLICIT, ODR_CONTEXT, 209, Z_RecordComp_complex,
1241 if (o->direction == ODR_DECODE)
1242 *p = odr_malloc(o, sizeof(**p));
1246 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1249 return opt && odr_ok(o);
1252 int z_Range(ODR o, Z_Range **p, int opt)
1254 if (!odr_sequence_begin(o, p, sizeof(**p)))
1255 return opt && odr_ok(o);
1257 odr_implicit(o, odr_integer, &(*p)->startingPosition, ODR_CONTEXT,
1259 odr_implicit(o, odr_integer, &(*p)->numberOfRecords, ODR_CONTEXT,
1261 odr_sequence_end(o);
1264 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
1266 Z_PresentRequest *pp;
1268 if (!odr_sequence_begin(o, p, sizeof(**p)))
1269 return opt && odr_ok(o);
1272 z_ReferenceId(o, &pp->referenceId, 1) &&
1273 z_ResultSetId(o, &pp->resultSetId, 0) &&
1274 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
1276 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
1279 odr_implicit_settag(o, ODR_CONTEXT, 212) &&
1280 (odr_sequence_of(o, z_Range, &(*p)->additionalRanges,
1281 &(*p)->num_ranges) || odr_ok(o)) &&
1282 z_RecordComposition(o, &(*p)->recordComposition, 1) &&
1284 odr_explicit(o, z_ElementSetNames, &pp->elementSetNames, ODR_CONTEXT,
1287 odr_implicit(o, odr_oid, &(*p)->preferredRecordSyntax, ODR_CONTEXT,
1290 odr_implicit(o, odr_integer, &(*p)->maxSegmentCount, ODR_CONTEXT,
1292 odr_implicit(o, odr_integer, &(*p)->maxRecordSize, ODR_CONTEXT,
1294 odr_implicit(o, odr_integer, &(*p)->maxSegmentSize, ODR_CONTEXT,
1296 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1298 odr_sequence_end(o);
1301 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
1303 Z_PresentResponse *pp;
1305 if (!odr_sequence_begin(o, p, sizeof(**p)))
1306 return opt && odr_ok(o);
1309 z_ReferenceId(o, &pp->referenceId, 1) &&
1310 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1311 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1312 z_PresentStatus(o, &pp->presentStatus, 0) &&
1313 z_Records(o, &pp->records, 1) &&
1315 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1317 odr_sequence_end(o);
1320 /* ----------------------DELETE -------------------------- */
1322 int z_DeleteSetStatus(ODR o, int **p, int opt)
1324 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
1327 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
1329 if (!odr_sequence_begin(o, p, sizeof(**p)))
1330 return opt && odr_ok(o);
1332 z_ResultSetId(o, &(*p)->id, 0) &&
1333 z_DeleteSetStatus(o, &(*p)->status, 0) &&
1334 odr_sequence_end(o);
1337 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
1339 if (!odr_sequence_begin(o, p, sizeof(**p)))
1340 return opt && odr_ok(o);
1342 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1343 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
1345 (odr_sequence_of(o, z_ListStatus, &(*p)->resultSetList,
1346 &(*p)->num_ids) || odr_ok(o)) &&
1348 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1350 odr_sequence_end(o);
1353 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
1355 if (!odr_sequence_begin(o, p, sizeof(**p)))
1356 return opt && odr_ok(o);
1358 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1359 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
1360 ODR_CONTEXT, 0, 1) &&
1361 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
1362 (odr_sequence_of(o, z_ListStatus, &(*p)->deleteListStatuses,
1363 &(*p)->num_statuses) || odr_ok(o)) &&
1364 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
1366 odr_implicit_settag(o, ODR_CONTEXT, 35) &&
1367 (odr_sequence_of(o, z_ListStatus, &(*p)->bulkStatuses,
1368 &(*p)->num_bulkStatuses) || odr_ok(o)) &&
1369 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
1372 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1374 odr_sequence_end(o);
1377 /* ------------------------ SEGMENT SERVICE -------------- */
1379 int z_Segment(ODR o, Z_Segment **p, int opt)
1381 if (!odr_sequence_begin(o, p, sizeof(**p)))
1382 return opt && odr_ok(o);
1384 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1385 odr_implicit(o, odr_integer, &(*p)->numberOfRecordsReturned,
1386 ODR_CONTEXT, 24, 0) &&
1387 odr_implicit_settag(o, ODR_CONTEXT, 0) &&
1388 odr_sequence_of(o, z_NamePlusRecord, &(*p)->segmentRecords,
1389 &(*p)->num_segmentRecords) &&
1390 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1391 odr_sequence_end(o);
1394 /* ------------------------ CLOSE SERVICE ---------------- */
1396 int z_Close(ODR o, Z_Close **p, int opt)
1398 if (!odr_sequence_begin(o, p, sizeof(**p)))
1399 return opt && odr_ok(o);
1401 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1402 odr_implicit(o, odr_integer, &(*p)->closeReason, ODR_CONTEXT, 211, 0) &&
1403 odr_implicit(o, odr_visiblestring, &(*p)->diagnosticInformation,
1404 ODR_CONTEXT, 3, 1) &&
1405 odr_implicit(o, odr_oid, &(*p)->resourceReportFormat, ODR_CONTEXT,
1407 odr_implicit(o, odr_external, &(*p)->resourceReport, ODR_CONTEXT,
1410 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1412 odr_sequence_end(o);
1415 /* ------------------------ APDU ------------------------- */
1417 int z_APDU(ODR o, Z_APDU **p, int opt)
1419 static Odr_arm arm[] =
1421 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
1422 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
1423 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
1424 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
1426 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
1428 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
1430 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
1431 z_DeleteResultSetRequest},
1432 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
1433 z_DeleteResultSetResponse},
1434 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
1435 z_ResourceControlRequest},
1436 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
1437 z_ResourceControlResponse},
1438 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
1439 z_TriggerResourceControlRequest},
1440 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
1441 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
1442 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_APDU_segmentRequest, z_Segment},
1443 {ODR_IMPLICIT, ODR_CONTEXT, 48, Z_APDU_close, z_Close},
1448 if (o->direction == ODR_DECODE)
1449 *p = odr_malloc(o, sizeof(**p));
1450 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
1452 if (o->direction == ODR_DECODE)
1454 return opt && odr_ok(o);