2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.39 1995-09-29 17:11:53 quinn
10 * Revision 1.38 1995/09/27 15:02:40 quinn
11 * Modified function heads & prototypes.
13 * Revision 1.37 1995/08/21 09:10:15 quinn
14 * Smallish fixes to suppport new formats.
16 * Revision 1.36 1995/08/15 11:59:39 quinn
19 * Revision 1.35 1995/08/10 08:53:59 quinn
22 * Revision 1.34 1995/06/19 17:01:48 quinn
23 * This should bring us in sync with the version distributed as 1.0b
25 * Revision 1.33 1995/06/19 13:39:56 quinn
26 * *** empty log message ***
28 * Revision 1.32 1995/06/19 12:37:28 quinn
29 * Fixed a bug in the compspec.
31 * Revision 1.31 1995/06/16 13:15:56 quinn
32 * Fixed Defaultdiagformat.
34 * Revision 1.30 1995/06/15 15:42:01 quinn
37 * Revision 1.29 1995/06/15 07:44:49 quinn
40 * Revision 1.28 1995/06/14 15:26:35 quinn
41 * *** empty log message ***
43 * Revision 1.27 1995/06/07 14:36:22 quinn
46 * Revision 1.26 1995/06/02 09:49:13 quinn
47 * Adding access control
49 * Revision 1.25 1995/05/25 11:00:08 quinn
50 * *** empty log message ***
52 * Revision 1.24 1995/05/22 13:58:18 quinn
53 * Fixed an ODR_NULLVAL.
55 * Revision 1.23 1995/05/22 11:30:18 quinn
56 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
58 * Revision 1.22 1995/05/17 08:40:56 quinn
59 * Added delete. Fixed some sequence_begins. Smallish.
61 * Revision 1.21 1995/05/16 08:50:24 quinn
62 * License, documentation, and memory fixes
64 * Revision 1.20 1995/05/15 11:55:25 quinn
67 * Revision 1.19 1995/04/11 11:58:35 quinn
70 * Revision 1.18 1995/04/11 11:52:02 quinn
71 * Fixed possible buf in proto.c
73 * Revision 1.17 1995/04/10 10:22:22 quinn
76 * Revision 1.16 1995/03/30 10:26:43 quinn
77 * Added Term structure
79 * Revision 1.15 1995/03/30 09:08:39 quinn
80 * Added Resource control protocol
82 * Revision 1.14 1995/03/29 08:06:13 quinn
83 * Added a few v3 elements
85 * Revision 1.13 1995/03/20 11:26:52 quinn
86 * *** empty log message ***
88 * Revision 1.12 1995/03/20 09:45:09 quinn
91 * Revision 1.11 1995/03/17 10:17:25 quinn
92 * Added memory management.
94 * Revision 1.10 1995/03/15 11:17:40 quinn
95 * Fixed some return-checks from choice.. need better ay to handle those..
97 * Revision 1.9 1995/03/15 08:37:06 quinn
98 * Fixed protocol bugs.
100 * Revision 1.8 1995/03/14 16:59:24 quinn
101 * Fixed OPTIONAL flag in attributeelement
103 * Revision 1.7 1995/03/07 16:29:33 quinn
104 * Added authentication stuff.
106 * Revision 1.6 1995/03/01 14:46:03 quinn
107 * Fixed protocol bug in 8777query.
109 * Revision 1.5 1995/02/14 11:54:22 quinn
112 * Revision 1.4 1995/02/10 15:54:30 quinn
115 * Revision 1.3 1995/02/09 15:51:39 quinn
118 * Revision 1.2 1995/02/06 21:26:07 quinn
119 * Repaired this evening's damages..
121 * Revision 1.1 1995/02/06 16:44:47 quinn
122 * First hack at Z/SR protocol
130 /* ---------------------- GLOBAL DEFS ------------------- */
133 * We'll use a general octetstring here, since string operations are
134 * clumsy on long strings.
136 int z_SUTRS(ODR o, Odr_oct **p, int opt)
138 return odr_implicit(o, odr_octetstring, p, ODR_UNIVERSAL,
139 ODR_GENERALSTRING, opt);
142 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
144 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
147 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
149 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
153 int z_ResultSetId(ODR o, char **p, int opt)
155 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
159 int z_ElementSetName(ODR o, char **p, int opt)
161 return odr_implicit(o, odr_visiblestring, p, ODR_CONTEXT, 103, opt);
164 int z_UserInformationField(ODR o, Z_External **p, int opt)
166 return odr_explicit(o, z_External, (Z_External **)p, ODR_CONTEXT,
170 int z_InternationalString(ODR o, char **p, int opt)
172 return odr_generalstring(o, p, opt);
175 int z_InfoCategory(ODR o, Z_InfoCategory **p, int opt)
177 if (!odr_sequence_begin(o, p, sizeof(**p)))
178 return opt && odr_ok(o);
180 odr_implicit(o, odr_oid, &(*p)->categoryTypeId, ODR_CONTEXT, 1, 1) &&
181 odr_implicit(o, odr_integer, &(*p)->categoryValue, ODR_CONTEXT, 2, 0) &&
185 int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt)
187 static Odr_arm arm[] =
189 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_OtherInfo_characterInfo,
191 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_OtherInfo_binaryInfo,
193 {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_OtherInfo_externallyDefinedInfo,
195 {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_OtherInfo_oid, odr_oid},
199 if (!odr_sequence_begin(o, p, sizeof(**p)))
200 return opt && odr_ok(o);
202 odr_implicit(o, z_InfoCategory, &(*p)->category, ODR_CONTEXT, 1, 1) &&
203 odr_choice(o, arm, &(*p)->which, &(*p)->information) &&
207 int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt)
209 if (o->direction == ODR_DECODE)
210 *p = odr_malloc(o, sizeof(**p));
213 odr_implicit_settag(o, ODR_CONTEXT, 201);
214 if (odr_sequence_of(o, z_OtherInformationUnit, &(*p)->list,
215 &(*p)->num_elements))
218 return opt && odr_ok(o);
221 int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt)
223 static Odr_arm arm[] =
225 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_StringOrNumeric_string,
227 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_StringOrNumeric_numeric,
232 if (o->direction == ODR_DECODE)
233 *p = odr_malloc(o, sizeof(**p));
236 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
239 return opt && odr_ok(o);
245 int z_Unit(ODR o, Z_Unit **p, int opt)
247 if (!odr_sequence_begin(o, p, sizeof(**p)))
248 return opt && odr_ok(o);
250 odr_implicit(o, odr_visiblestring, &(*p)->unitSystem, ODR_CONTEXT,
252 odr_explicit(o, z_StringOrNumeric, &(*p)->unitType, ODR_CONTEXT,
254 odr_explicit(o, z_StringOrNumeric, &(*p)->unit, ODR_CONTEXT, 3, 1) &&
255 odr_implicit(o, odr_integer, &(*p)->scaleFactor, ODR_CONTEXT, 4, 1) &&
259 int z_IntUnit(ODR o, Z_IntUnit **p, int opt)
261 if (!odr_sequence_begin(o, p, sizeof(**p)))
262 return opt && odr_ok(o);
264 odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 1, 0) &&
265 odr_implicit(o, z_Unit, &(*p)->unitUsed, ODR_CONTEXT, 2, 0) &&
269 /* ---------------------- INITIALIZE SERVICE ------------------- */
272 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
274 if (!odr_sequence_begin(o, p, sizeof(**p)))
275 return opt && odr_ok(o);
277 odr_visiblestring(o, &(*p)->user, 0) &&
278 odr_visiblestring(o, &(*p)->password, 0) &&
279 odr_visiblestring(o, &(*p)->account, 0) &&
284 int z_IdPass(ODR o, Z_IdPass **p, int opt)
286 if (!odr_sequence_begin(o, p, sizeof(**p)))
287 return opt && odr_ok(o);
289 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 1) &&
290 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 1) &&
291 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
296 int z_StrAuthentication(ODR o, char **p, int opt)
298 return odr_visiblestring(o, p, opt);
301 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
303 static Odr_arm arm[] =
305 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
306 {-1, -1, -1, Z_IdAuthentication_idPass, z_IdPass},
307 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
308 {-1, -1, -1, Z_IdAuthentication_other, z_External},
312 if (o->direction == ODR_DECODE)
313 *p = odr_malloc(o, sizeof(**p));
317 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
320 return opt && odr_ok(o);
323 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
327 if (!odr_sequence_begin(o, p, sizeof(**p)))
328 return opt && odr_ok(o);
331 z_ReferenceId(o, &pp->referenceId, 1) &&
332 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
334 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
335 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
337 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
339 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
341 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
343 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
345 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
346 ODR_CONTEXT, 112, 1) &&
347 z_UserInformationField(o, &pp->userInformationField, 1) &&
349 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
354 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
358 if (!odr_sequence_begin(o, p, sizeof(**p)))
359 return opt && odr_ok(o);
362 z_ReferenceId(o, &pp->referenceId, 1) &&
363 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
365 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
366 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
368 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
370 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
371 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
373 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
375 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
376 ODR_CONTEXT, 112, 1) &&
377 z_UserInformationField(o, &pp->userInformationField, 1) &&
379 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
384 /* ------------------ RESOURCE CONTROL ----------------*/
386 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
389 if (!odr_sequence_begin(o, p, sizeof(**p)))
390 return opt && odr_ok(o);
392 z_ReferenceId(o, &(*p)->referenceId, 1) &&
393 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
395 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
396 ODR_CONTEXT, 47, 1) &&
397 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
400 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
405 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
407 if (!odr_sequence_begin(o, p, sizeof(**p)))
408 return opt && odr_ok(o);
410 z_ReferenceId(o, &(*p)->referenceId, 1) &&
411 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
412 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
414 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
415 ODR_CONTEXT, 41, 1) &&
416 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
418 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
419 ODR_CONTEXT, 43, 1) &&
421 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
426 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
428 if (!odr_sequence_begin(o, p, sizeof(**p)))
429 return opt && odr_ok(o);
431 z_ReferenceId(o, &(*p)->referenceId, 1) &&
432 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
433 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
436 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
441 /* ------------------------ SEARCH SERVICE ----------------------- */
443 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
445 if (!odr_sequence_begin(o, p, sizeof(**p)))
446 return opt && odr_ok(o);
448 z_DatabaseName(o, &(*p)->databaseName, 0) &&
449 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
453 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
455 if (o->direction == ODR_DECODE)
456 *p = odr_malloc(o, sizeof(**p));
460 odr_implicit_settag(o, ODR_CONTEXT, 1);
461 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
462 &(*p)->num_elements))
468 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
470 static Odr_arm arm[] =
472 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
474 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
479 if (o->direction == ODR_DECODE)
480 *p = odr_malloc(o, sizeof(**p));
482 return opt && odr_ok(o);
484 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
490 /* ----------------------- RPN QUERY -----------------------*/
492 int z_ComplexAttribute(ODR o, Z_ComplexAttribute **p, int opt)
494 if (!odr_sequence_begin(o, p, sizeof(**p)))
495 return opt && odr_ok(o);
497 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
498 odr_sequence_of(o, z_StringOrNumeric, &(*p)->list,
500 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
501 (odr_sequence_of(o, odr_integer, &(*p)->semanticAction,
502 &(*p)->num_semanticAction) || odr_ok(o)) &&
506 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
509 static Odr_arm arm[] =
511 {ODR_IMPLICIT, ODR_CONTEXT, 121, Z_AttributeValue_numeric,
513 {ODR_IMPLICIT, ODR_CONTEXT, 224, Z_AttributeValue_complex,
519 if (!odr_sequence_begin(o, p, sizeof(**p)))
520 return opt && odr_ok(o);
523 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 1, 1) &&
525 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
528 odr_choice(o, arm, &(*p)->value, &(*p)->which) &&
530 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
536 int z_Term(ODR o, Z_Term **p, int opt)
538 static Odr_arm arm[] =
540 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
541 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
542 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
544 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
545 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
546 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, z_External},
547 /* add intUnit here */
548 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
552 if (o->direction ==ODR_DECODE)
553 *p = odr_malloc(o, sizeof(**p));
556 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
559 return opt && odr_ok(o);
562 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
564 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
565 odr_sequence_begin(o, p, sizeof(**p))))
566 return opt && odr_ok(o);
568 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
569 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
570 &(*p)->num_attributes) &&
571 z_Term(o, &(*p)->term, 0) &&
575 int z_ResultSetPlusAttributes(ODR o, Z_ResultSetPlusAttributes **p, int opt)
577 if (!(odr_implicit_settag(o, ODR_CONTEXT, 214) &&
578 odr_sequence_begin(o, p, sizeof(**p))))
579 return opt && odr_ok(o);
581 z_ResultSetId(o, &(*p)->resultSet, 0) &&
582 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
583 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
584 &(*p)->num_attributes) &&
588 int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
590 static Odr_arm arm[] =
592 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, odr_integer},
593 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_private, odr_integer},
597 if (!odr_sequence_begin(o, p, sizeof(**p)))
598 return opt && odr_ok(o);
600 odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
601 odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
602 odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
603 odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
604 odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
605 odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
606 odr_constructed_end(o) &&
610 int z_Operator(ODR o, Z_Operator **p, int opt)
612 static Odr_arm arm[] =
614 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
615 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
616 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
617 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, z_ProximityOperator},
621 if (!*p && o->direction != ODR_DECODE)
623 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
624 return opt && odr_ok(o);
625 if (o->direction == ODR_DECODE)
626 *p = odr_malloc(o, sizeof(**p));
628 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
629 odr_constructed_end(o))
632 return opt && odr_ok(o);
635 int z_Operand(ODR o, Z_Operand **p, int opt)
637 static Odr_arm arm[] =
639 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
640 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
641 {-1, -1, -1, Z_Operand_resultAttr, z_ResultSetPlusAttributes},
645 if (o->direction == ODR_DECODE)
646 *p = odr_malloc(o, sizeof(**p));
649 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
652 return opt && odr_ok(o);
655 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
657 int z_Complex(ODR o, Z_Complex **p, int opt)
659 if (!odr_sequence_begin(o, p, sizeof(**p)))
660 return opt && odr_ok(o);
662 z_RPNStructure(o, &(*p)->s1, 0) &&
663 z_RPNStructure(o, &(*p)->s2, 0) &&
664 z_Operator(o, &(*p)->operator, 0) &&
668 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
670 static Odr_arm arm[] =
672 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
673 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
677 if (o->direction == ODR_DECODE)
678 *p = odr_malloc(o, sizeof(**p));
681 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
684 return opt && odr_ok(o);
687 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
689 if (!odr_sequence_begin(o, p, sizeof(**p)))
690 return opt && odr_ok(o);
692 odr_oid(o, &(*p)->attributeSetId, 0) &&
693 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
697 /* -----------------------END RPN QUERY ----------------------- */
699 int z_Query(ODR o, Z_Query **p, int opt)
701 static Odr_arm arm[] =
703 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
704 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
705 {ODR_EXPLICIT, ODR_CONTEXT, 101, Z_Query_type_101, z_RPNQuery},
709 if (o->direction == ODR_DECODE)
710 *p = odr_malloc(o, sizeof(**p));
713 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
716 return opt && odr_ok(o);
719 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
723 if (!odr_sequence_begin(o, p, sizeof(**p)))
724 return opt && odr_ok(o);
727 z_ReferenceId(o, &pp->referenceId, 1) &&
728 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
730 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
732 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
734 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
735 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
737 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
738 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
739 &pp->num_databaseNames) &&
740 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
741 ODR_CONTEXT, 100, 1) &&
742 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
743 ODR_CONTEXT, 101, 1) &&
744 odr_implicit(o, odr_oid, &pp->preferredRecordSyntax,
745 ODR_CONTEXT, 104, 1) &&
746 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
748 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
749 ODR_CONTEXT, 203, 1) &&
750 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
755 /* ------------------------ RECORD ------------------------- */
757 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
759 return z_External(o, (Z_External **) p, opt);
764 int z_DefaultDiagFormat(ODR o, Z_DefaultDiagFormat **p, int opt)
766 static Odr_arm arm[] =
768 {-1, -1, -1, Z_DiagForm_v2AddInfo, odr_visiblestring},
769 {-1, -1, -1, Z_DiagForm_v3AddInfo, z_InternationalString},
770 {ODR_IMPLICIT, ODR_CONTEXT, ODR_VISIBLESTRING, Z_DiagForm_v2AddInfo,
771 odr_visiblestring}, /* To cater to a bug in the CNIDR servers */
774 if (!odr_sequence_begin(o, p, sizeof(**p)))
775 return opt && odr_ok(o);
777 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
778 odr_integer(o, &(*p)->condition, 0) &&
780 * I no longer recall what server tagged the addinfo.. but it isn't
781 * hurting anyone, so...
782 * We need to turn it into a choice, or something, because of
783 * that damn generalstring in v3.
785 odr_choice(o, arm, &(*p)->addinfo, &(*p)->which) &&
789 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
791 static Odr_arm arm[] =
793 {-1, -1, -1, Z_DiagRec_defaultFormat, z_DefaultDiagFormat},
794 {-1, -1, -1, Z_DiagRec_externallyDefined, z_External},
798 if (o->direction == ODR_DECODE)
799 *p = odr_malloc(o, sizeof(**p));
802 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
805 return opt && odr_ok(o);
810 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
812 if (!odr_sequence_begin(o, p, sizeof(**p)))
813 return opt && odr_ok(o);
815 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
816 odr_integer(o, &(*p)->condition, 0) &&
818 * I no longer recall what server tagged the addinfo.. but it isn't
819 * hurting anyone, so...
820 * We need to turn it into a choice, or something, because of
821 * that damn generalstring in v3.
823 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
824 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT,
825 ODR_VISIBLESTRING, 1)) &&
831 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
833 if (o->direction == ODR_DECODE)
834 *p = odr_malloc(o, sizeof(**p));
838 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
839 &(*p)->num_diagRecs))
845 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
847 static Odr_arm arm[] =
849 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
851 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
856 if (!odr_sequence_begin(o, p, sizeof(**p)))
857 return opt && odr_ok(o);
859 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
861 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
862 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
863 odr_constructed_end(o) &&
867 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
869 if (o->direction == ODR_DECODE)
870 *p = odr_malloc(o, sizeof(**p));
873 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
880 int z_Records(ODR o, Z_Records **p, int opt)
882 static Odr_arm arm[] =
884 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
885 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
886 {ODR_IMPLICIT, ODR_CONTEXT, 205, Z_Records_multipleNSD,
891 if (o->direction == ODR_DECODE)
892 *p = odr_malloc(o, sizeof(**p));
895 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
898 return opt && odr_ok(o);
901 /* ------------------------ ACCESS CTRL SERVICE ----------------------- */
903 int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
905 static Odr_arm arm[] =
907 {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
909 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
913 if (!odr_sequence_begin(o, p, sizeof(**p)))
914 return opt && odr_ok(o);
916 z_ReferenceId(o, &(*p)->referenceId, 1) &&
917 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
919 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
924 int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
926 static Odr_arm arm[] =
928 {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
930 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
934 if (!odr_sequence_begin(o, p, sizeof(**p)))
935 return opt && odr_ok(o);
937 z_ReferenceId(o, &(*p)->referenceId, 1) &&
938 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
939 odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
941 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
946 /* ------------------------ SCAN SERVICE -------------------- */
948 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
950 if (o->direction == ODR_DECODE)
951 *p = odr_malloc(o, sizeof(**p));
955 odr_implicit_settag(o, ODR_CONTEXT, 44);
956 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
957 &(*p)->num_attributes))
960 return opt && odr_ok(o);
964 * This is a temporary hack. We don't know just *what* old version of the
965 * protocol willow uses, so we'll just patiently wait for them to update
967 static int willow_scan = 0;
969 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
971 if (!*p && o->direction != ODR_DECODE)
973 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
976 return opt && odr_ok(o);
978 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
980 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
982 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
984 if (o->direction == ODR_DECODE)
985 *p = odr_malloc(o, sizeof(**p));
986 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
987 &(*p)->num_attributes))
989 if (!odr_sequence_end(o) || !odr_sequence_end(o))
991 if (!z_Term(o, &(*p)->term, 0))
993 if (!odr_constructed_end(o))
999 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
1001 if (o->direction == ODR_DECODE)
1002 *p = odr_malloc(o, sizeof(**p));
1006 return opt && odr_ok(o);
1009 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
1013 return opt && !o->error;
1016 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1018 if (!odr_sequence_begin(o, p, sizeof(**p)))
1019 return opt && odr_ok(o);
1021 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
1022 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
1023 odr_sequence_end(o);
1026 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
1028 if (!odr_sequence_begin(o, p, sizeof(**p)))
1029 return opt && odr_ok(o);
1032 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
1033 z_Term(o, &(*p)->term, 0)) &&
1034 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
1035 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
1036 ODR_CONTEXT, 4, 1) &&
1037 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
1039 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
1040 ODR_CONTEXT, 3, 1) &&
1041 odr_sequence_end(o);
1044 int z_Entry(ODR o, Z_Entry **p, int opt)
1046 static Odr_arm arm[] =
1048 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
1049 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
1054 if (o->direction == ODR_DECODE)
1055 *p = odr_malloc(o, sizeof(**p));
1059 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1062 return opt && odr_ok(o);
1065 int z_Entries(ODR o, Z_Entries **p, int opt)
1067 if (o->direction == ODR_DECODE)
1068 *p = odr_malloc(o, sizeof(**p));
1072 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
1073 &(*p)->num_entries))
1079 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
1081 static Odr_arm arm[] =
1083 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
1084 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
1089 if (o->direction == ODR_DECODE)
1090 *p = odr_malloc(o, sizeof(**p));
1094 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1097 return opt && odr_ok(o);
1100 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
1102 if (!odr_sequence_begin(o, p, sizeof(**p)))
1103 return opt && odr_ok(o);
1106 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1107 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1108 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
1109 &(*p)->num_databaseNames) &&
1110 odr_oid(o, &(*p)->attributeSet, 1) &&
1111 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
1112 ((*p)->termListAndStartPoint ? 1 :
1113 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
1114 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
1115 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
1116 ODR_CONTEXT, 6, 0) &&
1117 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
1118 ODR_CONTEXT, 7, 1) &&
1119 odr_sequence_end(o);
1122 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
1124 if (!odr_sequence_begin(o, p, sizeof(**p)))
1125 return opt && odr_ok(o);
1127 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1128 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
1129 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
1130 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
1131 ODR_CONTEXT, 5, 0) &&
1132 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
1133 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
1134 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
1135 odr_sequence_end(o);
1138 /* ------------------------ SEARCHRESPONSE ----------------*/
1140 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
1142 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
1145 int z_NextResultSetPosition(ODR o, int **p, int opt)
1147 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
1150 int z_PresentStatus(ODR o, int **p, int opt)
1152 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
1155 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
1157 Z_SearchResponse *pp;
1159 if (!odr_sequence_begin(o, p, sizeof(**p)))
1160 return opt && odr_ok(o);
1163 z_ReferenceId(o, &pp->referenceId, 1) &&
1164 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
1165 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1166 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1167 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
1168 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26,
1170 z_PresentStatus(o, &pp->presentStatus, 1) &&
1171 z_Records(o, &pp->records, 1) &&
1173 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
1174 ODR_CONTEXT, 203, 1) &&
1175 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1177 odr_sequence_end(o);
1180 /* --------------------- PRESENT SERVICE ---------------------- */
1182 int z_ElementSpec(ODR o, Z_ElementSpec **p, int opt)
1184 static Odr_arm arm[] =
1186 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSpec_elementSetName,
1188 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ElementSpec_externalSpec,
1193 if (o->direction == ODR_DECODE)
1194 *p = odr_malloc(o, sizeof(**p));
1198 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1201 return opt && odr_ok(o);
1204 int z_Specification(ODR o, Z_Specification **p, int opt)
1206 if (!odr_sequence_begin(o, p, sizeof(**p)))
1207 return opt && odr_ok(o);
1209 odr_implicit(o, odr_oid, &(*p)->schema, ODR_CONTEXT, 1, 1) &&
1210 z_ElementSpec(o, &(*p)->elementSpec, 1) &&
1211 odr_sequence_end(o);
1214 int z_DbSpecific(ODR o, Z_DbSpecific **p, int opt)
1216 if (!odr_sequence_begin(o, p, sizeof(**p)))
1217 return opt && odr_ok(o);
1219 odr_explicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
1221 odr_implicit(o, z_Specification, &(*p)->spec, ODR_CONTEXT, 2, 0) &&
1222 odr_sequence_end(o);
1225 int z_CompSpec(ODR o, Z_CompSpec **p, int opt)
1227 if (!odr_sequence_begin(o, p, sizeof(**p)))
1228 return opt && odr_ok(o);
1230 odr_implicit(o, odr_bool, &(*p)->selectAlternativeSyntax, ODR_CONTEXT,
1232 odr_implicit(o, z_Specification, &(*p)->generic, ODR_CONTEXT, 2, 1) &&
1233 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1234 (odr_sequence_of(o, z_DbSpecific, &(*p)->dbSpecific,
1235 &(*p)->num_dbSpecific) || odr_ok(o)) &&
1236 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1237 (odr_sequence_of(o, odr_oid, &(*p)->recordSyntax,
1238 &(*p)->num_recordSyntax) || odr_ok(o)) &&
1239 odr_sequence_end(o);
1242 int z_RecordComposition(ODR o, Z_RecordComposition **p, int opt)
1244 static Odr_arm arm[] =
1246 {ODR_EXPLICIT, ODR_CONTEXT, 19, Z_RecordComp_simple,
1248 {ODR_IMPLICIT, ODR_CONTEXT, 209, Z_RecordComp_complex,
1253 if (o->direction == ODR_DECODE)
1254 *p = odr_malloc(o, sizeof(**p));
1258 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1261 return opt && odr_ok(o);
1264 int z_Range(ODR o, Z_Range **p, int opt)
1266 if (!odr_sequence_begin(o, p, sizeof(**p)))
1267 return opt && odr_ok(o);
1269 odr_implicit(o, odr_integer, &(*p)->startingPosition, ODR_CONTEXT,
1271 odr_implicit(o, odr_integer, &(*p)->numberOfRecords, ODR_CONTEXT,
1273 odr_sequence_end(o);
1276 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
1278 Z_PresentRequest *pp;
1280 if (!odr_sequence_begin(o, p, sizeof(**p)))
1281 return opt && odr_ok(o);
1284 z_ReferenceId(o, &pp->referenceId, 1) &&
1285 z_ResultSetId(o, &pp->resultSetId, 0) &&
1286 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
1288 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
1291 odr_implicit_settag(o, ODR_CONTEXT, 212) &&
1292 (odr_sequence_of(o, z_Range, &(*p)->additionalRanges,
1293 &(*p)->num_ranges) || odr_ok(o)) &&
1294 z_RecordComposition(o, &(*p)->recordComposition, 1) &&
1296 odr_explicit(o, z_ElementSetNames, &pp->elementSetNames, ODR_CONTEXT,
1299 odr_implicit(o, odr_oid, &(*p)->preferredRecordSyntax, ODR_CONTEXT,
1302 odr_implicit(o, odr_integer, &(*p)->maxSegmentCount, ODR_CONTEXT,
1304 odr_implicit(o, odr_integer, &(*p)->maxRecordSize, ODR_CONTEXT,
1306 odr_implicit(o, odr_integer, &(*p)->maxSegmentSize, ODR_CONTEXT,
1308 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1310 odr_sequence_end(o);
1313 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
1315 Z_PresentResponse *pp;
1317 if (!odr_sequence_begin(o, p, sizeof(**p)))
1318 return opt && odr_ok(o);
1321 z_ReferenceId(o, &pp->referenceId, 1) &&
1322 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1323 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1324 z_PresentStatus(o, &pp->presentStatus, 0) &&
1325 z_Records(o, &pp->records, 1) &&
1327 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1329 odr_sequence_end(o);
1332 /* ----------------------DELETE -------------------------- */
1334 int z_DeleteSetStatus(ODR o, int **p, int opt)
1336 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
1339 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
1341 if (!odr_sequence_begin(o, p, sizeof(**p)))
1342 return opt && odr_ok(o);
1344 z_ResultSetId(o, &(*p)->id, 0) &&
1345 z_DeleteSetStatus(o, &(*p)->status, 0) &&
1346 odr_sequence_end(o);
1349 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
1351 if (!odr_sequence_begin(o, p, sizeof(**p)))
1352 return opt && odr_ok(o);
1354 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1355 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
1357 (odr_sequence_of(o, z_ListStatus, &(*p)->resultSetList,
1358 &(*p)->num_ids) || odr_ok(o)) &&
1360 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1362 odr_sequence_end(o);
1365 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
1367 if (!odr_sequence_begin(o, p, sizeof(**p)))
1368 return opt && odr_ok(o);
1370 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1371 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
1372 ODR_CONTEXT, 0, 1) &&
1373 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
1374 (odr_sequence_of(o, z_ListStatus, &(*p)->deleteListStatuses,
1375 &(*p)->num_statuses) || odr_ok(o)) &&
1376 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
1378 odr_implicit_settag(o, ODR_CONTEXT, 35) &&
1379 (odr_sequence_of(o, z_ListStatus, &(*p)->bulkStatuses,
1380 &(*p)->num_bulkStatuses) || odr_ok(o)) &&
1381 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
1384 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1386 odr_sequence_end(o);
1389 /* ------------------------ SEGMENT SERVICE -------------- */
1391 int z_Segment(ODR o, Z_Segment **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)->numberOfRecordsReturned,
1398 ODR_CONTEXT, 24, 0) &&
1399 odr_implicit_settag(o, ODR_CONTEXT, 0) &&
1400 odr_sequence_of(o, z_NamePlusRecord, &(*p)->segmentRecords,
1401 &(*p)->num_segmentRecords) &&
1402 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1403 odr_sequence_end(o);
1406 /* ------------------------ CLOSE SERVICE ---------------- */
1408 int z_Close(ODR o, Z_Close **p, int opt)
1410 if (!odr_sequence_begin(o, p, sizeof(**p)))
1411 return opt && odr_ok(o);
1413 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1414 odr_implicit(o, odr_integer, &(*p)->closeReason, ODR_CONTEXT, 211, 0) &&
1415 odr_implicit(o, odr_visiblestring, &(*p)->diagnosticInformation,
1416 ODR_CONTEXT, 3, 1) &&
1417 odr_implicit(o, odr_oid, &(*p)->resourceReportFormat, ODR_CONTEXT,
1419 odr_implicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1422 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1424 odr_sequence_end(o);
1427 /* ------------------------ APDU ------------------------- */
1429 int z_Permissions(ODR o, Z_Permissions **p, int opt)
1431 if (!odr_sequence_begin(o, p, sizeof(**p)))
1432 return opt && odr_ok(o);
1434 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT,
1436 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
1437 odr_sequence_of(o, odr_integer, &(*p)->allowableFunctions,
1438 &(*p)->num_allowableFunctions) &&
1439 odr_sequence_end(o);
1442 int z_ExtendedServicesRequest(ODR o, Z_ExtendedServicesRequest **p, int opt)
1444 if (!odr_sequence_begin(o, p, sizeof(**p)))
1445 return opt && odr_ok(o);
1447 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1448 odr_implicit(o, odr_integer, &(*p)->function, ODR_CONTEXT, 3, 0) &&
1449 odr_implicit(o, odr_oid, &(*p)->packageType, ODR_CONTEXT, 4, 0) &&
1450 odr_implicit(o, z_InternationalString, &(*p)->packageName, ODR_CONTEXT, 5, 1) &&
1451 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT, 6, 1) &&
1452 odr_implicit(o, z_IntUnit, &(*p)->retentionTime, ODR_CONTEXT, 7, 1) &&
1453 odr_implicit(o, z_Permissions, &(*p)->permissions, ODR_CONTEXT, 8, 1) &&
1454 odr_implicit(o, z_InternationalString, &(*p)->description, ODR_CONTEXT, 9, 1) &&
1455 odr_implicit(o, z_External, &(*p)->taskSpecificParameters, ODR_CONTEXT, 10, 1) &&
1456 odr_implicit(o, odr_integer, &(*p)->waitAction, ODR_CONTEXT, 11, 0) &&
1457 z_ElementSetName(o, &(*p)->elements, 1) &&
1458 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1459 odr_sequence_end(o);
1462 int z_ExtendedServicesResponse(ODR o, Z_ExtendedServicesResponse **p, int opt)
1464 if (!odr_sequence_begin(o, p, sizeof(**p)))
1465 return opt && odr_ok(o);
1467 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1468 odr_implicit(o, odr_integer, &(*p)->operationStatus, ODR_CONTEXT, 3, 0) &&
1469 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1470 (odr_sequence_of(o, z_DiagRec, &(*p)->diagnostics,
1471 &(*p)->num_diagnostics) || odr_ok(o)) &&
1472 odr_implicit(o, z_External, &(*p)->taskPackage, ODR_CONTEXT, 5, 1) &&
1473 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1474 odr_sequence_end(o);
1477 /* ------------------------ APDU ------------------------- */
1479 int z_APDU(ODR o, Z_APDU **p, int opt)
1481 static Odr_arm arm[] =
1483 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
1484 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
1485 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
1486 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
1488 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
1490 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
1492 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
1493 z_DeleteResultSetRequest},
1494 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
1495 z_DeleteResultSetResponse},
1496 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
1497 z_ResourceControlRequest},
1498 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
1499 z_ResourceControlResponse},
1500 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
1501 z_TriggerResourceControlRequest},
1502 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
1503 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
1504 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_APDU_segmentRequest, z_Segment},
1505 {ODR_IMPLICIT, ODR_CONTEXT, 46, Z_APDU_extendedServicesRequest,
1506 z_ExtendedServicesRequest},
1507 {ODR_IMPLICIT, ODR_CONTEXT, 47, Z_APDU_extendedServicesResponse,
1508 z_ExtendedServicesResponse},
1509 {ODR_IMPLICIT, ODR_CONTEXT, 48, Z_APDU_close, z_Close},
1514 if (o->direction == ODR_DECODE)
1515 *p = odr_malloc(o, sizeof(**p));
1516 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
1518 if (o->direction == ODR_DECODE)
1520 return opt && odr_ok(o);