2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.47 1996-05-29 15:47:50 quinn
8 * Fixed in bug DiagRecs decoder. Thanks to Linda Harris.
10 * Revision 1.46 1996/04/10 11:39:42 quinn
11 * Fixed bug in UserInfo
13 * Revision 1.45 1996/02/23 10:00:25 quinn
16 * Revision 1.44 1996/02/20 12:51:41 quinn
17 * Completed SCAN. Fixed problems with EXTERNAL.
19 * Revision 1.43 1996/02/10 12:22:49 quinn
22 * Revision 1.42 1996/01/22 09:46:31 quinn
23 * Added Sort PDU. Moved StringList to main protocol file.
25 * Revision 1.41 1996/01/10 15:21:24 quinn
26 * Added links to access control PDUs
28 * Revision 1.40 1996/01/02 11:46:40 quinn
29 * Changed 'operator' to 'roperator' to avoid C++ conflict.
31 * Revision 1.39 1995/09/29 17:11:53 quinn
34 * Revision 1.38 1995/09/27 15:02:40 quinn
35 * Modified function heads & prototypes.
37 * Revision 1.37 1995/08/21 09:10:15 quinn
38 * Smallish fixes to suppport new formats.
40 * Revision 1.36 1995/08/15 11:59:39 quinn
43 * Revision 1.35 1995/08/10 08:53:59 quinn
46 * Revision 1.34 1995/06/19 17:01:48 quinn
47 * This should bring us in sync with the version distributed as 1.0b
49 * Revision 1.33 1995/06/19 13:39:56 quinn
50 * *** empty log message ***
52 * Revision 1.32 1995/06/19 12:37:28 quinn
53 * Fixed a bug in the compspec.
55 * Revision 1.31 1995/06/16 13:15:56 quinn
56 * Fixed Defaultdiagformat.
58 * Revision 1.30 1995/06/15 15:42:01 quinn
61 * Revision 1.29 1995/06/15 07:44:49 quinn
64 * Revision 1.28 1995/06/14 15:26:35 quinn
65 * *** empty log message ***
67 * Revision 1.27 1995/06/07 14:36:22 quinn
70 * Revision 1.26 1995/06/02 09:49:13 quinn
71 * Adding access control
73 * Revision 1.25 1995/05/25 11:00:08 quinn
74 * *** empty log message ***
76 * Revision 1.24 1995/05/22 13:58:18 quinn
77 * Fixed an ODR_NULLVAL.
79 * Revision 1.23 1995/05/22 11:30:18 quinn
80 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
82 * Revision 1.22 1995/05/17 08:40:56 quinn
83 * Added delete. Fixed some sequence_begins. Smallish.
85 * Revision 1.21 1995/05/16 08:50:24 quinn
86 * License, documentation, and memory fixes
88 * Revision 1.20 1995/05/15 11:55:25 quinn
91 * Revision 1.19 1995/04/11 11:58:35 quinn
94 * Revision 1.18 1995/04/11 11:52:02 quinn
95 * Fixed possible buf in proto.c
97 * Revision 1.17 1995/04/10 10:22:22 quinn
100 * Revision 1.16 1995/03/30 10:26:43 quinn
101 * Added Term structure
103 * Revision 1.15 1995/03/30 09:08:39 quinn
104 * Added Resource control protocol
106 * Revision 1.14 1995/03/29 08:06:13 quinn
107 * Added a few v3 elements
109 * Revision 1.13 1995/03/20 11:26:52 quinn
110 * *** empty log message ***
112 * Revision 1.12 1995/03/20 09:45:09 quinn
115 * Revision 1.11 1995/03/17 10:17:25 quinn
116 * Added memory management.
118 * Revision 1.10 1995/03/15 11:17:40 quinn
119 * Fixed some return-checks from choice.. need better ay to handle those..
121 * Revision 1.9 1995/03/15 08:37:06 quinn
122 * Fixed protocol bugs.
124 * Revision 1.8 1995/03/14 16:59:24 quinn
125 * Fixed OPTIONAL flag in attributeelement
127 * Revision 1.7 1995/03/07 16:29:33 quinn
128 * Added authentication stuff.
130 * Revision 1.6 1995/03/01 14:46:03 quinn
131 * Fixed protocol bug in 8777query.
133 * Revision 1.5 1995/02/14 11:54:22 quinn
136 * Revision 1.4 1995/02/10 15:54:30 quinn
139 * Revision 1.3 1995/02/09 15:51:39 quinn
142 * Revision 1.2 1995/02/06 21:26:07 quinn
143 * Repaired this evening's damages..
145 * Revision 1.1 1995/02/06 16:44:47 quinn
146 * First hack at Z/SR protocol
154 /* ---------------------- GLOBAL DEFS ------------------- */
157 * We'll use a general octetstring here, since string operations are
158 * clumsy on long strings.
160 int z_SUTRS(ODR o, Odr_oct **p, int opt)
162 return odr_implicit(o, odr_octetstring, p, ODR_UNIVERSAL,
163 ODR_GENERALSTRING, opt);
166 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
168 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
171 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
173 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
177 int z_ResultSetId(ODR o, char **p, int opt)
179 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
183 int z_ElementSetName(ODR o, char **p, int opt)
185 return odr_implicit(o, odr_visiblestring, p, ODR_CONTEXT, 103, opt);
188 int z_UserInformationField(ODR o, Z_External **p, int opt)
190 return odr_explicit(o, z_External, (Z_External **)p, ODR_CONTEXT,
194 int z_InternationalString(ODR o, char **p, int opt)
196 return odr_generalstring(o, p, opt);
199 int z_InfoCategory(ODR o, Z_InfoCategory **p, int opt)
201 if (!odr_sequence_begin(o, p, sizeof(**p)))
202 return opt && odr_ok(o);
204 odr_implicit(o, odr_oid, &(*p)->categoryTypeId, ODR_CONTEXT, 1, 1) &&
205 odr_implicit(o, odr_integer, &(*p)->categoryValue, ODR_CONTEXT, 2, 0) &&
209 int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt)
211 static Odr_arm arm[] =
213 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_OtherInfo_characterInfo,
215 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_OtherInfo_binaryInfo,
217 {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_OtherInfo_externallyDefinedInfo,
219 {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_OtherInfo_oid, odr_oid},
223 if (!odr_sequence_begin(o, p, sizeof(**p)))
224 return opt && odr_ok(o);
226 odr_implicit(o, z_InfoCategory, &(*p)->category, ODR_CONTEXT, 1, 1) &&
227 odr_choice(o, arm, &(*p)->information, &(*p)->which) &&
231 int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt)
233 if (o->direction == ODR_DECODE)
234 *p = odr_malloc(o, sizeof(**p));
237 odr_implicit_settag(o, ODR_CONTEXT, 201);
238 if (odr_sequence_of(o, z_OtherInformationUnit, &(*p)->list,
239 &(*p)->num_elements))
242 return opt && odr_ok(o);
245 int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt)
247 static Odr_arm arm[] =
249 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_StringOrNumeric_string,
251 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_StringOrNumeric_numeric,
256 if (o->direction == ODR_DECODE)
257 *p = odr_malloc(o, sizeof(**p));
260 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
263 return opt && odr_ok(o);
269 int z_Unit(ODR o, Z_Unit **p, int opt)
271 if (!odr_sequence_begin(o, p, sizeof(**p)))
272 return opt && odr_ok(o);
274 odr_implicit(o, odr_visiblestring, &(*p)->unitSystem, ODR_CONTEXT,
276 odr_explicit(o, z_StringOrNumeric, &(*p)->unitType, ODR_CONTEXT,
278 odr_explicit(o, z_StringOrNumeric, &(*p)->unit, ODR_CONTEXT, 3, 1) &&
279 odr_implicit(o, odr_integer, &(*p)->scaleFactor, ODR_CONTEXT, 4, 1) &&
283 int z_IntUnit(ODR o, Z_IntUnit **p, int opt)
285 if (!odr_sequence_begin(o, p, sizeof(**p)))
286 return opt && odr_ok(o);
288 odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 1, 0) &&
289 odr_implicit(o, z_Unit, &(*p)->unitUsed, ODR_CONTEXT, 2, 0) &&
293 int z_StringList(ODR o, Z_StringList **p, int opt)
295 if (o->direction == ODR_DECODE)
296 *p = odr_malloc(o, sizeof(**p));
299 if (odr_sequence_of(o, z_InternationalString, &(*p)->strings,
303 return opt && odr_ok(o);
306 /* ---------------------- INITIALIZE SERVICE ------------------- */
309 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
311 if (!odr_sequence_begin(o, p, sizeof(**p)))
312 return opt && odr_ok(o);
314 odr_visiblestring(o, &(*p)->user, 0) &&
315 odr_visiblestring(o, &(*p)->password, 0) &&
316 odr_visiblestring(o, &(*p)->account, 0) &&
321 int z_IdPass(ODR o, Z_IdPass **p, int opt)
323 if (!odr_sequence_begin(o, p, sizeof(**p)))
324 return opt && odr_ok(o);
326 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 1) &&
327 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 1) &&
328 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
333 int z_StrAuthentication(ODR o, char **p, int opt)
335 return odr_visiblestring(o, p, opt);
338 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
340 static Odr_arm arm[] =
342 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
343 {-1, -1, -1, Z_IdAuthentication_idPass, z_IdPass},
344 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
345 {-1, -1, -1, Z_IdAuthentication_other, z_External},
349 if (o->direction == ODR_DECODE)
350 *p = odr_malloc(o, sizeof(**p));
354 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
357 return opt && odr_ok(o);
360 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
364 if (!odr_sequence_begin(o, p, sizeof(**p)))
365 return opt && odr_ok(o);
368 z_ReferenceId(o, &pp->referenceId, 1) &&
369 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
371 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
372 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
374 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
376 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
378 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
380 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
382 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
383 ODR_CONTEXT, 112, 1) &&
384 z_UserInformationField(o, &pp->userInformationField, 1) &&
386 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
391 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
395 if (!odr_sequence_begin(o, p, sizeof(**p)))
396 return opt && odr_ok(o);
399 z_ReferenceId(o, &pp->referenceId, 1) &&
400 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
402 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
403 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
405 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
407 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
408 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
410 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
412 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
413 ODR_CONTEXT, 112, 1) &&
414 z_UserInformationField(o, &pp->userInformationField, 1) &&
416 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
421 /* ------------------ RESOURCE CONTROL ----------------*/
423 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
426 if (!odr_sequence_begin(o, p, sizeof(**p)))
427 return opt && odr_ok(o);
429 z_ReferenceId(o, &(*p)->referenceId, 1) &&
430 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
432 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
433 ODR_CONTEXT, 47, 1) &&
434 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
437 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
442 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
444 if (!odr_sequence_begin(o, p, sizeof(**p)))
445 return opt && odr_ok(o);
447 z_ReferenceId(o, &(*p)->referenceId, 1) &&
448 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
449 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
451 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
452 ODR_CONTEXT, 41, 1) &&
453 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
455 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
456 ODR_CONTEXT, 43, 1) &&
458 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
463 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
465 if (!odr_sequence_begin(o, p, sizeof(**p)))
466 return opt && odr_ok(o);
468 z_ReferenceId(o, &(*p)->referenceId, 1) &&
469 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
470 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
473 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
478 /* ------------------------ SEARCH SERVICE ----------------------- */
480 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
482 if (!odr_sequence_begin(o, p, sizeof(**p)))
483 return opt && odr_ok(o);
485 z_DatabaseName(o, &(*p)->databaseName, 0) &&
486 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
490 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
492 if (o->direction == ODR_DECODE)
493 *p = odr_malloc(o, sizeof(**p));
497 odr_implicit_settag(o, ODR_CONTEXT, 1);
498 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
499 &(*p)->num_elements))
505 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
507 static Odr_arm arm[] =
509 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
511 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
516 if (o->direction == ODR_DECODE)
517 *p = odr_malloc(o, sizeof(**p));
519 return opt && odr_ok(o);
521 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
527 /* ----------------------- RPN QUERY -----------------------*/
529 int z_ComplexAttribute(ODR o, Z_ComplexAttribute **p, int opt)
531 if (!odr_sequence_begin(o, p, sizeof(**p)))
532 return opt && odr_ok(o);
534 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
535 odr_sequence_of(o, z_StringOrNumeric, &(*p)->list,
537 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
538 (odr_sequence_of(o, odr_integer, &(*p)->semanticAction,
539 &(*p)->num_semanticAction) || odr_ok(o)) &&
543 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
546 static Odr_arm arm[] =
548 {ODR_IMPLICIT, ODR_CONTEXT, 121, Z_AttributeValue_numeric,
550 {ODR_IMPLICIT, ODR_CONTEXT, 224, Z_AttributeValue_complex,
556 if (!odr_sequence_begin(o, p, sizeof(**p)))
557 return opt && odr_ok(o);
560 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 1, 1) &&
562 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
565 odr_choice(o, arm, &(*p)->value, &(*p)->which) &&
567 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
573 int z_Term(ODR o, Z_Term **p, int opt)
575 static Odr_arm arm[] =
577 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
578 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
579 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
581 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
582 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
583 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, z_External},
584 /* add intUnit here */
585 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
589 if (o->direction ==ODR_DECODE)
590 *p = odr_malloc(o, sizeof(**p));
593 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
596 return opt && odr_ok(o);
599 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
601 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
602 odr_sequence_begin(o, p, sizeof(**p))))
603 return opt && odr_ok(o);
605 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
606 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
607 &(*p)->num_attributes) &&
608 z_Term(o, &(*p)->term, 0) &&
612 int z_ResultSetPlusAttributes(ODR o, Z_ResultSetPlusAttributes **p, int opt)
614 if (!(odr_implicit_settag(o, ODR_CONTEXT, 214) &&
615 odr_sequence_begin(o, p, sizeof(**p))))
616 return opt && odr_ok(o);
618 z_ResultSetId(o, &(*p)->resultSet, 0) &&
619 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
620 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
621 &(*p)->num_attributes) &&
625 int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
627 static Odr_arm arm[] =
629 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, odr_integer},
630 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_private, odr_integer},
634 if (!odr_sequence_begin(o, p, sizeof(**p)))
635 return opt && odr_ok(o);
637 odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
638 odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
639 odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
640 odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
641 odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
642 odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
643 odr_constructed_end(o) &&
647 int z_Operator(ODR o, Z_Operator **p, int opt)
649 static Odr_arm arm[] =
651 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
652 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
653 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
654 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, z_ProximityOperator},
658 if (!*p && o->direction != ODR_DECODE)
660 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
661 return opt && odr_ok(o);
662 if (o->direction == ODR_DECODE)
663 *p = odr_malloc(o, sizeof(**p));
665 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
666 odr_constructed_end(o))
669 return opt && odr_ok(o);
672 int z_Operand(ODR o, Z_Operand **p, int opt)
674 static Odr_arm arm[] =
676 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
677 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
678 {-1, -1, -1, Z_Operand_resultAttr, z_ResultSetPlusAttributes},
682 if (o->direction == ODR_DECODE)
683 *p = odr_malloc(o, sizeof(**p));
686 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
689 return opt && odr_ok(o);
692 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
694 int z_Complex(ODR o, Z_Complex **p, int opt)
696 if (!odr_sequence_begin(o, p, sizeof(**p)))
697 return opt && odr_ok(o);
699 z_RPNStructure(o, &(*p)->s1, 0) &&
700 z_RPNStructure(o, &(*p)->s2, 0) &&
701 z_Operator(o, &(*p)->roperator, 0) &&
705 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
707 static Odr_arm arm[] =
709 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
710 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
714 if (o->direction == ODR_DECODE)
715 *p = odr_malloc(o, sizeof(**p));
718 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
721 return opt && odr_ok(o);
724 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
726 if (!odr_sequence_begin(o, p, sizeof(**p)))
727 return opt && odr_ok(o);
729 odr_oid(o, &(*p)->attributeSetId, 0) &&
730 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
734 /* -----------------------END RPN QUERY ----------------------- */
736 int z_Query(ODR o, Z_Query **p, int opt)
738 static Odr_arm arm[] =
740 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
741 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
742 {ODR_EXPLICIT, ODR_CONTEXT, 101, Z_Query_type_101, z_RPNQuery},
746 if (o->direction == ODR_DECODE)
747 *p = odr_malloc(o, sizeof(**p));
750 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
753 return opt && odr_ok(o);
756 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
760 if (!odr_sequence_begin(o, p, sizeof(**p)))
761 return opt && odr_ok(o);
764 z_ReferenceId(o, &pp->referenceId, 1) &&
765 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
767 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
769 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
771 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
772 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
774 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
775 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
776 &pp->num_databaseNames) &&
777 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
778 ODR_CONTEXT, 100, 1) &&
779 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
780 ODR_CONTEXT, 101, 1) &&
781 odr_implicit(o, odr_oid, &pp->preferredRecordSyntax,
782 ODR_CONTEXT, 104, 1) &&
783 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
785 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
786 ODR_CONTEXT, 203, 1) &&
787 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
792 /* ------------------------ RECORD ------------------------- */
794 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
796 return z_External(o, (Z_External **) p, opt);
801 int z_DefaultDiagFormat(ODR o, Z_DefaultDiagFormat **p, int opt)
803 static Odr_arm arm[] =
805 {-1, -1, -1, Z_DiagForm_v2AddInfo, odr_visiblestring},
806 {-1, -1, -1, Z_DiagForm_v3AddInfo, z_InternationalString},
807 {ODR_IMPLICIT, ODR_CONTEXT, ODR_VISIBLESTRING, Z_DiagForm_v2AddInfo,
808 odr_visiblestring}, /* To cater to a bug in the CNIDR servers */
811 if (!odr_sequence_begin(o, p, sizeof(**p)))
812 return opt && odr_ok(o);
814 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
815 odr_integer(o, &(*p)->condition, 0) &&
817 * I no longer recall what server tagged the addinfo.. but it isn't
818 * hurting anyone, so...
819 * We need to turn it into a choice, or something, because of
820 * that damn generalstring in v3.
822 odr_choice(o, arm, &(*p)->addinfo, &(*p)->which) &&
826 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
828 static Odr_arm arm[] =
830 {-1, -1, -1, Z_DiagRec_defaultFormat, z_DefaultDiagFormat},
831 {-1, -1, -1, Z_DiagRec_externallyDefined, z_External},
835 if (o->direction == ODR_DECODE)
836 *p = odr_malloc(o, sizeof(**p));
839 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
842 return opt && odr_ok(o);
847 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
849 if (!odr_sequence_begin(o, p, sizeof(**p)))
850 return opt && odr_ok(o);
852 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
853 odr_integer(o, &(*p)->condition, 0) &&
855 * I no longer recall what server tagged the addinfo.. but it isn't
856 * hurting anyone, so...
857 * We need to turn it into a choice, or something, because of
858 * that damn generalstring in v3.
860 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
861 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT,
862 ODR_VISIBLESTRING, 1)) &&
868 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
870 if (o->direction == ODR_DECODE)
871 *p = odr_malloc(o, sizeof(**p));
875 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
876 &(*p)->num_diagRecs))
879 return opt && odr_ok(o);
882 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
884 static Odr_arm arm[] =
886 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
888 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
893 if (!odr_sequence_begin(o, p, sizeof(**p)))
894 return opt && odr_ok(o);
896 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
898 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
899 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
900 odr_constructed_end(o) &&
904 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
906 if (o->direction == ODR_DECODE)
907 *p = odr_malloc(o, sizeof(**p));
910 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
917 int z_Records(ODR o, Z_Records **p, int opt)
919 static Odr_arm arm[] =
921 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
922 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
923 {ODR_IMPLICIT, ODR_CONTEXT, 205, Z_Records_multipleNSD,
928 if (o->direction == ODR_DECODE)
929 *p = odr_malloc(o, sizeof(**p));
932 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
935 return opt && odr_ok(o);
938 /* ------------------------ ACCESS CTRL SERVICE ----------------------- */
940 int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
942 static Odr_arm arm[] =
944 {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
946 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
950 if (!odr_sequence_begin(o, p, sizeof(**p)))
951 return opt && odr_ok(o);
953 z_ReferenceId(o, &(*p)->referenceId, 1) &&
954 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
956 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
961 int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
963 static Odr_arm arm[] =
965 {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
967 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
971 if (!odr_sequence_begin(o, p, sizeof(**p)))
972 return opt && odr_ok(o);
974 z_ReferenceId(o, &(*p)->referenceId, 1) &&
975 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
976 odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
978 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
983 /* ------------------------ SCAN SERVICE -------------------- */
985 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
987 if (o->direction == ODR_DECODE)
988 *p = odr_malloc(o, sizeof(**p));
992 odr_implicit_settag(o, ODR_CONTEXT, 44);
993 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
994 &(*p)->num_attributes))
997 return opt && odr_ok(o);
1001 * This is a temporary hack. We don't know just *what* old version of the
1002 * protocol willow uses, so we'll just patiently wait for them to update
1004 static int willow_scan = 0;
1006 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
1008 if (!*p && o->direction != ODR_DECODE)
1010 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
1013 return opt && odr_ok(o);
1015 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
1017 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
1019 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
1021 if (o->direction == ODR_DECODE)
1022 *p = odr_malloc(o, sizeof(**p));
1023 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
1024 &(*p)->num_attributes))
1026 if (!odr_sequence_end(o) || !odr_sequence_end(o))
1028 if (!z_Term(o, &(*p)->term, 0))
1030 if (!odr_constructed_end(o))
1036 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
1038 if (o->direction == ODR_DECODE)
1039 *p = odr_malloc(o, sizeof(**p));
1043 return opt && odr_ok(o);
1046 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
1050 return opt && !o->error;
1055 int z_ByDatabase(ODR o, Z_ByDatabase **p, int opt)
1057 if (!odr_sequence_begin(o, p, sizeof(**p)))
1058 return opt && odr_ok(o);
1060 z_DatabaseName(o, &(*p)->db, 1) &&
1061 odr_implicit(o, odr_integer, &(*p)->num, ODR_CONTEXT, 1, 1) &&
1062 z_OtherInformation(o, &(*p)->otherDbInfo, 1) &&
1063 odr_sequence_end(o);
1066 int z_ByDatabaseList(ODR o, Z_ByDatabaseList **p, int opt)
1068 if (!odr_initmember(o, p, sizeof(**p)))
1069 return opt && odr_ok(o);
1070 if (odr_sequence_of(o, z_ByDatabase, &(*p)->elements, &(*p)->num_elements))
1073 return opt && odr_ok(o);
1076 int z_ScanOccurrences(ODR o, Z_ScanOccurrences **p, int opt)
1080 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_ScanOccurrences_global, odr_integer},
1081 {ODR_EXPLICIT, ODR_CONTEXT, 3, Z_ScanOccurrences_byDatabase,
1086 if (!odr_initmember(o, p, sizeof(**p)))
1087 return opt && odr_ok(o);
1088 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1091 return opt && odr_ok(o);
1094 int z_OccurrenceByAttributesElem(ODR o, Z_OccurrenceByAttributesElem **p,
1097 if (!odr_sequence_begin(o, p, sizeof(**p)))
1098 return opt && odr_ok(o);
1100 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT,
1102 z_ScanOccurrences(o, &(*p)->occurrences, 1) &&
1103 z_OtherInformation(o, &(*p)->otherOccurInfo, 1) &&
1104 odr_sequence_end(o);
1107 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1109 if (!odr_initmember(o, p, sizeof(**p)))
1110 return opt && odr_ok(o);
1111 if (!odr_sequence_of(o, z_OccurrenceByAttributesElem, &(*p)->elements,
1112 &(*p)->num_elements))
1115 return opt && odr_ok(o);
1121 * Incomplete definition of occurencebyattributes.
1124 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1126 if (!odr_sequence_begin(o, p, sizeof(**p)))
1127 return opt && odr_ok(o);
1129 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
1130 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
1131 odr_sequence_end(o);
1136 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
1138 if (!odr_sequence_begin(o, p, sizeof(**p)))
1139 return opt && odr_ok(o);
1142 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
1143 z_Term(o, &(*p)->term, 0)) &&
1144 odr_implicit(o, z_InternationalString, &(*p)->displayTerm, ODR_CONTEXT,
1146 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
1147 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
1148 ODR_CONTEXT, 4, 1) &&
1149 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
1151 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
1152 ODR_CONTEXT, 3, 1) &&
1153 z_OtherInformation(o, &(*p)->otherTermInfo, 1) &&
1154 odr_sequence_end(o);
1157 int z_Entry(ODR o, Z_Entry **p, int opt)
1159 static Odr_arm arm[] =
1161 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
1162 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
1167 if (o->direction == ODR_DECODE)
1168 *p = odr_malloc(o, sizeof(**p));
1172 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1175 return opt && odr_ok(o);
1178 int z_Entries(ODR o, Z_Entries **p, int opt)
1180 if (o->direction == ODR_DECODE)
1181 *p = odr_malloc(o, sizeof(**p));
1185 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
1186 &(*p)->num_entries))
1192 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
1194 static Odr_arm arm[] =
1196 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
1197 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
1202 if (o->direction == ODR_DECODE)
1203 *p = odr_malloc(o, sizeof(**p));
1207 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1210 return opt && odr_ok(o);
1213 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
1215 if (!odr_sequence_begin(o, p, sizeof(**p)))
1216 return opt && odr_ok(o);
1219 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1220 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1221 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
1222 &(*p)->num_databaseNames) &&
1223 odr_oid(o, &(*p)->attributeSet, 1) &&
1224 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
1225 ((*p)->termListAndStartPoint ? 1 :
1226 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
1227 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
1228 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
1229 ODR_CONTEXT, 6, 0) &&
1230 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
1231 ODR_CONTEXT, 7, 1) &&
1232 odr_sequence_end(o);
1235 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
1237 if (!odr_sequence_begin(o, p, sizeof(**p)))
1238 return opt && odr_ok(o);
1240 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1241 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
1242 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
1243 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
1244 ODR_CONTEXT, 5, 0) &&
1245 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
1246 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
1247 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
1248 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1249 odr_sequence_end(o);
1252 /* ------------------------ SEARCHRESPONSE ----------------*/
1254 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
1256 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
1259 int z_NextResultSetPosition(ODR o, int **p, int opt)
1261 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
1264 int z_PresentStatus(ODR o, int **p, int opt)
1266 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
1269 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
1271 Z_SearchResponse *pp;
1273 if (!odr_sequence_begin(o, p, sizeof(**p)))
1274 return opt && odr_ok(o);
1277 z_ReferenceId(o, &pp->referenceId, 1) &&
1278 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
1279 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1280 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1281 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
1282 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26,
1284 z_PresentStatus(o, &pp->presentStatus, 1) &&
1285 z_Records(o, &pp->records, 1) &&
1287 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
1288 ODR_CONTEXT, 203, 1) &&
1289 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1291 odr_sequence_end(o);
1294 /* --------------------- PRESENT SERVICE ---------------------- */
1296 int z_ElementSpec(ODR o, Z_ElementSpec **p, int opt)
1298 static Odr_arm arm[] =
1300 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSpec_elementSetName,
1302 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ElementSpec_externalSpec,
1307 if (o->direction == ODR_DECODE)
1308 *p = odr_malloc(o, sizeof(**p));
1312 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1315 return opt && odr_ok(o);
1318 int z_Specification(ODR o, Z_Specification **p, int opt)
1320 if (!odr_sequence_begin(o, p, sizeof(**p)))
1321 return opt && odr_ok(o);
1323 odr_implicit(o, odr_oid, &(*p)->schema, ODR_CONTEXT, 1, 1) &&
1324 z_ElementSpec(o, &(*p)->elementSpec, 1) &&
1325 odr_sequence_end(o);
1328 int z_DbSpecific(ODR o, Z_DbSpecific **p, int opt)
1330 if (!odr_sequence_begin(o, p, sizeof(**p)))
1331 return opt && odr_ok(o);
1333 odr_explicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
1335 odr_implicit(o, z_Specification, &(*p)->spec, ODR_CONTEXT, 2, 0) &&
1336 odr_sequence_end(o);
1339 int z_CompSpec(ODR o, Z_CompSpec **p, int opt)
1341 if (!odr_sequence_begin(o, p, sizeof(**p)))
1342 return opt && odr_ok(o);
1344 odr_implicit(o, odr_bool, &(*p)->selectAlternativeSyntax, ODR_CONTEXT,
1346 odr_implicit(o, z_Specification, &(*p)->generic, ODR_CONTEXT, 2, 1) &&
1347 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1348 (odr_sequence_of(o, z_DbSpecific, &(*p)->dbSpecific,
1349 &(*p)->num_dbSpecific) || odr_ok(o)) &&
1350 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1351 (odr_sequence_of(o, odr_oid, &(*p)->recordSyntax,
1352 &(*p)->num_recordSyntax) || odr_ok(o)) &&
1353 odr_sequence_end(o);
1356 int z_RecordComposition(ODR o, Z_RecordComposition **p, int opt)
1358 static Odr_arm arm[] =
1360 {ODR_EXPLICIT, ODR_CONTEXT, 19, Z_RecordComp_simple,
1362 {ODR_IMPLICIT, ODR_CONTEXT, 209, Z_RecordComp_complex,
1367 if (o->direction == ODR_DECODE)
1368 *p = odr_malloc(o, sizeof(**p));
1372 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1375 return opt && odr_ok(o);
1378 int z_Range(ODR o, Z_Range **p, int opt)
1380 if (!odr_sequence_begin(o, p, sizeof(**p)))
1381 return opt && odr_ok(o);
1383 odr_implicit(o, odr_integer, &(*p)->startingPosition, ODR_CONTEXT,
1385 odr_implicit(o, odr_integer, &(*p)->numberOfRecords, ODR_CONTEXT,
1387 odr_sequence_end(o);
1390 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
1392 Z_PresentRequest *pp;
1394 if (!odr_sequence_begin(o, p, sizeof(**p)))
1395 return opt && odr_ok(o);
1398 z_ReferenceId(o, &pp->referenceId, 1) &&
1399 z_ResultSetId(o, &pp->resultSetId, 0) &&
1400 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
1402 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
1405 odr_implicit_settag(o, ODR_CONTEXT, 212) &&
1406 (odr_sequence_of(o, z_Range, &(*p)->additionalRanges,
1407 &(*p)->num_ranges) || odr_ok(o)) &&
1408 z_RecordComposition(o, &(*p)->recordComposition, 1) &&
1410 odr_explicit(o, z_ElementSetNames, &pp->elementSetNames, ODR_CONTEXT,
1413 odr_implicit(o, odr_oid, &(*p)->preferredRecordSyntax, ODR_CONTEXT,
1416 odr_implicit(o, odr_integer, &(*p)->maxSegmentCount, ODR_CONTEXT,
1418 odr_implicit(o, odr_integer, &(*p)->maxRecordSize, ODR_CONTEXT,
1420 odr_implicit(o, odr_integer, &(*p)->maxSegmentSize, ODR_CONTEXT,
1422 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1424 odr_sequence_end(o);
1427 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
1429 Z_PresentResponse *pp;
1431 if (!odr_sequence_begin(o, p, sizeof(**p)))
1432 return opt && odr_ok(o);
1435 z_ReferenceId(o, &pp->referenceId, 1) &&
1436 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1437 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1438 z_PresentStatus(o, &pp->presentStatus, 0) &&
1439 z_Records(o, &pp->records, 1) &&
1441 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1443 odr_sequence_end(o);
1446 /* ----------------------DELETE -------------------------- */
1448 int z_DeleteSetStatus(ODR o, int **p, int opt)
1450 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
1453 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
1455 if (!odr_sequence_begin(o, p, sizeof(**p)))
1456 return opt && odr_ok(o);
1458 z_ResultSetId(o, &(*p)->id, 0) &&
1459 z_DeleteSetStatus(o, &(*p)->status, 0) &&
1460 odr_sequence_end(o);
1463 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
1465 if (!odr_sequence_begin(o, p, sizeof(**p)))
1466 return opt && odr_ok(o);
1468 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1469 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
1471 (odr_sequence_of(o, z_ListStatus, &(*p)->resultSetList,
1472 &(*p)->num_ids) || odr_ok(o)) &&
1474 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1476 odr_sequence_end(o);
1479 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
1481 if (!odr_sequence_begin(o, p, sizeof(**p)))
1482 return opt && odr_ok(o);
1484 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1485 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
1486 ODR_CONTEXT, 0, 1) &&
1487 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
1488 (odr_sequence_of(o, z_ListStatus, &(*p)->deleteListStatuses,
1489 &(*p)->num_statuses) || odr_ok(o)) &&
1490 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
1492 odr_implicit_settag(o, ODR_CONTEXT, 35) &&
1493 (odr_sequence_of(o, z_ListStatus, &(*p)->bulkStatuses,
1494 &(*p)->num_bulkStatuses) || odr_ok(o)) &&
1495 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
1498 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1500 odr_sequence_end(o);
1503 /* ------------------------ SEGMENT SERVICE -------------- */
1505 int z_Segment(ODR o, Z_Segment **p, int opt)
1507 if (!odr_sequence_begin(o, p, sizeof(**p)))
1508 return opt && odr_ok(o);
1510 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1511 odr_implicit(o, odr_integer, &(*p)->numberOfRecordsReturned,
1512 ODR_CONTEXT, 24, 0) &&
1513 odr_implicit_settag(o, ODR_CONTEXT, 0) &&
1514 odr_sequence_of(o, z_NamePlusRecord, &(*p)->segmentRecords,
1515 &(*p)->num_segmentRecords) &&
1516 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1517 odr_sequence_end(o);
1520 /* ------------------------ CLOSE SERVICE ---------------- */
1522 int z_Close(ODR o, Z_Close **p, int opt)
1524 if (!odr_sequence_begin(o, p, sizeof(**p)))
1525 return opt && odr_ok(o);
1527 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1528 odr_implicit(o, odr_integer, &(*p)->closeReason, ODR_CONTEXT, 211, 0) &&
1529 odr_implicit(o, odr_visiblestring, &(*p)->diagnosticInformation,
1530 ODR_CONTEXT, 3, 1) &&
1531 odr_implicit(o, odr_oid, &(*p)->resourceReportFormat, ODR_CONTEXT,
1533 odr_implicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1536 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1538 odr_sequence_end(o);
1541 /* ------------------------ APDU ------------------------- */
1543 int z_Permissions(ODR o, Z_Permissions **p, int opt)
1545 if (!odr_sequence_begin(o, p, sizeof(**p)))
1546 return opt && odr_ok(o);
1548 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT,
1550 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
1551 odr_sequence_of(o, odr_integer, &(*p)->allowableFunctions,
1552 &(*p)->num_allowableFunctions) &&
1553 odr_sequence_end(o);
1556 int z_ExtendedServicesRequest(ODR o, Z_ExtendedServicesRequest **p, int opt)
1558 if (!odr_sequence_begin(o, p, sizeof(**p)))
1559 return opt && odr_ok(o);
1561 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1562 odr_implicit(o, odr_integer, &(*p)->function, ODR_CONTEXT, 3, 0) &&
1563 odr_implicit(o, odr_oid, &(*p)->packageType, ODR_CONTEXT, 4, 0) &&
1564 odr_implicit(o, z_InternationalString, &(*p)->packageName, ODR_CONTEXT, 5, 1) &&
1565 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT, 6, 1) &&
1566 odr_implicit(o, z_IntUnit, &(*p)->retentionTime, ODR_CONTEXT, 7, 1) &&
1567 odr_implicit(o, z_Permissions, &(*p)->permissions, ODR_CONTEXT, 8, 1) &&
1568 odr_implicit(o, z_InternationalString, &(*p)->description, ODR_CONTEXT, 9, 1) &&
1569 odr_implicit(o, z_External, &(*p)->taskSpecificParameters, ODR_CONTEXT, 10, 1) &&
1570 odr_implicit(o, odr_integer, &(*p)->waitAction, ODR_CONTEXT, 11, 0) &&
1571 z_ElementSetName(o, &(*p)->elements, 1) &&
1572 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1573 odr_sequence_end(o);
1576 int z_ExtendedServicesResponse(ODR o, Z_ExtendedServicesResponse **p, int opt)
1578 if (!odr_sequence_begin(o, p, sizeof(**p)))
1579 return opt && odr_ok(o);
1581 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1582 odr_implicit(o, odr_integer, &(*p)->operationStatus, ODR_CONTEXT, 3, 0) &&
1583 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1584 (odr_sequence_of(o, z_DiagRec, &(*p)->diagnostics,
1585 &(*p)->num_diagnostics) || odr_ok(o)) &&
1586 odr_implicit(o, z_External, &(*p)->taskPackage, ODR_CONTEXT, 5, 1) &&
1587 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1588 odr_sequence_end(o);
1591 /* ------------------------ SORT ------------------------- */
1593 int z_SortAttributes(ODR o, Z_SortAttributes **p, int opt)
1595 if (!odr_sequence_begin(o, p, sizeof(**p)))
1596 return opt && odr_ok(o);
1598 odr_oid(o, &(*p)->id, 0) &&
1599 z_AttributeList(o, &(*p)->list, 0) &&
1600 odr_sequence_end(o);
1603 int z_SortKey(ODR o, Z_SortKey **p, int opt)
1605 static Odr_arm arm[] =
1607 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_SortKey_sortField,
1608 z_InternationalString},
1609 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortKey_elementSpec, z_Specification},
1610 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortKey_sortAttributes,
1615 if (!odr_initmember(o, p, sizeof(**p)))
1616 return opt && odr_ok(o);
1617 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1620 return opt && odr_ok(o);
1623 int z_SortDbSpecific(ODR o, Z_SortDbSpecific **p, int opt)
1625 if (!odr_sequence_begin(o, p, sizeof(**p)))
1626 return opt && odr_ok(o);
1628 z_DatabaseName(o, &(*p)->databaseName, 0) &&
1629 z_SortKey(o, &(*p)->dbSort, 0) &&
1630 odr_sequence_end(o);
1633 int z_SortDbSpecificList(ODR o, Z_SortDbSpecificList **p, int opt)
1635 if (!odr_initmember(o, p, sizeof(**p)))
1636 return opt && odr_ok(o);
1637 if (odr_sequence_of(o, z_SortDbSpecific, &(*p)->dbSpecific,
1638 &(*p)->num_dbSpecific))
1641 return opt && odr_ok(o);
1644 int z_SortElement(ODR o, Z_SortElement **p, int opt)
1646 static Odr_arm arm[] =
1648 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_SortElement_generic, z_SortKey},
1649 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortElement_databaseSpecific,
1650 z_SortDbSpecificList},
1654 if (!odr_initmember(o, p, sizeof(**p)))
1655 return opt && odr_ok(o);
1656 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1659 return opt && odr_ok(o);
1662 int z_SortMissingValueAction(ODR o, Z_SortMissingValueAction **p, int opt)
1664 static Odr_arm arm[] =
1666 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortMissingValAct_abort, odr_null},
1667 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortMissingValAct_null, odr_null},
1668 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_SortMissingValAct_valData,
1673 if (!odr_initmember(o, p, sizeof(**p)))
1674 return opt && odr_ok(o);
1675 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1678 return opt && odr_ok(o);
1681 int z_SortKeySpec(ODR o, Z_SortKeySpec **p, int opt)
1683 if (!odr_sequence_begin(o, p, sizeof(**p)))
1684 return opt && odr_ok(o);
1686 z_SortElement(o, &(*p)->sortElement, 0) &&
1687 odr_implicit(o, odr_integer, &(*p)->sortRelation, ODR_CONTEXT, 1, 0) &&
1688 odr_implicit(o, odr_integer, &(*p)->caseSensitivity, ODR_CONTEXT,
1690 odr_explicit(o, z_SortMissingValueAction, &(*p)->missingValueAction,
1691 ODR_CONTEXT, 3, 1) &&
1692 odr_sequence_end(o);
1695 int z_SortResponse(ODR o, Z_SortResponse **p, int opt)
1697 if (!odr_sequence_begin(o, p, sizeof(**p)))
1698 return opt && odr_ok(o);
1700 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1701 odr_implicit(o, odr_integer, &(*p)->sortStatus, ODR_CONTEXT,
1703 odr_implicit(o, odr_integer, &(*p)->resultSetStatus, ODR_CONTEXT,
1705 odr_implicit(o, z_DiagRecs, &(*p)->diagnostics, ODR_CONTEXT, 5, 1) &&
1706 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1707 odr_sequence_end(o);
1710 int z_SortKeySpecList(ODR o, Z_SortKeySpecList **p, int opt)
1712 if (!odr_initmember(o, p, sizeof(**p)))
1713 return opt && odr_ok(o);
1714 if (odr_sequence_of(o, z_SortKeySpec, &(*p)->specs, &(*p)->num_specs))
1717 return opt && odr_ok(o);
1720 int z_SortRequest(ODR o, Z_SortRequest **p, int opt)
1722 if (!odr_sequence_begin(o, p, sizeof(**p)))
1723 return opt && odr_ok(o);
1725 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1726 odr_implicit(o, z_StringList, &(*p)->inputResultSetNames,
1727 ODR_CONTEXT, 3, 0) &&
1728 odr_implicit(o, z_InternationalString, &(*p)->sortedResultSetName,
1729 ODR_CONTEXT, 4, 0) &&
1730 odr_implicit(o, z_SortKeySpecList, &(*p)->sortSequence, ODR_CONTEXT,
1732 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1733 odr_sequence_end(o);
1736 /* ------------------------ APDU ------------------------- */
1738 int z_APDU(ODR o, Z_APDU **p, int opt)
1740 static Odr_arm arm[] =
1742 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
1743 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
1744 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
1745 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
1747 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
1749 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
1751 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
1752 z_DeleteResultSetRequest},
1753 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
1754 z_DeleteResultSetResponse},
1755 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_APDU_accessControlRequest,
1756 z_AccessControlRequest},
1757 {ODR_IMPLICIT, ODR_CONTEXT, 29, Z_APDU_accessControlResponse,
1758 z_AccessControlResponse},
1759 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
1760 z_ResourceControlRequest},
1761 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
1762 z_ResourceControlResponse},
1763 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
1764 z_TriggerResourceControlRequest},
1765 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
1766 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
1767 {ODR_IMPLICIT, ODR_CONTEXT, 43, Z_APDU_sortRequest, z_SortRequest},
1768 {ODR_IMPLICIT, ODR_CONTEXT, 44, Z_APDU_sortResponse, z_SortResponse},
1769 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_APDU_segmentRequest, z_Segment},
1770 {ODR_IMPLICIT, ODR_CONTEXT, 46, Z_APDU_extendedServicesRequest,
1771 z_ExtendedServicesRequest},
1772 {ODR_IMPLICIT, ODR_CONTEXT, 47, Z_APDU_extendedServicesResponse,
1773 z_ExtendedServicesResponse},
1774 {ODR_IMPLICIT, ODR_CONTEXT, 48, Z_APDU_close, z_Close},
1779 if (o->direction == ODR_DECODE)
1780 *p = odr_malloc(o, sizeof(**p));
1781 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
1783 if (o->direction == ODR_DECODE)
1785 return opt && odr_ok(o);