2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.42 1996-01-22 09:46:31 quinn
8 * Added Sort PDU. Moved StringList to main protocol file.
10 * Revision 1.41 1996/01/10 15:21:24 quinn
11 * Added links to access control PDUs
13 * Revision 1.40 1996/01/02 11:46:40 quinn
14 * Changed 'operator' to 'roperator' to avoid C++ conflict.
16 * Revision 1.39 1995/09/29 17:11:53 quinn
19 * Revision 1.38 1995/09/27 15:02:40 quinn
20 * Modified function heads & prototypes.
22 * Revision 1.37 1995/08/21 09:10:15 quinn
23 * Smallish fixes to suppport new formats.
25 * Revision 1.36 1995/08/15 11:59:39 quinn
28 * Revision 1.35 1995/08/10 08:53:59 quinn
31 * Revision 1.34 1995/06/19 17:01:48 quinn
32 * This should bring us in sync with the version distributed as 1.0b
34 * Revision 1.33 1995/06/19 13:39:56 quinn
35 * *** empty log message ***
37 * Revision 1.32 1995/06/19 12:37:28 quinn
38 * Fixed a bug in the compspec.
40 * Revision 1.31 1995/06/16 13:15:56 quinn
41 * Fixed Defaultdiagformat.
43 * Revision 1.30 1995/06/15 15:42:01 quinn
46 * Revision 1.29 1995/06/15 07:44:49 quinn
49 * Revision 1.28 1995/06/14 15:26:35 quinn
50 * *** empty log message ***
52 * Revision 1.27 1995/06/07 14:36:22 quinn
55 * Revision 1.26 1995/06/02 09:49:13 quinn
56 * Adding access control
58 * Revision 1.25 1995/05/25 11:00:08 quinn
59 * *** empty log message ***
61 * Revision 1.24 1995/05/22 13:58:18 quinn
62 * Fixed an ODR_NULLVAL.
64 * Revision 1.23 1995/05/22 11:30:18 quinn
65 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
67 * Revision 1.22 1995/05/17 08:40:56 quinn
68 * Added delete. Fixed some sequence_begins. Smallish.
70 * Revision 1.21 1995/05/16 08:50:24 quinn
71 * License, documentation, and memory fixes
73 * Revision 1.20 1995/05/15 11:55:25 quinn
76 * Revision 1.19 1995/04/11 11:58:35 quinn
79 * Revision 1.18 1995/04/11 11:52:02 quinn
80 * Fixed possible buf in proto.c
82 * Revision 1.17 1995/04/10 10:22:22 quinn
85 * Revision 1.16 1995/03/30 10:26:43 quinn
86 * Added Term structure
88 * Revision 1.15 1995/03/30 09:08:39 quinn
89 * Added Resource control protocol
91 * Revision 1.14 1995/03/29 08:06:13 quinn
92 * Added a few v3 elements
94 * Revision 1.13 1995/03/20 11:26:52 quinn
95 * *** empty log message ***
97 * Revision 1.12 1995/03/20 09:45:09 quinn
100 * Revision 1.11 1995/03/17 10:17:25 quinn
101 * Added memory management.
103 * Revision 1.10 1995/03/15 11:17:40 quinn
104 * Fixed some return-checks from choice.. need better ay to handle those..
106 * Revision 1.9 1995/03/15 08:37:06 quinn
107 * Fixed protocol bugs.
109 * Revision 1.8 1995/03/14 16:59:24 quinn
110 * Fixed OPTIONAL flag in attributeelement
112 * Revision 1.7 1995/03/07 16:29:33 quinn
113 * Added authentication stuff.
115 * Revision 1.6 1995/03/01 14:46:03 quinn
116 * Fixed protocol bug in 8777query.
118 * Revision 1.5 1995/02/14 11:54:22 quinn
121 * Revision 1.4 1995/02/10 15:54:30 quinn
124 * Revision 1.3 1995/02/09 15:51:39 quinn
127 * Revision 1.2 1995/02/06 21:26:07 quinn
128 * Repaired this evening's damages..
130 * Revision 1.1 1995/02/06 16:44:47 quinn
131 * First hack at Z/SR protocol
139 /* ---------------------- GLOBAL DEFS ------------------- */
142 * We'll use a general octetstring here, since string operations are
143 * clumsy on long strings.
145 int z_SUTRS(ODR o, Odr_oct **p, int opt)
147 return odr_implicit(o, odr_octetstring, p, ODR_UNIVERSAL,
148 ODR_GENERALSTRING, opt);
151 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
153 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
156 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
158 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
162 int z_ResultSetId(ODR o, char **p, int opt)
164 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
168 int z_ElementSetName(ODR o, char **p, int opt)
170 return odr_implicit(o, odr_visiblestring, p, ODR_CONTEXT, 103, opt);
173 int z_UserInformationField(ODR o, Z_External **p, int opt)
175 return odr_explicit(o, z_External, (Z_External **)p, ODR_CONTEXT,
179 int z_InternationalString(ODR o, char **p, int opt)
181 return odr_generalstring(o, p, opt);
184 int z_InfoCategory(ODR o, Z_InfoCategory **p, int opt)
186 if (!odr_sequence_begin(o, p, sizeof(**p)))
187 return opt && odr_ok(o);
189 odr_implicit(o, odr_oid, &(*p)->categoryTypeId, ODR_CONTEXT, 1, 1) &&
190 odr_implicit(o, odr_integer, &(*p)->categoryValue, ODR_CONTEXT, 2, 0) &&
194 int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt)
196 static Odr_arm arm[] =
198 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_OtherInfo_characterInfo,
200 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_OtherInfo_binaryInfo,
202 {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_OtherInfo_externallyDefinedInfo,
204 {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_OtherInfo_oid, odr_oid},
208 if (!odr_sequence_begin(o, p, sizeof(**p)))
209 return opt && odr_ok(o);
211 odr_implicit(o, z_InfoCategory, &(*p)->category, ODR_CONTEXT, 1, 1) &&
212 odr_choice(o, arm, &(*p)->which, &(*p)->information) &&
216 int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt)
218 if (o->direction == ODR_DECODE)
219 *p = odr_malloc(o, sizeof(**p));
222 odr_implicit_settag(o, ODR_CONTEXT, 201);
223 if (odr_sequence_of(o, z_OtherInformationUnit, &(*p)->list,
224 &(*p)->num_elements))
227 return opt && odr_ok(o);
230 int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt)
232 static Odr_arm arm[] =
234 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_StringOrNumeric_string,
236 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_StringOrNumeric_numeric,
241 if (o->direction == ODR_DECODE)
242 *p = odr_malloc(o, sizeof(**p));
245 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
248 return opt && odr_ok(o);
254 int z_Unit(ODR o, Z_Unit **p, int opt)
256 if (!odr_sequence_begin(o, p, sizeof(**p)))
257 return opt && odr_ok(o);
259 odr_implicit(o, odr_visiblestring, &(*p)->unitSystem, ODR_CONTEXT,
261 odr_explicit(o, z_StringOrNumeric, &(*p)->unitType, ODR_CONTEXT,
263 odr_explicit(o, z_StringOrNumeric, &(*p)->unit, ODR_CONTEXT, 3, 1) &&
264 odr_implicit(o, odr_integer, &(*p)->scaleFactor, ODR_CONTEXT, 4, 1) &&
268 int z_IntUnit(ODR o, Z_IntUnit **p, int opt)
270 if (!odr_sequence_begin(o, p, sizeof(**p)))
271 return opt && odr_ok(o);
273 odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 1, 0) &&
274 odr_implicit(o, z_Unit, &(*p)->unitUsed, ODR_CONTEXT, 2, 0) &&
278 int z_StringList(ODR o, Z_StringList **p, int opt)
280 if (o->direction == ODR_DECODE)
281 *p = odr_malloc(o, sizeof(**p));
284 if (odr_sequence_of(o, z_InternationalString, &(*p)->strings,
288 return opt && odr_ok(o);
291 /* ---------------------- INITIALIZE SERVICE ------------------- */
294 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
296 if (!odr_sequence_begin(o, p, sizeof(**p)))
297 return opt && odr_ok(o);
299 odr_visiblestring(o, &(*p)->user, 0) &&
300 odr_visiblestring(o, &(*p)->password, 0) &&
301 odr_visiblestring(o, &(*p)->account, 0) &&
306 int z_IdPass(ODR o, Z_IdPass **p, int opt)
308 if (!odr_sequence_begin(o, p, sizeof(**p)))
309 return opt && odr_ok(o);
311 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 1) &&
312 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 1) &&
313 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
318 int z_StrAuthentication(ODR o, char **p, int opt)
320 return odr_visiblestring(o, p, opt);
323 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
325 static Odr_arm arm[] =
327 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
328 {-1, -1, -1, Z_IdAuthentication_idPass, z_IdPass},
329 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
330 {-1, -1, -1, Z_IdAuthentication_other, z_External},
334 if (o->direction == ODR_DECODE)
335 *p = odr_malloc(o, sizeof(**p));
339 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
342 return opt && odr_ok(o);
345 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
349 if (!odr_sequence_begin(o, p, sizeof(**p)))
350 return opt && odr_ok(o);
353 z_ReferenceId(o, &pp->referenceId, 1) &&
354 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
356 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
357 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
359 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
361 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
363 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
365 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
367 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
368 ODR_CONTEXT, 112, 1) &&
369 z_UserInformationField(o, &pp->userInformationField, 1) &&
371 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
376 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
380 if (!odr_sequence_begin(o, p, sizeof(**p)))
381 return opt && odr_ok(o);
384 z_ReferenceId(o, &pp->referenceId, 1) &&
385 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
387 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
388 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
390 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
392 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
393 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
395 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
397 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
398 ODR_CONTEXT, 112, 1) &&
399 z_UserInformationField(o, &pp->userInformationField, 1) &&
401 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
406 /* ------------------ RESOURCE CONTROL ----------------*/
408 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
411 if (!odr_sequence_begin(o, p, sizeof(**p)))
412 return opt && odr_ok(o);
414 z_ReferenceId(o, &(*p)->referenceId, 1) &&
415 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
417 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
418 ODR_CONTEXT, 47, 1) &&
419 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
422 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
427 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
429 if (!odr_sequence_begin(o, p, sizeof(**p)))
430 return opt && odr_ok(o);
432 z_ReferenceId(o, &(*p)->referenceId, 1) &&
433 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
434 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
436 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
437 ODR_CONTEXT, 41, 1) &&
438 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
440 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
441 ODR_CONTEXT, 43, 1) &&
443 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
448 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
450 if (!odr_sequence_begin(o, p, sizeof(**p)))
451 return opt && odr_ok(o);
453 z_ReferenceId(o, &(*p)->referenceId, 1) &&
454 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
455 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
458 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
463 /* ------------------------ SEARCH SERVICE ----------------------- */
465 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
467 if (!odr_sequence_begin(o, p, sizeof(**p)))
468 return opt && odr_ok(o);
470 z_DatabaseName(o, &(*p)->databaseName, 0) &&
471 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
475 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
477 if (o->direction == ODR_DECODE)
478 *p = odr_malloc(o, sizeof(**p));
482 odr_implicit_settag(o, ODR_CONTEXT, 1);
483 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
484 &(*p)->num_elements))
490 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
492 static Odr_arm arm[] =
494 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
496 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
501 if (o->direction == ODR_DECODE)
502 *p = odr_malloc(o, sizeof(**p));
504 return opt && odr_ok(o);
506 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
512 /* ----------------------- RPN QUERY -----------------------*/
514 int z_ComplexAttribute(ODR o, Z_ComplexAttribute **p, int opt)
516 if (!odr_sequence_begin(o, p, sizeof(**p)))
517 return opt && odr_ok(o);
519 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
520 odr_sequence_of(o, z_StringOrNumeric, &(*p)->list,
522 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
523 (odr_sequence_of(o, odr_integer, &(*p)->semanticAction,
524 &(*p)->num_semanticAction) || odr_ok(o)) &&
528 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
531 static Odr_arm arm[] =
533 {ODR_IMPLICIT, ODR_CONTEXT, 121, Z_AttributeValue_numeric,
535 {ODR_IMPLICIT, ODR_CONTEXT, 224, Z_AttributeValue_complex,
541 if (!odr_sequence_begin(o, p, sizeof(**p)))
542 return opt && odr_ok(o);
545 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 1, 1) &&
547 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
550 odr_choice(o, arm, &(*p)->value, &(*p)->which) &&
552 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
558 int z_Term(ODR o, Z_Term **p, int opt)
560 static Odr_arm arm[] =
562 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
563 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
564 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
566 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
567 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
568 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, z_External},
569 /* add intUnit here */
570 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
574 if (o->direction ==ODR_DECODE)
575 *p = odr_malloc(o, sizeof(**p));
578 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
581 return opt && odr_ok(o);
584 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
586 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
587 odr_sequence_begin(o, p, sizeof(**p))))
588 return opt && odr_ok(o);
590 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
591 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
592 &(*p)->num_attributes) &&
593 z_Term(o, &(*p)->term, 0) &&
597 int z_ResultSetPlusAttributes(ODR o, Z_ResultSetPlusAttributes **p, int opt)
599 if (!(odr_implicit_settag(o, ODR_CONTEXT, 214) &&
600 odr_sequence_begin(o, p, sizeof(**p))))
601 return opt && odr_ok(o);
603 z_ResultSetId(o, &(*p)->resultSet, 0) &&
604 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
605 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
606 &(*p)->num_attributes) &&
610 int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
612 static Odr_arm arm[] =
614 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, odr_integer},
615 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_private, odr_integer},
619 if (!odr_sequence_begin(o, p, sizeof(**p)))
620 return opt && odr_ok(o);
622 odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
623 odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
624 odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
625 odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
626 odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
627 odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
628 odr_constructed_end(o) &&
632 int z_Operator(ODR o, Z_Operator **p, int opt)
634 static Odr_arm arm[] =
636 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
637 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
638 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
639 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, z_ProximityOperator},
643 if (!*p && o->direction != ODR_DECODE)
645 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
646 return opt && odr_ok(o);
647 if (o->direction == ODR_DECODE)
648 *p = odr_malloc(o, sizeof(**p));
650 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
651 odr_constructed_end(o))
654 return opt && odr_ok(o);
657 int z_Operand(ODR o, Z_Operand **p, int opt)
659 static Odr_arm arm[] =
661 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
662 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
663 {-1, -1, -1, Z_Operand_resultAttr, z_ResultSetPlusAttributes},
667 if (o->direction == ODR_DECODE)
668 *p = odr_malloc(o, sizeof(**p));
671 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
674 return opt && odr_ok(o);
677 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
679 int z_Complex(ODR o, Z_Complex **p, int opt)
681 if (!odr_sequence_begin(o, p, sizeof(**p)))
682 return opt && odr_ok(o);
684 z_RPNStructure(o, &(*p)->s1, 0) &&
685 z_RPNStructure(o, &(*p)->s2, 0) &&
686 z_Operator(o, &(*p)->roperator, 0) &&
690 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
692 static Odr_arm arm[] =
694 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
695 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
699 if (o->direction == ODR_DECODE)
700 *p = odr_malloc(o, sizeof(**p));
703 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
706 return opt && odr_ok(o);
709 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
711 if (!odr_sequence_begin(o, p, sizeof(**p)))
712 return opt && odr_ok(o);
714 odr_oid(o, &(*p)->attributeSetId, 0) &&
715 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
719 /* -----------------------END RPN QUERY ----------------------- */
721 int z_Query(ODR o, Z_Query **p, int opt)
723 static Odr_arm arm[] =
725 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
726 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
727 {ODR_EXPLICIT, ODR_CONTEXT, 101, Z_Query_type_101, z_RPNQuery},
731 if (o->direction == ODR_DECODE)
732 *p = odr_malloc(o, sizeof(**p));
735 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
738 return opt && odr_ok(o);
741 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
745 if (!odr_sequence_begin(o, p, sizeof(**p)))
746 return opt && odr_ok(o);
749 z_ReferenceId(o, &pp->referenceId, 1) &&
750 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
752 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
754 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
756 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
757 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
759 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
760 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
761 &pp->num_databaseNames) &&
762 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
763 ODR_CONTEXT, 100, 1) &&
764 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
765 ODR_CONTEXT, 101, 1) &&
766 odr_implicit(o, odr_oid, &pp->preferredRecordSyntax,
767 ODR_CONTEXT, 104, 1) &&
768 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
770 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
771 ODR_CONTEXT, 203, 1) &&
772 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
777 /* ------------------------ RECORD ------------------------- */
779 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
781 return z_External(o, (Z_External **) p, opt);
786 int z_DefaultDiagFormat(ODR o, Z_DefaultDiagFormat **p, int opt)
788 static Odr_arm arm[] =
790 {-1, -1, -1, Z_DiagForm_v2AddInfo, odr_visiblestring},
791 {-1, -1, -1, Z_DiagForm_v3AddInfo, z_InternationalString},
792 {ODR_IMPLICIT, ODR_CONTEXT, ODR_VISIBLESTRING, Z_DiagForm_v2AddInfo,
793 odr_visiblestring}, /* To cater to a bug in the CNIDR servers */
796 if (!odr_sequence_begin(o, p, sizeof(**p)))
797 return opt && odr_ok(o);
799 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
800 odr_integer(o, &(*p)->condition, 0) &&
802 * I no longer recall what server tagged the addinfo.. but it isn't
803 * hurting anyone, so...
804 * We need to turn it into a choice, or something, because of
805 * that damn generalstring in v3.
807 odr_choice(o, arm, &(*p)->addinfo, &(*p)->which) &&
811 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
813 static Odr_arm arm[] =
815 {-1, -1, -1, Z_DiagRec_defaultFormat, z_DefaultDiagFormat},
816 {-1, -1, -1, Z_DiagRec_externallyDefined, z_External},
820 if (o->direction == ODR_DECODE)
821 *p = odr_malloc(o, sizeof(**p));
824 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
827 return opt && odr_ok(o);
832 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
834 if (!odr_sequence_begin(o, p, sizeof(**p)))
835 return opt && odr_ok(o);
837 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
838 odr_integer(o, &(*p)->condition, 0) &&
840 * I no longer recall what server tagged the addinfo.. but it isn't
841 * hurting anyone, so...
842 * We need to turn it into a choice, or something, because of
843 * that damn generalstring in v3.
845 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
846 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT,
847 ODR_VISIBLESTRING, 1)) &&
853 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
855 if (o->direction == ODR_DECODE)
856 *p = odr_malloc(o, sizeof(**p));
860 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
861 &(*p)->num_diagRecs))
867 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
869 static Odr_arm arm[] =
871 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
873 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
878 if (!odr_sequence_begin(o, p, sizeof(**p)))
879 return opt && odr_ok(o);
881 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
883 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
884 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
885 odr_constructed_end(o) &&
889 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
891 if (o->direction == ODR_DECODE)
892 *p = odr_malloc(o, sizeof(**p));
895 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
902 int z_Records(ODR o, Z_Records **p, int opt)
904 static Odr_arm arm[] =
906 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
907 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
908 {ODR_IMPLICIT, ODR_CONTEXT, 205, Z_Records_multipleNSD,
913 if (o->direction == ODR_DECODE)
914 *p = odr_malloc(o, sizeof(**p));
917 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
920 return opt && odr_ok(o);
923 /* ------------------------ ACCESS CTRL SERVICE ----------------------- */
925 int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
927 static Odr_arm arm[] =
929 {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
931 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
935 if (!odr_sequence_begin(o, p, sizeof(**p)))
936 return opt && odr_ok(o);
938 z_ReferenceId(o, &(*p)->referenceId, 1) &&
939 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
941 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
946 int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
948 static Odr_arm arm[] =
950 {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
952 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
956 if (!odr_sequence_begin(o, p, sizeof(**p)))
957 return opt && odr_ok(o);
959 z_ReferenceId(o, &(*p)->referenceId, 1) &&
960 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
961 odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
963 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
968 /* ------------------------ SCAN SERVICE -------------------- */
970 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
972 if (o->direction == ODR_DECODE)
973 *p = odr_malloc(o, sizeof(**p));
977 odr_implicit_settag(o, ODR_CONTEXT, 44);
978 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
979 &(*p)->num_attributes))
982 return opt && odr_ok(o);
986 * This is a temporary hack. We don't know just *what* old version of the
987 * protocol willow uses, so we'll just patiently wait for them to update
989 static int willow_scan = 0;
991 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
993 if (!*p && o->direction != ODR_DECODE)
995 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
998 return opt && odr_ok(o);
1000 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
1002 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
1004 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
1006 if (o->direction == ODR_DECODE)
1007 *p = odr_malloc(o, sizeof(**p));
1008 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
1009 &(*p)->num_attributes))
1011 if (!odr_sequence_end(o) || !odr_sequence_end(o))
1013 if (!z_Term(o, &(*p)->term, 0))
1015 if (!odr_constructed_end(o))
1021 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
1023 if (o->direction == ODR_DECODE)
1024 *p = odr_malloc(o, sizeof(**p));
1028 return opt && odr_ok(o);
1031 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
1035 return opt && !o->error;
1038 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1040 if (!odr_sequence_begin(o, p, sizeof(**p)))
1041 return opt && odr_ok(o);
1043 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
1044 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
1045 odr_sequence_end(o);
1048 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
1050 if (!odr_sequence_begin(o, p, sizeof(**p)))
1051 return opt && odr_ok(o);
1054 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
1055 z_Term(o, &(*p)->term, 0)) &&
1056 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
1057 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
1058 ODR_CONTEXT, 4, 1) &&
1059 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
1061 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
1062 ODR_CONTEXT, 3, 1) &&
1063 odr_sequence_end(o);
1066 int z_Entry(ODR o, Z_Entry **p, int opt)
1068 static Odr_arm arm[] =
1070 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
1071 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
1076 if (o->direction == ODR_DECODE)
1077 *p = odr_malloc(o, sizeof(**p));
1081 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1084 return opt && odr_ok(o);
1087 int z_Entries(ODR o, Z_Entries **p, int opt)
1089 if (o->direction == ODR_DECODE)
1090 *p = odr_malloc(o, sizeof(**p));
1094 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
1095 &(*p)->num_entries))
1101 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
1103 static Odr_arm arm[] =
1105 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
1106 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
1111 if (o->direction == ODR_DECODE)
1112 *p = odr_malloc(o, sizeof(**p));
1116 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1119 return opt && odr_ok(o);
1122 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
1124 if (!odr_sequence_begin(o, p, sizeof(**p)))
1125 return opt && odr_ok(o);
1128 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1129 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1130 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
1131 &(*p)->num_databaseNames) &&
1132 odr_oid(o, &(*p)->attributeSet, 1) &&
1133 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
1134 ((*p)->termListAndStartPoint ? 1 :
1135 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
1136 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
1137 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
1138 ODR_CONTEXT, 6, 0) &&
1139 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
1140 ODR_CONTEXT, 7, 1) &&
1141 odr_sequence_end(o);
1144 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
1146 if (!odr_sequence_begin(o, p, sizeof(**p)))
1147 return opt && odr_ok(o);
1149 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1150 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
1151 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
1152 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
1153 ODR_CONTEXT, 5, 0) &&
1154 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
1155 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
1156 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
1157 odr_sequence_end(o);
1160 /* ------------------------ SEARCHRESPONSE ----------------*/
1162 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
1164 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
1167 int z_NextResultSetPosition(ODR o, int **p, int opt)
1169 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
1172 int z_PresentStatus(ODR o, int **p, int opt)
1174 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
1177 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
1179 Z_SearchResponse *pp;
1181 if (!odr_sequence_begin(o, p, sizeof(**p)))
1182 return opt && odr_ok(o);
1185 z_ReferenceId(o, &pp->referenceId, 1) &&
1186 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
1187 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1188 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1189 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
1190 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26,
1192 z_PresentStatus(o, &pp->presentStatus, 1) &&
1193 z_Records(o, &pp->records, 1) &&
1195 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
1196 ODR_CONTEXT, 203, 1) &&
1197 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1199 odr_sequence_end(o);
1202 /* --------------------- PRESENT SERVICE ---------------------- */
1204 int z_ElementSpec(ODR o, Z_ElementSpec **p, int opt)
1206 static Odr_arm arm[] =
1208 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSpec_elementSetName,
1210 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ElementSpec_externalSpec,
1215 if (o->direction == ODR_DECODE)
1216 *p = odr_malloc(o, sizeof(**p));
1220 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1223 return opt && odr_ok(o);
1226 int z_Specification(ODR o, Z_Specification **p, int opt)
1228 if (!odr_sequence_begin(o, p, sizeof(**p)))
1229 return opt && odr_ok(o);
1231 odr_implicit(o, odr_oid, &(*p)->schema, ODR_CONTEXT, 1, 1) &&
1232 z_ElementSpec(o, &(*p)->elementSpec, 1) &&
1233 odr_sequence_end(o);
1236 int z_DbSpecific(ODR o, Z_DbSpecific **p, int opt)
1238 if (!odr_sequence_begin(o, p, sizeof(**p)))
1239 return opt && odr_ok(o);
1241 odr_explicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
1243 odr_implicit(o, z_Specification, &(*p)->spec, ODR_CONTEXT, 2, 0) &&
1244 odr_sequence_end(o);
1247 int z_CompSpec(ODR o, Z_CompSpec **p, int opt)
1249 if (!odr_sequence_begin(o, p, sizeof(**p)))
1250 return opt && odr_ok(o);
1252 odr_implicit(o, odr_bool, &(*p)->selectAlternativeSyntax, ODR_CONTEXT,
1254 odr_implicit(o, z_Specification, &(*p)->generic, ODR_CONTEXT, 2, 1) &&
1255 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1256 (odr_sequence_of(o, z_DbSpecific, &(*p)->dbSpecific,
1257 &(*p)->num_dbSpecific) || odr_ok(o)) &&
1258 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1259 (odr_sequence_of(o, odr_oid, &(*p)->recordSyntax,
1260 &(*p)->num_recordSyntax) || odr_ok(o)) &&
1261 odr_sequence_end(o);
1264 int z_RecordComposition(ODR o, Z_RecordComposition **p, int opt)
1266 static Odr_arm arm[] =
1268 {ODR_EXPLICIT, ODR_CONTEXT, 19, Z_RecordComp_simple,
1270 {ODR_IMPLICIT, ODR_CONTEXT, 209, Z_RecordComp_complex,
1275 if (o->direction == ODR_DECODE)
1276 *p = odr_malloc(o, sizeof(**p));
1280 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1283 return opt && odr_ok(o);
1286 int z_Range(ODR o, Z_Range **p, int opt)
1288 if (!odr_sequence_begin(o, p, sizeof(**p)))
1289 return opt && odr_ok(o);
1291 odr_implicit(o, odr_integer, &(*p)->startingPosition, ODR_CONTEXT,
1293 odr_implicit(o, odr_integer, &(*p)->numberOfRecords, ODR_CONTEXT,
1295 odr_sequence_end(o);
1298 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
1300 Z_PresentRequest *pp;
1302 if (!odr_sequence_begin(o, p, sizeof(**p)))
1303 return opt && odr_ok(o);
1306 z_ReferenceId(o, &pp->referenceId, 1) &&
1307 z_ResultSetId(o, &pp->resultSetId, 0) &&
1308 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
1310 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
1313 odr_implicit_settag(o, ODR_CONTEXT, 212) &&
1314 (odr_sequence_of(o, z_Range, &(*p)->additionalRanges,
1315 &(*p)->num_ranges) || odr_ok(o)) &&
1316 z_RecordComposition(o, &(*p)->recordComposition, 1) &&
1318 odr_explicit(o, z_ElementSetNames, &pp->elementSetNames, ODR_CONTEXT,
1321 odr_implicit(o, odr_oid, &(*p)->preferredRecordSyntax, ODR_CONTEXT,
1324 odr_implicit(o, odr_integer, &(*p)->maxSegmentCount, ODR_CONTEXT,
1326 odr_implicit(o, odr_integer, &(*p)->maxRecordSize, ODR_CONTEXT,
1328 odr_implicit(o, odr_integer, &(*p)->maxSegmentSize, ODR_CONTEXT,
1330 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1332 odr_sequence_end(o);
1335 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
1337 Z_PresentResponse *pp;
1339 if (!odr_sequence_begin(o, p, sizeof(**p)))
1340 return opt && odr_ok(o);
1343 z_ReferenceId(o, &pp->referenceId, 1) &&
1344 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1345 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1346 z_PresentStatus(o, &pp->presentStatus, 0) &&
1347 z_Records(o, &pp->records, 1) &&
1349 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1351 odr_sequence_end(o);
1354 /* ----------------------DELETE -------------------------- */
1356 int z_DeleteSetStatus(ODR o, int **p, int opt)
1358 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
1361 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
1363 if (!odr_sequence_begin(o, p, sizeof(**p)))
1364 return opt && odr_ok(o);
1366 z_ResultSetId(o, &(*p)->id, 0) &&
1367 z_DeleteSetStatus(o, &(*p)->status, 0) &&
1368 odr_sequence_end(o);
1371 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
1373 if (!odr_sequence_begin(o, p, sizeof(**p)))
1374 return opt && odr_ok(o);
1376 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1377 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
1379 (odr_sequence_of(o, z_ListStatus, &(*p)->resultSetList,
1380 &(*p)->num_ids) || odr_ok(o)) &&
1382 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1384 odr_sequence_end(o);
1387 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
1389 if (!odr_sequence_begin(o, p, sizeof(**p)))
1390 return opt && odr_ok(o);
1392 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1393 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
1394 ODR_CONTEXT, 0, 1) &&
1395 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
1396 (odr_sequence_of(o, z_ListStatus, &(*p)->deleteListStatuses,
1397 &(*p)->num_statuses) || odr_ok(o)) &&
1398 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
1400 odr_implicit_settag(o, ODR_CONTEXT, 35) &&
1401 (odr_sequence_of(o, z_ListStatus, &(*p)->bulkStatuses,
1402 &(*p)->num_bulkStatuses) || odr_ok(o)) &&
1403 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
1406 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1408 odr_sequence_end(o);
1411 /* ------------------------ SEGMENT SERVICE -------------- */
1413 int z_Segment(ODR o, Z_Segment **p, int opt)
1415 if (!odr_sequence_begin(o, p, sizeof(**p)))
1416 return opt && odr_ok(o);
1418 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1419 odr_implicit(o, odr_integer, &(*p)->numberOfRecordsReturned,
1420 ODR_CONTEXT, 24, 0) &&
1421 odr_implicit_settag(o, ODR_CONTEXT, 0) &&
1422 odr_sequence_of(o, z_NamePlusRecord, &(*p)->segmentRecords,
1423 &(*p)->num_segmentRecords) &&
1424 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1425 odr_sequence_end(o);
1428 /* ------------------------ CLOSE SERVICE ---------------- */
1430 int z_Close(ODR o, Z_Close **p, int opt)
1432 if (!odr_sequence_begin(o, p, sizeof(**p)))
1433 return opt && odr_ok(o);
1435 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1436 odr_implicit(o, odr_integer, &(*p)->closeReason, ODR_CONTEXT, 211, 0) &&
1437 odr_implicit(o, odr_visiblestring, &(*p)->diagnosticInformation,
1438 ODR_CONTEXT, 3, 1) &&
1439 odr_implicit(o, odr_oid, &(*p)->resourceReportFormat, ODR_CONTEXT,
1441 odr_implicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1444 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1446 odr_sequence_end(o);
1449 /* ------------------------ APDU ------------------------- */
1451 int z_Permissions(ODR o, Z_Permissions **p, int opt)
1453 if (!odr_sequence_begin(o, p, sizeof(**p)))
1454 return opt && odr_ok(o);
1456 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT,
1458 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
1459 odr_sequence_of(o, odr_integer, &(*p)->allowableFunctions,
1460 &(*p)->num_allowableFunctions) &&
1461 odr_sequence_end(o);
1464 int z_ExtendedServicesRequest(ODR o, Z_ExtendedServicesRequest **p, int opt)
1466 if (!odr_sequence_begin(o, p, sizeof(**p)))
1467 return opt && odr_ok(o);
1469 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1470 odr_implicit(o, odr_integer, &(*p)->function, ODR_CONTEXT, 3, 0) &&
1471 odr_implicit(o, odr_oid, &(*p)->packageType, ODR_CONTEXT, 4, 0) &&
1472 odr_implicit(o, z_InternationalString, &(*p)->packageName, ODR_CONTEXT, 5, 1) &&
1473 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT, 6, 1) &&
1474 odr_implicit(o, z_IntUnit, &(*p)->retentionTime, ODR_CONTEXT, 7, 1) &&
1475 odr_implicit(o, z_Permissions, &(*p)->permissions, ODR_CONTEXT, 8, 1) &&
1476 odr_implicit(o, z_InternationalString, &(*p)->description, ODR_CONTEXT, 9, 1) &&
1477 odr_implicit(o, z_External, &(*p)->taskSpecificParameters, ODR_CONTEXT, 10, 1) &&
1478 odr_implicit(o, odr_integer, &(*p)->waitAction, ODR_CONTEXT, 11, 0) &&
1479 z_ElementSetName(o, &(*p)->elements, 1) &&
1480 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1481 odr_sequence_end(o);
1484 int z_ExtendedServicesResponse(ODR o, Z_ExtendedServicesResponse **p, int opt)
1486 if (!odr_sequence_begin(o, p, sizeof(**p)))
1487 return opt && odr_ok(o);
1489 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1490 odr_implicit(o, odr_integer, &(*p)->operationStatus, ODR_CONTEXT, 3, 0) &&
1491 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1492 (odr_sequence_of(o, z_DiagRec, &(*p)->diagnostics,
1493 &(*p)->num_diagnostics) || odr_ok(o)) &&
1494 odr_implicit(o, z_External, &(*p)->taskPackage, ODR_CONTEXT, 5, 1) &&
1495 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1496 odr_sequence_end(o);
1499 /* ------------------------ SORT ------------------------- */
1501 int z_SortAttributes(ODR o, Z_SortAttributes **p, int opt)
1503 if (!odr_sequence_begin(o, p, sizeof(**p)))
1504 return opt && odr_ok(o);
1506 odr_oid(o, &(*p)->id, 0) &&
1507 z_AttributeList(o, &(*p)->list, 0) &&
1508 odr_sequence_end(o);
1511 int z_SortKey(ODR o, Z_SortKey **p, int opt)
1513 static Odr_arm arm[] =
1515 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_SortKey_sortField,
1516 z_InternationalString},
1517 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortKey_elementSpec, z_Specification},
1518 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortKey_sortAttributes,
1523 if (!odr_initmember(o, p, sizeof(**p)))
1524 return opt && odr_ok(o);
1525 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1528 return opt && odr_ok(o);
1531 int z_SortDbSpecific(ODR o, Z_SortDbSpecific **p, int opt)
1533 if (!odr_sequence_begin(o, p, sizeof(**p)))
1534 return opt && odr_ok(o);
1536 z_DatabaseName(o, &(*p)->databaseName, 0) &&
1537 z_SortKey(o, &(*p)->dbSort, 0) &&
1538 odr_sequence_end(o);
1541 int z_SortDbSpecificList(ODR o, Z_SortDbSpecificList **p, int opt)
1543 if (!odr_initmember(o, p, sizeof(**p)))
1544 return opt && odr_ok(o);
1545 if (odr_sequence_of(o, z_SortDbSpecific, &(*p)->dbSpecific,
1546 &(*p)->num_dbSpecific))
1549 return opt && odr_ok(o);
1552 int z_SortElement(ODR o, Z_SortElement **p, int opt)
1554 static Odr_arm arm[] =
1556 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_SortElement_generic, z_SortKey},
1557 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortElement_databaseSpecific,
1558 z_SortDbSpecificList},
1562 if (!odr_initmember(o, p, sizeof(**p)))
1563 return opt && odr_ok(o);
1564 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1567 return opt && odr_ok(o);
1570 int z_SortMissingValueAction(ODR o, Z_SortMissingValueAction **p, int opt)
1572 static Odr_arm arm[] =
1574 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortMissingValAct_abort, odr_null},
1575 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortMissingValAct_null, odr_null},
1576 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_SortMissingValAct_valData,
1581 if (!odr_initmember(o, p, sizeof(**p)))
1582 return opt && odr_ok(o);
1583 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1586 return opt && odr_ok(o);
1589 int z_SortKeySpec(ODR o, Z_SortKeySpec **p, int opt)
1591 if (!odr_sequence_begin(o, p, sizeof(**p)))
1592 return opt && odr_ok(o);
1594 z_SortElement(o, &(*p)->sortElement, 0) &&
1595 odr_implicit(o, odr_integer, &(*p)->sortRelation, ODR_CONTEXT, 1, 0) &&
1596 odr_implicit(o, odr_integer, &(*p)->caseSensitivity, ODR_CONTEXT,
1598 odr_explicit(o, z_SortMissingValueAction, &(*p)->missingValueAction,
1599 ODR_CONTEXT, 3, 1) &&
1600 odr_sequence_end(o);
1603 int z_SortResponse(ODR o, Z_SortResponse **p, int opt)
1605 if (!odr_sequence_begin(o, p, sizeof(**p)))
1606 return opt && odr_ok(o);
1608 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1609 odr_implicit(o, odr_integer, &(*p)->sortStatus, ODR_CONTEXT,
1611 odr_implicit(o, odr_integer, &(*p)->resultSetStatus, ODR_CONTEXT,
1613 odr_implicit(o, z_DiagRecs, &(*p)->diagnostics, ODR_CONTEXT, 5, 1) &&
1614 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1615 odr_sequence_end(o);
1618 int z_SortKeySpecList(ODR o, Z_SortKeySpecList **p, int opt)
1620 if (!odr_initmember(o, p, sizeof(**p)))
1621 return opt && odr_ok(o);
1622 if (odr_sequence_of(o, z_SortKeySpec, &(*p)->specs, &(*p)->num_specs))
1625 return opt && odr_ok(o);
1628 int z_SortRequest(ODR o, Z_SortRequest **p, int opt)
1630 if (!odr_sequence_begin(o, p, sizeof(**p)))
1631 return opt && odr_ok(o);
1633 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1634 odr_implicit(o, z_StringList, &(*p)->inputResultSetNames,
1635 ODR_CONTEXT, 3, 0) &&
1636 odr_implicit(o, z_InternationalString, &(*p)->sortedResultSetName,
1637 ODR_CONTEXT, 4, 0) &&
1638 odr_implicit(o, z_SortKeySpecList, &(*p)->sortSequence, ODR_CONTEXT,
1640 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1641 odr_sequence_end(o);
1644 /* ------------------------ APDU ------------------------- */
1646 int z_APDU(ODR o, Z_APDU **p, int opt)
1648 static Odr_arm arm[] =
1650 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
1651 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
1652 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
1653 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
1655 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
1657 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
1659 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
1660 z_DeleteResultSetRequest},
1661 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
1662 z_DeleteResultSetResponse},
1663 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_APDU_accessControlRequest,
1664 z_AccessControlRequest},
1665 {ODR_IMPLICIT, ODR_CONTEXT, 29, Z_APDU_accessControlResponse,
1666 z_AccessControlResponse},
1667 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
1668 z_ResourceControlRequest},
1669 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
1670 z_ResourceControlResponse},
1671 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
1672 z_TriggerResourceControlRequest},
1673 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
1674 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
1675 {ODR_IMPLICIT, ODR_CONTEXT, 43, Z_APDU_sortRequest, z_SortRequest},
1676 {ODR_IMPLICIT, ODR_CONTEXT, 44, Z_APDU_sortResponse, z_SortResponse},
1677 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_APDU_segmentRequest, z_Segment},
1678 {ODR_IMPLICIT, ODR_CONTEXT, 46, Z_APDU_extendedServicesRequest,
1679 z_ExtendedServicesRequest},
1680 {ODR_IMPLICIT, ODR_CONTEXT, 47, Z_APDU_extendedServicesResponse,
1681 z_ExtendedServicesResponse},
1682 {ODR_IMPLICIT, ODR_CONTEXT, 48, Z_APDU_close, z_Close},
1687 if (o->direction == ODR_DECODE)
1688 *p = odr_malloc(o, sizeof(**p));
1689 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
1691 if (o->direction == ODR_DECODE)
1693 return opt && odr_ok(o);