2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.51 1996-07-26 14:07:21 quinn
10 * Revision 1.50 1996/07/26 13:36:15 quinn
13 * Revision 1.49 1996/07/06 19:58:28 quinn
14 * System headerfiles gathered in yconfig
16 * Revision 1.48 1996/06/10 08:53:33 quinn
17 * Added Summary,OPAC,ResourceReport
19 * Revision 1.47 1996/05/29 15:47:50 quinn
20 * Fixed in bug DiagRecs decoder. Thanks to Linda Harris.
22 * Revision 1.46 1996/04/10 11:39:42 quinn
23 * Fixed bug in UserInfo
25 * Revision 1.45 1996/02/23 10:00:25 quinn
28 * Revision 1.44 1996/02/20 12:51:41 quinn
29 * Completed SCAN. Fixed problems with EXTERNAL.
31 * Revision 1.43 1996/02/10 12:22:49 quinn
34 * Revision 1.42 1996/01/22 09:46:31 quinn
35 * Added Sort PDU. Moved StringList to main protocol file.
37 * Revision 1.41 1996/01/10 15:21:24 quinn
38 * Added links to access control PDUs
40 * Revision 1.40 1996/01/02 11:46:40 quinn
41 * Changed 'operator' to 'roperator' to avoid C++ conflict.
43 * Revision 1.39 1995/09/29 17:11:53 quinn
46 * Revision 1.38 1995/09/27 15:02:40 quinn
47 * Modified function heads & prototypes.
49 * Revision 1.37 1995/08/21 09:10:15 quinn
50 * Smallish fixes to suppport new formats.
52 * Revision 1.36 1995/08/15 11:59:39 quinn
55 * Revision 1.35 1995/08/10 08:53:59 quinn
58 * Revision 1.34 1995/06/19 17:01:48 quinn
59 * This should bring us in sync with the version distributed as 1.0b
61 * Revision 1.33 1995/06/19 13:39:56 quinn
62 * *** empty log message ***
64 * Revision 1.32 1995/06/19 12:37:28 quinn
65 * Fixed a bug in the compspec.
67 * Revision 1.31 1995/06/16 13:15:56 quinn
68 * Fixed Defaultdiagformat.
70 * Revision 1.30 1995/06/15 15:42:01 quinn
73 * Revision 1.29 1995/06/15 07:44:49 quinn
76 * Revision 1.28 1995/06/14 15:26:35 quinn
77 * *** empty log message ***
79 * Revision 1.27 1995/06/07 14:36:22 quinn
82 * Revision 1.26 1995/06/02 09:49:13 quinn
83 * Adding access control
85 * Revision 1.25 1995/05/25 11:00:08 quinn
86 * *** empty log message ***
88 * Revision 1.24 1995/05/22 13:58:18 quinn
89 * Fixed an ODR_NULLVAL.
91 * Revision 1.23 1995/05/22 11:30:18 quinn
92 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
94 * Revision 1.22 1995/05/17 08:40:56 quinn
95 * Added delete. Fixed some sequence_begins. Smallish.
97 * Revision 1.21 1995/05/16 08:50:24 quinn
98 * License, documentation, and memory fixes
100 * Revision 1.20 1995/05/15 11:55:25 quinn
103 * Revision 1.19 1995/04/11 11:58:35 quinn
106 * Revision 1.18 1995/04/11 11:52:02 quinn
107 * Fixed possible buf in proto.c
109 * Revision 1.17 1995/04/10 10:22:22 quinn
112 * Revision 1.16 1995/03/30 10:26:43 quinn
113 * Added Term structure
115 * Revision 1.15 1995/03/30 09:08:39 quinn
116 * Added Resource control protocol
118 * Revision 1.14 1995/03/29 08:06:13 quinn
119 * Added a few v3 elements
121 * Revision 1.13 1995/03/20 11:26:52 quinn
122 * *** empty log message ***
124 * Revision 1.12 1995/03/20 09:45:09 quinn
127 * Revision 1.11 1995/03/17 10:17:25 quinn
128 * Added memory management.
130 * Revision 1.10 1995/03/15 11:17:40 quinn
131 * Fixed some return-checks from choice.. need better ay to handle those..
133 * Revision 1.9 1995/03/15 08:37:06 quinn
134 * Fixed protocol bugs.
136 * Revision 1.8 1995/03/14 16:59:24 quinn
137 * Fixed OPTIONAL flag in attributeelement
139 * Revision 1.7 1995/03/07 16:29:33 quinn
140 * Added authentication stuff.
142 * Revision 1.6 1995/03/01 14:46:03 quinn
143 * Fixed protocol bug in 8777query.
145 * Revision 1.5 1995/02/14 11:54:22 quinn
148 * Revision 1.4 1995/02/10 15:54:30 quinn
151 * Revision 1.3 1995/02/09 15:51:39 quinn
154 * Revision 1.2 1995/02/06 21:26:07 quinn
155 * Repaired this evening's damages..
157 * Revision 1.1 1995/02/06 16:44:47 quinn
158 * First hack at Z/SR protocol
166 /* ---------------------- GLOBAL DEFS ------------------- */
169 * We'll use a general octetstring here, since string operations are
170 * clumsy on long strings.
172 int z_SUTRS(ODR o, Odr_oct **p, int opt)
174 return odr_implicit(o, odr_octetstring, p, ODR_UNIVERSAL,
175 ODR_GENERALSTRING, opt);
178 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
180 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
183 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
185 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
189 int z_ResultSetId(ODR o, char **p, int opt)
191 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
195 int z_ElementSetName(ODR o, char **p, int opt)
197 return odr_implicit(o, odr_visiblestring, p, ODR_CONTEXT, 103, opt);
200 int z_UserInformationField(ODR o, Z_External **p, int opt)
202 return odr_explicit(o, z_External, (Z_External **)p, ODR_CONTEXT,
206 int z_InternationalString(ODR o, char **p, int opt)
208 return odr_generalstring(o, p, opt);
211 int z_InfoCategory(ODR o, Z_InfoCategory **p, int opt)
213 if (!odr_sequence_begin(o, p, sizeof(**p)))
214 return opt && odr_ok(o);
216 odr_implicit(o, odr_oid, &(*p)->categoryTypeId, ODR_CONTEXT, 1, 1) &&
217 odr_implicit(o, odr_integer, &(*p)->categoryValue, ODR_CONTEXT, 2, 0) &&
221 int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt)
223 static Odr_arm arm[] =
225 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_OtherInfo_characterInfo,
227 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_OtherInfo_binaryInfo,
229 {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_OtherInfo_externallyDefinedInfo,
231 {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_OtherInfo_oid, odr_oid},
235 if (!odr_sequence_begin(o, p, sizeof(**p)))
236 return opt && odr_ok(o);
238 odr_implicit(o, z_InfoCategory, &(*p)->category, ODR_CONTEXT, 1, 1) &&
239 odr_choice(o, arm, &(*p)->information, &(*p)->which) &&
243 int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt)
245 if (o->direction == ODR_DECODE)
246 *p = odr_malloc(o, sizeof(**p));
249 odr_implicit_settag(o, ODR_CONTEXT, 201);
250 if (odr_sequence_of(o, z_OtherInformationUnit, &(*p)->list,
251 &(*p)->num_elements))
254 return opt && odr_ok(o);
257 int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt)
259 static Odr_arm arm[] =
261 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_StringOrNumeric_string,
263 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_StringOrNumeric_numeric,
268 if (o->direction == ODR_DECODE)
269 *p = odr_malloc(o, sizeof(**p));
272 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
275 return opt && odr_ok(o);
281 int z_Unit(ODR o, Z_Unit **p, int opt)
283 if (!odr_sequence_begin(o, p, sizeof(**p)))
284 return opt && odr_ok(o);
286 odr_explicit(o, z_InternationalString, &(*p)->unitSystem, ODR_CONTEXT,
288 odr_explicit(o, z_StringOrNumeric, &(*p)->unitType, ODR_CONTEXT,
290 odr_explicit(o, z_StringOrNumeric, &(*p)->unit, ODR_CONTEXT, 3, 1) &&
291 odr_implicit(o, odr_integer, &(*p)->scaleFactor, ODR_CONTEXT, 4, 1) &&
295 int z_IntUnit(ODR o, Z_IntUnit **p, int opt)
297 if (!odr_sequence_begin(o, p, sizeof(**p)))
298 return opt && odr_ok(o);
300 odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 1, 0) &&
301 odr_implicit(o, z_Unit, &(*p)->unitUsed, ODR_CONTEXT, 2, 0) &&
305 int z_StringList(ODR o, Z_StringList **p, int opt)
307 if (o->direction == ODR_DECODE)
308 *p = odr_malloc(o, sizeof(**p));
311 if (odr_sequence_of(o, z_InternationalString, &(*p)->strings,
315 return opt && odr_ok(o);
318 /* ---------------------- INITIALIZE SERVICE ------------------- */
321 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
323 if (!odr_sequence_begin(o, p, sizeof(**p)))
324 return opt && odr_ok(o);
326 odr_visiblestring(o, &(*p)->user, 0) &&
327 odr_visiblestring(o, &(*p)->password, 0) &&
328 odr_visiblestring(o, &(*p)->account, 0) &&
333 int z_IdPass(ODR o, Z_IdPass **p, int opt)
335 if (!odr_sequence_begin(o, p, sizeof(**p)))
336 return opt && odr_ok(o);
338 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 1) &&
339 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 1) &&
340 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
345 int z_StrAuthentication(ODR o, char **p, int opt)
347 return odr_visiblestring(o, p, opt);
350 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
352 static Odr_arm arm[] =
354 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
355 {-1, -1, -1, Z_IdAuthentication_idPass, z_IdPass},
356 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
357 {-1, -1, -1, Z_IdAuthentication_other, z_External},
361 if (o->direction == ODR_DECODE)
362 *p = odr_malloc(o, sizeof(**p));
366 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
369 return opt && odr_ok(o);
372 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
376 if (!odr_sequence_begin(o, p, sizeof(**p)))
377 return opt && odr_ok(o);
380 z_ReferenceId(o, &pp->referenceId, 1) &&
381 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
383 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
384 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
386 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
388 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
390 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
392 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
394 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
395 ODR_CONTEXT, 112, 1) &&
396 z_UserInformationField(o, &pp->userInformationField, 1) &&
398 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
403 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
407 if (!odr_sequence_begin(o, p, sizeof(**p)))
408 return opt && odr_ok(o);
411 z_ReferenceId(o, &pp->referenceId, 1) &&
412 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
414 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
415 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
417 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
419 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
420 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
422 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
424 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
425 ODR_CONTEXT, 112, 1) &&
426 z_UserInformationField(o, &pp->userInformationField, 1) &&
428 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
433 /* ------------------ RESOURCE CONTROL ----------------*/
435 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
438 if (!odr_sequence_begin(o, p, sizeof(**p)))
439 return opt && odr_ok(o);
441 z_ReferenceId(o, &(*p)->referenceId, 1) &&
442 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
444 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
445 ODR_CONTEXT, 47, 1) &&
446 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
449 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
454 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
456 if (!odr_sequence_begin(o, p, sizeof(**p)))
457 return opt && odr_ok(o);
459 z_ReferenceId(o, &(*p)->referenceId, 1) &&
460 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
461 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
463 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
464 ODR_CONTEXT, 41, 1) &&
465 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
467 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
468 ODR_CONTEXT, 43, 1) &&
470 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
475 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
477 if (!odr_sequence_begin(o, p, sizeof(**p)))
478 return opt && odr_ok(o);
480 z_ReferenceId(o, &(*p)->referenceId, 1) &&
481 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
482 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
485 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
490 /* ------------------------ SEARCH SERVICE ----------------------- */
492 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
494 if (!odr_sequence_begin(o, p, sizeof(**p)))
495 return opt && odr_ok(o);
497 z_DatabaseName(o, &(*p)->databaseName, 0) &&
498 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
502 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
504 if (o->direction == ODR_DECODE)
505 *p = odr_malloc(o, sizeof(**p));
509 odr_implicit_settag(o, ODR_CONTEXT, 1);
510 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
511 &(*p)->num_elements))
517 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
519 static Odr_arm arm[] =
521 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
523 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
528 if (o->direction == ODR_DECODE)
529 *p = odr_malloc(o, sizeof(**p));
531 return opt && odr_ok(o);
533 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
539 /* ----------------------- RPN QUERY -----------------------*/
541 int z_ComplexAttribute(ODR o, Z_ComplexAttribute **p, int opt)
543 if (!odr_sequence_begin(o, p, sizeof(**p)))
544 return opt && odr_ok(o);
546 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
547 odr_sequence_of(o, z_StringOrNumeric, &(*p)->list,
549 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
550 (odr_sequence_of(o, odr_integer, &(*p)->semanticAction,
551 &(*p)->num_semanticAction) || odr_ok(o)) &&
555 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
558 static Odr_arm arm[] =
560 {ODR_IMPLICIT, ODR_CONTEXT, 121, Z_AttributeValue_numeric,
562 {ODR_IMPLICIT, ODR_CONTEXT, 224, Z_AttributeValue_complex,
568 if (!odr_sequence_begin(o, p, sizeof(**p)))
569 return opt && odr_ok(o);
572 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 1, 1) &&
574 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
577 odr_choice(o, arm, &(*p)->value, &(*p)->which) &&
579 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
585 int z_Term(ODR o, Z_Term **p, int opt)
587 static Odr_arm arm[] =
589 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
590 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
591 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
593 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
594 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
595 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, z_External},
596 /* add intUnit here */
597 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
601 if (o->direction ==ODR_DECODE)
602 *p = odr_malloc(o, sizeof(**p));
605 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
608 return opt && odr_ok(o);
611 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
613 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
614 odr_sequence_begin(o, p, sizeof(**p))))
615 return opt && odr_ok(o);
617 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
618 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
619 &(*p)->num_attributes) &&
620 z_Term(o, &(*p)->term, 0) &&
624 int z_ResultSetPlusAttributes(ODR o, Z_ResultSetPlusAttributes **p, int opt)
626 if (!(odr_implicit_settag(o, ODR_CONTEXT, 214) &&
627 odr_sequence_begin(o, p, sizeof(**p))))
628 return opt && odr_ok(o);
630 z_ResultSetId(o, &(*p)->resultSet, 0) &&
631 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
632 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
633 &(*p)->num_attributes) &&
637 int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
639 static Odr_arm arm[] =
641 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, odr_integer},
642 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_private, odr_integer},
646 if (!odr_sequence_begin(o, p, sizeof(**p)))
647 return opt && odr_ok(o);
649 odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
650 odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
651 odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
652 odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
653 odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
654 odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
655 odr_constructed_end(o) &&
659 int z_Operator(ODR o, Z_Operator **p, int opt)
661 static Odr_arm arm[] =
663 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
664 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
665 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
666 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, z_ProximityOperator},
670 if (!*p && o->direction != ODR_DECODE)
672 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
673 return opt && odr_ok(o);
674 if (o->direction == ODR_DECODE)
675 *p = odr_malloc(o, sizeof(**p));
677 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
678 odr_constructed_end(o))
681 return opt && odr_ok(o);
684 int z_Operand(ODR o, Z_Operand **p, int opt)
686 static Odr_arm arm[] =
688 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
689 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
690 {-1, -1, -1, Z_Operand_resultAttr, z_ResultSetPlusAttributes},
694 if (o->direction == ODR_DECODE)
695 *p = odr_malloc(o, sizeof(**p));
698 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
701 return opt && odr_ok(o);
704 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
706 int z_Complex(ODR o, Z_Complex **p, int opt)
708 if (!odr_sequence_begin(o, p, sizeof(**p)))
709 return opt && odr_ok(o);
711 z_RPNStructure(o, &(*p)->s1, 0) &&
712 z_RPNStructure(o, &(*p)->s2, 0) &&
713 z_Operator(o, &(*p)->roperator, 0) &&
717 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
719 static Odr_arm arm[] =
721 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
722 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
726 if (o->direction == ODR_DECODE)
727 *p = odr_malloc(o, sizeof(**p));
730 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
733 return opt && odr_ok(o);
736 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
738 if (!odr_sequence_begin(o, p, sizeof(**p)))
739 return opt && odr_ok(o);
741 odr_oid(o, &(*p)->attributeSetId, 0) &&
742 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
746 /* -----------------------END RPN QUERY ----------------------- */
748 int z_Query(ODR o, Z_Query **p, int opt)
750 static Odr_arm arm[] =
752 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
753 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
754 {ODR_EXPLICIT, ODR_CONTEXT, 101, Z_Query_type_101, z_RPNQuery},
758 if (o->direction == ODR_DECODE)
759 *p = odr_malloc(o, sizeof(**p));
762 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
765 return opt && odr_ok(o);
768 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
772 if (!odr_sequence_begin(o, p, sizeof(**p)))
773 return opt && odr_ok(o);
776 z_ReferenceId(o, &pp->referenceId, 1) &&
777 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
779 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
781 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
783 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
784 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
786 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
787 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
788 &pp->num_databaseNames) &&
789 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
790 ODR_CONTEXT, 100, 1) &&
791 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
792 ODR_CONTEXT, 101, 1) &&
793 odr_implicit(o, odr_oid, &pp->preferredRecordSyntax,
794 ODR_CONTEXT, 104, 1) &&
795 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
797 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
798 ODR_CONTEXT, 203, 1) &&
799 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
804 /* ------------------------ RECORD ------------------------- */
806 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
808 return z_External(o, (Z_External **) p, opt);
813 int z_DefaultDiagFormat(ODR o, Z_DefaultDiagFormat **p, int opt)
815 static Odr_arm arm[] =
817 {-1, -1, -1, Z_DiagForm_v2AddInfo, odr_visiblestring},
818 {-1, -1, -1, Z_DiagForm_v3AddInfo, z_InternationalString},
819 {ODR_IMPLICIT, ODR_CONTEXT, ODR_VISIBLESTRING, Z_DiagForm_v2AddInfo,
820 odr_visiblestring}, /* To cater to a bug in the CNIDR servers */
823 if (!odr_sequence_begin(o, p, sizeof(**p)))
824 return opt && odr_ok(o);
826 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
827 odr_integer(o, &(*p)->condition, 0) &&
829 * I no longer recall what server tagged the addinfo.. but it isn't
830 * hurting anyone, so...
831 * We need to turn it into a choice, or something, because of
832 * that damn generalstring in v3.
834 odr_choice(o, arm, &(*p)->addinfo, &(*p)->which) &&
838 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
840 static Odr_arm arm[] =
842 {-1, -1, -1, Z_DiagRec_defaultFormat, z_DefaultDiagFormat},
843 {-1, -1, -1, Z_DiagRec_externallyDefined, z_External},
847 if (o->direction == ODR_DECODE)
848 *p = odr_malloc(o, sizeof(**p));
851 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
854 return opt && odr_ok(o);
859 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
861 if (!odr_sequence_begin(o, p, sizeof(**p)))
862 return opt && odr_ok(o);
864 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
865 odr_integer(o, &(*p)->condition, 0) &&
867 * I no longer recall what server tagged the addinfo.. but it isn't
868 * hurting anyone, so...
869 * We need to turn it into a choice, or something, because of
870 * that damn generalstring in v3.
872 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
873 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT,
874 ODR_VISIBLESTRING, 1)) &&
880 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
882 if (o->direction == ODR_DECODE)
883 *p = odr_malloc(o, sizeof(**p));
887 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
888 &(*p)->num_diagRecs))
891 return opt && odr_ok(o);
894 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
896 static Odr_arm arm[] =
898 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
900 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
905 if (!odr_sequence_begin(o, p, sizeof(**p)))
906 return opt && odr_ok(o);
908 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
910 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
911 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
912 odr_constructed_end(o) &&
916 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
918 if (o->direction == ODR_DECODE)
919 *p = odr_malloc(o, sizeof(**p));
922 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
929 int z_Records(ODR o, Z_Records **p, int opt)
931 static Odr_arm arm[] =
933 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
934 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
935 {ODR_IMPLICIT, ODR_CONTEXT, 205, Z_Records_multipleNSD,
940 if (o->direction == ODR_DECODE)
941 *p = odr_malloc(o, sizeof(**p));
944 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
947 return opt && odr_ok(o);
950 /* ------------------------ ACCESS CTRL SERVICE ----------------------- */
952 int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
954 static Odr_arm arm[] =
956 {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
958 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
962 if (!odr_sequence_begin(o, p, sizeof(**p)))
963 return opt && odr_ok(o);
965 z_ReferenceId(o, &(*p)->referenceId, 1) &&
966 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
968 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
973 int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
975 static Odr_arm arm[] =
977 {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
979 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
983 if (!odr_sequence_begin(o, p, sizeof(**p)))
984 return opt && odr_ok(o);
986 z_ReferenceId(o, &(*p)->referenceId, 1) &&
987 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
988 odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
990 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
995 /* ------------------------ SCAN SERVICE -------------------- */
997 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
999 if (o->direction == ODR_DECODE)
1000 *p = odr_malloc(o, sizeof(**p));
1004 odr_implicit_settag(o, ODR_CONTEXT, 44);
1005 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
1006 &(*p)->num_attributes))
1009 return opt && odr_ok(o);
1013 * This is a temporary hack. We don't know just *what* old version of the
1014 * protocol willow uses, so we'll just patiently wait for them to update
1016 static int willow_scan = 0;
1018 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
1020 if (!*p && o->direction != ODR_DECODE)
1022 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
1025 return opt && odr_ok(o);
1027 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
1029 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
1031 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
1033 if (o->direction == ODR_DECODE)
1034 *p = odr_malloc(o, sizeof(**p));
1035 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
1036 &(*p)->num_attributes))
1038 if (!odr_sequence_end(o) || !odr_sequence_end(o))
1040 if (!z_Term(o, &(*p)->term, 0))
1042 if (!odr_constructed_end(o))
1048 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
1050 if (o->direction == ODR_DECODE)
1051 *p = odr_malloc(o, sizeof(**p));
1055 return opt && odr_ok(o);
1058 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
1062 return opt && !o->error;
1067 int z_ByDatabase(ODR o, Z_ByDatabase **p, int opt)
1069 if (!odr_sequence_begin(o, p, sizeof(**p)))
1070 return opt && odr_ok(o);
1072 z_DatabaseName(o, &(*p)->db, 1) &&
1073 odr_implicit(o, odr_integer, &(*p)->num, ODR_CONTEXT, 1, 1) &&
1074 z_OtherInformation(o, &(*p)->otherDbInfo, 1) &&
1075 odr_sequence_end(o);
1078 int z_ByDatabaseList(ODR o, Z_ByDatabaseList **p, int opt)
1080 if (!odr_initmember(o, p, sizeof(**p)))
1081 return opt && odr_ok(o);
1082 if (odr_sequence_of(o, z_ByDatabase, &(*p)->elements, &(*p)->num_elements))
1085 return opt && odr_ok(o);
1088 int z_ScanOccurrences(ODR o, Z_ScanOccurrences **p, int opt)
1092 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_ScanOccurrences_global, odr_integer},
1093 {ODR_EXPLICIT, ODR_CONTEXT, 3, Z_ScanOccurrences_byDatabase,
1098 if (!odr_initmember(o, p, sizeof(**p)))
1099 return opt && odr_ok(o);
1100 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1103 return opt && odr_ok(o);
1106 int z_OccurrenceByAttributesElem(ODR o, Z_OccurrenceByAttributesElem **p,
1109 if (!odr_sequence_begin(o, p, sizeof(**p)))
1110 return opt && odr_ok(o);
1112 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT,
1114 z_ScanOccurrences(o, &(*p)->occurrences, 1) &&
1115 z_OtherInformation(o, &(*p)->otherOccurInfo, 1) &&
1116 odr_sequence_end(o);
1119 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1121 if (!odr_initmember(o, p, sizeof(**p)))
1122 return opt && odr_ok(o);
1123 if (!odr_sequence_of(o, z_OccurrenceByAttributesElem, &(*p)->elements,
1124 &(*p)->num_elements))
1127 return opt && odr_ok(o);
1133 * Incomplete definition of occurencebyattributes.
1136 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1138 if (!odr_sequence_begin(o, p, sizeof(**p)))
1139 return opt && odr_ok(o);
1141 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
1142 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
1143 odr_sequence_end(o);
1148 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
1150 if (!odr_sequence_begin(o, p, sizeof(**p)))
1151 return opt && odr_ok(o);
1154 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
1155 z_Term(o, &(*p)->term, 0)) &&
1156 odr_implicit(o, z_InternationalString, &(*p)->displayTerm, ODR_CONTEXT,
1158 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
1159 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
1160 ODR_CONTEXT, 4, 1) &&
1161 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
1163 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
1164 ODR_CONTEXT, 3, 1) &&
1165 z_OtherInformation(o, &(*p)->otherTermInfo, 1) &&
1166 odr_sequence_end(o);
1169 int z_Entry(ODR o, Z_Entry **p, int opt)
1171 static Odr_arm arm[] =
1173 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
1174 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
1179 if (o->direction == ODR_DECODE)
1180 *p = odr_malloc(o, sizeof(**p));
1184 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1187 return opt && odr_ok(o);
1190 int z_Entries(ODR o, Z_Entries **p, int opt)
1192 if (o->direction == ODR_DECODE)
1193 *p = odr_malloc(o, sizeof(**p));
1197 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
1198 &(*p)->num_entries))
1204 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
1206 static Odr_arm arm[] =
1208 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
1209 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
1214 if (o->direction == ODR_DECODE)
1215 *p = odr_malloc(o, sizeof(**p));
1219 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1222 return opt && odr_ok(o);
1225 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
1227 if (!odr_sequence_begin(o, p, sizeof(**p)))
1228 return opt && odr_ok(o);
1231 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1232 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1233 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
1234 &(*p)->num_databaseNames) &&
1235 odr_oid(o, &(*p)->attributeSet, 1) &&
1236 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
1237 ((*p)->termListAndStartPoint ? 1 :
1238 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
1239 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
1240 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
1241 ODR_CONTEXT, 6, 0) &&
1242 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
1243 ODR_CONTEXT, 7, 1) &&
1244 odr_sequence_end(o);
1247 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
1249 if (!odr_sequence_begin(o, p, sizeof(**p)))
1250 return opt && odr_ok(o);
1252 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1253 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
1254 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
1255 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
1256 ODR_CONTEXT, 5, 0) &&
1257 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
1258 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
1259 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
1260 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1261 odr_sequence_end(o);
1264 /* ------------------------ SEARCHRESPONSE ----------------*/
1266 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
1268 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
1271 int z_NextResultSetPosition(ODR o, int **p, int opt)
1273 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
1276 int z_PresentStatus(ODR o, int **p, int opt)
1278 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
1281 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
1283 Z_SearchResponse *pp;
1285 if (!odr_sequence_begin(o, p, sizeof(**p)))
1286 return opt && odr_ok(o);
1289 z_ReferenceId(o, &pp->referenceId, 1) &&
1290 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
1291 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1292 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1293 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
1294 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26,
1296 z_PresentStatus(o, &pp->presentStatus, 1) &&
1297 z_Records(o, &pp->records, 1) &&
1299 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
1300 ODR_CONTEXT, 203, 1) &&
1301 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1303 odr_sequence_end(o);
1306 /* --------------------- PRESENT SERVICE ---------------------- */
1308 int z_ElementSpec(ODR o, Z_ElementSpec **p, int opt)
1310 static Odr_arm arm[] =
1312 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSpec_elementSetName,
1314 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ElementSpec_externalSpec,
1319 if (o->direction == ODR_DECODE)
1320 *p = odr_malloc(o, sizeof(**p));
1324 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1327 return opt && odr_ok(o);
1330 int z_Specification(ODR o, Z_Specification **p, int opt)
1332 if (!odr_sequence_begin(o, p, sizeof(**p)))
1333 return opt && odr_ok(o);
1335 odr_implicit(o, odr_oid, &(*p)->schema, ODR_CONTEXT, 1, 1) &&
1336 z_ElementSpec(o, &(*p)->elementSpec, 1) &&
1337 odr_sequence_end(o);
1340 int z_DbSpecific(ODR o, Z_DbSpecific **p, int opt)
1342 if (!odr_sequence_begin(o, p, sizeof(**p)))
1343 return opt && odr_ok(o);
1345 odr_explicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
1347 odr_implicit(o, z_Specification, &(*p)->spec, ODR_CONTEXT, 2, 0) &&
1348 odr_sequence_end(o);
1351 int z_CompSpec(ODR o, Z_CompSpec **p, int opt)
1353 if (!odr_sequence_begin(o, p, sizeof(**p)))
1354 return opt && odr_ok(o);
1356 odr_implicit(o, odr_bool, &(*p)->selectAlternativeSyntax, ODR_CONTEXT,
1358 odr_implicit(o, z_Specification, &(*p)->generic, ODR_CONTEXT, 2, 1) &&
1359 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1360 (odr_sequence_of(o, z_DbSpecific, &(*p)->dbSpecific,
1361 &(*p)->num_dbSpecific) || odr_ok(o)) &&
1362 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1363 (odr_sequence_of(o, odr_oid, &(*p)->recordSyntax,
1364 &(*p)->num_recordSyntax) || odr_ok(o)) &&
1365 odr_sequence_end(o);
1368 int z_RecordComposition(ODR o, Z_RecordComposition **p, int opt)
1370 static Odr_arm arm[] =
1372 {ODR_EXPLICIT, ODR_CONTEXT, 19, Z_RecordComp_simple,
1374 {ODR_IMPLICIT, ODR_CONTEXT, 209, Z_RecordComp_complex,
1379 if (o->direction == ODR_DECODE)
1380 *p = odr_malloc(o, sizeof(**p));
1384 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1387 return opt && odr_ok(o);
1390 int z_Range(ODR o, Z_Range **p, int opt)
1392 if (!odr_sequence_begin(o, p, sizeof(**p)))
1393 return opt && odr_ok(o);
1395 odr_implicit(o, odr_integer, &(*p)->startingPosition, ODR_CONTEXT,
1397 odr_implicit(o, odr_integer, &(*p)->numberOfRecords, ODR_CONTEXT,
1399 odr_sequence_end(o);
1402 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
1404 Z_PresentRequest *pp;
1406 if (!odr_sequence_begin(o, p, sizeof(**p)))
1407 return opt && odr_ok(o);
1410 z_ReferenceId(o, &pp->referenceId, 1) &&
1411 z_ResultSetId(o, &pp->resultSetId, 0) &&
1412 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
1414 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
1417 odr_implicit_settag(o, ODR_CONTEXT, 212) &&
1418 (odr_sequence_of(o, z_Range, &(*p)->additionalRanges,
1419 &(*p)->num_ranges) || odr_ok(o)) &&
1420 z_RecordComposition(o, &(*p)->recordComposition, 1) &&
1422 odr_explicit(o, z_ElementSetNames, &pp->elementSetNames, ODR_CONTEXT,
1425 odr_implicit(o, odr_oid, &(*p)->preferredRecordSyntax, ODR_CONTEXT,
1428 odr_implicit(o, odr_integer, &(*p)->maxSegmentCount, ODR_CONTEXT,
1430 odr_implicit(o, odr_integer, &(*p)->maxRecordSize, ODR_CONTEXT,
1432 odr_implicit(o, odr_integer, &(*p)->maxSegmentSize, ODR_CONTEXT,
1434 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1436 odr_sequence_end(o);
1439 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
1441 Z_PresentResponse *pp;
1443 if (!odr_sequence_begin(o, p, sizeof(**p)))
1444 return opt && odr_ok(o);
1447 z_ReferenceId(o, &pp->referenceId, 1) &&
1448 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1449 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1450 z_PresentStatus(o, &pp->presentStatus, 0) &&
1451 z_Records(o, &pp->records, 1) &&
1453 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1455 odr_sequence_end(o);
1458 /* ----------------------DELETE -------------------------- */
1460 int z_DeleteSetStatus(ODR o, int **p, int opt)
1462 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
1465 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
1467 if (!odr_sequence_begin(o, p, sizeof(**p)))
1468 return opt && odr_ok(o);
1470 z_ResultSetId(o, &(*p)->id, 0) &&
1471 z_DeleteSetStatus(o, &(*p)->status, 0) &&
1472 odr_sequence_end(o);
1475 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
1477 if (!odr_sequence_begin(o, p, sizeof(**p)))
1478 return opt && odr_ok(o);
1480 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1481 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
1483 (odr_sequence_of(o, z_ListStatus, &(*p)->resultSetList,
1484 &(*p)->num_ids) || odr_ok(o)) &&
1486 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1488 odr_sequence_end(o);
1491 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
1493 if (!odr_sequence_begin(o, p, sizeof(**p)))
1494 return opt && odr_ok(o);
1496 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1497 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
1498 ODR_CONTEXT, 0, 1) &&
1499 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
1500 (odr_sequence_of(o, z_ListStatus, &(*p)->deleteListStatuses,
1501 &(*p)->num_statuses) || odr_ok(o)) &&
1502 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
1504 odr_implicit_settag(o, ODR_CONTEXT, 35) &&
1505 (odr_sequence_of(o, z_ListStatus, &(*p)->bulkStatuses,
1506 &(*p)->num_bulkStatuses) || odr_ok(o)) &&
1507 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
1510 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1512 odr_sequence_end(o);
1515 /* ------------------------ SEGMENT SERVICE -------------- */
1517 int z_Segment(ODR o, Z_Segment **p, int opt)
1519 if (!odr_sequence_begin(o, p, sizeof(**p)))
1520 return opt && odr_ok(o);
1522 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1523 odr_implicit(o, odr_integer, &(*p)->numberOfRecordsReturned,
1524 ODR_CONTEXT, 24, 0) &&
1525 odr_implicit_settag(o, ODR_CONTEXT, 0) &&
1526 odr_sequence_of(o, z_NamePlusRecord, &(*p)->segmentRecords,
1527 &(*p)->num_segmentRecords) &&
1528 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1529 odr_sequence_end(o);
1532 /* ------------------------ CLOSE SERVICE ---------------- */
1534 int z_Close(ODR o, Z_Close **p, int opt)
1536 if (!odr_sequence_begin(o, p, sizeof(**p)))
1537 return opt && odr_ok(o);
1539 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1540 odr_implicit(o, odr_integer, &(*p)->closeReason, ODR_CONTEXT, 211, 0) &&
1541 odr_implicit(o, odr_visiblestring, &(*p)->diagnosticInformation,
1542 ODR_CONTEXT, 3, 1) &&
1543 odr_implicit(o, odr_oid, &(*p)->resourceReportFormat, ODR_CONTEXT,
1545 odr_implicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1548 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1550 odr_sequence_end(o);
1553 /* ------------------------ APDU ------------------------- */
1555 int z_Permissions(ODR o, Z_Permissions **p, int opt)
1557 if (!odr_sequence_begin(o, p, sizeof(**p)))
1558 return opt && odr_ok(o);
1560 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT,
1562 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
1563 odr_sequence_of(o, odr_integer, &(*p)->allowableFunctions,
1564 &(*p)->num_allowableFunctions) &&
1565 odr_sequence_end(o);
1568 int z_ExtendedServicesRequest(ODR o, Z_ExtendedServicesRequest **p, int opt)
1570 if (!odr_sequence_begin(o, p, sizeof(**p)))
1571 return opt && odr_ok(o);
1573 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1574 odr_implicit(o, odr_integer, &(*p)->function, ODR_CONTEXT, 3, 0) &&
1575 odr_implicit(o, odr_oid, &(*p)->packageType, ODR_CONTEXT, 4, 0) &&
1576 odr_implicit(o, z_InternationalString, &(*p)->packageName, ODR_CONTEXT, 5, 1) &&
1577 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT, 6, 1) &&
1578 odr_implicit(o, z_IntUnit, &(*p)->retentionTime, ODR_CONTEXT, 7, 1) &&
1579 odr_implicit(o, z_Permissions, &(*p)->permissions, ODR_CONTEXT, 8, 1) &&
1580 odr_implicit(o, z_InternationalString, &(*p)->description, ODR_CONTEXT, 9, 1) &&
1581 odr_implicit(o, z_External, &(*p)->taskSpecificParameters, ODR_CONTEXT, 10, 1) &&
1582 odr_implicit(o, odr_integer, &(*p)->waitAction, ODR_CONTEXT, 11, 0) &&
1583 z_ElementSetName(o, &(*p)->elements, 1) &&
1584 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1585 odr_sequence_end(o);
1588 int z_ExtendedServicesResponse(ODR o, Z_ExtendedServicesResponse **p, int opt)
1590 if (!odr_sequence_begin(o, p, sizeof(**p)))
1591 return opt && odr_ok(o);
1593 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1594 odr_implicit(o, odr_integer, &(*p)->operationStatus, ODR_CONTEXT, 3, 0) &&
1595 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1596 (odr_sequence_of(o, z_DiagRec, &(*p)->diagnostics,
1597 &(*p)->num_diagnostics) || odr_ok(o)) &&
1598 odr_implicit(o, z_External, &(*p)->taskPackage, ODR_CONTEXT, 5, 1) &&
1599 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1600 odr_sequence_end(o);
1603 /* ------------------------ SORT ------------------------- */
1605 int z_SortAttributes(ODR o, Z_SortAttributes **p, int opt)
1607 if (!odr_sequence_begin(o, p, sizeof(**p)))
1608 return opt && odr_ok(o);
1610 odr_oid(o, &(*p)->id, 0) &&
1611 z_AttributeList(o, &(*p)->list, 0) &&
1612 odr_sequence_end(o);
1615 int z_SortKey(ODR o, Z_SortKey **p, int opt)
1617 static Odr_arm arm[] =
1619 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_SortKey_sortField,
1620 z_InternationalString},
1621 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortKey_elementSpec, z_Specification},
1622 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortKey_sortAttributes,
1627 if (!odr_initmember(o, p, sizeof(**p)))
1628 return opt && odr_ok(o);
1629 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1632 return opt && odr_ok(o);
1635 int z_SortDbSpecific(ODR o, Z_SortDbSpecific **p, int opt)
1637 if (!odr_sequence_begin(o, p, sizeof(**p)))
1638 return opt && odr_ok(o);
1640 z_DatabaseName(o, &(*p)->databaseName, 0) &&
1641 z_SortKey(o, &(*p)->dbSort, 0) &&
1642 odr_sequence_end(o);
1645 int z_SortDbSpecificList(ODR o, Z_SortDbSpecificList **p, int opt)
1647 if (!odr_initmember(o, p, sizeof(**p)))
1648 return opt && odr_ok(o);
1649 if (odr_sequence_of(o, z_SortDbSpecific, &(*p)->dbSpecific,
1650 &(*p)->num_dbSpecific))
1653 return opt && odr_ok(o);
1656 int z_SortElement(ODR o, Z_SortElement **p, int opt)
1658 static Odr_arm arm[] =
1660 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_SortElement_generic, z_SortKey},
1661 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortElement_databaseSpecific,
1662 z_SortDbSpecificList},
1666 if (!odr_initmember(o, p, sizeof(**p)))
1667 return opt && odr_ok(o);
1668 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1671 return opt && odr_ok(o);
1674 int z_SortMissingValueAction(ODR o, Z_SortMissingValueAction **p, int opt)
1676 static Odr_arm arm[] =
1678 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortMissingValAct_abort, odr_null},
1679 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortMissingValAct_null, odr_null},
1680 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_SortMissingValAct_valData,
1685 if (!odr_initmember(o, p, sizeof(**p)))
1686 return opt && odr_ok(o);
1687 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1690 return opt && odr_ok(o);
1693 int z_SortKeySpec(ODR o, Z_SortKeySpec **p, int opt)
1695 if (!odr_sequence_begin(o, p, sizeof(**p)))
1696 return opt && odr_ok(o);
1698 z_SortElement(o, &(*p)->sortElement, 0) &&
1699 odr_implicit(o, odr_integer, &(*p)->sortRelation, ODR_CONTEXT, 1, 0) &&
1700 odr_implicit(o, odr_integer, &(*p)->caseSensitivity, ODR_CONTEXT,
1702 odr_explicit(o, z_SortMissingValueAction, &(*p)->missingValueAction,
1703 ODR_CONTEXT, 3, 1) &&
1704 odr_sequence_end(o);
1707 int z_SortResponse(ODR o, Z_SortResponse **p, int opt)
1709 if (!odr_sequence_begin(o, p, sizeof(**p)))
1710 return opt && odr_ok(o);
1712 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1713 odr_implicit(o, odr_integer, &(*p)->sortStatus, ODR_CONTEXT,
1715 odr_implicit(o, odr_integer, &(*p)->resultSetStatus, ODR_CONTEXT,
1717 odr_implicit(o, z_DiagRecs, &(*p)->diagnostics, ODR_CONTEXT, 5, 1) &&
1718 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1719 odr_sequence_end(o);
1722 int z_SortKeySpecList(ODR o, Z_SortKeySpecList **p, int opt)
1724 if (!odr_initmember(o, p, sizeof(**p)))
1725 return opt && odr_ok(o);
1726 if (odr_sequence_of(o, z_SortKeySpec, &(*p)->specs, &(*p)->num_specs))
1729 return opt && odr_ok(o);
1732 int z_SortRequest(ODR o, Z_SortRequest **p, int opt)
1734 if (!odr_sequence_begin(o, p, sizeof(**p)))
1735 return opt && odr_ok(o);
1737 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1738 odr_implicit(o, z_StringList, &(*p)->inputResultSetNames,
1739 ODR_CONTEXT, 3, 0) &&
1740 odr_implicit(o, z_InternationalString, &(*p)->sortedResultSetName,
1741 ODR_CONTEXT, 4, 0) &&
1742 odr_implicit(o, z_SortKeySpecList, &(*p)->sortSequence, ODR_CONTEXT,
1744 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1745 odr_sequence_end(o);
1748 /* ---------------------- Resource Report ---------------- */
1750 int z_ResourceReportRequest(ODR o, Z_ResourceReportRequest **p, int opt)
1752 if (!odr_sequence_begin(o, p, sizeof(**p)))
1753 return opt && odr_ok(o);
1755 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1756 odr_implicit(o, z_ReferenceId, &(*p)->opId, ODR_CONTEXT, 210, 1) &&
1757 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat, ODR_CONTEXT,
1759 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1760 odr_sequence_end(o);
1763 int z_ResourceReportResponse(ODR o, Z_ResourceReportResponse **p, int opt)
1765 if (!odr_sequence_begin(o, p, sizeof(**p)))
1766 return opt && odr_ok(o);
1768 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1769 odr_implicit(o, odr_integer, &(*p)->resourceReportStatus,
1770 ODR_CONTEXT, 50, 0) &&
1771 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1773 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1774 odr_sequence_end(o);
1777 /* ------------------------ APDU ------------------------- */
1779 int z_APDU(ODR o, Z_APDU **p, int opt)
1781 static Odr_arm arm[] =
1783 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
1784 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
1785 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
1786 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
1788 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
1790 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
1792 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
1793 z_DeleteResultSetRequest},
1794 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
1795 z_DeleteResultSetResponse},
1796 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_APDU_accessControlRequest,
1797 z_AccessControlRequest},
1798 {ODR_IMPLICIT, ODR_CONTEXT, 29, Z_APDU_accessControlResponse,
1799 z_AccessControlResponse},
1800 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
1801 z_ResourceControlRequest},
1802 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
1803 z_ResourceControlResponse},
1804 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
1805 z_TriggerResourceControlRequest},
1806 {ODR_IMPLICIT, ODR_CONTEXT, 33, Z_APDU_resourceReportRequest,
1807 z_ResourceReportRequest},
1808 {ODR_IMPLICIT, ODR_CONTEXT, 34, Z_APDU_resourceReportResponse,
1809 z_ResourceReportResponse},
1810 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
1811 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
1812 {ODR_IMPLICIT, ODR_CONTEXT, 43, Z_APDU_sortRequest, z_SortRequest},
1813 {ODR_IMPLICIT, ODR_CONTEXT, 44, Z_APDU_sortResponse, z_SortResponse},
1814 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_APDU_segmentRequest, z_Segment},
1815 {ODR_IMPLICIT, ODR_CONTEXT, 46, Z_APDU_extendedServicesRequest,
1816 z_ExtendedServicesRequest},
1817 {ODR_IMPLICIT, ODR_CONTEXT, 47, Z_APDU_extendedServicesResponse,
1818 z_ExtendedServicesResponse},
1819 {ODR_IMPLICIT, ODR_CONTEXT, 48, Z_APDU_close, z_Close},
1824 if (o->direction == ODR_DECODE)
1825 *p = odr_malloc(o, sizeof(**p));
1826 odr_setlenlen(o, 5);
1827 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
1829 if (o->direction == ODR_DECODE)
1831 return opt && odr_ok(o);