2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.54 1996-11-11 13:14:46 adam
8 * Fixed tagging bug in z_ProximityOperator.
10 * Revision 1.53 1996/10/09 15:54:55 quinn
11 * Added SearchInfoReport
13 * Revision 1.52 1996/10/08 12:56:57 adam
14 * Bug fix: tagging of type 101 query.
16 * Revision 1.51 1996/07/26 14:07:21 quinn
19 * Revision 1.50 1996/07/26 13:36:15 quinn
22 * Revision 1.49 1996/07/06 19:58:28 quinn
23 * System headerfiles gathered in yconfig
25 * Revision 1.48 1996/06/10 08:53:33 quinn
26 * Added Summary,OPAC,ResourceReport
28 * Revision 1.47 1996/05/29 15:47:50 quinn
29 * Fixed in bug DiagRecs decoder. Thanks to Linda Harris.
31 * Revision 1.46 1996/04/10 11:39:42 quinn
32 * Fixed bug in UserInfo
34 * Revision 1.45 1996/02/23 10:00:25 quinn
37 * Revision 1.44 1996/02/20 12:51:41 quinn
38 * Completed SCAN. Fixed problems with EXTERNAL.
40 * Revision 1.43 1996/02/10 12:22:49 quinn
43 * Revision 1.42 1996/01/22 09:46:31 quinn
44 * Added Sort PDU. Moved StringList to main protocol file.
46 * Revision 1.41 1996/01/10 15:21:24 quinn
47 * Added links to access control PDUs
49 * Revision 1.40 1996/01/02 11:46:40 quinn
50 * Changed 'operator' to 'roperator' to avoid C++ conflict.
52 * Revision 1.39 1995/09/29 17:11:53 quinn
55 * Revision 1.38 1995/09/27 15:02:40 quinn
56 * Modified function heads & prototypes.
58 * Revision 1.37 1995/08/21 09:10:15 quinn
59 * Smallish fixes to suppport new formats.
61 * Revision 1.36 1995/08/15 11:59:39 quinn
64 * Revision 1.35 1995/08/10 08:53:59 quinn
67 * Revision 1.34 1995/06/19 17:01:48 quinn
68 * This should bring us in sync with the version distributed as 1.0b
70 * Revision 1.33 1995/06/19 13:39:56 quinn
71 * *** empty log message ***
73 * Revision 1.32 1995/06/19 12:37:28 quinn
74 * Fixed a bug in the compspec.
76 * Revision 1.31 1995/06/16 13:15:56 quinn
77 * Fixed Defaultdiagformat.
79 * Revision 1.30 1995/06/15 15:42:01 quinn
82 * Revision 1.29 1995/06/15 07:44:49 quinn
85 * Revision 1.28 1995/06/14 15:26:35 quinn
86 * *** empty log message ***
88 * Revision 1.27 1995/06/07 14:36:22 quinn
91 * Revision 1.26 1995/06/02 09:49:13 quinn
92 * Adding access control
94 * Revision 1.25 1995/05/25 11:00:08 quinn
95 * *** empty log message ***
97 * Revision 1.24 1995/05/22 13:58:18 quinn
98 * Fixed an ODR_NULLVAL.
100 * Revision 1.23 1995/05/22 11:30:18 quinn
101 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
103 * Revision 1.22 1995/05/17 08:40:56 quinn
104 * Added delete. Fixed some sequence_begins. Smallish.
106 * Revision 1.21 1995/05/16 08:50:24 quinn
107 * License, documentation, and memory fixes
109 * Revision 1.20 1995/05/15 11:55:25 quinn
112 * Revision 1.19 1995/04/11 11:58:35 quinn
115 * Revision 1.18 1995/04/11 11:52:02 quinn
116 * Fixed possible buf in proto.c
118 * Revision 1.17 1995/04/10 10:22:22 quinn
121 * Revision 1.16 1995/03/30 10:26:43 quinn
122 * Added Term structure
124 * Revision 1.15 1995/03/30 09:08:39 quinn
125 * Added Resource control protocol
127 * Revision 1.14 1995/03/29 08:06:13 quinn
128 * Added a few v3 elements
130 * Revision 1.13 1995/03/20 11:26:52 quinn
131 * *** empty log message ***
133 * Revision 1.12 1995/03/20 09:45:09 quinn
136 * Revision 1.11 1995/03/17 10:17:25 quinn
137 * Added memory management.
139 * Revision 1.10 1995/03/15 11:17:40 quinn
140 * Fixed some return-checks from choice.. need better ay to handle those..
142 * Revision 1.9 1995/03/15 08:37:06 quinn
143 * Fixed protocol bugs.
145 * Revision 1.8 1995/03/14 16:59:24 quinn
146 * Fixed OPTIONAL flag in attributeelement
148 * Revision 1.7 1995/03/07 16:29:33 quinn
149 * Added authentication stuff.
151 * Revision 1.6 1995/03/01 14:46:03 quinn
152 * Fixed protocol bug in 8777query.
154 * Revision 1.5 1995/02/14 11:54:22 quinn
157 * Revision 1.4 1995/02/10 15:54:30 quinn
160 * Revision 1.3 1995/02/09 15:51:39 quinn
163 * Revision 1.2 1995/02/06 21:26:07 quinn
164 * Repaired this evening's damages..
166 * Revision 1.1 1995/02/06 16:44:47 quinn
167 * First hack at Z/SR protocol
175 /* ---------------------- GLOBAL DEFS ------------------- */
178 * We'll use a general octetstring here, since string operations are
179 * clumsy on long strings.
181 int z_SUTRS(ODR o, Odr_oct **p, int opt)
183 return odr_implicit(o, odr_octetstring, p, ODR_UNIVERSAL,
184 ODR_GENERALSTRING, opt);
187 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
189 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
192 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
194 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
198 int z_ResultSetId(ODR o, char **p, int opt)
200 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
204 int z_ElementSetName(ODR o, char **p, int opt)
206 return odr_implicit(o, odr_visiblestring, p, ODR_CONTEXT, 103, opt);
209 int z_UserInformationField(ODR o, Z_External **p, int opt)
211 return odr_explicit(o, z_External, (Z_External **)p, ODR_CONTEXT,
215 int z_InternationalString(ODR o, char **p, int opt)
217 return odr_generalstring(o, p, opt);
220 int z_InfoCategory(ODR o, Z_InfoCategory **p, int opt)
222 if (!odr_sequence_begin(o, p, sizeof(**p)))
223 return opt && odr_ok(o);
225 odr_implicit(o, odr_oid, &(*p)->categoryTypeId, ODR_CONTEXT, 1, 1) &&
226 odr_implicit(o, odr_integer, &(*p)->categoryValue, ODR_CONTEXT, 2, 0) &&
230 int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt)
232 static Odr_arm arm[] =
234 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_OtherInfo_characterInfo,
236 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_OtherInfo_binaryInfo,
238 {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_OtherInfo_externallyDefinedInfo,
240 {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_OtherInfo_oid, odr_oid},
244 if (!odr_sequence_begin(o, p, sizeof(**p)))
245 return opt && odr_ok(o);
247 odr_implicit(o, z_InfoCategory, &(*p)->category, ODR_CONTEXT, 1, 1) &&
248 odr_choice(o, arm, &(*p)->information, &(*p)->which) &&
252 int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt)
254 if (o->direction == ODR_DECODE)
255 *p = odr_malloc(o, sizeof(**p));
258 odr_implicit_settag(o, ODR_CONTEXT, 201);
259 if (odr_sequence_of(o, z_OtherInformationUnit, &(*p)->list,
260 &(*p)->num_elements))
263 return opt && odr_ok(o);
266 int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt)
268 static Odr_arm arm[] =
270 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_StringOrNumeric_string,
272 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_StringOrNumeric_numeric,
277 if (o->direction == ODR_DECODE)
278 *p = odr_malloc(o, sizeof(**p));
281 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
284 return opt && odr_ok(o);
290 int z_Unit(ODR o, Z_Unit **p, int opt)
292 if (!odr_sequence_begin(o, p, sizeof(**p)))
293 return opt && odr_ok(o);
295 odr_explicit(o, z_InternationalString, &(*p)->unitSystem, ODR_CONTEXT,
297 odr_explicit(o, z_StringOrNumeric, &(*p)->unitType, ODR_CONTEXT,
299 odr_explicit(o, z_StringOrNumeric, &(*p)->unit, ODR_CONTEXT, 3, 1) &&
300 odr_implicit(o, odr_integer, &(*p)->scaleFactor, ODR_CONTEXT, 4, 1) &&
304 int z_IntUnit(ODR o, Z_IntUnit **p, int opt)
306 if (!odr_sequence_begin(o, p, sizeof(**p)))
307 return opt && odr_ok(o);
309 odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 1, 0) &&
310 odr_implicit(o, z_Unit, &(*p)->unitUsed, ODR_CONTEXT, 2, 0) &&
314 int z_StringList(ODR o, Z_StringList **p, int opt)
316 if (o->direction == ODR_DECODE)
317 *p = odr_malloc(o, sizeof(**p));
320 if (odr_sequence_of(o, z_InternationalString, &(*p)->strings,
324 return opt && odr_ok(o);
327 /* ---------------------- INITIALIZE SERVICE ------------------- */
330 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
332 if (!odr_sequence_begin(o, p, sizeof(**p)))
333 return opt && odr_ok(o);
335 odr_visiblestring(o, &(*p)->user, 0) &&
336 odr_visiblestring(o, &(*p)->password, 0) &&
337 odr_visiblestring(o, &(*p)->account, 0) &&
342 int z_IdPass(ODR o, Z_IdPass **p, int opt)
344 if (!odr_sequence_begin(o, p, sizeof(**p)))
345 return opt && odr_ok(o);
347 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 1) &&
348 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 1) &&
349 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
354 int z_StrAuthentication(ODR o, char **p, int opt)
356 return odr_visiblestring(o, p, opt);
359 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
361 static Odr_arm arm[] =
363 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
364 {-1, -1, -1, Z_IdAuthentication_idPass, z_IdPass},
365 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
366 {-1, -1, -1, Z_IdAuthentication_other, z_External},
370 if (o->direction == ODR_DECODE)
371 *p = odr_malloc(o, sizeof(**p));
375 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
378 return opt && odr_ok(o);
381 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
385 if (!odr_sequence_begin(o, p, sizeof(**p)))
386 return opt && odr_ok(o);
389 z_ReferenceId(o, &pp->referenceId, 1) &&
390 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
392 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
393 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
395 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
397 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
399 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
401 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
403 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
404 ODR_CONTEXT, 112, 1) &&
405 z_UserInformationField(o, &pp->userInformationField, 1) &&
407 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
412 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
416 if (!odr_sequence_begin(o, p, sizeof(**p)))
417 return opt && odr_ok(o);
420 z_ReferenceId(o, &pp->referenceId, 1) &&
421 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
423 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
424 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
426 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
428 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
429 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
431 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
433 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
434 ODR_CONTEXT, 112, 1) &&
435 z_UserInformationField(o, &pp->userInformationField, 1) &&
437 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
442 /* ------------------ RESOURCE CONTROL ----------------*/
444 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
447 if (!odr_sequence_begin(o, p, sizeof(**p)))
448 return opt && odr_ok(o);
450 z_ReferenceId(o, &(*p)->referenceId, 1) &&
451 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
453 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
454 ODR_CONTEXT, 47, 1) &&
455 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
458 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
463 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **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)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
470 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
472 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
473 ODR_CONTEXT, 41, 1) &&
474 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
476 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
477 ODR_CONTEXT, 43, 1) &&
479 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
484 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
486 if (!odr_sequence_begin(o, p, sizeof(**p)))
487 return opt && odr_ok(o);
489 z_ReferenceId(o, &(*p)->referenceId, 1) &&
490 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
491 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
494 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
499 /* ------------------------ SEARCH SERVICE ----------------------- */
501 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
503 if (!odr_sequence_begin(o, p, sizeof(**p)))
504 return opt && odr_ok(o);
506 z_DatabaseName(o, &(*p)->databaseName, 0) &&
507 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
511 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
513 if (o->direction == ODR_DECODE)
514 *p = odr_malloc(o, sizeof(**p));
518 odr_implicit_settag(o, ODR_CONTEXT, 1);
519 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
520 &(*p)->num_elements))
526 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
528 static Odr_arm arm[] =
530 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
532 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
537 if (o->direction == ODR_DECODE)
538 *p = odr_malloc(o, sizeof(**p));
540 return opt && odr_ok(o);
542 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
548 /* ----------------------- RPN QUERY -----------------------*/
550 int z_ComplexAttribute(ODR o, Z_ComplexAttribute **p, int opt)
552 if (!odr_sequence_begin(o, p, sizeof(**p)))
553 return opt && odr_ok(o);
555 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
556 odr_sequence_of(o, z_StringOrNumeric, &(*p)->list,
558 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
559 (odr_sequence_of(o, odr_integer, &(*p)->semanticAction,
560 &(*p)->num_semanticAction) || odr_ok(o)) &&
564 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
567 static Odr_arm arm[] =
569 {ODR_IMPLICIT, ODR_CONTEXT, 121, Z_AttributeValue_numeric,
571 {ODR_IMPLICIT, ODR_CONTEXT, 224, Z_AttributeValue_complex,
577 if (!odr_sequence_begin(o, p, sizeof(**p)))
578 return opt && odr_ok(o);
581 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 1, 1) &&
583 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
586 odr_choice(o, arm, &(*p)->value, &(*p)->which) &&
588 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
594 int z_Term(ODR o, Z_Term **p, int opt)
596 static Odr_arm arm[] =
598 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
599 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
600 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
602 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
603 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
604 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, z_External},
605 /* add intUnit here */
606 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
610 if (o->direction ==ODR_DECODE)
611 *p = odr_malloc(o, sizeof(**p));
614 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
617 return opt && odr_ok(o);
620 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
622 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
623 odr_sequence_begin(o, p, sizeof(**p))))
624 return opt && odr_ok(o);
626 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
627 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
628 &(*p)->num_attributes) &&
629 z_Term(o, &(*p)->term, 0) &&
633 int z_ResultSetPlusAttributes(ODR o, Z_ResultSetPlusAttributes **p, int opt)
635 if (!(odr_implicit_settag(o, ODR_CONTEXT, 214) &&
636 odr_sequence_begin(o, p, sizeof(**p))))
637 return opt && odr_ok(o);
639 z_ResultSetId(o, &(*p)->resultSet, 0) &&
640 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
641 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
642 &(*p)->num_attributes) &&
646 int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
648 static Odr_arm arm[] =
650 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, odr_integer},
651 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ProxCode_private, odr_integer},
655 if (!odr_sequence_begin(o, p, sizeof(**p)))
656 return opt && odr_ok(o);
658 odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
659 odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
660 odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
661 odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
662 odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
663 odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
664 odr_constructed_end(o) &&
668 int z_Operator(ODR o, Z_Operator **p, int opt)
670 static Odr_arm arm[] =
672 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
673 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
674 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
675 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, z_ProximityOperator},
679 if (!*p && o->direction != ODR_DECODE)
681 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
682 return opt && odr_ok(o);
683 if (o->direction == ODR_DECODE)
684 *p = odr_malloc(o, sizeof(**p));
686 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
687 odr_constructed_end(o))
690 return opt && odr_ok(o);
693 int z_Operand(ODR o, Z_Operand **p, int opt)
695 static Odr_arm arm[] =
697 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
698 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
699 {-1, -1, -1, Z_Operand_resultAttr, z_ResultSetPlusAttributes},
703 if (o->direction == ODR_DECODE)
704 *p = odr_malloc(o, sizeof(**p));
707 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
710 return opt && odr_ok(o);
713 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
715 int z_Complex(ODR o, Z_Complex **p, int opt)
717 if (!odr_sequence_begin(o, p, sizeof(**p)))
718 return opt && odr_ok(o);
720 z_RPNStructure(o, &(*p)->s1, 0) &&
721 z_RPNStructure(o, &(*p)->s2, 0) &&
722 z_Operator(o, &(*p)->roperator, 0) &&
726 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
728 static Odr_arm arm[] =
730 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
731 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
735 if (o->direction == ODR_DECODE)
736 *p = odr_malloc(o, sizeof(**p));
739 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
742 return opt && odr_ok(o);
745 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
747 if (!odr_sequence_begin(o, p, sizeof(**p)))
748 return opt && odr_ok(o);
750 odr_oid(o, &(*p)->attributeSetId, 0) &&
751 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
755 /* -----------------------END RPN QUERY ----------------------- */
757 int z_Query(ODR o, Z_Query **p, int opt)
759 static Odr_arm arm[] =
761 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
762 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
763 {ODR_IMPLICIT, ODR_CONTEXT, 101, Z_Query_type_101, z_RPNQuery},
767 if (o->direction == ODR_DECODE)
768 *p = odr_malloc(o, sizeof(**p));
771 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
774 return opt && odr_ok(o);
777 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
781 if (!odr_sequence_begin(o, p, sizeof(**p)))
782 return opt && odr_ok(o);
785 z_ReferenceId(o, &pp->referenceId, 1) &&
786 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
788 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
790 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
792 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
793 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
795 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
796 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
797 &pp->num_databaseNames) &&
798 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
799 ODR_CONTEXT, 100, 1) &&
800 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
801 ODR_CONTEXT, 101, 1) &&
802 odr_implicit(o, odr_oid, &pp->preferredRecordSyntax,
803 ODR_CONTEXT, 104, 1) &&
804 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
806 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
807 ODR_CONTEXT, 203, 1) &&
808 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
813 /* ------------------------ RECORD ------------------------- */
815 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
817 return z_External(o, (Z_External **) p, opt);
822 int z_DefaultDiagFormat(ODR o, Z_DefaultDiagFormat **p, int opt)
824 static Odr_arm arm[] =
826 {-1, -1, -1, Z_DiagForm_v2AddInfo, odr_visiblestring},
827 {-1, -1, -1, Z_DiagForm_v3AddInfo, z_InternationalString},
828 {ODR_IMPLICIT, ODR_CONTEXT, ODR_VISIBLESTRING, Z_DiagForm_v2AddInfo,
829 odr_visiblestring}, /* To cater to a bug in the CNIDR servers */
832 if (!odr_sequence_begin(o, p, sizeof(**p)))
833 return opt && odr_ok(o);
835 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
836 odr_integer(o, &(*p)->condition, 0) &&
838 * I no longer recall what server tagged the addinfo.. but it isn't
839 * hurting anyone, so...
840 * We need to turn it into a choice, or something, because of
841 * that damn generalstring in v3.
843 odr_choice(o, arm, &(*p)->addinfo, &(*p)->which) &&
847 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
849 static Odr_arm arm[] =
851 {-1, -1, -1, Z_DiagRec_defaultFormat, z_DefaultDiagFormat},
852 {-1, -1, -1, Z_DiagRec_externallyDefined, z_External},
856 if (o->direction == ODR_DECODE)
857 *p = odr_malloc(o, sizeof(**p));
860 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
863 return opt && odr_ok(o);
868 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
870 if (!odr_sequence_begin(o, p, sizeof(**p)))
871 return opt && odr_ok(o);
873 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
874 odr_integer(o, &(*p)->condition, 0) &&
876 * I no longer recall what server tagged the addinfo.. but it isn't
877 * hurting anyone, so...
878 * We need to turn it into a choice, or something, because of
879 * that damn generalstring in v3.
881 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
882 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT,
883 ODR_VISIBLESTRING, 1)) &&
889 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
891 if (o->direction == ODR_DECODE)
892 *p = odr_malloc(o, sizeof(**p));
896 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
897 &(*p)->num_diagRecs))
900 return opt && odr_ok(o);
903 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
905 static Odr_arm arm[] =
907 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
909 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
914 if (!odr_sequence_begin(o, p, sizeof(**p)))
915 return opt && odr_ok(o);
917 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
919 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
920 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
921 odr_constructed_end(o) &&
925 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
927 if (o->direction == ODR_DECODE)
928 *p = odr_malloc(o, sizeof(**p));
931 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
938 int z_Records(ODR o, Z_Records **p, int opt)
940 static Odr_arm arm[] =
942 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
943 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
944 {ODR_IMPLICIT, ODR_CONTEXT, 205, Z_Records_multipleNSD,
949 if (o->direction == ODR_DECODE)
950 *p = odr_malloc(o, sizeof(**p));
953 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
956 return opt && odr_ok(o);
959 /* ------------------------ ACCESS CTRL SERVICE ----------------------- */
961 int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
963 static Odr_arm arm[] =
965 {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
967 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_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) &&
977 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
982 int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
984 static Odr_arm arm[] =
986 {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
988 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
992 if (!odr_sequence_begin(o, p, sizeof(**p)))
993 return opt && odr_ok(o);
995 z_ReferenceId(o, &(*p)->referenceId, 1) &&
996 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
997 odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
999 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1001 odr_sequence_end(o);
1004 /* ------------------------ SCAN SERVICE -------------------- */
1006 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
1008 if (o->direction == ODR_DECODE)
1009 *p = odr_malloc(o, sizeof(**p));
1013 odr_implicit_settag(o, ODR_CONTEXT, 44);
1014 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
1015 &(*p)->num_attributes))
1018 return opt && odr_ok(o);
1022 * This is a temporary hack. We don't know just *what* old version of the
1023 * protocol willow uses, so we'll just patiently wait for them to update
1025 static int willow_scan = 0;
1027 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
1029 if (!*p && o->direction != ODR_DECODE)
1031 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
1034 return opt && odr_ok(o);
1036 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
1038 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
1040 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
1042 if (o->direction == ODR_DECODE)
1043 *p = odr_malloc(o, sizeof(**p));
1044 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
1045 &(*p)->num_attributes))
1047 if (!odr_sequence_end(o) || !odr_sequence_end(o))
1049 if (!z_Term(o, &(*p)->term, 0))
1051 if (!odr_constructed_end(o))
1057 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
1059 if (o->direction == ODR_DECODE)
1060 *p = odr_malloc(o, sizeof(**p));
1064 return opt && odr_ok(o);
1067 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
1071 return opt && !o->error;
1076 int z_ByDatabase(ODR o, Z_ByDatabase **p, int opt)
1078 if (!odr_sequence_begin(o, p, sizeof(**p)))
1079 return opt && odr_ok(o);
1081 z_DatabaseName(o, &(*p)->db, 1) &&
1082 odr_implicit(o, odr_integer, &(*p)->num, ODR_CONTEXT, 1, 1) &&
1083 z_OtherInformation(o, &(*p)->otherDbInfo, 1) &&
1084 odr_sequence_end(o);
1087 int z_ByDatabaseList(ODR o, Z_ByDatabaseList **p, int opt)
1089 if (!odr_initmember(o, p, sizeof(**p)))
1090 return opt && odr_ok(o);
1091 if (odr_sequence_of(o, z_ByDatabase, &(*p)->elements, &(*p)->num_elements))
1094 return opt && odr_ok(o);
1097 int z_ScanOccurrences(ODR o, Z_ScanOccurrences **p, int opt)
1101 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_ScanOccurrences_global, odr_integer},
1102 {ODR_EXPLICIT, ODR_CONTEXT, 3, Z_ScanOccurrences_byDatabase,
1107 if (!odr_initmember(o, p, sizeof(**p)))
1108 return opt && odr_ok(o);
1109 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1112 return opt && odr_ok(o);
1115 int z_OccurrenceByAttributesElem(ODR o, Z_OccurrenceByAttributesElem **p,
1118 if (!odr_sequence_begin(o, p, sizeof(**p)))
1119 return opt && odr_ok(o);
1121 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT,
1123 z_ScanOccurrences(o, &(*p)->occurrences, 1) &&
1124 z_OtherInformation(o, &(*p)->otherOccurInfo, 1) &&
1125 odr_sequence_end(o);
1128 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1130 if (!odr_initmember(o, p, sizeof(**p)))
1131 return opt && odr_ok(o);
1132 if (!odr_sequence_of(o, z_OccurrenceByAttributesElem, &(*p)->elements,
1133 &(*p)->num_elements))
1136 return opt && odr_ok(o);
1142 * Incomplete definition of occurencebyattributes.
1145 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1147 if (!odr_sequence_begin(o, p, sizeof(**p)))
1148 return opt && odr_ok(o);
1150 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
1151 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
1152 odr_sequence_end(o);
1157 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
1159 if (!odr_sequence_begin(o, p, sizeof(**p)))
1160 return opt && odr_ok(o);
1163 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
1164 z_Term(o, &(*p)->term, 0)) &&
1165 odr_implicit(o, z_InternationalString, &(*p)->displayTerm, ODR_CONTEXT,
1167 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
1168 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
1169 ODR_CONTEXT, 4, 1) &&
1170 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
1172 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
1173 ODR_CONTEXT, 3, 1) &&
1174 z_OtherInformation(o, &(*p)->otherTermInfo, 1) &&
1175 odr_sequence_end(o);
1178 int z_Entry(ODR o, Z_Entry **p, int opt)
1180 static Odr_arm arm[] =
1182 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
1183 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
1188 if (o->direction == ODR_DECODE)
1189 *p = odr_malloc(o, sizeof(**p));
1193 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1196 return opt && odr_ok(o);
1199 int z_Entries(ODR o, Z_Entries **p, int opt)
1201 if (o->direction == ODR_DECODE)
1202 *p = odr_malloc(o, sizeof(**p));
1206 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
1207 &(*p)->num_entries))
1213 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
1215 static Odr_arm arm[] =
1217 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
1218 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
1223 if (o->direction == ODR_DECODE)
1224 *p = odr_malloc(o, sizeof(**p));
1228 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1231 return opt && odr_ok(o);
1234 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
1236 if (!odr_sequence_begin(o, p, sizeof(**p)))
1237 return opt && odr_ok(o);
1240 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1241 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1242 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
1243 &(*p)->num_databaseNames) &&
1244 odr_oid(o, &(*p)->attributeSet, 1) &&
1245 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
1246 ((*p)->termListAndStartPoint ? 1 :
1247 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
1248 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
1249 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
1250 ODR_CONTEXT, 6, 0) &&
1251 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
1252 ODR_CONTEXT, 7, 1) &&
1253 odr_sequence_end(o);
1256 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
1258 if (!odr_sequence_begin(o, p, sizeof(**p)))
1259 return opt && odr_ok(o);
1261 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1262 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
1263 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
1264 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
1265 ODR_CONTEXT, 5, 0) &&
1266 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
1267 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
1268 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
1269 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1270 odr_sequence_end(o);
1273 /* ------------------------ SEARCHRESPONSE ----------------*/
1275 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
1277 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
1280 int z_NextResultSetPosition(ODR o, int **p, int opt)
1282 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
1285 int z_PresentStatus(ODR o, int **p, int opt)
1287 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
1290 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
1292 Z_SearchResponse *pp;
1294 if (!odr_sequence_begin(o, p, sizeof(**p)))
1295 return opt && odr_ok(o);
1298 z_ReferenceId(o, &pp->referenceId, 1) &&
1299 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
1300 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1301 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1302 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
1303 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26,
1305 z_PresentStatus(o, &pp->presentStatus, 1) &&
1306 z_Records(o, &pp->records, 1) &&
1308 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
1309 ODR_CONTEXT, 203, 1) &&
1310 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1312 odr_sequence_end(o);
1315 /* --------------------- PRESENT SERVICE ---------------------- */
1317 int z_ElementSpec(ODR o, Z_ElementSpec **p, int opt)
1319 static Odr_arm arm[] =
1321 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSpec_elementSetName,
1323 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ElementSpec_externalSpec,
1328 if (o->direction == ODR_DECODE)
1329 *p = odr_malloc(o, sizeof(**p));
1333 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1336 return opt && odr_ok(o);
1339 int z_Specification(ODR o, Z_Specification **p, int opt)
1341 if (!odr_sequence_begin(o, p, sizeof(**p)))
1342 return opt && odr_ok(o);
1344 odr_implicit(o, odr_oid, &(*p)->schema, ODR_CONTEXT, 1, 1) &&
1345 z_ElementSpec(o, &(*p)->elementSpec, 1) &&
1346 odr_sequence_end(o);
1349 int z_DbSpecific(ODR o, Z_DbSpecific **p, int opt)
1351 if (!odr_sequence_begin(o, p, sizeof(**p)))
1352 return opt && odr_ok(o);
1354 odr_explicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
1356 odr_implicit(o, z_Specification, &(*p)->spec, ODR_CONTEXT, 2, 0) &&
1357 odr_sequence_end(o);
1360 int z_CompSpec(ODR o, Z_CompSpec **p, int opt)
1362 if (!odr_sequence_begin(o, p, sizeof(**p)))
1363 return opt && odr_ok(o);
1365 odr_implicit(o, odr_bool, &(*p)->selectAlternativeSyntax, ODR_CONTEXT,
1367 odr_implicit(o, z_Specification, &(*p)->generic, ODR_CONTEXT, 2, 1) &&
1368 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1369 (odr_sequence_of(o, z_DbSpecific, &(*p)->dbSpecific,
1370 &(*p)->num_dbSpecific) || odr_ok(o)) &&
1371 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1372 (odr_sequence_of(o, odr_oid, &(*p)->recordSyntax,
1373 &(*p)->num_recordSyntax) || odr_ok(o)) &&
1374 odr_sequence_end(o);
1377 int z_RecordComposition(ODR o, Z_RecordComposition **p, int opt)
1379 static Odr_arm arm[] =
1381 {ODR_EXPLICIT, ODR_CONTEXT, 19, Z_RecordComp_simple,
1383 {ODR_IMPLICIT, ODR_CONTEXT, 209, Z_RecordComp_complex,
1388 if (o->direction == ODR_DECODE)
1389 *p = odr_malloc(o, sizeof(**p));
1393 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1396 return opt && odr_ok(o);
1399 int z_Range(ODR o, Z_Range **p, int opt)
1401 if (!odr_sequence_begin(o, p, sizeof(**p)))
1402 return opt && odr_ok(o);
1404 odr_implicit(o, odr_integer, &(*p)->startingPosition, ODR_CONTEXT,
1406 odr_implicit(o, odr_integer, &(*p)->numberOfRecords, ODR_CONTEXT,
1408 odr_sequence_end(o);
1411 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
1413 Z_PresentRequest *pp;
1415 if (!odr_sequence_begin(o, p, sizeof(**p)))
1416 return opt && odr_ok(o);
1419 z_ReferenceId(o, &pp->referenceId, 1) &&
1420 z_ResultSetId(o, &pp->resultSetId, 0) &&
1421 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
1423 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
1426 odr_implicit_settag(o, ODR_CONTEXT, 212) &&
1427 (odr_sequence_of(o, z_Range, &(*p)->additionalRanges,
1428 &(*p)->num_ranges) || odr_ok(o)) &&
1429 z_RecordComposition(o, &(*p)->recordComposition, 1) &&
1431 odr_explicit(o, z_ElementSetNames, &pp->elementSetNames, ODR_CONTEXT,
1434 odr_implicit(o, odr_oid, &(*p)->preferredRecordSyntax, ODR_CONTEXT,
1437 odr_implicit(o, odr_integer, &(*p)->maxSegmentCount, ODR_CONTEXT,
1439 odr_implicit(o, odr_integer, &(*p)->maxRecordSize, ODR_CONTEXT,
1441 odr_implicit(o, odr_integer, &(*p)->maxSegmentSize, ODR_CONTEXT,
1443 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1445 odr_sequence_end(o);
1448 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
1450 Z_PresentResponse *pp;
1452 if (!odr_sequence_begin(o, p, sizeof(**p)))
1453 return opt && odr_ok(o);
1456 z_ReferenceId(o, &pp->referenceId, 1) &&
1457 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1458 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1459 z_PresentStatus(o, &pp->presentStatus, 0) &&
1460 z_Records(o, &pp->records, 1) &&
1462 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1464 odr_sequence_end(o);
1467 /* ----------------------DELETE -------------------------- */
1469 int z_DeleteSetStatus(ODR o, int **p, int opt)
1471 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
1474 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
1476 if (!odr_sequence_begin(o, p, sizeof(**p)))
1477 return opt && odr_ok(o);
1479 z_ResultSetId(o, &(*p)->id, 0) &&
1480 z_DeleteSetStatus(o, &(*p)->status, 0) &&
1481 odr_sequence_end(o);
1484 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
1486 if (!odr_sequence_begin(o, p, sizeof(**p)))
1487 return opt && odr_ok(o);
1489 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1490 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
1492 (odr_sequence_of(o, z_ResultSetId, &(*p)->resultSetList,
1493 &(*p)->num_ids) || odr_ok(o)) &&
1495 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1497 odr_sequence_end(o);
1500 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
1502 if (!odr_sequence_begin(o, p, sizeof(**p)))
1503 return opt && odr_ok(o);
1505 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1506 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
1507 ODR_CONTEXT, 0, 1) &&
1508 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
1509 (odr_sequence_of(o, z_ListStatus, &(*p)->deleteListStatuses,
1510 &(*p)->num_statuses) || odr_ok(o)) &&
1511 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
1513 odr_implicit_settag(o, ODR_CONTEXT, 35) &&
1514 (odr_sequence_of(o, z_ListStatus, &(*p)->bulkStatuses,
1515 &(*p)->num_bulkStatuses) || odr_ok(o)) &&
1516 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
1519 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1521 odr_sequence_end(o);
1524 /* ------------------------ SEGMENT SERVICE -------------- */
1526 int z_Segment(ODR o, Z_Segment **p, int opt)
1528 if (!odr_sequence_begin(o, p, sizeof(**p)))
1529 return opt && odr_ok(o);
1531 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1532 odr_implicit(o, odr_integer, &(*p)->numberOfRecordsReturned,
1533 ODR_CONTEXT, 24, 0) &&
1534 odr_implicit_settag(o, ODR_CONTEXT, 0) &&
1535 odr_sequence_of(o, z_NamePlusRecord, &(*p)->segmentRecords,
1536 &(*p)->num_segmentRecords) &&
1537 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1538 odr_sequence_end(o);
1541 /* ------------------------ CLOSE SERVICE ---------------- */
1543 int z_Close(ODR o, Z_Close **p, int opt)
1545 if (!odr_sequence_begin(o, p, sizeof(**p)))
1546 return opt && odr_ok(o);
1548 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1549 odr_implicit(o, odr_integer, &(*p)->closeReason, ODR_CONTEXT, 211, 0) &&
1550 odr_implicit(o, odr_visiblestring, &(*p)->diagnosticInformation,
1551 ODR_CONTEXT, 3, 1) &&
1552 odr_implicit(o, odr_oid, &(*p)->resourceReportFormat, ODR_CONTEXT,
1554 odr_implicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1557 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1559 odr_sequence_end(o);
1562 /* ------------------------ APDU ------------------------- */
1564 int z_Permissions(ODR o, Z_Permissions **p, int opt)
1566 if (!odr_sequence_begin(o, p, sizeof(**p)))
1567 return opt && odr_ok(o);
1569 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT,
1571 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
1572 odr_sequence_of(o, odr_integer, &(*p)->allowableFunctions,
1573 &(*p)->num_allowableFunctions) &&
1574 odr_sequence_end(o);
1577 int z_ExtendedServicesRequest(ODR o, Z_ExtendedServicesRequest **p, int opt)
1579 if (!odr_sequence_begin(o, p, sizeof(**p)))
1580 return opt && odr_ok(o);
1582 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1583 odr_implicit(o, odr_integer, &(*p)->function, ODR_CONTEXT, 3, 0) &&
1584 odr_implicit(o, odr_oid, &(*p)->packageType, ODR_CONTEXT, 4, 0) &&
1585 odr_implicit(o, z_InternationalString, &(*p)->packageName, ODR_CONTEXT, 5, 1) &&
1586 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT, 6, 1) &&
1587 odr_implicit(o, z_IntUnit, &(*p)->retentionTime, ODR_CONTEXT, 7, 1) &&
1588 odr_implicit(o, z_Permissions, &(*p)->permissions, ODR_CONTEXT, 8, 1) &&
1589 odr_implicit(o, z_InternationalString, &(*p)->description, ODR_CONTEXT, 9, 1) &&
1590 odr_implicit(o, z_External, &(*p)->taskSpecificParameters, ODR_CONTEXT, 10, 1) &&
1591 odr_implicit(o, odr_integer, &(*p)->waitAction, ODR_CONTEXT, 11, 0) &&
1592 z_ElementSetName(o, &(*p)->elements, 1) &&
1593 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1594 odr_sequence_end(o);
1597 int z_ExtendedServicesResponse(ODR o, Z_ExtendedServicesResponse **p, int opt)
1599 if (!odr_sequence_begin(o, p, sizeof(**p)))
1600 return opt && odr_ok(o);
1602 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1603 odr_implicit(o, odr_integer, &(*p)->operationStatus, ODR_CONTEXT, 3, 0) &&
1604 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1605 (odr_sequence_of(o, z_DiagRec, &(*p)->diagnostics,
1606 &(*p)->num_diagnostics) || odr_ok(o)) &&
1607 odr_implicit(o, z_External, &(*p)->taskPackage, ODR_CONTEXT, 5, 1) &&
1608 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1609 odr_sequence_end(o);
1612 /* ------------------------ SORT ------------------------- */
1614 int z_SortAttributes(ODR o, Z_SortAttributes **p, int opt)
1616 if (!odr_sequence_begin(o, p, sizeof(**p)))
1617 return opt && odr_ok(o);
1619 odr_oid(o, &(*p)->id, 0) &&
1620 z_AttributeList(o, &(*p)->list, 0) &&
1621 odr_sequence_end(o);
1624 int z_SortKey(ODR o, Z_SortKey **p, int opt)
1626 static Odr_arm arm[] =
1628 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_SortKey_sortField,
1629 z_InternationalString},
1630 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortKey_elementSpec, z_Specification},
1631 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortKey_sortAttributes,
1636 if (!odr_initmember(o, p, sizeof(**p)))
1637 return opt && odr_ok(o);
1638 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1641 return opt && odr_ok(o);
1644 int z_SortDbSpecific(ODR o, Z_SortDbSpecific **p, int opt)
1646 if (!odr_sequence_begin(o, p, sizeof(**p)))
1647 return opt && odr_ok(o);
1649 z_DatabaseName(o, &(*p)->databaseName, 0) &&
1650 z_SortKey(o, &(*p)->dbSort, 0) &&
1651 odr_sequence_end(o);
1654 int z_SortDbSpecificList(ODR o, Z_SortDbSpecificList **p, int opt)
1656 if (!odr_initmember(o, p, sizeof(**p)))
1657 return opt && odr_ok(o);
1658 if (odr_sequence_of(o, z_SortDbSpecific, &(*p)->dbSpecific,
1659 &(*p)->num_dbSpecific))
1662 return opt && odr_ok(o);
1665 int z_SortElement(ODR o, Z_SortElement **p, int opt)
1667 static Odr_arm arm[] =
1669 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_SortElement_generic, z_SortKey},
1670 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortElement_databaseSpecific,
1671 z_SortDbSpecificList},
1675 if (!odr_initmember(o, p, sizeof(**p)))
1676 return opt && odr_ok(o);
1677 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1680 return opt && odr_ok(o);
1683 int z_SortMissingValueAction(ODR o, Z_SortMissingValueAction **p, int opt)
1685 static Odr_arm arm[] =
1687 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortMissingValAct_abort, odr_null},
1688 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortMissingValAct_null, odr_null},
1689 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_SortMissingValAct_valData,
1694 if (!odr_initmember(o, p, sizeof(**p)))
1695 return opt && odr_ok(o);
1696 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1699 return opt && odr_ok(o);
1702 int z_SortKeySpec(ODR o, Z_SortKeySpec **p, int opt)
1704 if (!odr_sequence_begin(o, p, sizeof(**p)))
1705 return opt && odr_ok(o);
1707 z_SortElement(o, &(*p)->sortElement, 0) &&
1708 odr_implicit(o, odr_integer, &(*p)->sortRelation, ODR_CONTEXT, 1, 0) &&
1709 odr_implicit(o, odr_integer, &(*p)->caseSensitivity, ODR_CONTEXT,
1711 odr_explicit(o, z_SortMissingValueAction, &(*p)->missingValueAction,
1712 ODR_CONTEXT, 3, 1) &&
1713 odr_sequence_end(o);
1716 int z_SortResponse(ODR o, Z_SortResponse **p, int opt)
1718 if (!odr_sequence_begin(o, p, sizeof(**p)))
1719 return opt && odr_ok(o);
1721 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1722 odr_implicit(o, odr_integer, &(*p)->sortStatus, ODR_CONTEXT,
1724 odr_implicit(o, odr_integer, &(*p)->resultSetStatus, ODR_CONTEXT,
1726 odr_implicit(o, z_DiagRecs, &(*p)->diagnostics, ODR_CONTEXT, 5, 1) &&
1727 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1728 odr_sequence_end(o);
1731 int z_SortKeySpecList(ODR o, Z_SortKeySpecList **p, int opt)
1733 if (!odr_initmember(o, p, sizeof(**p)))
1734 return opt && odr_ok(o);
1735 if (odr_sequence_of(o, z_SortKeySpec, &(*p)->specs, &(*p)->num_specs))
1738 return opt && odr_ok(o);
1741 int z_SortRequest(ODR o, Z_SortRequest **p, int opt)
1743 if (!odr_sequence_begin(o, p, sizeof(**p)))
1744 return opt && odr_ok(o);
1746 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1747 odr_implicit(o, z_StringList, &(*p)->inputResultSetNames,
1748 ODR_CONTEXT, 3, 0) &&
1749 odr_implicit(o, z_InternationalString, &(*p)->sortedResultSetName,
1750 ODR_CONTEXT, 4, 0) &&
1751 odr_implicit(o, z_SortKeySpecList, &(*p)->sortSequence, ODR_CONTEXT,
1753 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1754 odr_sequence_end(o);
1757 /* ---------------------- Resource Report ---------------- */
1759 int z_ResourceReportRequest(ODR o, Z_ResourceReportRequest **p, int opt)
1761 if (!odr_sequence_begin(o, p, sizeof(**p)))
1762 return opt && odr_ok(o);
1764 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1765 odr_implicit(o, z_ReferenceId, &(*p)->opId, ODR_CONTEXT, 210, 1) &&
1766 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat, ODR_CONTEXT,
1768 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1769 odr_sequence_end(o);
1772 int z_ResourceReportResponse(ODR o, Z_ResourceReportResponse **p, int opt)
1774 if (!odr_sequence_begin(o, p, sizeof(**p)))
1775 return opt && odr_ok(o);
1777 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1778 odr_implicit(o, odr_integer, &(*p)->resourceReportStatus,
1779 ODR_CONTEXT, 50, 0) &&
1780 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1782 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1783 odr_sequence_end(o);
1786 /* ------------------------ APDU ------------------------- */
1788 int z_APDU(ODR o, Z_APDU **p, int opt)
1790 static Odr_arm arm[] =
1792 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
1793 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
1794 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
1795 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
1797 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
1799 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
1801 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
1802 z_DeleteResultSetRequest},
1803 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
1804 z_DeleteResultSetResponse},
1805 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_APDU_accessControlRequest,
1806 z_AccessControlRequest},
1807 {ODR_IMPLICIT, ODR_CONTEXT, 29, Z_APDU_accessControlResponse,
1808 z_AccessControlResponse},
1809 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
1810 z_ResourceControlRequest},
1811 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
1812 z_ResourceControlResponse},
1813 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
1814 z_TriggerResourceControlRequest},
1815 {ODR_IMPLICIT, ODR_CONTEXT, 33, Z_APDU_resourceReportRequest,
1816 z_ResourceReportRequest},
1817 {ODR_IMPLICIT, ODR_CONTEXT, 34, Z_APDU_resourceReportResponse,
1818 z_ResourceReportResponse},
1819 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
1820 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
1821 {ODR_IMPLICIT, ODR_CONTEXT, 43, Z_APDU_sortRequest, z_SortRequest},
1822 {ODR_IMPLICIT, ODR_CONTEXT, 44, Z_APDU_sortResponse, z_SortResponse},
1823 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_APDU_segmentRequest, z_Segment},
1824 {ODR_IMPLICIT, ODR_CONTEXT, 46, Z_APDU_extendedServicesRequest,
1825 z_ExtendedServicesRequest},
1826 {ODR_IMPLICIT, ODR_CONTEXT, 47, Z_APDU_extendedServicesResponse,
1827 z_ExtendedServicesResponse},
1828 {ODR_IMPLICIT, ODR_CONTEXT, 48, Z_APDU_close, z_Close},
1833 if (o->direction == ODR_DECODE)
1834 *p = odr_malloc(o, sizeof(**p));
1835 odr_setlenlen(o, 5);
1836 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
1838 if (o->direction == ODR_DECODE)
1840 return opt && odr_ok(o);