2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.37 1995-08-21 09:10:15 quinn
8 * Smallish fixes to suppport new formats.
10 * Revision 1.36 1995/08/15 11:59:39 quinn
13 * Revision 1.35 1995/08/10 08:53:59 quinn
16 * Revision 1.34 1995/06/19 17:01:48 quinn
17 * This should bring us in sync with the version distributed as 1.0b
19 * Revision 1.33 1995/06/19 13:39:56 quinn
20 * *** empty log message ***
22 * Revision 1.32 1995/06/19 12:37:28 quinn
23 * Fixed a bug in the compspec.
25 * Revision 1.31 1995/06/16 13:15:56 quinn
26 * Fixed Defaultdiagformat.
28 * Revision 1.30 1995/06/15 15:42:01 quinn
31 * Revision 1.29 1995/06/15 07:44:49 quinn
34 * Revision 1.28 1995/06/14 15:26:35 quinn
35 * *** empty log message ***
37 * Revision 1.27 1995/06/07 14:36:22 quinn
40 * Revision 1.26 1995/06/02 09:49:13 quinn
41 * Adding access control
43 * Revision 1.25 1995/05/25 11:00:08 quinn
44 * *** empty log message ***
46 * Revision 1.24 1995/05/22 13:58:18 quinn
47 * Fixed an ODR_NULLVAL.
49 * Revision 1.23 1995/05/22 11:30:18 quinn
50 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
52 * Revision 1.22 1995/05/17 08:40:56 quinn
53 * Added delete. Fixed some sequence_begins. Smallish.
55 * Revision 1.21 1995/05/16 08:50:24 quinn
56 * License, documentation, and memory fixes
58 * Revision 1.20 1995/05/15 11:55:25 quinn
61 * Revision 1.19 1995/04/11 11:58:35 quinn
64 * Revision 1.18 1995/04/11 11:52:02 quinn
65 * Fixed possible buf in proto.c
67 * Revision 1.17 1995/04/10 10:22:22 quinn
70 * Revision 1.16 1995/03/30 10:26:43 quinn
71 * Added Term structure
73 * Revision 1.15 1995/03/30 09:08:39 quinn
74 * Added Resource control protocol
76 * Revision 1.14 1995/03/29 08:06:13 quinn
77 * Added a few v3 elements
79 * Revision 1.13 1995/03/20 11:26:52 quinn
80 * *** empty log message ***
82 * Revision 1.12 1995/03/20 09:45:09 quinn
85 * Revision 1.11 1995/03/17 10:17:25 quinn
86 * Added memory management.
88 * Revision 1.10 1995/03/15 11:17:40 quinn
89 * Fixed some return-checks from choice.. need better ay to handle those..
91 * Revision 1.9 1995/03/15 08:37:06 quinn
92 * Fixed protocol bugs.
94 * Revision 1.8 1995/03/14 16:59:24 quinn
95 * Fixed OPTIONAL flag in attributeelement
97 * Revision 1.7 1995/03/07 16:29:33 quinn
98 * Added authentication stuff.
100 * Revision 1.6 1995/03/01 14:46:03 quinn
101 * Fixed protocol bug in 8777query.
103 * Revision 1.5 1995/02/14 11:54:22 quinn
106 * Revision 1.4 1995/02/10 15:54:30 quinn
109 * Revision 1.3 1995/02/09 15:51:39 quinn
112 * Revision 1.2 1995/02/06 21:26:07 quinn
113 * Repaired this evening's damages..
115 * Revision 1.1 1995/02/06 16:44:47 quinn
116 * First hack at Z/SR protocol
124 /* ---------------------- GLOBAL DEFS ------------------- */
127 * We'll use a general octetstring here, since string operations are
128 * clumsy on long strings.
130 int z_SUTRS(ODR o, Odr_oct **p, int opt)
132 return odr_implicit(o, odr_octetstring, p, ODR_UNIVERSAL,
133 ODR_GENERALSTRING, opt);
136 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
138 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
141 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
143 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
147 int z_ResultSetId(ODR o, char **p, int opt)
149 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
153 int z_ElementSetName(ODR o, char **p, int opt)
155 return odr_implicit(o, odr_visiblestring, p, ODR_CONTEXT, 103, opt);
158 int z_UserInformationField(ODR o, Z_External **p, int opt)
160 return odr_explicit(o, z_External, (Z_External **)p, ODR_CONTEXT,
164 int z_InternationalString(ODR o, char **p, int opt)
166 return odr_generalstring(o, p, opt);
169 int z_InfoCategory(ODR o, Z_InfoCategory **p, int opt)
171 if (!odr_sequence_begin(o, p, sizeof(**p)))
172 return opt && odr_ok(o);
174 odr_implicit(o, odr_oid, &(*p)->categoryTypeId, ODR_CONTEXT, 1, 1) &&
175 odr_implicit(o, odr_integer, &(*p)->categoryValue, ODR_CONTEXT, 2, 0) &&
179 int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt)
181 static Odr_arm arm[] =
183 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_OtherInfo_characterInfo,
185 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_OtherInfo_binaryInfo,
187 {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_OtherInfo_externallyDefinedInfo,
189 {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_OtherInfo_oid, odr_oid},
193 if (!odr_sequence_begin(o, p, sizeof(**p)))
194 return opt && odr_ok(o);
196 odr_implicit(o, z_InfoCategory, &(*p)->category, ODR_CONTEXT, 1, 1) &&
197 odr_choice(o, arm, &(*p)->which, &(*p)->information) &&
201 int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt)
203 if (o->direction == ODR_DECODE)
204 *p = odr_malloc(o, sizeof(**p));
207 odr_implicit_settag(o, ODR_CONTEXT, 201);
208 if (odr_sequence_of(o, z_OtherInformationUnit, &(*p)->list,
209 &(*p)->num_elements))
212 return opt && odr_ok(o);
215 int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt)
217 static Odr_arm arm[] =
219 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_StringOrNumeric_string,
221 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_StringOrNumeric_numeric,
226 if (o->direction == ODR_DECODE)
227 *p = odr_malloc(o, sizeof(**p));
230 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
233 return opt && odr_ok(o);
239 int z_Unit(ODR o, Z_Unit **p, int opt)
241 if (!odr_sequence_begin(o, p, sizeof(**p)))
242 return opt && odr_ok(o);
244 odr_implicit(o, odr_visiblestring, &(*p)->unitSystem, ODR_CONTEXT,
246 odr_explicit(o, z_StringOrNumeric, &(*p)->unitType, ODR_CONTEXT,
248 odr_explicit(o, z_StringOrNumeric, &(*p)->unit, ODR_CONTEXT, 3, 1) &&
249 odr_implicit(o, odr_integer, &(*p)->scaleFactor, ODR_CONTEXT, 4, 1) &&
253 int z_IntUnit(ODR o, Z_IntUnit **p, int opt)
255 if (!odr_sequence_begin(o, p, sizeof(**p)))
256 return opt && odr_ok(o);
258 odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 1, 0) &&
259 odr_implicit(o, z_Unit, &(*p)->unitUsed, ODR_CONTEXT, 2, 0) &&
263 /* ---------------------- INITIALIZE SERVICE ------------------- */
266 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
268 if (!odr_sequence_begin(o, p, sizeof(**p)))
269 return opt && odr_ok(o);
271 odr_visiblestring(o, &(*p)->user, 0) &&
272 odr_visiblestring(o, &(*p)->password, 0) &&
273 odr_visiblestring(o, &(*p)->account, 0) &&
278 int z_IdPass(ODR o, Z_IdPass **p, int opt)
280 if (!odr_sequence_begin(o, p, sizeof(**p)))
281 return opt && odr_ok(o);
283 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 1) &&
284 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 1) &&
285 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
290 int z_StrAuthentication(ODR o, char **p, int opt)
292 return odr_visiblestring(o, p, opt);
295 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
297 static Odr_arm arm[] =
299 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
300 {-1, -1, -1, Z_IdAuthentication_idPass, z_IdPass},
301 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
302 {-1, -1, -1, Z_IdAuthentication_other, z_External},
306 if (o->direction == ODR_DECODE)
307 *p = odr_malloc(o, sizeof(**p));
311 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
314 return opt && odr_ok(o);
317 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
321 if (!odr_sequence_begin(o, p, sizeof(**p)))
322 return opt && odr_ok(o);
325 z_ReferenceId(o, &pp->referenceId, 1) &&
326 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
328 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
329 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
331 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
333 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
335 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
337 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
339 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
340 ODR_CONTEXT, 112, 1) &&
341 z_UserInformationField(o, &pp->userInformationField, 1) &&
343 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
348 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
352 if (!odr_sequence_begin(o, p, sizeof(**p)))
353 return opt && odr_ok(o);
356 z_ReferenceId(o, &pp->referenceId, 1) &&
357 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
359 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
360 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
362 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
364 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
365 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
367 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
369 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
370 ODR_CONTEXT, 112, 1) &&
371 z_UserInformationField(o, &pp->userInformationField, 1) &&
373 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
378 /* ------------------ RESOURCE CONTROL ----------------*/
380 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
383 if (!odr_sequence_begin(o, p, sizeof(**p)))
384 return opt && odr_ok(o);
386 z_ReferenceId(o, &(*p)->referenceId, 1) &&
387 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
389 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
390 ODR_CONTEXT, 47, 1) &&
391 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
394 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
399 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
401 if (!odr_sequence_begin(o, p, sizeof(**p)))
402 return opt && odr_ok(o);
404 z_ReferenceId(o, &(*p)->referenceId, 1) &&
405 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
406 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
408 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
409 ODR_CONTEXT, 41, 1) &&
410 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
412 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
413 ODR_CONTEXT, 43, 1) &&
415 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
420 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
422 if (!odr_sequence_begin(o, p, sizeof(**p)))
423 return opt && odr_ok(o);
425 z_ReferenceId(o, &(*p)->referenceId, 1) &&
426 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
427 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
430 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
435 /* ------------------------ SEARCH SERVICE ----------------------- */
437 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
439 if (!odr_sequence_begin(o, p, sizeof(**p)))
440 return opt && odr_ok(o);
442 z_DatabaseName(o, &(*p)->databaseName, 0) &&
443 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
447 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
449 if (o->direction == ODR_DECODE)
450 *p = odr_malloc(o, sizeof(**p));
454 odr_implicit_settag(o, ODR_CONTEXT, 1);
455 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
456 &(*p)->num_elements))
462 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
464 static Odr_arm arm[] =
466 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
468 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
473 if (o->direction == ODR_DECODE)
474 *p = odr_malloc(o, sizeof(**p));
476 return opt && odr_ok(o);
478 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
484 /* ----------------------- RPN QUERY -----------------------*/
486 int z_ComplexAttribute(ODR o, Z_ComplexAttribute **p, int opt)
488 if (!odr_sequence_begin(o, p, sizeof(**p)))
489 return opt && odr_ok(o);
491 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
492 odr_sequence_of(o, z_StringOrNumeric, &(*p)->list,
494 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
495 (odr_sequence_of(o, odr_integer, &(*p)->semanticAction,
496 &(*p)->num_semanticAction) || odr_ok(o)) &&
500 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
503 static Odr_arm arm[] =
505 {ODR_IMPLICIT, ODR_CONTEXT, 121, Z_AttributeValue_numeric,
507 {ODR_IMPLICIT, ODR_CONTEXT, 224, Z_AttributeValue_complex,
513 if (!odr_sequence_begin(o, p, sizeof(**p)))
514 return opt && odr_ok(o);
517 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 1, 1) &&
519 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
522 odr_choice(o, arm, &(*p)->value, &(*p)->which) &&
524 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
530 int z_Term(ODR o, Z_Term **p, int opt)
532 static Odr_arm arm[] =
534 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
535 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
536 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
538 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
539 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
540 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, z_External},
541 /* add intUnit here */
542 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
546 if (o->direction ==ODR_DECODE)
547 *p = odr_malloc(o, sizeof(**p));
550 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
553 return opt && odr_ok(o);
556 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
558 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
559 odr_sequence_begin(o, p, sizeof(**p))))
560 return opt && odr_ok(o);
562 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
563 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
564 &(*p)->num_attributes) &&
565 z_Term(o, &(*p)->term, 0) &&
569 int z_ResultSetPlusAttributes(ODR o, Z_ResultSetPlusAttributes **p, int opt)
571 if (!(odr_implicit_settag(o, ODR_CONTEXT, 214) &&
572 odr_sequence_begin(o, p, sizeof(**p))))
573 return opt && odr_ok(o);
575 z_ResultSetId(o, &(*p)->resultSet, 0) &&
576 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
577 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
578 &(*p)->num_attributes) &&
582 int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
584 static Odr_arm arm[] =
586 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, odr_integer},
587 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_private, odr_integer},
591 if (!odr_sequence_begin(o, p, sizeof(**p)))
592 return opt && odr_ok(o);
594 odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
595 odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
596 odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
597 odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
598 odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
599 odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
600 odr_constructed_end(o) &&
604 int z_Operator(ODR o, Z_Operator **p, int opt)
606 static Odr_arm arm[] =
608 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
609 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
610 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
611 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, z_ProximityOperator},
615 if (!*p && o->direction != ODR_DECODE)
617 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
618 return opt && odr_ok(o);
619 if (o->direction == ODR_DECODE)
620 *p = odr_malloc(o, sizeof(**p));
622 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
623 odr_constructed_end(o))
626 return opt && odr_ok(o);
629 int z_Operand(ODR o, Z_Operand **p, int opt)
631 static Odr_arm arm[] =
633 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
634 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
635 {-1, -1, -1, Z_Operand_resultAttr, z_ResultSetPlusAttributes},
639 if (o->direction == ODR_DECODE)
640 *p = odr_malloc(o, sizeof(**p));
643 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
646 return opt && odr_ok(o);
649 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
651 int z_Complex(ODR o, Z_Complex **p, int opt)
653 if (!odr_sequence_begin(o, p, sizeof(**p)))
654 return opt && odr_ok(o);
656 z_RPNStructure(o, &(*p)->s1, 0) &&
657 z_RPNStructure(o, &(*p)->s2, 0) &&
658 z_Operator(o, &(*p)->operator, 0) &&
662 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
664 static Odr_arm arm[] =
666 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
667 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
671 if (o->direction == ODR_DECODE)
672 *p = odr_malloc(o, sizeof(**p));
675 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
678 return opt && odr_ok(o);
681 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
683 if (!odr_sequence_begin(o, p, sizeof(**p)))
684 return opt && odr_ok(o);
686 odr_oid(o, &(*p)->attributeSetId, 0) &&
687 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
691 /* -----------------------END RPN QUERY ----------------------- */
693 int z_Query(ODR o, Z_Query **p, int opt)
695 static Odr_arm arm[] =
697 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
698 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
699 {ODR_EXPLICIT, ODR_CONTEXT, 101, Z_Query_type_101, z_RPNQuery},
703 if (o->direction == ODR_DECODE)
704 *p = odr_malloc(o, sizeof(**p));
707 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
710 return opt && odr_ok(o);
713 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
717 if (!odr_sequence_begin(o, p, sizeof(**p)))
718 return opt && odr_ok(o);
721 z_ReferenceId(o, &pp->referenceId, 1) &&
722 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
724 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
726 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
728 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
729 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
731 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
732 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
733 &pp->num_databaseNames) &&
734 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
735 ODR_CONTEXT, 100, 1) &&
736 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
737 ODR_CONTEXT, 101, 1) &&
738 odr_implicit(o, odr_oid, &pp->preferredRecordSyntax,
739 ODR_CONTEXT, 104, 1) &&
740 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
742 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
743 ODR_CONTEXT, 203, 1) &&
744 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
749 /* ------------------------ RECORD ------------------------- */
751 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
753 return z_External(o, (Z_External **) p, opt);
758 int z_DefaultDiagFormat(ODR o, Z_DefaultDiagFormat **p, int opt)
760 static Odr_arm arm[] =
762 {-1, -1, -1, Z_DiagForm_v2AddInfo, odr_visiblestring},
763 {-1, -1, -1, Z_DiagForm_v3AddInfo, z_InternationalString},
764 {ODR_IMPLICIT, ODR_CONTEXT, ODR_VISIBLESTRING, Z_DiagForm_v2AddInfo,
765 odr_visiblestring}, /* To cater to a bug in the CNIDR servers */
768 if (!odr_sequence_begin(o, p, sizeof(**p)))
769 return opt && odr_ok(o);
771 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
772 odr_integer(o, &(*p)->condition, 0) &&
774 * I no longer recall what server tagged the addinfo.. but it isn't
775 * hurting anyone, so...
776 * We need to turn it into a choice, or something, because of
777 * that damn generalstring in v3.
779 odr_choice(o, arm, &(*p)->addinfo, &(*p)->which) &&
783 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
785 static Odr_arm arm[] =
787 {-1, -1, -1, Z_DiagRec_defaultFormat, z_DefaultDiagFormat},
788 {-1, -1, -1, Z_DiagRec_externallyDefined, z_External},
792 if (o->direction == ODR_DECODE)
793 *p = odr_malloc(o, sizeof(**p));
796 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
799 return opt && odr_ok(o);
804 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
806 if (!odr_sequence_begin(o, p, sizeof(**p)))
807 return opt && odr_ok(o);
809 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
810 odr_integer(o, &(*p)->condition, 0) &&
812 * I no longer recall what server tagged the addinfo.. but it isn't
813 * hurting anyone, so...
814 * We need to turn it into a choice, or something, because of
815 * that damn generalstring in v3.
817 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
818 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT,
819 ODR_VISIBLESTRING, 1)) &&
825 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
827 if (o->direction == ODR_DECODE)
828 *p = odr_malloc(o, sizeof(**p));
832 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
833 &(*p)->num_diagRecs))
839 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
841 static Odr_arm arm[] =
843 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
845 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
850 if (!odr_sequence_begin(o, p, sizeof(**p)))
851 return opt && odr_ok(o);
853 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
855 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
856 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
857 odr_constructed_end(o) &&
861 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
863 if (o->direction == ODR_DECODE)
864 *p = odr_malloc(o, sizeof(**p));
867 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
874 int z_Records(ODR o, Z_Records **p, int opt)
876 static Odr_arm arm[] =
878 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
879 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
880 {ODR_IMPLICIT, ODR_CONTEXT, 205, Z_Records_multipleNSD,
885 if (o->direction == ODR_DECODE)
886 *p = odr_malloc(o, sizeof(**p));
889 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
892 return opt && odr_ok(o);
895 /* ------------------------ ACCESS CTRL SERVICE ----------------------- */
897 int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
899 static Odr_arm arm[] =
901 {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
903 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
907 if (!odr_sequence_begin(o, p, sizeof(**p)))
908 return opt && odr_ok(o);
910 z_ReferenceId(o, &(*p)->referenceId, 1) &&
911 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
913 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
918 int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
920 static Odr_arm arm[] =
922 {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
924 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
928 if (!odr_sequence_begin(o, p, sizeof(**p)))
929 return opt && odr_ok(o);
931 z_ReferenceId(o, &(*p)->referenceId, 1) &&
932 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
933 odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
935 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
940 /* ------------------------ SCAN SERVICE -------------------- */
942 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
944 if (o->direction == ODR_DECODE)
945 *p = odr_malloc(o, sizeof(**p));
949 odr_implicit_settag(o, ODR_CONTEXT, 44);
950 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
951 &(*p)->num_attributes))
954 return opt && odr_ok(o);
958 * This is a temporary hack. We don't know just *what* old version of the
959 * protocol willow uses, so we'll just patiently wait for them to update
961 static int willow_scan = 0;
963 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
965 if (!*p && o->direction != ODR_DECODE)
967 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
970 return opt && odr_ok(o);
972 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
974 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
976 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
978 if (o->direction == ODR_DECODE)
979 *p = odr_malloc(o, sizeof(**p));
980 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
981 &(*p)->num_attributes))
983 if (!odr_sequence_end(o) || !odr_sequence_end(o))
985 if (!z_Term(o, &(*p)->term, 0))
987 if (!odr_constructed_end(o))
993 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
995 if (o->direction == ODR_DECODE)
996 *p = odr_malloc(o, sizeof(**p));
1000 return opt && odr_ok(o);
1003 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
1007 return opt && !o->error;
1010 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1012 if (!odr_sequence_begin(o, p, sizeof(**p)))
1013 return opt && odr_ok(o);
1015 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
1016 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
1017 odr_sequence_end(o);
1020 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
1022 if (!odr_sequence_begin(o, p, sizeof(**p)))
1023 return opt && odr_ok(o);
1026 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
1027 z_Term(o, &(*p)->term, 0)) &&
1028 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
1029 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
1030 ODR_CONTEXT, 4, 1) &&
1031 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
1033 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
1034 ODR_CONTEXT, 3, 1) &&
1035 odr_sequence_end(o);
1038 int z_Entry(ODR o, Z_Entry **p, int opt)
1040 static Odr_arm arm[] =
1042 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
1043 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
1048 if (o->direction == ODR_DECODE)
1049 *p = odr_malloc(o, sizeof(**p));
1053 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1056 return opt && odr_ok(o);
1059 int z_Entries(ODR o, Z_Entries **p, int opt)
1061 if (o->direction == ODR_DECODE)
1062 *p = odr_malloc(o, sizeof(**p));
1066 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
1067 &(*p)->num_entries))
1073 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
1075 static Odr_arm arm[] =
1077 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
1078 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
1083 if (o->direction == ODR_DECODE)
1084 *p = odr_malloc(o, sizeof(**p));
1088 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1091 return opt && odr_ok(o);
1094 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
1096 if (!odr_sequence_begin(o, p, sizeof(**p)))
1097 return opt && odr_ok(o);
1100 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1101 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1102 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
1103 &(*p)->num_databaseNames) &&
1104 odr_oid(o, &(*p)->attributeSet, 1) &&
1105 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
1106 ((*p)->termListAndStartPoint ? 1 :
1107 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
1108 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
1109 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
1110 ODR_CONTEXT, 6, 0) &&
1111 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
1112 ODR_CONTEXT, 7, 1) &&
1113 odr_sequence_end(o);
1116 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
1118 if (!odr_sequence_begin(o, p, sizeof(**p)))
1119 return opt && odr_ok(o);
1121 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1122 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
1123 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
1124 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
1125 ODR_CONTEXT, 5, 0) &&
1126 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
1127 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
1128 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
1129 odr_sequence_end(o);
1132 /* ------------------------ SEARCHRESPONSE ----------------*/
1134 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
1136 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
1139 int z_NextResultSetPosition(ODR o, int **p, int opt)
1141 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
1144 int z_PresentStatus(ODR o, int **p, int opt)
1146 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
1149 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
1151 Z_SearchResponse *pp;
1153 if (!odr_sequence_begin(o, p, sizeof(**p)))
1154 return opt && odr_ok(o);
1157 z_ReferenceId(o, &pp->referenceId, 1) &&
1158 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
1159 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1160 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1161 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
1162 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26,
1164 z_PresentStatus(o, &pp->presentStatus, 1) &&
1165 z_Records(o, &pp->records, 1) &&
1167 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
1168 ODR_CONTEXT, 203, 1) &&
1169 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1171 odr_sequence_end(o);
1174 /* --------------------- PRESENT SERVICE ---------------------- */
1176 int z_ElementSpec(ODR o, Z_ElementSpec **p, int opt)
1178 static Odr_arm arm[] =
1180 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSpec_elementSetName,
1182 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ElementSpec_externalSpec,
1187 if (o->direction == ODR_DECODE)
1188 *p = odr_malloc(o, sizeof(**p));
1192 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1195 return opt && odr_ok(o);
1198 int z_Specification(ODR o, Z_Specification **p, int opt)
1200 if (!odr_sequence_begin(o, p, sizeof(**p)))
1201 return opt && odr_ok(o);
1203 odr_implicit(o, odr_oid, &(*p)->schema, ODR_CONTEXT, 1, 1) &&
1204 z_ElementSpec(o, &(*p)->elementSpec, 1) &&
1205 odr_sequence_end(o);
1208 int z_DbSpecific(ODR o, Z_DbSpecific **p, int opt)
1210 if (!odr_sequence_begin(o, p, sizeof(**p)))
1211 return opt && odr_ok(o);
1213 odr_explicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
1215 odr_implicit(o, z_Specification, &(*p)->spec, ODR_CONTEXT, 2, 0) &&
1216 odr_sequence_end(o);
1219 int z_CompSpec(ODR o, Z_CompSpec **p, int opt)
1221 if (!odr_sequence_begin(o, p, sizeof(**p)))
1222 return opt && odr_ok(o);
1224 odr_implicit(o, odr_bool, &(*p)->selectAlternativeSyntax, ODR_CONTEXT,
1226 odr_implicit(o, z_Specification, &(*p)->generic, ODR_CONTEXT, 2, 1) &&
1227 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1228 (odr_sequence_of(o, z_DbSpecific, &(*p)->dbSpecific,
1229 &(*p)->num_dbSpecific) || odr_ok(o)) &&
1230 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1231 (odr_sequence_of(o, odr_oid, &(*p)->recordSyntax,
1232 &(*p)->num_recordSyntax) || odr_ok(o)) &&
1233 odr_sequence_end(o);
1236 int z_RecordComposition(ODR o, Z_RecordComposition **p, int opt)
1238 static Odr_arm arm[] =
1240 {ODR_EXPLICIT, ODR_CONTEXT, 19, Z_RecordComp_simple,
1242 {ODR_IMPLICIT, ODR_CONTEXT, 209, Z_RecordComp_complex,
1247 if (o->direction == ODR_DECODE)
1248 *p = odr_malloc(o, sizeof(**p));
1252 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1255 return opt && odr_ok(o);
1258 int z_Range(ODR o, Z_Range **p, int opt)
1260 if (!odr_sequence_begin(o, p, sizeof(**p)))
1261 return opt && odr_ok(o);
1263 odr_implicit(o, odr_integer, &(*p)->startingPosition, ODR_CONTEXT,
1265 odr_implicit(o, odr_integer, &(*p)->numberOfRecords, ODR_CONTEXT,
1267 odr_sequence_end(o);
1270 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
1272 Z_PresentRequest *pp;
1274 if (!odr_sequence_begin(o, p, sizeof(**p)))
1275 return opt && odr_ok(o);
1278 z_ReferenceId(o, &pp->referenceId, 1) &&
1279 z_ResultSetId(o, &pp->resultSetId, 0) &&
1280 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
1282 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
1285 odr_implicit_settag(o, ODR_CONTEXT, 212) &&
1286 (odr_sequence_of(o, z_Range, &(*p)->additionalRanges,
1287 &(*p)->num_ranges) || odr_ok(o)) &&
1288 z_RecordComposition(o, &(*p)->recordComposition, 1) &&
1290 odr_explicit(o, z_ElementSetNames, &pp->elementSetNames, ODR_CONTEXT,
1293 odr_implicit(o, odr_oid, &(*p)->preferredRecordSyntax, ODR_CONTEXT,
1296 odr_implicit(o, odr_integer, &(*p)->maxSegmentCount, ODR_CONTEXT,
1298 odr_implicit(o, odr_integer, &(*p)->maxRecordSize, ODR_CONTEXT,
1300 odr_implicit(o, odr_integer, &(*p)->maxSegmentSize, ODR_CONTEXT,
1302 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1304 odr_sequence_end(o);
1307 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
1309 Z_PresentResponse *pp;
1311 if (!odr_sequence_begin(o, p, sizeof(**p)))
1312 return opt && odr_ok(o);
1315 z_ReferenceId(o, &pp->referenceId, 1) &&
1316 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1317 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1318 z_PresentStatus(o, &pp->presentStatus, 0) &&
1319 z_Records(o, &pp->records, 1) &&
1321 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1323 odr_sequence_end(o);
1326 /* ----------------------DELETE -------------------------- */
1328 int z_DeleteSetStatus(ODR o, int **p, int opt)
1330 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
1333 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
1335 if (!odr_sequence_begin(o, p, sizeof(**p)))
1336 return opt && odr_ok(o);
1338 z_ResultSetId(o, &(*p)->id, 0) &&
1339 z_DeleteSetStatus(o, &(*p)->status, 0) &&
1340 odr_sequence_end(o);
1343 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
1345 if (!odr_sequence_begin(o, p, sizeof(**p)))
1346 return opt && odr_ok(o);
1348 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1349 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
1351 (odr_sequence_of(o, z_ListStatus, &(*p)->resultSetList,
1352 &(*p)->num_ids) || odr_ok(o)) &&
1354 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1356 odr_sequence_end(o);
1359 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
1361 if (!odr_sequence_begin(o, p, sizeof(**p)))
1362 return opt && odr_ok(o);
1364 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1365 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
1366 ODR_CONTEXT, 0, 1) &&
1367 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
1368 (odr_sequence_of(o, z_ListStatus, &(*p)->deleteListStatuses,
1369 &(*p)->num_statuses) || odr_ok(o)) &&
1370 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
1372 odr_implicit_settag(o, ODR_CONTEXT, 35) &&
1373 (odr_sequence_of(o, z_ListStatus, &(*p)->bulkStatuses,
1374 &(*p)->num_bulkStatuses) || odr_ok(o)) &&
1375 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
1378 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1380 odr_sequence_end(o);
1383 /* ------------------------ SEGMENT SERVICE -------------- */
1385 int z_Segment(ODR o, Z_Segment **p, int opt)
1387 if (!odr_sequence_begin(o, p, sizeof(**p)))
1388 return opt && odr_ok(o);
1390 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1391 odr_implicit(o, odr_integer, &(*p)->numberOfRecordsReturned,
1392 ODR_CONTEXT, 24, 0) &&
1393 odr_implicit_settag(o, ODR_CONTEXT, 0) &&
1394 odr_sequence_of(o, z_NamePlusRecord, &(*p)->segmentRecords,
1395 &(*p)->num_segmentRecords) &&
1396 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1397 odr_sequence_end(o);
1400 /* ------------------------ CLOSE SERVICE ---------------- */
1402 int z_Close(ODR o, Z_Close **p, int opt)
1404 if (!odr_sequence_begin(o, p, sizeof(**p)))
1405 return opt && odr_ok(o);
1407 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1408 odr_implicit(o, odr_integer, &(*p)->closeReason, ODR_CONTEXT, 211, 0) &&
1409 odr_implicit(o, odr_visiblestring, &(*p)->diagnosticInformation,
1410 ODR_CONTEXT, 3, 1) &&
1411 odr_implicit(o, odr_oid, &(*p)->resourceReportFormat, ODR_CONTEXT,
1413 odr_implicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1416 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1418 odr_sequence_end(o);
1421 /* ------------------------ APDU ------------------------- */
1423 int z_Permissions(ODR o, Z_Permissions **p, int opt)
1425 if (!odr_sequence_begin(o, p, sizeof(**p)))
1426 return opt && odr_ok(o);
1428 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT,
1430 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
1431 odr_sequence_of(o, odr_integer, &(*p)->allowableFunctions,
1432 &(*p)->num_allowableFunctions) &&
1433 odr_sequence_end(o);
1436 int z_ExtendedServicesRequest(ODR o, Z_ExtendedServicesRequest **p, int opt)
1438 if (!odr_sequence_begin(o, p, sizeof(**p)))
1439 return opt && odr_ok(o);
1441 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1442 odr_implicit(o, odr_integer, &(*p)->function, ODR_CONTEXT, 3, 0) &&
1443 odr_implicit(o, odr_oid, &(*p)->packageType, ODR_CONTEXT, 4, 0) &&
1444 odr_implicit(o, z_InternationalString, &(*p)->packageName, ODR_CONTEXT, 5, 1) &&
1445 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT, 6, 1) &&
1446 odr_implicit(o, z_IntUnit, &(*p)->retentionTime, ODR_CONTEXT, 7, 1) &&
1447 odr_implicit(o, z_Permissions, &(*p)->permissions, ODR_CONTEXT, 8, 1) &&
1448 odr_implicit(o, z_InternationalString, &(*p)->description, ODR_CONTEXT, 9, 1) &&
1449 odr_implicit(o, z_External, &(*p)->taskSpecificParameters, ODR_CONTEXT, 10, 1) &&
1450 odr_implicit(o, odr_integer, &(*p)->waitAction, ODR_CONTEXT, 11, 0) &&
1451 z_ElementSetName(o, &(*p)->elements, 1) &&
1452 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1453 odr_sequence_end(o);
1456 int z_ExtendedServicesResponse(ODR o, Z_ExtendedServicesResponse **p, int opt)
1458 if (!odr_sequence_begin(o, p, sizeof(**p)))
1459 return opt && odr_ok(o);
1461 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1462 odr_implicit(o, odr_integer, &(*p)->operationStatus, ODR_CONTEXT, 3, 0) &&
1463 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1464 (odr_sequence_of(o, z_DiagRec, &(*p)->diagnostics,
1465 &(*p)->num_diagnostics) || odr_ok(o)) &&
1466 odr_implicit(o, z_External, &(*p)->taskPackage, ODR_CONTEXT, 5, 1) &&
1467 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1468 odr_sequence_end(o);
1471 /* ------------------------ APDU ------------------------- */
1473 int z_APDU(ODR o, Z_APDU **p, int opt)
1475 static Odr_arm arm[] =
1477 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
1478 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
1479 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
1480 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
1482 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
1484 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
1486 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
1487 z_DeleteResultSetRequest},
1488 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
1489 z_DeleteResultSetResponse},
1490 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
1491 z_ResourceControlRequest},
1492 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
1493 z_ResourceControlResponse},
1494 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
1495 z_TriggerResourceControlRequest},
1496 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
1497 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
1498 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_APDU_segmentRequest, z_Segment},
1499 {ODR_IMPLICIT, ODR_CONTEXT, 46, Z_APDU_extendedServicesRequest,
1500 z_ExtendedServicesRequest},
1501 {ODR_IMPLICIT, ODR_CONTEXT, 47, Z_APDU_extendedServicesResponse,
1502 z_ExtendedServicesResponse},
1503 {ODR_IMPLICIT, ODR_CONTEXT, 48, Z_APDU_close, z_Close},
1508 if (o->direction == ODR_DECODE)
1509 *p = odr_malloc(o, sizeof(**p));
1510 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
1512 if (o->direction == ODR_DECODE)
1514 return opt && odr_ok(o);