2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.53 1996-10-09 15:54:55 quinn
8 * Added SearchInfoReport
10 * Revision 1.52 1996/10/08 12:56:57 adam
11 * Bug fix: tagging of type 101 query.
13 * Revision 1.51 1996/07/26 14:07:21 quinn
16 * Revision 1.50 1996/07/26 13:36:15 quinn
19 * Revision 1.49 1996/07/06 19:58:28 quinn
20 * System headerfiles gathered in yconfig
22 * Revision 1.48 1996/06/10 08:53:33 quinn
23 * Added Summary,OPAC,ResourceReport
25 * Revision 1.47 1996/05/29 15:47:50 quinn
26 * Fixed in bug DiagRecs decoder. Thanks to Linda Harris.
28 * Revision 1.46 1996/04/10 11:39:42 quinn
29 * Fixed bug in UserInfo
31 * Revision 1.45 1996/02/23 10:00:25 quinn
34 * Revision 1.44 1996/02/20 12:51:41 quinn
35 * Completed SCAN. Fixed problems with EXTERNAL.
37 * Revision 1.43 1996/02/10 12:22:49 quinn
40 * Revision 1.42 1996/01/22 09:46:31 quinn
41 * Added Sort PDU. Moved StringList to main protocol file.
43 * Revision 1.41 1996/01/10 15:21:24 quinn
44 * Added links to access control PDUs
46 * Revision 1.40 1996/01/02 11:46:40 quinn
47 * Changed 'operator' to 'roperator' to avoid C++ conflict.
49 * Revision 1.39 1995/09/29 17:11:53 quinn
52 * Revision 1.38 1995/09/27 15:02:40 quinn
53 * Modified function heads & prototypes.
55 * Revision 1.37 1995/08/21 09:10:15 quinn
56 * Smallish fixes to suppport new formats.
58 * Revision 1.36 1995/08/15 11:59:39 quinn
61 * Revision 1.35 1995/08/10 08:53:59 quinn
64 * Revision 1.34 1995/06/19 17:01:48 quinn
65 * This should bring us in sync with the version distributed as 1.0b
67 * Revision 1.33 1995/06/19 13:39:56 quinn
68 * *** empty log message ***
70 * Revision 1.32 1995/06/19 12:37:28 quinn
71 * Fixed a bug in the compspec.
73 * Revision 1.31 1995/06/16 13:15:56 quinn
74 * Fixed Defaultdiagformat.
76 * Revision 1.30 1995/06/15 15:42:01 quinn
79 * Revision 1.29 1995/06/15 07:44:49 quinn
82 * Revision 1.28 1995/06/14 15:26:35 quinn
83 * *** empty log message ***
85 * Revision 1.27 1995/06/07 14:36:22 quinn
88 * Revision 1.26 1995/06/02 09:49:13 quinn
89 * Adding access control
91 * Revision 1.25 1995/05/25 11:00:08 quinn
92 * *** empty log message ***
94 * Revision 1.24 1995/05/22 13:58:18 quinn
95 * Fixed an ODR_NULLVAL.
97 * Revision 1.23 1995/05/22 11:30:18 quinn
98 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
100 * Revision 1.22 1995/05/17 08:40:56 quinn
101 * Added delete. Fixed some sequence_begins. Smallish.
103 * Revision 1.21 1995/05/16 08:50:24 quinn
104 * License, documentation, and memory fixes
106 * Revision 1.20 1995/05/15 11:55:25 quinn
109 * Revision 1.19 1995/04/11 11:58:35 quinn
112 * Revision 1.18 1995/04/11 11:52:02 quinn
113 * Fixed possible buf in proto.c
115 * Revision 1.17 1995/04/10 10:22:22 quinn
118 * Revision 1.16 1995/03/30 10:26:43 quinn
119 * Added Term structure
121 * Revision 1.15 1995/03/30 09:08:39 quinn
122 * Added Resource control protocol
124 * Revision 1.14 1995/03/29 08:06:13 quinn
125 * Added a few v3 elements
127 * Revision 1.13 1995/03/20 11:26:52 quinn
128 * *** empty log message ***
130 * Revision 1.12 1995/03/20 09:45:09 quinn
133 * Revision 1.11 1995/03/17 10:17:25 quinn
134 * Added memory management.
136 * Revision 1.10 1995/03/15 11:17:40 quinn
137 * Fixed some return-checks from choice.. need better ay to handle those..
139 * Revision 1.9 1995/03/15 08:37:06 quinn
140 * Fixed protocol bugs.
142 * Revision 1.8 1995/03/14 16:59:24 quinn
143 * Fixed OPTIONAL flag in attributeelement
145 * Revision 1.7 1995/03/07 16:29:33 quinn
146 * Added authentication stuff.
148 * Revision 1.6 1995/03/01 14:46:03 quinn
149 * Fixed protocol bug in 8777query.
151 * Revision 1.5 1995/02/14 11:54:22 quinn
154 * Revision 1.4 1995/02/10 15:54:30 quinn
157 * Revision 1.3 1995/02/09 15:51:39 quinn
160 * Revision 1.2 1995/02/06 21:26:07 quinn
161 * Repaired this evening's damages..
163 * Revision 1.1 1995/02/06 16:44:47 quinn
164 * First hack at Z/SR protocol
172 /* ---------------------- GLOBAL DEFS ------------------- */
175 * We'll use a general octetstring here, since string operations are
176 * clumsy on long strings.
178 int z_SUTRS(ODR o, Odr_oct **p, int opt)
180 return odr_implicit(o, odr_octetstring, p, ODR_UNIVERSAL,
181 ODR_GENERALSTRING, opt);
184 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
186 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
189 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
191 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
195 int z_ResultSetId(ODR o, char **p, int opt)
197 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
201 int z_ElementSetName(ODR o, char **p, int opt)
203 return odr_implicit(o, odr_visiblestring, p, ODR_CONTEXT, 103, opt);
206 int z_UserInformationField(ODR o, Z_External **p, int opt)
208 return odr_explicit(o, z_External, (Z_External **)p, ODR_CONTEXT,
212 int z_InternationalString(ODR o, char **p, int opt)
214 return odr_generalstring(o, p, opt);
217 int z_InfoCategory(ODR o, Z_InfoCategory **p, int opt)
219 if (!odr_sequence_begin(o, p, sizeof(**p)))
220 return opt && odr_ok(o);
222 odr_implicit(o, odr_oid, &(*p)->categoryTypeId, ODR_CONTEXT, 1, 1) &&
223 odr_implicit(o, odr_integer, &(*p)->categoryValue, ODR_CONTEXT, 2, 0) &&
227 int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt)
229 static Odr_arm arm[] =
231 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_OtherInfo_characterInfo,
233 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_OtherInfo_binaryInfo,
235 {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_OtherInfo_externallyDefinedInfo,
237 {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_OtherInfo_oid, odr_oid},
241 if (!odr_sequence_begin(o, p, sizeof(**p)))
242 return opt && odr_ok(o);
244 odr_implicit(o, z_InfoCategory, &(*p)->category, ODR_CONTEXT, 1, 1) &&
245 odr_choice(o, arm, &(*p)->information, &(*p)->which) &&
249 int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt)
251 if (o->direction == ODR_DECODE)
252 *p = odr_malloc(o, sizeof(**p));
255 odr_implicit_settag(o, ODR_CONTEXT, 201);
256 if (odr_sequence_of(o, z_OtherInformationUnit, &(*p)->list,
257 &(*p)->num_elements))
260 return opt && odr_ok(o);
263 int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt)
265 static Odr_arm arm[] =
267 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_StringOrNumeric_string,
269 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_StringOrNumeric_numeric,
274 if (o->direction == ODR_DECODE)
275 *p = odr_malloc(o, sizeof(**p));
278 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
281 return opt && odr_ok(o);
287 int z_Unit(ODR o, Z_Unit **p, int opt)
289 if (!odr_sequence_begin(o, p, sizeof(**p)))
290 return opt && odr_ok(o);
292 odr_explicit(o, z_InternationalString, &(*p)->unitSystem, ODR_CONTEXT,
294 odr_explicit(o, z_StringOrNumeric, &(*p)->unitType, ODR_CONTEXT,
296 odr_explicit(o, z_StringOrNumeric, &(*p)->unit, ODR_CONTEXT, 3, 1) &&
297 odr_implicit(o, odr_integer, &(*p)->scaleFactor, ODR_CONTEXT, 4, 1) &&
301 int z_IntUnit(ODR o, Z_IntUnit **p, int opt)
303 if (!odr_sequence_begin(o, p, sizeof(**p)))
304 return opt && odr_ok(o);
306 odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 1, 0) &&
307 odr_implicit(o, z_Unit, &(*p)->unitUsed, ODR_CONTEXT, 2, 0) &&
311 int z_StringList(ODR o, Z_StringList **p, int opt)
313 if (o->direction == ODR_DECODE)
314 *p = odr_malloc(o, sizeof(**p));
317 if (odr_sequence_of(o, z_InternationalString, &(*p)->strings,
321 return opt && odr_ok(o);
324 /* ---------------------- INITIALIZE SERVICE ------------------- */
327 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
329 if (!odr_sequence_begin(o, p, sizeof(**p)))
330 return opt && odr_ok(o);
332 odr_visiblestring(o, &(*p)->user, 0) &&
333 odr_visiblestring(o, &(*p)->password, 0) &&
334 odr_visiblestring(o, &(*p)->account, 0) &&
339 int z_IdPass(ODR o, Z_IdPass **p, int opt)
341 if (!odr_sequence_begin(o, p, sizeof(**p)))
342 return opt && odr_ok(o);
344 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 1) &&
345 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 1) &&
346 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
351 int z_StrAuthentication(ODR o, char **p, int opt)
353 return odr_visiblestring(o, p, opt);
356 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
358 static Odr_arm arm[] =
360 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
361 {-1, -1, -1, Z_IdAuthentication_idPass, z_IdPass},
362 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
363 {-1, -1, -1, Z_IdAuthentication_other, z_External},
367 if (o->direction == ODR_DECODE)
368 *p = odr_malloc(o, sizeof(**p));
372 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
375 return opt && odr_ok(o);
378 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
382 if (!odr_sequence_begin(o, p, sizeof(**p)))
383 return opt && odr_ok(o);
386 z_ReferenceId(o, &pp->referenceId, 1) &&
387 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
389 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
390 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
392 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
394 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
396 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
398 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
400 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
401 ODR_CONTEXT, 112, 1) &&
402 z_UserInformationField(o, &pp->userInformationField, 1) &&
404 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
409 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
413 if (!odr_sequence_begin(o, p, sizeof(**p)))
414 return opt && odr_ok(o);
417 z_ReferenceId(o, &pp->referenceId, 1) &&
418 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
420 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
421 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
423 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
425 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
426 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
428 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
430 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
431 ODR_CONTEXT, 112, 1) &&
432 z_UserInformationField(o, &pp->userInformationField, 1) &&
434 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
439 /* ------------------ RESOURCE CONTROL ----------------*/
441 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
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_integer, &(*p)->requestedAction, ODR_CONTEXT,
450 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
451 ODR_CONTEXT, 47, 1) &&
452 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
455 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
460 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
462 if (!odr_sequence_begin(o, p, sizeof(**p)))
463 return opt && odr_ok(o);
465 z_ReferenceId(o, &(*p)->referenceId, 1) &&
466 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
467 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
469 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
470 ODR_CONTEXT, 41, 1) &&
471 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
473 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
474 ODR_CONTEXT, 43, 1) &&
476 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
481 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
483 if (!odr_sequence_begin(o, p, sizeof(**p)))
484 return opt && odr_ok(o);
486 z_ReferenceId(o, &(*p)->referenceId, 1) &&
487 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
488 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
491 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
496 /* ------------------------ SEARCH SERVICE ----------------------- */
498 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
500 if (!odr_sequence_begin(o, p, sizeof(**p)))
501 return opt && odr_ok(o);
503 z_DatabaseName(o, &(*p)->databaseName, 0) &&
504 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
508 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
510 if (o->direction == ODR_DECODE)
511 *p = odr_malloc(o, sizeof(**p));
515 odr_implicit_settag(o, ODR_CONTEXT, 1);
516 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
517 &(*p)->num_elements))
523 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
525 static Odr_arm arm[] =
527 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
529 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
534 if (o->direction == ODR_DECODE)
535 *p = odr_malloc(o, sizeof(**p));
537 return opt && odr_ok(o);
539 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
545 /* ----------------------- RPN QUERY -----------------------*/
547 int z_ComplexAttribute(ODR o, Z_ComplexAttribute **p, int opt)
549 if (!odr_sequence_begin(o, p, sizeof(**p)))
550 return opt && odr_ok(o);
552 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
553 odr_sequence_of(o, z_StringOrNumeric, &(*p)->list,
555 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
556 (odr_sequence_of(o, odr_integer, &(*p)->semanticAction,
557 &(*p)->num_semanticAction) || odr_ok(o)) &&
561 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
564 static Odr_arm arm[] =
566 {ODR_IMPLICIT, ODR_CONTEXT, 121, Z_AttributeValue_numeric,
568 {ODR_IMPLICIT, ODR_CONTEXT, 224, Z_AttributeValue_complex,
574 if (!odr_sequence_begin(o, p, sizeof(**p)))
575 return opt && odr_ok(o);
578 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 1, 1) &&
580 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
583 odr_choice(o, arm, &(*p)->value, &(*p)->which) &&
585 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
591 int z_Term(ODR o, Z_Term **p, int opt)
593 static Odr_arm arm[] =
595 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
596 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
597 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
599 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
600 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
601 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, z_External},
602 /* add intUnit here */
603 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
607 if (o->direction ==ODR_DECODE)
608 *p = odr_malloc(o, sizeof(**p));
611 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
614 return opt && odr_ok(o);
617 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
619 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
620 odr_sequence_begin(o, p, sizeof(**p))))
621 return opt && odr_ok(o);
623 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
624 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
625 &(*p)->num_attributes) &&
626 z_Term(o, &(*p)->term, 0) &&
630 int z_ResultSetPlusAttributes(ODR o, Z_ResultSetPlusAttributes **p, int opt)
632 if (!(odr_implicit_settag(o, ODR_CONTEXT, 214) &&
633 odr_sequence_begin(o, p, sizeof(**p))))
634 return opt && odr_ok(o);
636 z_ResultSetId(o, &(*p)->resultSet, 0) &&
637 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
638 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
639 &(*p)->num_attributes) &&
643 int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
645 static Odr_arm arm[] =
647 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, odr_integer},
648 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_private, odr_integer},
652 if (!odr_sequence_begin(o, p, sizeof(**p)))
653 return opt && odr_ok(o);
655 odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
656 odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
657 odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
658 odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
659 odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
660 odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
661 odr_constructed_end(o) &&
665 int z_Operator(ODR o, Z_Operator **p, int opt)
667 static Odr_arm arm[] =
669 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
670 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
671 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
672 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, z_ProximityOperator},
676 if (!*p && o->direction != ODR_DECODE)
678 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
679 return opt && odr_ok(o);
680 if (o->direction == ODR_DECODE)
681 *p = odr_malloc(o, sizeof(**p));
683 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
684 odr_constructed_end(o))
687 return opt && odr_ok(o);
690 int z_Operand(ODR o, Z_Operand **p, int opt)
692 static Odr_arm arm[] =
694 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
695 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
696 {-1, -1, -1, Z_Operand_resultAttr, z_ResultSetPlusAttributes},
700 if (o->direction == ODR_DECODE)
701 *p = odr_malloc(o, sizeof(**p));
704 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
707 return opt && odr_ok(o);
710 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
712 int z_Complex(ODR o, Z_Complex **p, int opt)
714 if (!odr_sequence_begin(o, p, sizeof(**p)))
715 return opt && odr_ok(o);
717 z_RPNStructure(o, &(*p)->s1, 0) &&
718 z_RPNStructure(o, &(*p)->s2, 0) &&
719 z_Operator(o, &(*p)->roperator, 0) &&
723 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
725 static Odr_arm arm[] =
727 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
728 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
732 if (o->direction == ODR_DECODE)
733 *p = odr_malloc(o, sizeof(**p));
736 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
739 return opt && odr_ok(o);
742 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
744 if (!odr_sequence_begin(o, p, sizeof(**p)))
745 return opt && odr_ok(o);
747 odr_oid(o, &(*p)->attributeSetId, 0) &&
748 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
752 /* -----------------------END RPN QUERY ----------------------- */
754 int z_Query(ODR o, Z_Query **p, int opt)
756 static Odr_arm arm[] =
758 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
759 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
760 {ODR_IMPLICIT, ODR_CONTEXT, 101, Z_Query_type_101, z_RPNQuery},
764 if (o->direction == ODR_DECODE)
765 *p = odr_malloc(o, sizeof(**p));
768 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
771 return opt && odr_ok(o);
774 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
778 if (!odr_sequence_begin(o, p, sizeof(**p)))
779 return opt && odr_ok(o);
782 z_ReferenceId(o, &pp->referenceId, 1) &&
783 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
785 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
787 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
789 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
790 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
792 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
793 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
794 &pp->num_databaseNames) &&
795 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
796 ODR_CONTEXT, 100, 1) &&
797 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
798 ODR_CONTEXT, 101, 1) &&
799 odr_implicit(o, odr_oid, &pp->preferredRecordSyntax,
800 ODR_CONTEXT, 104, 1) &&
801 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
803 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
804 ODR_CONTEXT, 203, 1) &&
805 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
810 /* ------------------------ RECORD ------------------------- */
812 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
814 return z_External(o, (Z_External **) p, opt);
819 int z_DefaultDiagFormat(ODR o, Z_DefaultDiagFormat **p, int opt)
821 static Odr_arm arm[] =
823 {-1, -1, -1, Z_DiagForm_v2AddInfo, odr_visiblestring},
824 {-1, -1, -1, Z_DiagForm_v3AddInfo, z_InternationalString},
825 {ODR_IMPLICIT, ODR_CONTEXT, ODR_VISIBLESTRING, Z_DiagForm_v2AddInfo,
826 odr_visiblestring}, /* To cater to a bug in the CNIDR servers */
829 if (!odr_sequence_begin(o, p, sizeof(**p)))
830 return opt && odr_ok(o);
832 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
833 odr_integer(o, &(*p)->condition, 0) &&
835 * I no longer recall what server tagged the addinfo.. but it isn't
836 * hurting anyone, so...
837 * We need to turn it into a choice, or something, because of
838 * that damn generalstring in v3.
840 odr_choice(o, arm, &(*p)->addinfo, &(*p)->which) &&
844 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
846 static Odr_arm arm[] =
848 {-1, -1, -1, Z_DiagRec_defaultFormat, z_DefaultDiagFormat},
849 {-1, -1, -1, Z_DiagRec_externallyDefined, z_External},
853 if (o->direction == ODR_DECODE)
854 *p = odr_malloc(o, sizeof(**p));
857 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
860 return opt && odr_ok(o);
865 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
867 if (!odr_sequence_begin(o, p, sizeof(**p)))
868 return opt && odr_ok(o);
870 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
871 odr_integer(o, &(*p)->condition, 0) &&
873 * I no longer recall what server tagged the addinfo.. but it isn't
874 * hurting anyone, so...
875 * We need to turn it into a choice, or something, because of
876 * that damn generalstring in v3.
878 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
879 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT,
880 ODR_VISIBLESTRING, 1)) &&
886 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
888 if (o->direction == ODR_DECODE)
889 *p = odr_malloc(o, sizeof(**p));
893 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
894 &(*p)->num_diagRecs))
897 return opt && odr_ok(o);
900 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
902 static Odr_arm arm[] =
904 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
906 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
911 if (!odr_sequence_begin(o, p, sizeof(**p)))
912 return opt && odr_ok(o);
914 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
916 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
917 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
918 odr_constructed_end(o) &&
922 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
924 if (o->direction == ODR_DECODE)
925 *p = odr_malloc(o, sizeof(**p));
928 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
935 int z_Records(ODR o, Z_Records **p, int opt)
937 static Odr_arm arm[] =
939 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
940 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
941 {ODR_IMPLICIT, ODR_CONTEXT, 205, Z_Records_multipleNSD,
946 if (o->direction == ODR_DECODE)
947 *p = odr_malloc(o, sizeof(**p));
950 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
953 return opt && odr_ok(o);
956 /* ------------------------ ACCESS CTRL SERVICE ----------------------- */
958 int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
960 static Odr_arm arm[] =
962 {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
964 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
968 if (!odr_sequence_begin(o, p, sizeof(**p)))
969 return opt && odr_ok(o);
971 z_ReferenceId(o, &(*p)->referenceId, 1) &&
972 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
974 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
979 int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
981 static Odr_arm arm[] =
983 {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
985 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
989 if (!odr_sequence_begin(o, p, sizeof(**p)))
990 return opt && odr_ok(o);
992 z_ReferenceId(o, &(*p)->referenceId, 1) &&
993 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
994 odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
996 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1001 /* ------------------------ SCAN SERVICE -------------------- */
1003 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
1005 if (o->direction == ODR_DECODE)
1006 *p = odr_malloc(o, sizeof(**p));
1010 odr_implicit_settag(o, ODR_CONTEXT, 44);
1011 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
1012 &(*p)->num_attributes))
1015 return opt && odr_ok(o);
1019 * This is a temporary hack. We don't know just *what* old version of the
1020 * protocol willow uses, so we'll just patiently wait for them to update
1022 static int willow_scan = 0;
1024 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
1026 if (!*p && o->direction != ODR_DECODE)
1028 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
1031 return opt && odr_ok(o);
1033 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
1035 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
1037 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
1039 if (o->direction == ODR_DECODE)
1040 *p = odr_malloc(o, sizeof(**p));
1041 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
1042 &(*p)->num_attributes))
1044 if (!odr_sequence_end(o) || !odr_sequence_end(o))
1046 if (!z_Term(o, &(*p)->term, 0))
1048 if (!odr_constructed_end(o))
1054 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
1056 if (o->direction == ODR_DECODE)
1057 *p = odr_malloc(o, sizeof(**p));
1061 return opt && odr_ok(o);
1064 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
1068 return opt && !o->error;
1073 int z_ByDatabase(ODR o, Z_ByDatabase **p, int opt)
1075 if (!odr_sequence_begin(o, p, sizeof(**p)))
1076 return opt && odr_ok(o);
1078 z_DatabaseName(o, &(*p)->db, 1) &&
1079 odr_implicit(o, odr_integer, &(*p)->num, ODR_CONTEXT, 1, 1) &&
1080 z_OtherInformation(o, &(*p)->otherDbInfo, 1) &&
1081 odr_sequence_end(o);
1084 int z_ByDatabaseList(ODR o, Z_ByDatabaseList **p, int opt)
1086 if (!odr_initmember(o, p, sizeof(**p)))
1087 return opt && odr_ok(o);
1088 if (odr_sequence_of(o, z_ByDatabase, &(*p)->elements, &(*p)->num_elements))
1091 return opt && odr_ok(o);
1094 int z_ScanOccurrences(ODR o, Z_ScanOccurrences **p, int opt)
1098 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_ScanOccurrences_global, odr_integer},
1099 {ODR_EXPLICIT, ODR_CONTEXT, 3, Z_ScanOccurrences_byDatabase,
1104 if (!odr_initmember(o, p, sizeof(**p)))
1105 return opt && odr_ok(o);
1106 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1109 return opt && odr_ok(o);
1112 int z_OccurrenceByAttributesElem(ODR o, Z_OccurrenceByAttributesElem **p,
1115 if (!odr_sequence_begin(o, p, sizeof(**p)))
1116 return opt && odr_ok(o);
1118 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT,
1120 z_ScanOccurrences(o, &(*p)->occurrences, 1) &&
1121 z_OtherInformation(o, &(*p)->otherOccurInfo, 1) &&
1122 odr_sequence_end(o);
1125 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1127 if (!odr_initmember(o, p, sizeof(**p)))
1128 return opt && odr_ok(o);
1129 if (!odr_sequence_of(o, z_OccurrenceByAttributesElem, &(*p)->elements,
1130 &(*p)->num_elements))
1133 return opt && odr_ok(o);
1139 * Incomplete definition of occurencebyattributes.
1142 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1144 if (!odr_sequence_begin(o, p, sizeof(**p)))
1145 return opt && odr_ok(o);
1147 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
1148 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
1149 odr_sequence_end(o);
1154 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
1156 if (!odr_sequence_begin(o, p, sizeof(**p)))
1157 return opt && odr_ok(o);
1160 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
1161 z_Term(o, &(*p)->term, 0)) &&
1162 odr_implicit(o, z_InternationalString, &(*p)->displayTerm, ODR_CONTEXT,
1164 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
1165 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
1166 ODR_CONTEXT, 4, 1) &&
1167 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
1169 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
1170 ODR_CONTEXT, 3, 1) &&
1171 z_OtherInformation(o, &(*p)->otherTermInfo, 1) &&
1172 odr_sequence_end(o);
1175 int z_Entry(ODR o, Z_Entry **p, int opt)
1177 static Odr_arm arm[] =
1179 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
1180 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
1185 if (o->direction == ODR_DECODE)
1186 *p = odr_malloc(o, sizeof(**p));
1190 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1193 return opt && odr_ok(o);
1196 int z_Entries(ODR o, Z_Entries **p, int opt)
1198 if (o->direction == ODR_DECODE)
1199 *p = odr_malloc(o, sizeof(**p));
1203 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
1204 &(*p)->num_entries))
1210 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
1212 static Odr_arm arm[] =
1214 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
1215 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
1220 if (o->direction == ODR_DECODE)
1221 *p = odr_malloc(o, sizeof(**p));
1225 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1228 return opt && odr_ok(o);
1231 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
1233 if (!odr_sequence_begin(o, p, sizeof(**p)))
1234 return opt && odr_ok(o);
1237 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1238 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1239 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
1240 &(*p)->num_databaseNames) &&
1241 odr_oid(o, &(*p)->attributeSet, 1) &&
1242 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
1243 ((*p)->termListAndStartPoint ? 1 :
1244 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
1245 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
1246 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
1247 ODR_CONTEXT, 6, 0) &&
1248 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
1249 ODR_CONTEXT, 7, 1) &&
1250 odr_sequence_end(o);
1253 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
1255 if (!odr_sequence_begin(o, p, sizeof(**p)))
1256 return opt && odr_ok(o);
1258 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1259 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
1260 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
1261 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
1262 ODR_CONTEXT, 5, 0) &&
1263 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
1264 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
1265 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
1266 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1267 odr_sequence_end(o);
1270 /* ------------------------ SEARCHRESPONSE ----------------*/
1272 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
1274 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
1277 int z_NextResultSetPosition(ODR o, int **p, int opt)
1279 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
1282 int z_PresentStatus(ODR o, int **p, int opt)
1284 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
1287 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
1289 Z_SearchResponse *pp;
1291 if (!odr_sequence_begin(o, p, sizeof(**p)))
1292 return opt && odr_ok(o);
1295 z_ReferenceId(o, &pp->referenceId, 1) &&
1296 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
1297 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1298 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1299 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
1300 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26,
1302 z_PresentStatus(o, &pp->presentStatus, 1) &&
1303 z_Records(o, &pp->records, 1) &&
1305 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
1306 ODR_CONTEXT, 203, 1) &&
1307 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1309 odr_sequence_end(o);
1312 /* --------------------- PRESENT SERVICE ---------------------- */
1314 int z_ElementSpec(ODR o, Z_ElementSpec **p, int opt)
1316 static Odr_arm arm[] =
1318 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSpec_elementSetName,
1320 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ElementSpec_externalSpec,
1325 if (o->direction == ODR_DECODE)
1326 *p = odr_malloc(o, sizeof(**p));
1330 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1333 return opt && odr_ok(o);
1336 int z_Specification(ODR o, Z_Specification **p, int opt)
1338 if (!odr_sequence_begin(o, p, sizeof(**p)))
1339 return opt && odr_ok(o);
1341 odr_implicit(o, odr_oid, &(*p)->schema, ODR_CONTEXT, 1, 1) &&
1342 z_ElementSpec(o, &(*p)->elementSpec, 1) &&
1343 odr_sequence_end(o);
1346 int z_DbSpecific(ODR o, Z_DbSpecific **p, int opt)
1348 if (!odr_sequence_begin(o, p, sizeof(**p)))
1349 return opt && odr_ok(o);
1351 odr_explicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
1353 odr_implicit(o, z_Specification, &(*p)->spec, ODR_CONTEXT, 2, 0) &&
1354 odr_sequence_end(o);
1357 int z_CompSpec(ODR o, Z_CompSpec **p, int opt)
1359 if (!odr_sequence_begin(o, p, sizeof(**p)))
1360 return opt && odr_ok(o);
1362 odr_implicit(o, odr_bool, &(*p)->selectAlternativeSyntax, ODR_CONTEXT,
1364 odr_implicit(o, z_Specification, &(*p)->generic, ODR_CONTEXT, 2, 1) &&
1365 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1366 (odr_sequence_of(o, z_DbSpecific, &(*p)->dbSpecific,
1367 &(*p)->num_dbSpecific) || odr_ok(o)) &&
1368 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1369 (odr_sequence_of(o, odr_oid, &(*p)->recordSyntax,
1370 &(*p)->num_recordSyntax) || odr_ok(o)) &&
1371 odr_sequence_end(o);
1374 int z_RecordComposition(ODR o, Z_RecordComposition **p, int opt)
1376 static Odr_arm arm[] =
1378 {ODR_EXPLICIT, ODR_CONTEXT, 19, Z_RecordComp_simple,
1380 {ODR_IMPLICIT, ODR_CONTEXT, 209, Z_RecordComp_complex,
1385 if (o->direction == ODR_DECODE)
1386 *p = odr_malloc(o, sizeof(**p));
1390 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1393 return opt && odr_ok(o);
1396 int z_Range(ODR o, Z_Range **p, int opt)
1398 if (!odr_sequence_begin(o, p, sizeof(**p)))
1399 return opt && odr_ok(o);
1401 odr_implicit(o, odr_integer, &(*p)->startingPosition, ODR_CONTEXT,
1403 odr_implicit(o, odr_integer, &(*p)->numberOfRecords, ODR_CONTEXT,
1405 odr_sequence_end(o);
1408 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
1410 Z_PresentRequest *pp;
1412 if (!odr_sequence_begin(o, p, sizeof(**p)))
1413 return opt && odr_ok(o);
1416 z_ReferenceId(o, &pp->referenceId, 1) &&
1417 z_ResultSetId(o, &pp->resultSetId, 0) &&
1418 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
1420 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
1423 odr_implicit_settag(o, ODR_CONTEXT, 212) &&
1424 (odr_sequence_of(o, z_Range, &(*p)->additionalRanges,
1425 &(*p)->num_ranges) || odr_ok(o)) &&
1426 z_RecordComposition(o, &(*p)->recordComposition, 1) &&
1428 odr_explicit(o, z_ElementSetNames, &pp->elementSetNames, ODR_CONTEXT,
1431 odr_implicit(o, odr_oid, &(*p)->preferredRecordSyntax, ODR_CONTEXT,
1434 odr_implicit(o, odr_integer, &(*p)->maxSegmentCount, ODR_CONTEXT,
1436 odr_implicit(o, odr_integer, &(*p)->maxRecordSize, ODR_CONTEXT,
1438 odr_implicit(o, odr_integer, &(*p)->maxSegmentSize, ODR_CONTEXT,
1440 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1442 odr_sequence_end(o);
1445 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
1447 Z_PresentResponse *pp;
1449 if (!odr_sequence_begin(o, p, sizeof(**p)))
1450 return opt && odr_ok(o);
1453 z_ReferenceId(o, &pp->referenceId, 1) &&
1454 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1455 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1456 z_PresentStatus(o, &pp->presentStatus, 0) &&
1457 z_Records(o, &pp->records, 1) &&
1459 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1461 odr_sequence_end(o);
1464 /* ----------------------DELETE -------------------------- */
1466 int z_DeleteSetStatus(ODR o, int **p, int opt)
1468 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
1471 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
1473 if (!odr_sequence_begin(o, p, sizeof(**p)))
1474 return opt && odr_ok(o);
1476 z_ResultSetId(o, &(*p)->id, 0) &&
1477 z_DeleteSetStatus(o, &(*p)->status, 0) &&
1478 odr_sequence_end(o);
1481 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
1483 if (!odr_sequence_begin(o, p, sizeof(**p)))
1484 return opt && odr_ok(o);
1486 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1487 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
1489 (odr_sequence_of(o, z_ResultSetId, &(*p)->resultSetList,
1490 &(*p)->num_ids) || odr_ok(o)) &&
1492 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1494 odr_sequence_end(o);
1497 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
1499 if (!odr_sequence_begin(o, p, sizeof(**p)))
1500 return opt && odr_ok(o);
1502 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1503 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
1504 ODR_CONTEXT, 0, 1) &&
1505 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
1506 (odr_sequence_of(o, z_ListStatus, &(*p)->deleteListStatuses,
1507 &(*p)->num_statuses) || odr_ok(o)) &&
1508 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
1510 odr_implicit_settag(o, ODR_CONTEXT, 35) &&
1511 (odr_sequence_of(o, z_ListStatus, &(*p)->bulkStatuses,
1512 &(*p)->num_bulkStatuses) || odr_ok(o)) &&
1513 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
1516 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1518 odr_sequence_end(o);
1521 /* ------------------------ SEGMENT SERVICE -------------- */
1523 int z_Segment(ODR o, Z_Segment **p, int opt)
1525 if (!odr_sequence_begin(o, p, sizeof(**p)))
1526 return opt && odr_ok(o);
1528 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1529 odr_implicit(o, odr_integer, &(*p)->numberOfRecordsReturned,
1530 ODR_CONTEXT, 24, 0) &&
1531 odr_implicit_settag(o, ODR_CONTEXT, 0) &&
1532 odr_sequence_of(o, z_NamePlusRecord, &(*p)->segmentRecords,
1533 &(*p)->num_segmentRecords) &&
1534 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1535 odr_sequence_end(o);
1538 /* ------------------------ CLOSE SERVICE ---------------- */
1540 int z_Close(ODR o, Z_Close **p, int opt)
1542 if (!odr_sequence_begin(o, p, sizeof(**p)))
1543 return opt && odr_ok(o);
1545 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1546 odr_implicit(o, odr_integer, &(*p)->closeReason, ODR_CONTEXT, 211, 0) &&
1547 odr_implicit(o, odr_visiblestring, &(*p)->diagnosticInformation,
1548 ODR_CONTEXT, 3, 1) &&
1549 odr_implicit(o, odr_oid, &(*p)->resourceReportFormat, ODR_CONTEXT,
1551 odr_implicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1554 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1556 odr_sequence_end(o);
1559 /* ------------------------ APDU ------------------------- */
1561 int z_Permissions(ODR o, Z_Permissions **p, int opt)
1563 if (!odr_sequence_begin(o, p, sizeof(**p)))
1564 return opt && odr_ok(o);
1566 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT,
1568 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
1569 odr_sequence_of(o, odr_integer, &(*p)->allowableFunctions,
1570 &(*p)->num_allowableFunctions) &&
1571 odr_sequence_end(o);
1574 int z_ExtendedServicesRequest(ODR o, Z_ExtendedServicesRequest **p, int opt)
1576 if (!odr_sequence_begin(o, p, sizeof(**p)))
1577 return opt && odr_ok(o);
1579 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1580 odr_implicit(o, odr_integer, &(*p)->function, ODR_CONTEXT, 3, 0) &&
1581 odr_implicit(o, odr_oid, &(*p)->packageType, ODR_CONTEXT, 4, 0) &&
1582 odr_implicit(o, z_InternationalString, &(*p)->packageName, ODR_CONTEXT, 5, 1) &&
1583 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT, 6, 1) &&
1584 odr_implicit(o, z_IntUnit, &(*p)->retentionTime, ODR_CONTEXT, 7, 1) &&
1585 odr_implicit(o, z_Permissions, &(*p)->permissions, ODR_CONTEXT, 8, 1) &&
1586 odr_implicit(o, z_InternationalString, &(*p)->description, ODR_CONTEXT, 9, 1) &&
1587 odr_implicit(o, z_External, &(*p)->taskSpecificParameters, ODR_CONTEXT, 10, 1) &&
1588 odr_implicit(o, odr_integer, &(*p)->waitAction, ODR_CONTEXT, 11, 0) &&
1589 z_ElementSetName(o, &(*p)->elements, 1) &&
1590 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1591 odr_sequence_end(o);
1594 int z_ExtendedServicesResponse(ODR o, Z_ExtendedServicesResponse **p, int opt)
1596 if (!odr_sequence_begin(o, p, sizeof(**p)))
1597 return opt && odr_ok(o);
1599 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1600 odr_implicit(o, odr_integer, &(*p)->operationStatus, ODR_CONTEXT, 3, 0) &&
1601 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1602 (odr_sequence_of(o, z_DiagRec, &(*p)->diagnostics,
1603 &(*p)->num_diagnostics) || odr_ok(o)) &&
1604 odr_implicit(o, z_External, &(*p)->taskPackage, ODR_CONTEXT, 5, 1) &&
1605 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1606 odr_sequence_end(o);
1609 /* ------------------------ SORT ------------------------- */
1611 int z_SortAttributes(ODR o, Z_SortAttributes **p, int opt)
1613 if (!odr_sequence_begin(o, p, sizeof(**p)))
1614 return opt && odr_ok(o);
1616 odr_oid(o, &(*p)->id, 0) &&
1617 z_AttributeList(o, &(*p)->list, 0) &&
1618 odr_sequence_end(o);
1621 int z_SortKey(ODR o, Z_SortKey **p, int opt)
1623 static Odr_arm arm[] =
1625 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_SortKey_sortField,
1626 z_InternationalString},
1627 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortKey_elementSpec, z_Specification},
1628 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortKey_sortAttributes,
1633 if (!odr_initmember(o, p, sizeof(**p)))
1634 return opt && odr_ok(o);
1635 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1638 return opt && odr_ok(o);
1641 int z_SortDbSpecific(ODR o, Z_SortDbSpecific **p, int opt)
1643 if (!odr_sequence_begin(o, p, sizeof(**p)))
1644 return opt && odr_ok(o);
1646 z_DatabaseName(o, &(*p)->databaseName, 0) &&
1647 z_SortKey(o, &(*p)->dbSort, 0) &&
1648 odr_sequence_end(o);
1651 int z_SortDbSpecificList(ODR o, Z_SortDbSpecificList **p, int opt)
1653 if (!odr_initmember(o, p, sizeof(**p)))
1654 return opt && odr_ok(o);
1655 if (odr_sequence_of(o, z_SortDbSpecific, &(*p)->dbSpecific,
1656 &(*p)->num_dbSpecific))
1659 return opt && odr_ok(o);
1662 int z_SortElement(ODR o, Z_SortElement **p, int opt)
1664 static Odr_arm arm[] =
1666 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_SortElement_generic, z_SortKey},
1667 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortElement_databaseSpecific,
1668 z_SortDbSpecificList},
1672 if (!odr_initmember(o, p, sizeof(**p)))
1673 return opt && odr_ok(o);
1674 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1677 return opt && odr_ok(o);
1680 int z_SortMissingValueAction(ODR o, Z_SortMissingValueAction **p, int opt)
1682 static Odr_arm arm[] =
1684 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortMissingValAct_abort, odr_null},
1685 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortMissingValAct_null, odr_null},
1686 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_SortMissingValAct_valData,
1691 if (!odr_initmember(o, p, sizeof(**p)))
1692 return opt && odr_ok(o);
1693 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1696 return opt && odr_ok(o);
1699 int z_SortKeySpec(ODR o, Z_SortKeySpec **p, int opt)
1701 if (!odr_sequence_begin(o, p, sizeof(**p)))
1702 return opt && odr_ok(o);
1704 z_SortElement(o, &(*p)->sortElement, 0) &&
1705 odr_implicit(o, odr_integer, &(*p)->sortRelation, ODR_CONTEXT, 1, 0) &&
1706 odr_implicit(o, odr_integer, &(*p)->caseSensitivity, ODR_CONTEXT,
1708 odr_explicit(o, z_SortMissingValueAction, &(*p)->missingValueAction,
1709 ODR_CONTEXT, 3, 1) &&
1710 odr_sequence_end(o);
1713 int z_SortResponse(ODR o, Z_SortResponse **p, int opt)
1715 if (!odr_sequence_begin(o, p, sizeof(**p)))
1716 return opt && odr_ok(o);
1718 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1719 odr_implicit(o, odr_integer, &(*p)->sortStatus, ODR_CONTEXT,
1721 odr_implicit(o, odr_integer, &(*p)->resultSetStatus, ODR_CONTEXT,
1723 odr_implicit(o, z_DiagRecs, &(*p)->diagnostics, ODR_CONTEXT, 5, 1) &&
1724 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1725 odr_sequence_end(o);
1728 int z_SortKeySpecList(ODR o, Z_SortKeySpecList **p, int opt)
1730 if (!odr_initmember(o, p, sizeof(**p)))
1731 return opt && odr_ok(o);
1732 if (odr_sequence_of(o, z_SortKeySpec, &(*p)->specs, &(*p)->num_specs))
1735 return opt && odr_ok(o);
1738 int z_SortRequest(ODR o, Z_SortRequest **p, int opt)
1740 if (!odr_sequence_begin(o, p, sizeof(**p)))
1741 return opt && odr_ok(o);
1743 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1744 odr_implicit(o, z_StringList, &(*p)->inputResultSetNames,
1745 ODR_CONTEXT, 3, 0) &&
1746 odr_implicit(o, z_InternationalString, &(*p)->sortedResultSetName,
1747 ODR_CONTEXT, 4, 0) &&
1748 odr_implicit(o, z_SortKeySpecList, &(*p)->sortSequence, ODR_CONTEXT,
1750 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1751 odr_sequence_end(o);
1754 /* ---------------------- Resource Report ---------------- */
1756 int z_ResourceReportRequest(ODR o, Z_ResourceReportRequest **p, int opt)
1758 if (!odr_sequence_begin(o, p, sizeof(**p)))
1759 return opt && odr_ok(o);
1761 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1762 odr_implicit(o, z_ReferenceId, &(*p)->opId, ODR_CONTEXT, 210, 1) &&
1763 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat, ODR_CONTEXT,
1765 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1766 odr_sequence_end(o);
1769 int z_ResourceReportResponse(ODR o, Z_ResourceReportResponse **p, int opt)
1771 if (!odr_sequence_begin(o, p, sizeof(**p)))
1772 return opt && odr_ok(o);
1774 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1775 odr_implicit(o, odr_integer, &(*p)->resourceReportStatus,
1776 ODR_CONTEXT, 50, 0) &&
1777 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1779 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1780 odr_sequence_end(o);
1783 /* ------------------------ APDU ------------------------- */
1785 int z_APDU(ODR o, Z_APDU **p, int opt)
1787 static Odr_arm arm[] =
1789 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
1790 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
1791 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
1792 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
1794 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
1796 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
1798 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
1799 z_DeleteResultSetRequest},
1800 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
1801 z_DeleteResultSetResponse},
1802 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_APDU_accessControlRequest,
1803 z_AccessControlRequest},
1804 {ODR_IMPLICIT, ODR_CONTEXT, 29, Z_APDU_accessControlResponse,
1805 z_AccessControlResponse},
1806 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
1807 z_ResourceControlRequest},
1808 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
1809 z_ResourceControlResponse},
1810 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
1811 z_TriggerResourceControlRequest},
1812 {ODR_IMPLICIT, ODR_CONTEXT, 33, Z_APDU_resourceReportRequest,
1813 z_ResourceReportRequest},
1814 {ODR_IMPLICIT, ODR_CONTEXT, 34, Z_APDU_resourceReportResponse,
1815 z_ResourceReportResponse},
1816 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
1817 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
1818 {ODR_IMPLICIT, ODR_CONTEXT, 43, Z_APDU_sortRequest, z_SortRequest},
1819 {ODR_IMPLICIT, ODR_CONTEXT, 44, Z_APDU_sortResponse, z_SortResponse},
1820 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_APDU_segmentRequest, z_Segment},
1821 {ODR_IMPLICIT, ODR_CONTEXT, 46, Z_APDU_extendedServicesRequest,
1822 z_ExtendedServicesRequest},
1823 {ODR_IMPLICIT, ODR_CONTEXT, 47, Z_APDU_extendedServicesResponse,
1824 z_ExtendedServicesResponse},
1825 {ODR_IMPLICIT, ODR_CONTEXT, 48, Z_APDU_close, z_Close},
1830 if (o->direction == ODR_DECODE)
1831 *p = odr_malloc(o, sizeof(**p));
1832 odr_setlenlen(o, 5);
1833 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
1835 if (o->direction == ODR_DECODE)
1837 return opt && odr_ok(o);