2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.43 1996-02-10 12:22:49 quinn
10 * Revision 1.42 1996/01/22 09:46:31 quinn
11 * Added Sort PDU. Moved StringList to main protocol file.
13 * Revision 1.41 1996/01/10 15:21:24 quinn
14 * Added links to access control PDUs
16 * Revision 1.40 1996/01/02 11:46:40 quinn
17 * Changed 'operator' to 'roperator' to avoid C++ conflict.
19 * Revision 1.39 1995/09/29 17:11:53 quinn
22 * Revision 1.38 1995/09/27 15:02:40 quinn
23 * Modified function heads & prototypes.
25 * Revision 1.37 1995/08/21 09:10:15 quinn
26 * Smallish fixes to suppport new formats.
28 * Revision 1.36 1995/08/15 11:59:39 quinn
31 * Revision 1.35 1995/08/10 08:53:59 quinn
34 * Revision 1.34 1995/06/19 17:01:48 quinn
35 * This should bring us in sync with the version distributed as 1.0b
37 * Revision 1.33 1995/06/19 13:39:56 quinn
38 * *** empty log message ***
40 * Revision 1.32 1995/06/19 12:37:28 quinn
41 * Fixed a bug in the compspec.
43 * Revision 1.31 1995/06/16 13:15:56 quinn
44 * Fixed Defaultdiagformat.
46 * Revision 1.30 1995/06/15 15:42:01 quinn
49 * Revision 1.29 1995/06/15 07:44:49 quinn
52 * Revision 1.28 1995/06/14 15:26:35 quinn
53 * *** empty log message ***
55 * Revision 1.27 1995/06/07 14:36:22 quinn
58 * Revision 1.26 1995/06/02 09:49:13 quinn
59 * Adding access control
61 * Revision 1.25 1995/05/25 11:00:08 quinn
62 * *** empty log message ***
64 * Revision 1.24 1995/05/22 13:58:18 quinn
65 * Fixed an ODR_NULLVAL.
67 * Revision 1.23 1995/05/22 11:30:18 quinn
68 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
70 * Revision 1.22 1995/05/17 08:40:56 quinn
71 * Added delete. Fixed some sequence_begins. Smallish.
73 * Revision 1.21 1995/05/16 08:50:24 quinn
74 * License, documentation, and memory fixes
76 * Revision 1.20 1995/05/15 11:55:25 quinn
79 * Revision 1.19 1995/04/11 11:58:35 quinn
82 * Revision 1.18 1995/04/11 11:52:02 quinn
83 * Fixed possible buf in proto.c
85 * Revision 1.17 1995/04/10 10:22:22 quinn
88 * Revision 1.16 1995/03/30 10:26:43 quinn
89 * Added Term structure
91 * Revision 1.15 1995/03/30 09:08:39 quinn
92 * Added Resource control protocol
94 * Revision 1.14 1995/03/29 08:06:13 quinn
95 * Added a few v3 elements
97 * Revision 1.13 1995/03/20 11:26:52 quinn
98 * *** empty log message ***
100 * Revision 1.12 1995/03/20 09:45:09 quinn
103 * Revision 1.11 1995/03/17 10:17:25 quinn
104 * Added memory management.
106 * Revision 1.10 1995/03/15 11:17:40 quinn
107 * Fixed some return-checks from choice.. need better ay to handle those..
109 * Revision 1.9 1995/03/15 08:37:06 quinn
110 * Fixed protocol bugs.
112 * Revision 1.8 1995/03/14 16:59:24 quinn
113 * Fixed OPTIONAL flag in attributeelement
115 * Revision 1.7 1995/03/07 16:29:33 quinn
116 * Added authentication stuff.
118 * Revision 1.6 1995/03/01 14:46:03 quinn
119 * Fixed protocol bug in 8777query.
121 * Revision 1.5 1995/02/14 11:54:22 quinn
124 * Revision 1.4 1995/02/10 15:54:30 quinn
127 * Revision 1.3 1995/02/09 15:51:39 quinn
130 * Revision 1.2 1995/02/06 21:26:07 quinn
131 * Repaired this evening's damages..
133 * Revision 1.1 1995/02/06 16:44:47 quinn
134 * First hack at Z/SR protocol
142 /* ---------------------- GLOBAL DEFS ------------------- */
145 * We'll use a general octetstring here, since string operations are
146 * clumsy on long strings.
148 int z_SUTRS(ODR o, Odr_oct **p, int opt)
150 return odr_implicit(o, odr_octetstring, p, ODR_UNIVERSAL,
151 ODR_GENERALSTRING, opt);
154 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
156 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
159 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
161 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
165 int z_ResultSetId(ODR o, char **p, int opt)
167 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
171 int z_ElementSetName(ODR o, char **p, int opt)
173 return odr_implicit(o, odr_visiblestring, p, ODR_CONTEXT, 103, opt);
176 int z_UserInformationField(ODR o, Z_External **p, int opt)
178 return odr_explicit(o, z_External, (Z_External **)p, ODR_CONTEXT,
182 int z_InternationalString(ODR o, char **p, int opt)
184 return odr_generalstring(o, p, opt);
187 int z_InfoCategory(ODR o, Z_InfoCategory **p, int opt)
189 if (!odr_sequence_begin(o, p, sizeof(**p)))
190 return opt && odr_ok(o);
192 odr_implicit(o, odr_oid, &(*p)->categoryTypeId, ODR_CONTEXT, 1, 1) &&
193 odr_implicit(o, odr_integer, &(*p)->categoryValue, ODR_CONTEXT, 2, 0) &&
197 int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt)
199 static Odr_arm arm[] =
201 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_OtherInfo_characterInfo,
203 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_OtherInfo_binaryInfo,
205 {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_OtherInfo_externallyDefinedInfo,
207 {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_OtherInfo_oid, odr_oid},
211 if (!odr_sequence_begin(o, p, sizeof(**p)))
212 return opt && odr_ok(o);
214 odr_implicit(o, z_InfoCategory, &(*p)->category, ODR_CONTEXT, 1, 1) &&
215 odr_choice(o, arm, &(*p)->which, &(*p)->information) &&
219 int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt)
221 if (o->direction == ODR_DECODE)
222 *p = odr_malloc(o, sizeof(**p));
225 odr_implicit_settag(o, ODR_CONTEXT, 201);
226 if (odr_sequence_of(o, z_OtherInformationUnit, &(*p)->list,
227 &(*p)->num_elements))
230 return opt && odr_ok(o);
233 int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt)
235 static Odr_arm arm[] =
237 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_StringOrNumeric_string,
239 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_StringOrNumeric_numeric,
244 if (o->direction == ODR_DECODE)
245 *p = odr_malloc(o, sizeof(**p));
248 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
251 return opt && odr_ok(o);
257 int z_Unit(ODR o, Z_Unit **p, int opt)
259 if (!odr_sequence_begin(o, p, sizeof(**p)))
260 return opt && odr_ok(o);
262 odr_implicit(o, odr_visiblestring, &(*p)->unitSystem, ODR_CONTEXT,
264 odr_explicit(o, z_StringOrNumeric, &(*p)->unitType, ODR_CONTEXT,
266 odr_explicit(o, z_StringOrNumeric, &(*p)->unit, ODR_CONTEXT, 3, 1) &&
267 odr_implicit(o, odr_integer, &(*p)->scaleFactor, ODR_CONTEXT, 4, 1) &&
271 int z_IntUnit(ODR o, Z_IntUnit **p, int opt)
273 if (!odr_sequence_begin(o, p, sizeof(**p)))
274 return opt && odr_ok(o);
276 odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 1, 0) &&
277 odr_implicit(o, z_Unit, &(*p)->unitUsed, ODR_CONTEXT, 2, 0) &&
281 int z_StringList(ODR o, Z_StringList **p, int opt)
283 if (o->direction == ODR_DECODE)
284 *p = odr_malloc(o, sizeof(**p));
287 if (odr_sequence_of(o, z_InternationalString, &(*p)->strings,
291 return opt && odr_ok(o);
294 /* ---------------------- INITIALIZE SERVICE ------------------- */
297 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
299 if (!odr_sequence_begin(o, p, sizeof(**p)))
300 return opt && odr_ok(o);
302 odr_visiblestring(o, &(*p)->user, 0) &&
303 odr_visiblestring(o, &(*p)->password, 0) &&
304 odr_visiblestring(o, &(*p)->account, 0) &&
309 int z_IdPass(ODR o, Z_IdPass **p, int opt)
311 if (!odr_sequence_begin(o, p, sizeof(**p)))
312 return opt && odr_ok(o);
314 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 1) &&
315 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 1) &&
316 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
321 int z_StrAuthentication(ODR o, char **p, int opt)
323 return odr_visiblestring(o, p, opt);
326 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
328 static Odr_arm arm[] =
330 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
331 {-1, -1, -1, Z_IdAuthentication_idPass, z_IdPass},
332 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
333 {-1, -1, -1, Z_IdAuthentication_other, z_External},
337 if (o->direction == ODR_DECODE)
338 *p = odr_malloc(o, sizeof(**p));
342 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
345 return opt && odr_ok(o);
348 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
352 if (!odr_sequence_begin(o, p, sizeof(**p)))
353 return opt && odr_ok(o);
356 z_ReferenceId(o, &pp->referenceId, 1) &&
357 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
359 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
360 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
362 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
364 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
366 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
368 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
370 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
371 ODR_CONTEXT, 112, 1) &&
372 z_UserInformationField(o, &pp->userInformationField, 1) &&
374 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
379 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
383 if (!odr_sequence_begin(o, p, sizeof(**p)))
384 return opt && odr_ok(o);
387 z_ReferenceId(o, &pp->referenceId, 1) &&
388 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
390 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
391 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
393 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
395 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
396 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
398 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
400 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
401 ODR_CONTEXT, 112, 1) &&
402 z_UserInformationField(o, &pp->userInformationField, 1) &&
404 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
409 /* ------------------ RESOURCE CONTROL ----------------*/
411 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
414 if (!odr_sequence_begin(o, p, sizeof(**p)))
415 return opt && odr_ok(o);
417 z_ReferenceId(o, &(*p)->referenceId, 1) &&
418 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
420 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
421 ODR_CONTEXT, 47, 1) &&
422 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
425 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
430 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
432 if (!odr_sequence_begin(o, p, sizeof(**p)))
433 return opt && odr_ok(o);
435 z_ReferenceId(o, &(*p)->referenceId, 1) &&
436 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
437 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
439 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
440 ODR_CONTEXT, 41, 1) &&
441 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
443 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
444 ODR_CONTEXT, 43, 1) &&
446 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
451 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **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)->continueFlag, ODR_CONTEXT, 44, 0) &&
458 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
461 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
466 /* ------------------------ SEARCH SERVICE ----------------------- */
468 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
470 if (!odr_sequence_begin(o, p, sizeof(**p)))
471 return opt && odr_ok(o);
473 z_DatabaseName(o, &(*p)->databaseName, 0) &&
474 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
478 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
480 if (o->direction == ODR_DECODE)
481 *p = odr_malloc(o, sizeof(**p));
485 odr_implicit_settag(o, ODR_CONTEXT, 1);
486 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
487 &(*p)->num_elements))
493 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
495 static Odr_arm arm[] =
497 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
499 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
504 if (o->direction == ODR_DECODE)
505 *p = odr_malloc(o, sizeof(**p));
507 return opt && odr_ok(o);
509 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
515 /* ----------------------- RPN QUERY -----------------------*/
517 int z_ComplexAttribute(ODR o, Z_ComplexAttribute **p, int opt)
519 if (!odr_sequence_begin(o, p, sizeof(**p)))
520 return opt && odr_ok(o);
522 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
523 odr_sequence_of(o, z_StringOrNumeric, &(*p)->list,
525 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
526 (odr_sequence_of(o, odr_integer, &(*p)->semanticAction,
527 &(*p)->num_semanticAction) || odr_ok(o)) &&
531 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
534 static Odr_arm arm[] =
536 {ODR_IMPLICIT, ODR_CONTEXT, 121, Z_AttributeValue_numeric,
538 {ODR_IMPLICIT, ODR_CONTEXT, 224, Z_AttributeValue_complex,
544 if (!odr_sequence_begin(o, p, sizeof(**p)))
545 return opt && odr_ok(o);
548 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 1, 1) &&
550 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
553 odr_choice(o, arm, &(*p)->value, &(*p)->which) &&
555 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
561 int z_Term(ODR o, Z_Term **p, int opt)
563 static Odr_arm arm[] =
565 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
566 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
567 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
569 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
570 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
571 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, z_External},
572 /* add intUnit here */
573 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
577 if (o->direction ==ODR_DECODE)
578 *p = odr_malloc(o, sizeof(**p));
581 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
584 return opt && odr_ok(o);
587 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
589 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
590 odr_sequence_begin(o, p, sizeof(**p))))
591 return opt && odr_ok(o);
593 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
594 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
595 &(*p)->num_attributes) &&
596 z_Term(o, &(*p)->term, 0) &&
600 int z_ResultSetPlusAttributes(ODR o, Z_ResultSetPlusAttributes **p, int opt)
602 if (!(odr_implicit_settag(o, ODR_CONTEXT, 214) &&
603 odr_sequence_begin(o, p, sizeof(**p))))
604 return opt && odr_ok(o);
606 z_ResultSetId(o, &(*p)->resultSet, 0) &&
607 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
608 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
609 &(*p)->num_attributes) &&
613 int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
615 static Odr_arm arm[] =
617 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, odr_integer},
618 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_private, odr_integer},
622 if (!odr_sequence_begin(o, p, sizeof(**p)))
623 return opt && odr_ok(o);
625 odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
626 odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
627 odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
628 odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
629 odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
630 odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
631 odr_constructed_end(o) &&
635 int z_Operator(ODR o, Z_Operator **p, int opt)
637 static Odr_arm arm[] =
639 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
640 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
641 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
642 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, z_ProximityOperator},
646 if (!*p && o->direction != ODR_DECODE)
648 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
649 return opt && odr_ok(o);
650 if (o->direction == ODR_DECODE)
651 *p = odr_malloc(o, sizeof(**p));
653 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
654 odr_constructed_end(o))
657 return opt && odr_ok(o);
660 int z_Operand(ODR o, Z_Operand **p, int opt)
662 static Odr_arm arm[] =
664 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
665 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
666 {-1, -1, -1, Z_Operand_resultAttr, z_ResultSetPlusAttributes},
670 if (o->direction == ODR_DECODE)
671 *p = odr_malloc(o, sizeof(**p));
674 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
677 return opt && odr_ok(o);
680 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
682 int z_Complex(ODR o, Z_Complex **p, int opt)
684 if (!odr_sequence_begin(o, p, sizeof(**p)))
685 return opt && odr_ok(o);
687 z_RPNStructure(o, &(*p)->s1, 0) &&
688 z_RPNStructure(o, &(*p)->s2, 0) &&
689 z_Operator(o, &(*p)->roperator, 0) &&
693 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
695 static Odr_arm arm[] =
697 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
698 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
702 if (o->direction == ODR_DECODE)
703 *p = odr_malloc(o, sizeof(**p));
706 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
709 return opt && odr_ok(o);
712 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
714 if (!odr_sequence_begin(o, p, sizeof(**p)))
715 return opt && odr_ok(o);
717 odr_oid(o, &(*p)->attributeSetId, 0) &&
718 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
722 /* -----------------------END RPN QUERY ----------------------- */
724 int z_Query(ODR o, Z_Query **p, int opt)
726 static Odr_arm arm[] =
728 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
729 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
730 {ODR_EXPLICIT, ODR_CONTEXT, 101, Z_Query_type_101, z_RPNQuery},
734 if (o->direction == ODR_DECODE)
735 *p = odr_malloc(o, sizeof(**p));
738 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
741 return opt && odr_ok(o);
744 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
748 if (!odr_sequence_begin(o, p, sizeof(**p)))
749 return opt && odr_ok(o);
752 z_ReferenceId(o, &pp->referenceId, 1) &&
753 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
755 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
757 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
759 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
760 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
762 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
763 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
764 &pp->num_databaseNames) &&
765 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
766 ODR_CONTEXT, 100, 1) &&
767 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
768 ODR_CONTEXT, 101, 1) &&
769 odr_implicit(o, odr_oid, &pp->preferredRecordSyntax,
770 ODR_CONTEXT, 104, 1) &&
771 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
773 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
774 ODR_CONTEXT, 203, 1) &&
775 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
780 /* ------------------------ RECORD ------------------------- */
782 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
784 return z_External(o, (Z_External **) p, opt);
789 int z_DefaultDiagFormat(ODR o, Z_DefaultDiagFormat **p, int opt)
791 static Odr_arm arm[] =
793 {-1, -1, -1, Z_DiagForm_v2AddInfo, odr_visiblestring},
794 {-1, -1, -1, Z_DiagForm_v3AddInfo, z_InternationalString},
795 {ODR_IMPLICIT, ODR_CONTEXT, ODR_VISIBLESTRING, Z_DiagForm_v2AddInfo,
796 odr_visiblestring}, /* To cater to a bug in the CNIDR servers */
799 if (!odr_sequence_begin(o, p, sizeof(**p)))
800 return opt && odr_ok(o);
802 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
803 odr_integer(o, &(*p)->condition, 0) &&
805 * I no longer recall what server tagged the addinfo.. but it isn't
806 * hurting anyone, so...
807 * We need to turn it into a choice, or something, because of
808 * that damn generalstring in v3.
810 odr_choice(o, arm, &(*p)->addinfo, &(*p)->which) &&
814 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
816 static Odr_arm arm[] =
818 {-1, -1, -1, Z_DiagRec_defaultFormat, z_DefaultDiagFormat},
819 {-1, -1, -1, Z_DiagRec_externallyDefined, z_External},
823 if (o->direction == ODR_DECODE)
824 *p = odr_malloc(o, sizeof(**p));
827 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
830 return opt && odr_ok(o);
835 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
837 if (!odr_sequence_begin(o, p, sizeof(**p)))
838 return opt && odr_ok(o);
840 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
841 odr_integer(o, &(*p)->condition, 0) &&
843 * I no longer recall what server tagged the addinfo.. but it isn't
844 * hurting anyone, so...
845 * We need to turn it into a choice, or something, because of
846 * that damn generalstring in v3.
848 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
849 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT,
850 ODR_VISIBLESTRING, 1)) &&
856 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
858 if (o->direction == ODR_DECODE)
859 *p = odr_malloc(o, sizeof(**p));
863 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
864 &(*p)->num_diagRecs))
870 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
872 static Odr_arm arm[] =
874 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
876 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
881 if (!odr_sequence_begin(o, p, sizeof(**p)))
882 return opt && odr_ok(o);
884 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
886 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
887 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
888 odr_constructed_end(o) &&
892 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
894 if (o->direction == ODR_DECODE)
895 *p = odr_malloc(o, sizeof(**p));
898 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
905 int z_Records(ODR o, Z_Records **p, int opt)
907 static Odr_arm arm[] =
909 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
910 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
911 {ODR_IMPLICIT, ODR_CONTEXT, 205, Z_Records_multipleNSD,
916 if (o->direction == ODR_DECODE)
917 *p = odr_malloc(o, sizeof(**p));
920 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
923 return opt && odr_ok(o);
926 /* ------------------------ ACCESS CTRL SERVICE ----------------------- */
928 int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
930 static Odr_arm arm[] =
932 {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
934 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
938 if (!odr_sequence_begin(o, p, sizeof(**p)))
939 return opt && odr_ok(o);
941 z_ReferenceId(o, &(*p)->referenceId, 1) &&
942 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
944 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
949 int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
951 static Odr_arm arm[] =
953 {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
955 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_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) &&
964 odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
966 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
971 /* ------------------------ SCAN SERVICE -------------------- */
973 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
975 if (o->direction == ODR_DECODE)
976 *p = odr_malloc(o, sizeof(**p));
980 odr_implicit_settag(o, ODR_CONTEXT, 44);
981 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
982 &(*p)->num_attributes))
985 return opt && odr_ok(o);
989 * This is a temporary hack. We don't know just *what* old version of the
990 * protocol willow uses, so we'll just patiently wait for them to update
992 static int willow_scan = 0;
994 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
996 if (!*p && o->direction != ODR_DECODE)
998 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
1001 return opt && odr_ok(o);
1003 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
1005 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
1007 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
1009 if (o->direction == ODR_DECODE)
1010 *p = odr_malloc(o, sizeof(**p));
1011 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
1012 &(*p)->num_attributes))
1014 if (!odr_sequence_end(o) || !odr_sequence_end(o))
1016 if (!z_Term(o, &(*p)->term, 0))
1018 if (!odr_constructed_end(o))
1024 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
1026 if (o->direction == ODR_DECODE)
1027 *p = odr_malloc(o, sizeof(**p));
1031 return opt && odr_ok(o);
1034 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
1038 return opt && !o->error;
1041 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1043 if (!odr_sequence_begin(o, p, sizeof(**p)))
1044 return opt && odr_ok(o);
1046 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
1047 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
1048 odr_sequence_end(o);
1051 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
1053 if (!odr_sequence_begin(o, p, sizeof(**p)))
1054 return opt && odr_ok(o);
1057 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
1058 z_Term(o, &(*p)->term, 0)) &&
1059 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
1060 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
1061 ODR_CONTEXT, 4, 1) &&
1062 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
1064 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
1065 ODR_CONTEXT, 3, 1) &&
1066 odr_sequence_end(o);
1069 int z_Entry(ODR o, Z_Entry **p, int opt)
1071 static Odr_arm arm[] =
1073 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
1074 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
1079 if (o->direction == ODR_DECODE)
1080 *p = odr_malloc(o, sizeof(**p));
1084 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1087 return opt && odr_ok(o);
1090 int z_Entries(ODR o, Z_Entries **p, int opt)
1092 if (o->direction == ODR_DECODE)
1093 *p = odr_malloc(o, sizeof(**p));
1097 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
1098 &(*p)->num_entries))
1104 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
1106 static Odr_arm arm[] =
1108 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
1109 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
1114 if (o->direction == ODR_DECODE)
1115 *p = odr_malloc(o, sizeof(**p));
1119 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1122 return opt && odr_ok(o);
1125 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
1127 if (!odr_sequence_begin(o, p, sizeof(**p)))
1128 return opt && odr_ok(o);
1131 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1132 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1133 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
1134 &(*p)->num_databaseNames) &&
1135 odr_oid(o, &(*p)->attributeSet, 1) &&
1136 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
1137 ((*p)->termListAndStartPoint ? 1 :
1138 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
1139 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
1140 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
1141 ODR_CONTEXT, 6, 0) &&
1142 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
1143 ODR_CONTEXT, 7, 1) &&
1144 odr_sequence_end(o);
1147 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
1149 if (!odr_sequence_begin(o, p, sizeof(**p)))
1150 return opt && odr_ok(o);
1152 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1153 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
1154 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
1155 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
1156 ODR_CONTEXT, 5, 0) &&
1157 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
1158 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
1159 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
1160 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1161 odr_sequence_end(o);
1164 /* ------------------------ SEARCHRESPONSE ----------------*/
1166 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
1168 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
1171 int z_NextResultSetPosition(ODR o, int **p, int opt)
1173 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
1176 int z_PresentStatus(ODR o, int **p, int opt)
1178 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
1181 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
1183 Z_SearchResponse *pp;
1185 if (!odr_sequence_begin(o, p, sizeof(**p)))
1186 return opt && odr_ok(o);
1189 z_ReferenceId(o, &pp->referenceId, 1) &&
1190 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
1191 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1192 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1193 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
1194 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26,
1196 z_PresentStatus(o, &pp->presentStatus, 1) &&
1197 z_Records(o, &pp->records, 1) &&
1199 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
1200 ODR_CONTEXT, 203, 1) &&
1201 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1203 odr_sequence_end(o);
1206 /* --------------------- PRESENT SERVICE ---------------------- */
1208 int z_ElementSpec(ODR o, Z_ElementSpec **p, int opt)
1210 static Odr_arm arm[] =
1212 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSpec_elementSetName,
1214 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ElementSpec_externalSpec,
1219 if (o->direction == ODR_DECODE)
1220 *p = odr_malloc(o, sizeof(**p));
1224 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1227 return opt && odr_ok(o);
1230 int z_Specification(ODR o, Z_Specification **p, int opt)
1232 if (!odr_sequence_begin(o, p, sizeof(**p)))
1233 return opt && odr_ok(o);
1235 odr_implicit(o, odr_oid, &(*p)->schema, ODR_CONTEXT, 1, 1) &&
1236 z_ElementSpec(o, &(*p)->elementSpec, 1) &&
1237 odr_sequence_end(o);
1240 int z_DbSpecific(ODR o, Z_DbSpecific **p, int opt)
1242 if (!odr_sequence_begin(o, p, sizeof(**p)))
1243 return opt && odr_ok(o);
1245 odr_explicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
1247 odr_implicit(o, z_Specification, &(*p)->spec, ODR_CONTEXT, 2, 0) &&
1248 odr_sequence_end(o);
1251 int z_CompSpec(ODR o, Z_CompSpec **p, int opt)
1253 if (!odr_sequence_begin(o, p, sizeof(**p)))
1254 return opt && odr_ok(o);
1256 odr_implicit(o, odr_bool, &(*p)->selectAlternativeSyntax, ODR_CONTEXT,
1258 odr_implicit(o, z_Specification, &(*p)->generic, ODR_CONTEXT, 2, 1) &&
1259 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1260 (odr_sequence_of(o, z_DbSpecific, &(*p)->dbSpecific,
1261 &(*p)->num_dbSpecific) || odr_ok(o)) &&
1262 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1263 (odr_sequence_of(o, odr_oid, &(*p)->recordSyntax,
1264 &(*p)->num_recordSyntax) || odr_ok(o)) &&
1265 odr_sequence_end(o);
1268 int z_RecordComposition(ODR o, Z_RecordComposition **p, int opt)
1270 static Odr_arm arm[] =
1272 {ODR_EXPLICIT, ODR_CONTEXT, 19, Z_RecordComp_simple,
1274 {ODR_IMPLICIT, ODR_CONTEXT, 209, Z_RecordComp_complex,
1279 if (o->direction == ODR_DECODE)
1280 *p = odr_malloc(o, sizeof(**p));
1284 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1287 return opt && odr_ok(o);
1290 int z_Range(ODR o, Z_Range **p, int opt)
1292 if (!odr_sequence_begin(o, p, sizeof(**p)))
1293 return opt && odr_ok(o);
1295 odr_implicit(o, odr_integer, &(*p)->startingPosition, ODR_CONTEXT,
1297 odr_implicit(o, odr_integer, &(*p)->numberOfRecords, ODR_CONTEXT,
1299 odr_sequence_end(o);
1302 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
1304 Z_PresentRequest *pp;
1306 if (!odr_sequence_begin(o, p, sizeof(**p)))
1307 return opt && odr_ok(o);
1310 z_ReferenceId(o, &pp->referenceId, 1) &&
1311 z_ResultSetId(o, &pp->resultSetId, 0) &&
1312 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
1314 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
1317 odr_implicit_settag(o, ODR_CONTEXT, 212) &&
1318 (odr_sequence_of(o, z_Range, &(*p)->additionalRanges,
1319 &(*p)->num_ranges) || odr_ok(o)) &&
1320 z_RecordComposition(o, &(*p)->recordComposition, 1) &&
1322 odr_explicit(o, z_ElementSetNames, &pp->elementSetNames, ODR_CONTEXT,
1325 odr_implicit(o, odr_oid, &(*p)->preferredRecordSyntax, ODR_CONTEXT,
1328 odr_implicit(o, odr_integer, &(*p)->maxSegmentCount, ODR_CONTEXT,
1330 odr_implicit(o, odr_integer, &(*p)->maxRecordSize, ODR_CONTEXT,
1332 odr_implicit(o, odr_integer, &(*p)->maxSegmentSize, ODR_CONTEXT,
1334 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1336 odr_sequence_end(o);
1339 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
1341 Z_PresentResponse *pp;
1343 if (!odr_sequence_begin(o, p, sizeof(**p)))
1344 return opt && odr_ok(o);
1347 z_ReferenceId(o, &pp->referenceId, 1) &&
1348 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1349 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1350 z_PresentStatus(o, &pp->presentStatus, 0) &&
1351 z_Records(o, &pp->records, 1) &&
1353 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1355 odr_sequence_end(o);
1358 /* ----------------------DELETE -------------------------- */
1360 int z_DeleteSetStatus(ODR o, int **p, int opt)
1362 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
1365 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
1367 if (!odr_sequence_begin(o, p, sizeof(**p)))
1368 return opt && odr_ok(o);
1370 z_ResultSetId(o, &(*p)->id, 0) &&
1371 z_DeleteSetStatus(o, &(*p)->status, 0) &&
1372 odr_sequence_end(o);
1375 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
1377 if (!odr_sequence_begin(o, p, sizeof(**p)))
1378 return opt && odr_ok(o);
1380 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1381 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
1383 (odr_sequence_of(o, z_ListStatus, &(*p)->resultSetList,
1384 &(*p)->num_ids) || odr_ok(o)) &&
1386 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1388 odr_sequence_end(o);
1391 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
1393 if (!odr_sequence_begin(o, p, sizeof(**p)))
1394 return opt && odr_ok(o);
1396 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1397 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
1398 ODR_CONTEXT, 0, 1) &&
1399 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
1400 (odr_sequence_of(o, z_ListStatus, &(*p)->deleteListStatuses,
1401 &(*p)->num_statuses) || odr_ok(o)) &&
1402 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
1404 odr_implicit_settag(o, ODR_CONTEXT, 35) &&
1405 (odr_sequence_of(o, z_ListStatus, &(*p)->bulkStatuses,
1406 &(*p)->num_bulkStatuses) || odr_ok(o)) &&
1407 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
1410 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1412 odr_sequence_end(o);
1415 /* ------------------------ SEGMENT SERVICE -------------- */
1417 int z_Segment(ODR o, Z_Segment **p, int opt)
1419 if (!odr_sequence_begin(o, p, sizeof(**p)))
1420 return opt && odr_ok(o);
1422 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1423 odr_implicit(o, odr_integer, &(*p)->numberOfRecordsReturned,
1424 ODR_CONTEXT, 24, 0) &&
1425 odr_implicit_settag(o, ODR_CONTEXT, 0) &&
1426 odr_sequence_of(o, z_NamePlusRecord, &(*p)->segmentRecords,
1427 &(*p)->num_segmentRecords) &&
1428 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1429 odr_sequence_end(o);
1432 /* ------------------------ CLOSE SERVICE ---------------- */
1434 int z_Close(ODR o, Z_Close **p, int opt)
1436 if (!odr_sequence_begin(o, p, sizeof(**p)))
1437 return opt && odr_ok(o);
1439 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1440 odr_implicit(o, odr_integer, &(*p)->closeReason, ODR_CONTEXT, 211, 0) &&
1441 odr_implicit(o, odr_visiblestring, &(*p)->diagnosticInformation,
1442 ODR_CONTEXT, 3, 1) &&
1443 odr_implicit(o, odr_oid, &(*p)->resourceReportFormat, ODR_CONTEXT,
1445 odr_implicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1448 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1450 odr_sequence_end(o);
1453 /* ------------------------ APDU ------------------------- */
1455 int z_Permissions(ODR o, Z_Permissions **p, int opt)
1457 if (!odr_sequence_begin(o, p, sizeof(**p)))
1458 return opt && odr_ok(o);
1460 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT,
1462 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
1463 odr_sequence_of(o, odr_integer, &(*p)->allowableFunctions,
1464 &(*p)->num_allowableFunctions) &&
1465 odr_sequence_end(o);
1468 int z_ExtendedServicesRequest(ODR o, Z_ExtendedServicesRequest **p, int opt)
1470 if (!odr_sequence_begin(o, p, sizeof(**p)))
1471 return opt && odr_ok(o);
1473 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1474 odr_implicit(o, odr_integer, &(*p)->function, ODR_CONTEXT, 3, 0) &&
1475 odr_implicit(o, odr_oid, &(*p)->packageType, ODR_CONTEXT, 4, 0) &&
1476 odr_implicit(o, z_InternationalString, &(*p)->packageName, ODR_CONTEXT, 5, 1) &&
1477 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT, 6, 1) &&
1478 odr_implicit(o, z_IntUnit, &(*p)->retentionTime, ODR_CONTEXT, 7, 1) &&
1479 odr_implicit(o, z_Permissions, &(*p)->permissions, ODR_CONTEXT, 8, 1) &&
1480 odr_implicit(o, z_InternationalString, &(*p)->description, ODR_CONTEXT, 9, 1) &&
1481 odr_implicit(o, z_External, &(*p)->taskSpecificParameters, ODR_CONTEXT, 10, 1) &&
1482 odr_implicit(o, odr_integer, &(*p)->waitAction, ODR_CONTEXT, 11, 0) &&
1483 z_ElementSetName(o, &(*p)->elements, 1) &&
1484 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1485 odr_sequence_end(o);
1488 int z_ExtendedServicesResponse(ODR o, Z_ExtendedServicesResponse **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, odr_integer, &(*p)->operationStatus, ODR_CONTEXT, 3, 0) &&
1495 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1496 (odr_sequence_of(o, z_DiagRec, &(*p)->diagnostics,
1497 &(*p)->num_diagnostics) || odr_ok(o)) &&
1498 odr_implicit(o, z_External, &(*p)->taskPackage, ODR_CONTEXT, 5, 1) &&
1499 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1500 odr_sequence_end(o);
1503 /* ------------------------ SORT ------------------------- */
1505 int z_SortAttributes(ODR o, Z_SortAttributes **p, int opt)
1507 if (!odr_sequence_begin(o, p, sizeof(**p)))
1508 return opt && odr_ok(o);
1510 odr_oid(o, &(*p)->id, 0) &&
1511 z_AttributeList(o, &(*p)->list, 0) &&
1512 odr_sequence_end(o);
1515 int z_SortKey(ODR o, Z_SortKey **p, int opt)
1517 static Odr_arm arm[] =
1519 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_SortKey_sortField,
1520 z_InternationalString},
1521 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortKey_elementSpec, z_Specification},
1522 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortKey_sortAttributes,
1527 if (!odr_initmember(o, p, sizeof(**p)))
1528 return opt && odr_ok(o);
1529 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1532 return opt && odr_ok(o);
1535 int z_SortDbSpecific(ODR o, Z_SortDbSpecific **p, int opt)
1537 if (!odr_sequence_begin(o, p, sizeof(**p)))
1538 return opt && odr_ok(o);
1540 z_DatabaseName(o, &(*p)->databaseName, 0) &&
1541 z_SortKey(o, &(*p)->dbSort, 0) &&
1542 odr_sequence_end(o);
1545 int z_SortDbSpecificList(ODR o, Z_SortDbSpecificList **p, int opt)
1547 if (!odr_initmember(o, p, sizeof(**p)))
1548 return opt && odr_ok(o);
1549 if (odr_sequence_of(o, z_SortDbSpecific, &(*p)->dbSpecific,
1550 &(*p)->num_dbSpecific))
1553 return opt && odr_ok(o);
1556 int z_SortElement(ODR o, Z_SortElement **p, int opt)
1558 static Odr_arm arm[] =
1560 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_SortElement_generic, z_SortKey},
1561 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortElement_databaseSpecific,
1562 z_SortDbSpecificList},
1566 if (!odr_initmember(o, p, sizeof(**p)))
1567 return opt && odr_ok(o);
1568 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1571 return opt && odr_ok(o);
1574 int z_SortMissingValueAction(ODR o, Z_SortMissingValueAction **p, int opt)
1576 static Odr_arm arm[] =
1578 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortMissingValAct_abort, odr_null},
1579 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortMissingValAct_null, odr_null},
1580 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_SortMissingValAct_valData,
1585 if (!odr_initmember(o, p, sizeof(**p)))
1586 return opt && odr_ok(o);
1587 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1590 return opt && odr_ok(o);
1593 int z_SortKeySpec(ODR o, Z_SortKeySpec **p, int opt)
1595 if (!odr_sequence_begin(o, p, sizeof(**p)))
1596 return opt && odr_ok(o);
1598 z_SortElement(o, &(*p)->sortElement, 0) &&
1599 odr_implicit(o, odr_integer, &(*p)->sortRelation, ODR_CONTEXT, 1, 0) &&
1600 odr_implicit(o, odr_integer, &(*p)->caseSensitivity, ODR_CONTEXT,
1602 odr_explicit(o, z_SortMissingValueAction, &(*p)->missingValueAction,
1603 ODR_CONTEXT, 3, 1) &&
1604 odr_sequence_end(o);
1607 int z_SortResponse(ODR o, Z_SortResponse **p, int opt)
1609 if (!odr_sequence_begin(o, p, sizeof(**p)))
1610 return opt && odr_ok(o);
1612 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1613 odr_implicit(o, odr_integer, &(*p)->sortStatus, ODR_CONTEXT,
1615 odr_implicit(o, odr_integer, &(*p)->resultSetStatus, ODR_CONTEXT,
1617 odr_implicit(o, z_DiagRecs, &(*p)->diagnostics, ODR_CONTEXT, 5, 1) &&
1618 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1619 odr_sequence_end(o);
1622 int z_SortKeySpecList(ODR o, Z_SortKeySpecList **p, int opt)
1624 if (!odr_initmember(o, p, sizeof(**p)))
1625 return opt && odr_ok(o);
1626 if (odr_sequence_of(o, z_SortKeySpec, &(*p)->specs, &(*p)->num_specs))
1629 return opt && odr_ok(o);
1632 int z_SortRequest(ODR o, Z_SortRequest **p, int opt)
1634 if (!odr_sequence_begin(o, p, sizeof(**p)))
1635 return opt && odr_ok(o);
1637 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1638 odr_implicit(o, z_StringList, &(*p)->inputResultSetNames,
1639 ODR_CONTEXT, 3, 0) &&
1640 odr_implicit(o, z_InternationalString, &(*p)->sortedResultSetName,
1641 ODR_CONTEXT, 4, 0) &&
1642 odr_implicit(o, z_SortKeySpecList, &(*p)->sortSequence, ODR_CONTEXT,
1644 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1645 odr_sequence_end(o);
1648 /* ------------------------ APDU ------------------------- */
1650 int z_APDU(ODR o, Z_APDU **p, int opt)
1652 static Odr_arm arm[] =
1654 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
1655 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
1656 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
1657 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
1659 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
1661 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
1663 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
1664 z_DeleteResultSetRequest},
1665 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
1666 z_DeleteResultSetResponse},
1667 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_APDU_accessControlRequest,
1668 z_AccessControlRequest},
1669 {ODR_IMPLICIT, ODR_CONTEXT, 29, Z_APDU_accessControlResponse,
1670 z_AccessControlResponse},
1671 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
1672 z_ResourceControlRequest},
1673 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
1674 z_ResourceControlResponse},
1675 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
1676 z_TriggerResourceControlRequest},
1677 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
1678 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
1679 {ODR_IMPLICIT, ODR_CONTEXT, 43, Z_APDU_sortRequest, z_SortRequest},
1680 {ODR_IMPLICIT, ODR_CONTEXT, 44, Z_APDU_sortResponse, z_SortResponse},
1681 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_APDU_segmentRequest, z_Segment},
1682 {ODR_IMPLICIT, ODR_CONTEXT, 46, Z_APDU_extendedServicesRequest,
1683 z_ExtendedServicesRequest},
1684 {ODR_IMPLICIT, ODR_CONTEXT, 47, Z_APDU_extendedServicesResponse,
1685 z_ExtendedServicesResponse},
1686 {ODR_IMPLICIT, ODR_CONTEXT, 48, Z_APDU_close, z_Close},
1691 if (o->direction == ODR_DECODE)
1692 *p = odr_malloc(o, sizeof(**p));
1693 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
1695 if (o->direction == ODR_DECODE)
1697 return opt && odr_ok(o);