2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.50 1996-07-26 13:36:15 quinn
10 * Revision 1.49 1996/07/06 19:58:28 quinn
11 * System headerfiles gathered in yconfig
13 * Revision 1.48 1996/06/10 08:53:33 quinn
14 * Added Summary,OPAC,ResourceReport
16 * Revision 1.47 1996/05/29 15:47:50 quinn
17 * Fixed in bug DiagRecs decoder. Thanks to Linda Harris.
19 * Revision 1.46 1996/04/10 11:39:42 quinn
20 * Fixed bug in UserInfo
22 * Revision 1.45 1996/02/23 10:00:25 quinn
25 * Revision 1.44 1996/02/20 12:51:41 quinn
26 * Completed SCAN. Fixed problems with EXTERNAL.
28 * Revision 1.43 1996/02/10 12:22:49 quinn
31 * Revision 1.42 1996/01/22 09:46:31 quinn
32 * Added Sort PDU. Moved StringList to main protocol file.
34 * Revision 1.41 1996/01/10 15:21:24 quinn
35 * Added links to access control PDUs
37 * Revision 1.40 1996/01/02 11:46:40 quinn
38 * Changed 'operator' to 'roperator' to avoid C++ conflict.
40 * Revision 1.39 1995/09/29 17:11:53 quinn
43 * Revision 1.38 1995/09/27 15:02:40 quinn
44 * Modified function heads & prototypes.
46 * Revision 1.37 1995/08/21 09:10:15 quinn
47 * Smallish fixes to suppport new formats.
49 * Revision 1.36 1995/08/15 11:59:39 quinn
52 * Revision 1.35 1995/08/10 08:53:59 quinn
55 * Revision 1.34 1995/06/19 17:01:48 quinn
56 * This should bring us in sync with the version distributed as 1.0b
58 * Revision 1.33 1995/06/19 13:39:56 quinn
59 * *** empty log message ***
61 * Revision 1.32 1995/06/19 12:37:28 quinn
62 * Fixed a bug in the compspec.
64 * Revision 1.31 1995/06/16 13:15:56 quinn
65 * Fixed Defaultdiagformat.
67 * Revision 1.30 1995/06/15 15:42:01 quinn
70 * Revision 1.29 1995/06/15 07:44:49 quinn
73 * Revision 1.28 1995/06/14 15:26:35 quinn
74 * *** empty log message ***
76 * Revision 1.27 1995/06/07 14:36:22 quinn
79 * Revision 1.26 1995/06/02 09:49:13 quinn
80 * Adding access control
82 * Revision 1.25 1995/05/25 11:00:08 quinn
83 * *** empty log message ***
85 * Revision 1.24 1995/05/22 13:58:18 quinn
86 * Fixed an ODR_NULLVAL.
88 * Revision 1.23 1995/05/22 11:30:18 quinn
89 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
91 * Revision 1.22 1995/05/17 08:40:56 quinn
92 * Added delete. Fixed some sequence_begins. Smallish.
94 * Revision 1.21 1995/05/16 08:50:24 quinn
95 * License, documentation, and memory fixes
97 * Revision 1.20 1995/05/15 11:55:25 quinn
100 * Revision 1.19 1995/04/11 11:58:35 quinn
103 * Revision 1.18 1995/04/11 11:52:02 quinn
104 * Fixed possible buf in proto.c
106 * Revision 1.17 1995/04/10 10:22:22 quinn
109 * Revision 1.16 1995/03/30 10:26:43 quinn
110 * Added Term structure
112 * Revision 1.15 1995/03/30 09:08:39 quinn
113 * Added Resource control protocol
115 * Revision 1.14 1995/03/29 08:06:13 quinn
116 * Added a few v3 elements
118 * Revision 1.13 1995/03/20 11:26:52 quinn
119 * *** empty log message ***
121 * Revision 1.12 1995/03/20 09:45:09 quinn
124 * Revision 1.11 1995/03/17 10:17:25 quinn
125 * Added memory management.
127 * Revision 1.10 1995/03/15 11:17:40 quinn
128 * Fixed some return-checks from choice.. need better ay to handle those..
130 * Revision 1.9 1995/03/15 08:37:06 quinn
131 * Fixed protocol bugs.
133 * Revision 1.8 1995/03/14 16:59:24 quinn
134 * Fixed OPTIONAL flag in attributeelement
136 * Revision 1.7 1995/03/07 16:29:33 quinn
137 * Added authentication stuff.
139 * Revision 1.6 1995/03/01 14:46:03 quinn
140 * Fixed protocol bug in 8777query.
142 * Revision 1.5 1995/02/14 11:54:22 quinn
145 * Revision 1.4 1995/02/10 15:54:30 quinn
148 * Revision 1.3 1995/02/09 15:51:39 quinn
151 * Revision 1.2 1995/02/06 21:26:07 quinn
152 * Repaired this evening's damages..
154 * Revision 1.1 1995/02/06 16:44:47 quinn
155 * First hack at Z/SR protocol
163 /* ---------------------- GLOBAL DEFS ------------------- */
166 * We'll use a general octetstring here, since string operations are
167 * clumsy on long strings.
169 int z_SUTRS(ODR o, Odr_oct **p, int opt)
171 return odr_implicit(o, odr_octetstring, p, ODR_UNIVERSAL,
172 ODR_GENERALSTRING, opt);
175 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
177 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
180 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
182 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
186 int z_ResultSetId(ODR o, char **p, int opt)
188 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
192 int z_ElementSetName(ODR o, char **p, int opt)
194 return odr_implicit(o, odr_visiblestring, p, ODR_CONTEXT, 103, opt);
197 int z_UserInformationField(ODR o, Z_External **p, int opt)
199 return odr_explicit(o, z_External, (Z_External **)p, ODR_CONTEXT,
203 int z_InternationalString(ODR o, char **p, int opt)
205 return odr_generalstring(o, p, opt);
208 int z_InfoCategory(ODR o, Z_InfoCategory **p, int opt)
210 if (!odr_sequence_begin(o, p, sizeof(**p)))
211 return opt && odr_ok(o);
213 odr_implicit(o, odr_oid, &(*p)->categoryTypeId, ODR_CONTEXT, 1, 1) &&
214 odr_implicit(o, odr_integer, &(*p)->categoryValue, ODR_CONTEXT, 2, 0) &&
218 int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt)
220 static Odr_arm arm[] =
222 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_OtherInfo_characterInfo,
224 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_OtherInfo_binaryInfo,
226 {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_OtherInfo_externallyDefinedInfo,
228 {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_OtherInfo_oid, odr_oid},
232 if (!odr_sequence_begin(o, p, sizeof(**p)))
233 return opt && odr_ok(o);
235 odr_implicit(o, z_InfoCategory, &(*p)->category, ODR_CONTEXT, 1, 1) &&
236 odr_choice(o, arm, &(*p)->information, &(*p)->which) &&
240 int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt)
242 if (o->direction == ODR_DECODE)
243 *p = odr_malloc(o, sizeof(**p));
246 odr_implicit_settag(o, ODR_CONTEXT, 201);
247 if (odr_sequence_of(o, z_OtherInformationUnit, &(*p)->list,
248 &(*p)->num_elements))
251 return opt && odr_ok(o);
254 int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt)
256 static Odr_arm arm[] =
258 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_StringOrNumeric_string,
260 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_StringOrNumeric_numeric,
265 if (o->direction == ODR_DECODE)
266 *p = odr_malloc(o, sizeof(**p));
269 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
272 return opt && odr_ok(o);
278 int z_Unit(ODR o, Z_Unit **p, int opt)
280 if (!odr_sequence_begin(o, p, sizeof(**p)))
281 return opt && odr_ok(o);
283 odr_explicit(o, odr_visiblestring, &(*p)->unitSystem, ODR_CONTEXT,
285 odr_explicit(o, z_StringOrNumeric, &(*p)->unitType, ODR_CONTEXT,
287 odr_explicit(o, z_StringOrNumeric, &(*p)->unit, ODR_CONTEXT, 3, 1) &&
288 odr_implicit(o, odr_integer, &(*p)->scaleFactor, ODR_CONTEXT, 4, 1) &&
292 int z_IntUnit(ODR o, Z_IntUnit **p, int opt)
294 if (!odr_sequence_begin(o, p, sizeof(**p)))
295 return opt && odr_ok(o);
297 odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 1, 0) &&
298 odr_implicit(o, z_Unit, &(*p)->unitUsed, ODR_CONTEXT, 2, 0) &&
302 int z_StringList(ODR o, Z_StringList **p, int opt)
304 if (o->direction == ODR_DECODE)
305 *p = odr_malloc(o, sizeof(**p));
308 if (odr_sequence_of(o, z_InternationalString, &(*p)->strings,
312 return opt && odr_ok(o);
315 /* ---------------------- INITIALIZE SERVICE ------------------- */
318 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
320 if (!odr_sequence_begin(o, p, sizeof(**p)))
321 return opt && odr_ok(o);
323 odr_visiblestring(o, &(*p)->user, 0) &&
324 odr_visiblestring(o, &(*p)->password, 0) &&
325 odr_visiblestring(o, &(*p)->account, 0) &&
330 int z_IdPass(ODR o, Z_IdPass **p, int opt)
332 if (!odr_sequence_begin(o, p, sizeof(**p)))
333 return opt && odr_ok(o);
335 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 1) &&
336 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 1) &&
337 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
342 int z_StrAuthentication(ODR o, char **p, int opt)
344 return odr_visiblestring(o, p, opt);
347 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
349 static Odr_arm arm[] =
351 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
352 {-1, -1, -1, Z_IdAuthentication_idPass, z_IdPass},
353 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
354 {-1, -1, -1, Z_IdAuthentication_other, z_External},
358 if (o->direction == ODR_DECODE)
359 *p = odr_malloc(o, sizeof(**p));
363 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
366 return opt && odr_ok(o);
369 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
373 if (!odr_sequence_begin(o, p, sizeof(**p)))
374 return opt && odr_ok(o);
377 z_ReferenceId(o, &pp->referenceId, 1) &&
378 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
380 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
381 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
383 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
385 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
387 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
389 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
391 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
392 ODR_CONTEXT, 112, 1) &&
393 z_UserInformationField(o, &pp->userInformationField, 1) &&
395 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
400 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
404 if (!odr_sequence_begin(o, p, sizeof(**p)))
405 return opt && odr_ok(o);
408 z_ReferenceId(o, &pp->referenceId, 1) &&
409 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
411 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
412 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
414 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
416 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
417 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
419 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
421 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
422 ODR_CONTEXT, 112, 1) &&
423 z_UserInformationField(o, &pp->userInformationField, 1) &&
425 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
430 /* ------------------ RESOURCE CONTROL ----------------*/
432 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
435 if (!odr_sequence_begin(o, p, sizeof(**p)))
436 return opt && odr_ok(o);
438 z_ReferenceId(o, &(*p)->referenceId, 1) &&
439 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
441 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
442 ODR_CONTEXT, 47, 1) &&
443 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
446 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
451 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
453 if (!odr_sequence_begin(o, p, sizeof(**p)))
454 return opt && odr_ok(o);
456 z_ReferenceId(o, &(*p)->referenceId, 1) &&
457 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
458 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
460 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
461 ODR_CONTEXT, 41, 1) &&
462 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
464 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
465 ODR_CONTEXT, 43, 1) &&
467 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
472 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
474 if (!odr_sequence_begin(o, p, sizeof(**p)))
475 return opt && odr_ok(o);
477 z_ReferenceId(o, &(*p)->referenceId, 1) &&
478 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
479 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
482 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
487 /* ------------------------ SEARCH SERVICE ----------------------- */
489 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
491 if (!odr_sequence_begin(o, p, sizeof(**p)))
492 return opt && odr_ok(o);
494 z_DatabaseName(o, &(*p)->databaseName, 0) &&
495 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
499 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
501 if (o->direction == ODR_DECODE)
502 *p = odr_malloc(o, sizeof(**p));
506 odr_implicit_settag(o, ODR_CONTEXT, 1);
507 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
508 &(*p)->num_elements))
514 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
516 static Odr_arm arm[] =
518 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
520 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
525 if (o->direction == ODR_DECODE)
526 *p = odr_malloc(o, sizeof(**p));
528 return opt && odr_ok(o);
530 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
536 /* ----------------------- RPN QUERY -----------------------*/
538 int z_ComplexAttribute(ODR o, Z_ComplexAttribute **p, int opt)
540 if (!odr_sequence_begin(o, p, sizeof(**p)))
541 return opt && odr_ok(o);
543 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
544 odr_sequence_of(o, z_StringOrNumeric, &(*p)->list,
546 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
547 (odr_sequence_of(o, odr_integer, &(*p)->semanticAction,
548 &(*p)->num_semanticAction) || odr_ok(o)) &&
552 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
555 static Odr_arm arm[] =
557 {ODR_IMPLICIT, ODR_CONTEXT, 121, Z_AttributeValue_numeric,
559 {ODR_IMPLICIT, ODR_CONTEXT, 224, Z_AttributeValue_complex,
565 if (!odr_sequence_begin(o, p, sizeof(**p)))
566 return opt && odr_ok(o);
569 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 1, 1) &&
571 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
574 odr_choice(o, arm, &(*p)->value, &(*p)->which) &&
576 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
582 int z_Term(ODR o, Z_Term **p, int opt)
584 static Odr_arm arm[] =
586 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
587 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
588 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
590 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
591 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
592 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, z_External},
593 /* add intUnit here */
594 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
598 if (o->direction ==ODR_DECODE)
599 *p = odr_malloc(o, sizeof(**p));
602 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
605 return opt && odr_ok(o);
608 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
610 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
611 odr_sequence_begin(o, p, sizeof(**p))))
612 return opt && odr_ok(o);
614 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
615 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
616 &(*p)->num_attributes) &&
617 z_Term(o, &(*p)->term, 0) &&
621 int z_ResultSetPlusAttributes(ODR o, Z_ResultSetPlusAttributes **p, int opt)
623 if (!(odr_implicit_settag(o, ODR_CONTEXT, 214) &&
624 odr_sequence_begin(o, p, sizeof(**p))))
625 return opt && odr_ok(o);
627 z_ResultSetId(o, &(*p)->resultSet, 0) &&
628 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
629 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
630 &(*p)->num_attributes) &&
634 int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
636 static Odr_arm arm[] =
638 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, odr_integer},
639 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_private, odr_integer},
643 if (!odr_sequence_begin(o, p, sizeof(**p)))
644 return opt && odr_ok(o);
646 odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
647 odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
648 odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
649 odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
650 odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
651 odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
652 odr_constructed_end(o) &&
656 int z_Operator(ODR o, Z_Operator **p, int opt)
658 static Odr_arm arm[] =
660 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
661 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
662 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
663 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, z_ProximityOperator},
667 if (!*p && o->direction != ODR_DECODE)
669 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
670 return opt && odr_ok(o);
671 if (o->direction == ODR_DECODE)
672 *p = odr_malloc(o, sizeof(**p));
674 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
675 odr_constructed_end(o))
678 return opt && odr_ok(o);
681 int z_Operand(ODR o, Z_Operand **p, int opt)
683 static Odr_arm arm[] =
685 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
686 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
687 {-1, -1, -1, Z_Operand_resultAttr, z_ResultSetPlusAttributes},
691 if (o->direction == ODR_DECODE)
692 *p = odr_malloc(o, sizeof(**p));
695 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
698 return opt && odr_ok(o);
701 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
703 int z_Complex(ODR o, Z_Complex **p, int opt)
705 if (!odr_sequence_begin(o, p, sizeof(**p)))
706 return opt && odr_ok(o);
708 z_RPNStructure(o, &(*p)->s1, 0) &&
709 z_RPNStructure(o, &(*p)->s2, 0) &&
710 z_Operator(o, &(*p)->roperator, 0) &&
714 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
716 static Odr_arm arm[] =
718 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
719 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
723 if (o->direction == ODR_DECODE)
724 *p = odr_malloc(o, sizeof(**p));
727 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
730 return opt && odr_ok(o);
733 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
735 if (!odr_sequence_begin(o, p, sizeof(**p)))
736 return opt && odr_ok(o);
738 odr_oid(o, &(*p)->attributeSetId, 0) &&
739 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
743 /* -----------------------END RPN QUERY ----------------------- */
745 int z_Query(ODR o, Z_Query **p, int opt)
747 static Odr_arm arm[] =
749 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
750 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
751 {ODR_EXPLICIT, ODR_CONTEXT, 101, Z_Query_type_101, z_RPNQuery},
755 if (o->direction == ODR_DECODE)
756 *p = odr_malloc(o, sizeof(**p));
759 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
762 return opt && odr_ok(o);
765 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
769 if (!odr_sequence_begin(o, p, sizeof(**p)))
770 return opt && odr_ok(o);
773 z_ReferenceId(o, &pp->referenceId, 1) &&
774 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
776 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
778 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
780 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
781 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
783 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
784 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
785 &pp->num_databaseNames) &&
786 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
787 ODR_CONTEXT, 100, 1) &&
788 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
789 ODR_CONTEXT, 101, 1) &&
790 odr_implicit(o, odr_oid, &pp->preferredRecordSyntax,
791 ODR_CONTEXT, 104, 1) &&
792 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
794 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
795 ODR_CONTEXT, 203, 1) &&
796 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
801 /* ------------------------ RECORD ------------------------- */
803 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
805 return z_External(o, (Z_External **) p, opt);
810 int z_DefaultDiagFormat(ODR o, Z_DefaultDiagFormat **p, int opt)
812 static Odr_arm arm[] =
814 {-1, -1, -1, Z_DiagForm_v2AddInfo, odr_visiblestring},
815 {-1, -1, -1, Z_DiagForm_v3AddInfo, z_InternationalString},
816 {ODR_IMPLICIT, ODR_CONTEXT, ODR_VISIBLESTRING, Z_DiagForm_v2AddInfo,
817 odr_visiblestring}, /* To cater to a bug in the CNIDR servers */
820 if (!odr_sequence_begin(o, p, sizeof(**p)))
821 return opt && odr_ok(o);
823 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
824 odr_integer(o, &(*p)->condition, 0) &&
826 * I no longer recall what server tagged the addinfo.. but it isn't
827 * hurting anyone, so...
828 * We need to turn it into a choice, or something, because of
829 * that damn generalstring in v3.
831 odr_choice(o, arm, &(*p)->addinfo, &(*p)->which) &&
835 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
837 static Odr_arm arm[] =
839 {-1, -1, -1, Z_DiagRec_defaultFormat, z_DefaultDiagFormat},
840 {-1, -1, -1, Z_DiagRec_externallyDefined, z_External},
844 if (o->direction == ODR_DECODE)
845 *p = odr_malloc(o, sizeof(**p));
848 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
851 return opt && odr_ok(o);
856 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
858 if (!odr_sequence_begin(o, p, sizeof(**p)))
859 return opt && odr_ok(o);
861 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
862 odr_integer(o, &(*p)->condition, 0) &&
864 * I no longer recall what server tagged the addinfo.. but it isn't
865 * hurting anyone, so...
866 * We need to turn it into a choice, or something, because of
867 * that damn generalstring in v3.
869 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
870 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT,
871 ODR_VISIBLESTRING, 1)) &&
877 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
879 if (o->direction == ODR_DECODE)
880 *p = odr_malloc(o, sizeof(**p));
884 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
885 &(*p)->num_diagRecs))
888 return opt && odr_ok(o);
891 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
893 static Odr_arm arm[] =
895 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
897 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
902 if (!odr_sequence_begin(o, p, sizeof(**p)))
903 return opt && odr_ok(o);
905 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
907 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
908 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
909 odr_constructed_end(o) &&
913 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
915 if (o->direction == ODR_DECODE)
916 *p = odr_malloc(o, sizeof(**p));
919 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
926 int z_Records(ODR o, Z_Records **p, int opt)
928 static Odr_arm arm[] =
930 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
931 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
932 {ODR_IMPLICIT, ODR_CONTEXT, 205, Z_Records_multipleNSD,
937 if (o->direction == ODR_DECODE)
938 *p = odr_malloc(o, sizeof(**p));
941 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
944 return opt && odr_ok(o);
947 /* ------------------------ ACCESS CTRL SERVICE ----------------------- */
949 int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
951 static Odr_arm arm[] =
953 {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
955 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
959 if (!odr_sequence_begin(o, p, sizeof(**p)))
960 return opt && odr_ok(o);
962 z_ReferenceId(o, &(*p)->referenceId, 1) &&
963 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
965 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
970 int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
972 static Odr_arm arm[] =
974 {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
976 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
980 if (!odr_sequence_begin(o, p, sizeof(**p)))
981 return opt && odr_ok(o);
983 z_ReferenceId(o, &(*p)->referenceId, 1) &&
984 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
985 odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
987 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
992 /* ------------------------ SCAN SERVICE -------------------- */
994 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
996 if (o->direction == ODR_DECODE)
997 *p = odr_malloc(o, sizeof(**p));
1001 odr_implicit_settag(o, ODR_CONTEXT, 44);
1002 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
1003 &(*p)->num_attributes))
1006 return opt && odr_ok(o);
1010 * This is a temporary hack. We don't know just *what* old version of the
1011 * protocol willow uses, so we'll just patiently wait for them to update
1013 static int willow_scan = 0;
1015 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
1017 if (!*p && o->direction != ODR_DECODE)
1019 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
1022 return opt && odr_ok(o);
1024 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
1026 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
1028 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
1030 if (o->direction == ODR_DECODE)
1031 *p = odr_malloc(o, sizeof(**p));
1032 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
1033 &(*p)->num_attributes))
1035 if (!odr_sequence_end(o) || !odr_sequence_end(o))
1037 if (!z_Term(o, &(*p)->term, 0))
1039 if (!odr_constructed_end(o))
1045 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
1047 if (o->direction == ODR_DECODE)
1048 *p = odr_malloc(o, sizeof(**p));
1052 return opt && odr_ok(o);
1055 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
1059 return opt && !o->error;
1064 int z_ByDatabase(ODR o, Z_ByDatabase **p, int opt)
1066 if (!odr_sequence_begin(o, p, sizeof(**p)))
1067 return opt && odr_ok(o);
1069 z_DatabaseName(o, &(*p)->db, 1) &&
1070 odr_implicit(o, odr_integer, &(*p)->num, ODR_CONTEXT, 1, 1) &&
1071 z_OtherInformation(o, &(*p)->otherDbInfo, 1) &&
1072 odr_sequence_end(o);
1075 int z_ByDatabaseList(ODR o, Z_ByDatabaseList **p, int opt)
1077 if (!odr_initmember(o, p, sizeof(**p)))
1078 return opt && odr_ok(o);
1079 if (odr_sequence_of(o, z_ByDatabase, &(*p)->elements, &(*p)->num_elements))
1082 return opt && odr_ok(o);
1085 int z_ScanOccurrences(ODR o, Z_ScanOccurrences **p, int opt)
1089 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_ScanOccurrences_global, odr_integer},
1090 {ODR_EXPLICIT, ODR_CONTEXT, 3, Z_ScanOccurrences_byDatabase,
1095 if (!odr_initmember(o, p, sizeof(**p)))
1096 return opt && odr_ok(o);
1097 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1100 return opt && odr_ok(o);
1103 int z_OccurrenceByAttributesElem(ODR o, Z_OccurrenceByAttributesElem **p,
1106 if (!odr_sequence_begin(o, p, sizeof(**p)))
1107 return opt && odr_ok(o);
1109 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT,
1111 z_ScanOccurrences(o, &(*p)->occurrences, 1) &&
1112 z_OtherInformation(o, &(*p)->otherOccurInfo, 1) &&
1113 odr_sequence_end(o);
1116 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1118 if (!odr_initmember(o, p, sizeof(**p)))
1119 return opt && odr_ok(o);
1120 if (!odr_sequence_of(o, z_OccurrenceByAttributesElem, &(*p)->elements,
1121 &(*p)->num_elements))
1124 return opt && odr_ok(o);
1130 * Incomplete definition of occurencebyattributes.
1133 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1135 if (!odr_sequence_begin(o, p, sizeof(**p)))
1136 return opt && odr_ok(o);
1138 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
1139 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
1140 odr_sequence_end(o);
1145 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
1147 if (!odr_sequence_begin(o, p, sizeof(**p)))
1148 return opt && odr_ok(o);
1151 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
1152 z_Term(o, &(*p)->term, 0)) &&
1153 odr_implicit(o, z_InternationalString, &(*p)->displayTerm, ODR_CONTEXT,
1155 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
1156 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
1157 ODR_CONTEXT, 4, 1) &&
1158 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
1160 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
1161 ODR_CONTEXT, 3, 1) &&
1162 z_OtherInformation(o, &(*p)->otherTermInfo, 1) &&
1163 odr_sequence_end(o);
1166 int z_Entry(ODR o, Z_Entry **p, int opt)
1168 static Odr_arm arm[] =
1170 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
1171 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
1176 if (o->direction == ODR_DECODE)
1177 *p = odr_malloc(o, sizeof(**p));
1181 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1184 return opt && odr_ok(o);
1187 int z_Entries(ODR o, Z_Entries **p, int opt)
1189 if (o->direction == ODR_DECODE)
1190 *p = odr_malloc(o, sizeof(**p));
1194 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
1195 &(*p)->num_entries))
1201 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
1203 static Odr_arm arm[] =
1205 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
1206 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
1211 if (o->direction == ODR_DECODE)
1212 *p = odr_malloc(o, sizeof(**p));
1216 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1219 return opt && odr_ok(o);
1222 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
1224 if (!odr_sequence_begin(o, p, sizeof(**p)))
1225 return opt && odr_ok(o);
1228 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1229 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1230 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
1231 &(*p)->num_databaseNames) &&
1232 odr_oid(o, &(*p)->attributeSet, 1) &&
1233 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
1234 ((*p)->termListAndStartPoint ? 1 :
1235 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
1236 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
1237 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
1238 ODR_CONTEXT, 6, 0) &&
1239 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
1240 ODR_CONTEXT, 7, 1) &&
1241 odr_sequence_end(o);
1244 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
1246 if (!odr_sequence_begin(o, p, sizeof(**p)))
1247 return opt && odr_ok(o);
1249 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1250 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
1251 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
1252 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
1253 ODR_CONTEXT, 5, 0) &&
1254 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
1255 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
1256 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
1257 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1258 odr_sequence_end(o);
1261 /* ------------------------ SEARCHRESPONSE ----------------*/
1263 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
1265 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
1268 int z_NextResultSetPosition(ODR o, int **p, int opt)
1270 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
1273 int z_PresentStatus(ODR o, int **p, int opt)
1275 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
1278 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
1280 Z_SearchResponse *pp;
1282 if (!odr_sequence_begin(o, p, sizeof(**p)))
1283 return opt && odr_ok(o);
1286 z_ReferenceId(o, &pp->referenceId, 1) &&
1287 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
1288 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1289 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1290 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
1291 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26,
1293 z_PresentStatus(o, &pp->presentStatus, 1) &&
1294 z_Records(o, &pp->records, 1) &&
1296 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
1297 ODR_CONTEXT, 203, 1) &&
1298 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1300 odr_sequence_end(o);
1303 /* --------------------- PRESENT SERVICE ---------------------- */
1305 int z_ElementSpec(ODR o, Z_ElementSpec **p, int opt)
1307 static Odr_arm arm[] =
1309 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSpec_elementSetName,
1311 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ElementSpec_externalSpec,
1316 if (o->direction == ODR_DECODE)
1317 *p = odr_malloc(o, sizeof(**p));
1321 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1324 return opt && odr_ok(o);
1327 int z_Specification(ODR o, Z_Specification **p, int opt)
1329 if (!odr_sequence_begin(o, p, sizeof(**p)))
1330 return opt && odr_ok(o);
1332 odr_implicit(o, odr_oid, &(*p)->schema, ODR_CONTEXT, 1, 1) &&
1333 z_ElementSpec(o, &(*p)->elementSpec, 1) &&
1334 odr_sequence_end(o);
1337 int z_DbSpecific(ODR o, Z_DbSpecific **p, int opt)
1339 if (!odr_sequence_begin(o, p, sizeof(**p)))
1340 return opt && odr_ok(o);
1342 odr_explicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
1344 odr_implicit(o, z_Specification, &(*p)->spec, ODR_CONTEXT, 2, 0) &&
1345 odr_sequence_end(o);
1348 int z_CompSpec(ODR o, Z_CompSpec **p, int opt)
1350 if (!odr_sequence_begin(o, p, sizeof(**p)))
1351 return opt && odr_ok(o);
1353 odr_implicit(o, odr_bool, &(*p)->selectAlternativeSyntax, ODR_CONTEXT,
1355 odr_implicit(o, z_Specification, &(*p)->generic, ODR_CONTEXT, 2, 1) &&
1356 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1357 (odr_sequence_of(o, z_DbSpecific, &(*p)->dbSpecific,
1358 &(*p)->num_dbSpecific) || odr_ok(o)) &&
1359 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1360 (odr_sequence_of(o, odr_oid, &(*p)->recordSyntax,
1361 &(*p)->num_recordSyntax) || odr_ok(o)) &&
1362 odr_sequence_end(o);
1365 int z_RecordComposition(ODR o, Z_RecordComposition **p, int opt)
1367 static Odr_arm arm[] =
1369 {ODR_EXPLICIT, ODR_CONTEXT, 19, Z_RecordComp_simple,
1371 {ODR_IMPLICIT, ODR_CONTEXT, 209, Z_RecordComp_complex,
1376 if (o->direction == ODR_DECODE)
1377 *p = odr_malloc(o, sizeof(**p));
1381 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1384 return opt && odr_ok(o);
1387 int z_Range(ODR o, Z_Range **p, int opt)
1389 if (!odr_sequence_begin(o, p, sizeof(**p)))
1390 return opt && odr_ok(o);
1392 odr_implicit(o, odr_integer, &(*p)->startingPosition, ODR_CONTEXT,
1394 odr_implicit(o, odr_integer, &(*p)->numberOfRecords, ODR_CONTEXT,
1396 odr_sequence_end(o);
1399 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
1401 Z_PresentRequest *pp;
1403 if (!odr_sequence_begin(o, p, sizeof(**p)))
1404 return opt && odr_ok(o);
1407 z_ReferenceId(o, &pp->referenceId, 1) &&
1408 z_ResultSetId(o, &pp->resultSetId, 0) &&
1409 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
1411 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
1414 odr_implicit_settag(o, ODR_CONTEXT, 212) &&
1415 (odr_sequence_of(o, z_Range, &(*p)->additionalRanges,
1416 &(*p)->num_ranges) || odr_ok(o)) &&
1417 z_RecordComposition(o, &(*p)->recordComposition, 1) &&
1419 odr_explicit(o, z_ElementSetNames, &pp->elementSetNames, ODR_CONTEXT,
1422 odr_implicit(o, odr_oid, &(*p)->preferredRecordSyntax, ODR_CONTEXT,
1425 odr_implicit(o, odr_integer, &(*p)->maxSegmentCount, ODR_CONTEXT,
1427 odr_implicit(o, odr_integer, &(*p)->maxRecordSize, ODR_CONTEXT,
1429 odr_implicit(o, odr_integer, &(*p)->maxSegmentSize, ODR_CONTEXT,
1431 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1433 odr_sequence_end(o);
1436 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
1438 Z_PresentResponse *pp;
1440 if (!odr_sequence_begin(o, p, sizeof(**p)))
1441 return opt && odr_ok(o);
1444 z_ReferenceId(o, &pp->referenceId, 1) &&
1445 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1446 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1447 z_PresentStatus(o, &pp->presentStatus, 0) &&
1448 z_Records(o, &pp->records, 1) &&
1450 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1452 odr_sequence_end(o);
1455 /* ----------------------DELETE -------------------------- */
1457 int z_DeleteSetStatus(ODR o, int **p, int opt)
1459 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
1462 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
1464 if (!odr_sequence_begin(o, p, sizeof(**p)))
1465 return opt && odr_ok(o);
1467 z_ResultSetId(o, &(*p)->id, 0) &&
1468 z_DeleteSetStatus(o, &(*p)->status, 0) &&
1469 odr_sequence_end(o);
1472 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
1474 if (!odr_sequence_begin(o, p, sizeof(**p)))
1475 return opt && odr_ok(o);
1477 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1478 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
1480 (odr_sequence_of(o, z_ListStatus, &(*p)->resultSetList,
1481 &(*p)->num_ids) || odr_ok(o)) &&
1483 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1485 odr_sequence_end(o);
1488 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
1490 if (!odr_sequence_begin(o, p, sizeof(**p)))
1491 return opt && odr_ok(o);
1493 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1494 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
1495 ODR_CONTEXT, 0, 1) &&
1496 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
1497 (odr_sequence_of(o, z_ListStatus, &(*p)->deleteListStatuses,
1498 &(*p)->num_statuses) || odr_ok(o)) &&
1499 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
1501 odr_implicit_settag(o, ODR_CONTEXT, 35) &&
1502 (odr_sequence_of(o, z_ListStatus, &(*p)->bulkStatuses,
1503 &(*p)->num_bulkStatuses) || odr_ok(o)) &&
1504 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
1507 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1509 odr_sequence_end(o);
1512 /* ------------------------ SEGMENT SERVICE -------------- */
1514 int z_Segment(ODR o, Z_Segment **p, int opt)
1516 if (!odr_sequence_begin(o, p, sizeof(**p)))
1517 return opt && odr_ok(o);
1519 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1520 odr_implicit(o, odr_integer, &(*p)->numberOfRecordsReturned,
1521 ODR_CONTEXT, 24, 0) &&
1522 odr_implicit_settag(o, ODR_CONTEXT, 0) &&
1523 odr_sequence_of(o, z_NamePlusRecord, &(*p)->segmentRecords,
1524 &(*p)->num_segmentRecords) &&
1525 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1526 odr_sequence_end(o);
1529 /* ------------------------ CLOSE SERVICE ---------------- */
1531 int z_Close(ODR o, Z_Close **p, int opt)
1533 if (!odr_sequence_begin(o, p, sizeof(**p)))
1534 return opt && odr_ok(o);
1536 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1537 odr_implicit(o, odr_integer, &(*p)->closeReason, ODR_CONTEXT, 211, 0) &&
1538 odr_implicit(o, odr_visiblestring, &(*p)->diagnosticInformation,
1539 ODR_CONTEXT, 3, 1) &&
1540 odr_implicit(o, odr_oid, &(*p)->resourceReportFormat, ODR_CONTEXT,
1542 odr_implicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1545 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1547 odr_sequence_end(o);
1550 /* ------------------------ APDU ------------------------- */
1552 int z_Permissions(ODR o, Z_Permissions **p, int opt)
1554 if (!odr_sequence_begin(o, p, sizeof(**p)))
1555 return opt && odr_ok(o);
1557 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT,
1559 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
1560 odr_sequence_of(o, odr_integer, &(*p)->allowableFunctions,
1561 &(*p)->num_allowableFunctions) &&
1562 odr_sequence_end(o);
1565 int z_ExtendedServicesRequest(ODR o, Z_ExtendedServicesRequest **p, int opt)
1567 if (!odr_sequence_begin(o, p, sizeof(**p)))
1568 return opt && odr_ok(o);
1570 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1571 odr_implicit(o, odr_integer, &(*p)->function, ODR_CONTEXT, 3, 0) &&
1572 odr_implicit(o, odr_oid, &(*p)->packageType, ODR_CONTEXT, 4, 0) &&
1573 odr_implicit(o, z_InternationalString, &(*p)->packageName, ODR_CONTEXT, 5, 1) &&
1574 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT, 6, 1) &&
1575 odr_implicit(o, z_IntUnit, &(*p)->retentionTime, ODR_CONTEXT, 7, 1) &&
1576 odr_implicit(o, z_Permissions, &(*p)->permissions, ODR_CONTEXT, 8, 1) &&
1577 odr_implicit(o, z_InternationalString, &(*p)->description, ODR_CONTEXT, 9, 1) &&
1578 odr_implicit(o, z_External, &(*p)->taskSpecificParameters, ODR_CONTEXT, 10, 1) &&
1579 odr_implicit(o, odr_integer, &(*p)->waitAction, ODR_CONTEXT, 11, 0) &&
1580 z_ElementSetName(o, &(*p)->elements, 1) &&
1581 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1582 odr_sequence_end(o);
1585 int z_ExtendedServicesResponse(ODR o, Z_ExtendedServicesResponse **p, int opt)
1587 if (!odr_sequence_begin(o, p, sizeof(**p)))
1588 return opt && odr_ok(o);
1590 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1591 odr_implicit(o, odr_integer, &(*p)->operationStatus, ODR_CONTEXT, 3, 0) &&
1592 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1593 (odr_sequence_of(o, z_DiagRec, &(*p)->diagnostics,
1594 &(*p)->num_diagnostics) || odr_ok(o)) &&
1595 odr_implicit(o, z_External, &(*p)->taskPackage, ODR_CONTEXT, 5, 1) &&
1596 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1597 odr_sequence_end(o);
1600 /* ------------------------ SORT ------------------------- */
1602 int z_SortAttributes(ODR o, Z_SortAttributes **p, int opt)
1604 if (!odr_sequence_begin(o, p, sizeof(**p)))
1605 return opt && odr_ok(o);
1607 odr_oid(o, &(*p)->id, 0) &&
1608 z_AttributeList(o, &(*p)->list, 0) &&
1609 odr_sequence_end(o);
1612 int z_SortKey(ODR o, Z_SortKey **p, int opt)
1614 static Odr_arm arm[] =
1616 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_SortKey_sortField,
1617 z_InternationalString},
1618 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortKey_elementSpec, z_Specification},
1619 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortKey_sortAttributes,
1624 if (!odr_initmember(o, p, sizeof(**p)))
1625 return opt && odr_ok(o);
1626 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1629 return opt && odr_ok(o);
1632 int z_SortDbSpecific(ODR o, Z_SortDbSpecific **p, int opt)
1634 if (!odr_sequence_begin(o, p, sizeof(**p)))
1635 return opt && odr_ok(o);
1637 z_DatabaseName(o, &(*p)->databaseName, 0) &&
1638 z_SortKey(o, &(*p)->dbSort, 0) &&
1639 odr_sequence_end(o);
1642 int z_SortDbSpecificList(ODR o, Z_SortDbSpecificList **p, int opt)
1644 if (!odr_initmember(o, p, sizeof(**p)))
1645 return opt && odr_ok(o);
1646 if (odr_sequence_of(o, z_SortDbSpecific, &(*p)->dbSpecific,
1647 &(*p)->num_dbSpecific))
1650 return opt && odr_ok(o);
1653 int z_SortElement(ODR o, Z_SortElement **p, int opt)
1655 static Odr_arm arm[] =
1657 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_SortElement_generic, z_SortKey},
1658 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortElement_databaseSpecific,
1659 z_SortDbSpecificList},
1663 if (!odr_initmember(o, p, sizeof(**p)))
1664 return opt && odr_ok(o);
1665 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1668 return opt && odr_ok(o);
1671 int z_SortMissingValueAction(ODR o, Z_SortMissingValueAction **p, int opt)
1673 static Odr_arm arm[] =
1675 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortMissingValAct_abort, odr_null},
1676 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortMissingValAct_null, odr_null},
1677 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_SortMissingValAct_valData,
1682 if (!odr_initmember(o, p, sizeof(**p)))
1683 return opt && odr_ok(o);
1684 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1687 return opt && odr_ok(o);
1690 int z_SortKeySpec(ODR o, Z_SortKeySpec **p, int opt)
1692 if (!odr_sequence_begin(o, p, sizeof(**p)))
1693 return opt && odr_ok(o);
1695 z_SortElement(o, &(*p)->sortElement, 0) &&
1696 odr_implicit(o, odr_integer, &(*p)->sortRelation, ODR_CONTEXT, 1, 0) &&
1697 odr_implicit(o, odr_integer, &(*p)->caseSensitivity, ODR_CONTEXT,
1699 odr_explicit(o, z_SortMissingValueAction, &(*p)->missingValueAction,
1700 ODR_CONTEXT, 3, 1) &&
1701 odr_sequence_end(o);
1704 int z_SortResponse(ODR o, Z_SortResponse **p, int opt)
1706 if (!odr_sequence_begin(o, p, sizeof(**p)))
1707 return opt && odr_ok(o);
1709 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1710 odr_implicit(o, odr_integer, &(*p)->sortStatus, ODR_CONTEXT,
1712 odr_implicit(o, odr_integer, &(*p)->resultSetStatus, ODR_CONTEXT,
1714 odr_implicit(o, z_DiagRecs, &(*p)->diagnostics, ODR_CONTEXT, 5, 1) &&
1715 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1716 odr_sequence_end(o);
1719 int z_SortKeySpecList(ODR o, Z_SortKeySpecList **p, int opt)
1721 if (!odr_initmember(o, p, sizeof(**p)))
1722 return opt && odr_ok(o);
1723 if (odr_sequence_of(o, z_SortKeySpec, &(*p)->specs, &(*p)->num_specs))
1726 return opt && odr_ok(o);
1729 int z_SortRequest(ODR o, Z_SortRequest **p, int opt)
1731 if (!odr_sequence_begin(o, p, sizeof(**p)))
1732 return opt && odr_ok(o);
1734 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1735 odr_implicit(o, z_StringList, &(*p)->inputResultSetNames,
1736 ODR_CONTEXT, 3, 0) &&
1737 odr_implicit(o, z_InternationalString, &(*p)->sortedResultSetName,
1738 ODR_CONTEXT, 4, 0) &&
1739 odr_implicit(o, z_SortKeySpecList, &(*p)->sortSequence, ODR_CONTEXT,
1741 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1742 odr_sequence_end(o);
1745 /* ---------------------- Resource Report ---------------- */
1747 int z_ResourceReportRequest(ODR o, Z_ResourceReportRequest **p, int opt)
1749 if (!odr_sequence_begin(o, p, sizeof(**p)))
1750 return opt && odr_ok(o);
1752 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1753 odr_implicit(o, z_ReferenceId, &(*p)->opId, ODR_CONTEXT, 210, 1) &&
1754 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat, ODR_CONTEXT,
1756 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1757 odr_sequence_end(o);
1760 int z_ResourceReportResponse(ODR o, Z_ResourceReportResponse **p, int opt)
1762 if (!odr_sequence_begin(o, p, sizeof(**p)))
1763 return opt && odr_ok(o);
1765 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1766 odr_implicit(o, odr_integer, &(*p)->resourceReportStatus,
1767 ODR_CONTEXT, 50, 0) &&
1768 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1770 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1771 odr_sequence_end(o);
1774 /* ------------------------ APDU ------------------------- */
1776 int z_APDU(ODR o, Z_APDU **p, int opt)
1778 static Odr_arm arm[] =
1780 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
1781 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
1782 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
1783 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
1785 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
1787 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
1789 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
1790 z_DeleteResultSetRequest},
1791 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
1792 z_DeleteResultSetResponse},
1793 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_APDU_accessControlRequest,
1794 z_AccessControlRequest},
1795 {ODR_IMPLICIT, ODR_CONTEXT, 29, Z_APDU_accessControlResponse,
1796 z_AccessControlResponse},
1797 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
1798 z_ResourceControlRequest},
1799 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
1800 z_ResourceControlResponse},
1801 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
1802 z_TriggerResourceControlRequest},
1803 {ODR_IMPLICIT, ODR_CONTEXT, 33, Z_APDU_resourceReportRequest,
1804 z_ResourceReportRequest},
1805 {ODR_IMPLICIT, ODR_CONTEXT, 34, Z_APDU_resourceReportResponse,
1806 z_ResourceReportResponse},
1807 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
1808 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
1809 {ODR_IMPLICIT, ODR_CONTEXT, 43, Z_APDU_sortRequest, z_SortRequest},
1810 {ODR_IMPLICIT, ODR_CONTEXT, 44, Z_APDU_sortResponse, z_SortResponse},
1811 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_APDU_segmentRequest, z_Segment},
1812 {ODR_IMPLICIT, ODR_CONTEXT, 46, Z_APDU_extendedServicesRequest,
1813 z_ExtendedServicesRequest},
1814 {ODR_IMPLICIT, ODR_CONTEXT, 47, Z_APDU_extendedServicesResponse,
1815 z_ExtendedServicesResponse},
1816 {ODR_IMPLICIT, ODR_CONTEXT, 48, Z_APDU_close, z_Close},
1821 if (o->direction == ODR_DECODE)
1822 *p = odr_malloc(o, sizeof(**p));
1823 odr_setlenlen(o, 5);
1824 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
1826 if (o->direction == ODR_DECODE)
1828 return opt && odr_ok(o);