2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.45 1996-02-23 10:00:25 quinn
10 * Revision 1.44 1996/02/20 12:51:41 quinn
11 * Completed SCAN. Fixed problems with EXTERNAL.
13 * Revision 1.43 1996/02/10 12:22:49 quinn
16 * Revision 1.42 1996/01/22 09:46:31 quinn
17 * Added Sort PDU. Moved StringList to main protocol file.
19 * Revision 1.41 1996/01/10 15:21:24 quinn
20 * Added links to access control PDUs
22 * Revision 1.40 1996/01/02 11:46:40 quinn
23 * Changed 'operator' to 'roperator' to avoid C++ conflict.
25 * Revision 1.39 1995/09/29 17:11:53 quinn
28 * Revision 1.38 1995/09/27 15:02:40 quinn
29 * Modified function heads & prototypes.
31 * Revision 1.37 1995/08/21 09:10:15 quinn
32 * Smallish fixes to suppport new formats.
34 * Revision 1.36 1995/08/15 11:59:39 quinn
37 * Revision 1.35 1995/08/10 08:53:59 quinn
40 * Revision 1.34 1995/06/19 17:01:48 quinn
41 * This should bring us in sync with the version distributed as 1.0b
43 * Revision 1.33 1995/06/19 13:39:56 quinn
44 * *** empty log message ***
46 * Revision 1.32 1995/06/19 12:37:28 quinn
47 * Fixed a bug in the compspec.
49 * Revision 1.31 1995/06/16 13:15:56 quinn
50 * Fixed Defaultdiagformat.
52 * Revision 1.30 1995/06/15 15:42:01 quinn
55 * Revision 1.29 1995/06/15 07:44:49 quinn
58 * Revision 1.28 1995/06/14 15:26:35 quinn
59 * *** empty log message ***
61 * Revision 1.27 1995/06/07 14:36:22 quinn
64 * Revision 1.26 1995/06/02 09:49:13 quinn
65 * Adding access control
67 * Revision 1.25 1995/05/25 11:00:08 quinn
68 * *** empty log message ***
70 * Revision 1.24 1995/05/22 13:58:18 quinn
71 * Fixed an ODR_NULLVAL.
73 * Revision 1.23 1995/05/22 11:30:18 quinn
74 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
76 * Revision 1.22 1995/05/17 08:40:56 quinn
77 * Added delete. Fixed some sequence_begins. Smallish.
79 * Revision 1.21 1995/05/16 08:50:24 quinn
80 * License, documentation, and memory fixes
82 * Revision 1.20 1995/05/15 11:55:25 quinn
85 * Revision 1.19 1995/04/11 11:58:35 quinn
88 * Revision 1.18 1995/04/11 11:52:02 quinn
89 * Fixed possible buf in proto.c
91 * Revision 1.17 1995/04/10 10:22:22 quinn
94 * Revision 1.16 1995/03/30 10:26:43 quinn
95 * Added Term structure
97 * Revision 1.15 1995/03/30 09:08:39 quinn
98 * Added Resource control protocol
100 * Revision 1.14 1995/03/29 08:06:13 quinn
101 * Added a few v3 elements
103 * Revision 1.13 1995/03/20 11:26:52 quinn
104 * *** empty log message ***
106 * Revision 1.12 1995/03/20 09:45:09 quinn
109 * Revision 1.11 1995/03/17 10:17:25 quinn
110 * Added memory management.
112 * Revision 1.10 1995/03/15 11:17:40 quinn
113 * Fixed some return-checks from choice.. need better ay to handle those..
115 * Revision 1.9 1995/03/15 08:37:06 quinn
116 * Fixed protocol bugs.
118 * Revision 1.8 1995/03/14 16:59:24 quinn
119 * Fixed OPTIONAL flag in attributeelement
121 * Revision 1.7 1995/03/07 16:29:33 quinn
122 * Added authentication stuff.
124 * Revision 1.6 1995/03/01 14:46:03 quinn
125 * Fixed protocol bug in 8777query.
127 * Revision 1.5 1995/02/14 11:54:22 quinn
130 * Revision 1.4 1995/02/10 15:54:30 quinn
133 * Revision 1.3 1995/02/09 15:51:39 quinn
136 * Revision 1.2 1995/02/06 21:26:07 quinn
137 * Repaired this evening's damages..
139 * Revision 1.1 1995/02/06 16:44:47 quinn
140 * First hack at Z/SR protocol
148 /* ---------------------- GLOBAL DEFS ------------------- */
151 * We'll use a general octetstring here, since string operations are
152 * clumsy on long strings.
154 int z_SUTRS(ODR o, Odr_oct **p, int opt)
156 return odr_implicit(o, odr_octetstring, p, ODR_UNIVERSAL,
157 ODR_GENERALSTRING, opt);
160 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
162 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
165 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
167 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
171 int z_ResultSetId(ODR o, char **p, int opt)
173 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
177 int z_ElementSetName(ODR o, char **p, int opt)
179 return odr_implicit(o, odr_visiblestring, p, ODR_CONTEXT, 103, opt);
182 int z_UserInformationField(ODR o, Z_External **p, int opt)
184 return odr_explicit(o, z_External, (Z_External **)p, ODR_CONTEXT,
188 int z_InternationalString(ODR o, char **p, int opt)
190 return odr_generalstring(o, p, opt);
193 int z_InfoCategory(ODR o, Z_InfoCategory **p, int opt)
195 if (!odr_sequence_begin(o, p, sizeof(**p)))
196 return opt && odr_ok(o);
198 odr_implicit(o, odr_oid, &(*p)->categoryTypeId, ODR_CONTEXT, 1, 1) &&
199 odr_implicit(o, odr_integer, &(*p)->categoryValue, ODR_CONTEXT, 2, 0) &&
203 int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt)
205 static Odr_arm arm[] =
207 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_OtherInfo_characterInfo,
209 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_OtherInfo_binaryInfo,
211 {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_OtherInfo_externallyDefinedInfo,
213 {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_OtherInfo_oid, odr_oid},
217 if (!odr_sequence_begin(o, p, sizeof(**p)))
218 return opt && odr_ok(o);
220 odr_implicit(o, z_InfoCategory, &(*p)->category, ODR_CONTEXT, 1, 1) &&
221 odr_choice(o, arm, &(*p)->which, &(*p)->information) &&
225 int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt)
227 if (o->direction == ODR_DECODE)
228 *p = odr_malloc(o, sizeof(**p));
231 odr_implicit_settag(o, ODR_CONTEXT, 201);
232 if (odr_sequence_of(o, z_OtherInformationUnit, &(*p)->list,
233 &(*p)->num_elements))
236 return opt && odr_ok(o);
239 int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt)
241 static Odr_arm arm[] =
243 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_StringOrNumeric_string,
245 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_StringOrNumeric_numeric,
250 if (o->direction == ODR_DECODE)
251 *p = odr_malloc(o, sizeof(**p));
254 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
257 return opt && odr_ok(o);
263 int z_Unit(ODR o, Z_Unit **p, int opt)
265 if (!odr_sequence_begin(o, p, sizeof(**p)))
266 return opt && odr_ok(o);
268 odr_implicit(o, odr_visiblestring, &(*p)->unitSystem, ODR_CONTEXT,
270 odr_explicit(o, z_StringOrNumeric, &(*p)->unitType, ODR_CONTEXT,
272 odr_explicit(o, z_StringOrNumeric, &(*p)->unit, ODR_CONTEXT, 3, 1) &&
273 odr_implicit(o, odr_integer, &(*p)->scaleFactor, ODR_CONTEXT, 4, 1) &&
277 int z_IntUnit(ODR o, Z_IntUnit **p, int opt)
279 if (!odr_sequence_begin(o, p, sizeof(**p)))
280 return opt && odr_ok(o);
282 odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 1, 0) &&
283 odr_implicit(o, z_Unit, &(*p)->unitUsed, ODR_CONTEXT, 2, 0) &&
287 int z_StringList(ODR o, Z_StringList **p, int opt)
289 if (o->direction == ODR_DECODE)
290 *p = odr_malloc(o, sizeof(**p));
293 if (odr_sequence_of(o, z_InternationalString, &(*p)->strings,
297 return opt && odr_ok(o);
300 /* ---------------------- INITIALIZE SERVICE ------------------- */
303 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
305 if (!odr_sequence_begin(o, p, sizeof(**p)))
306 return opt && odr_ok(o);
308 odr_visiblestring(o, &(*p)->user, 0) &&
309 odr_visiblestring(o, &(*p)->password, 0) &&
310 odr_visiblestring(o, &(*p)->account, 0) &&
315 int z_IdPass(ODR o, Z_IdPass **p, int opt)
317 if (!odr_sequence_begin(o, p, sizeof(**p)))
318 return opt && odr_ok(o);
320 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 1) &&
321 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 1) &&
322 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
327 int z_StrAuthentication(ODR o, char **p, int opt)
329 return odr_visiblestring(o, p, opt);
332 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
334 static Odr_arm arm[] =
336 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
337 {-1, -1, -1, Z_IdAuthentication_idPass, z_IdPass},
338 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
339 {-1, -1, -1, Z_IdAuthentication_other, z_External},
343 if (o->direction == ODR_DECODE)
344 *p = odr_malloc(o, sizeof(**p));
348 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
351 return opt && odr_ok(o);
354 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
358 if (!odr_sequence_begin(o, p, sizeof(**p)))
359 return opt && odr_ok(o);
362 z_ReferenceId(o, &pp->referenceId, 1) &&
363 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
365 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
366 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
368 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
370 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
372 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
374 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
376 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
377 ODR_CONTEXT, 112, 1) &&
378 z_UserInformationField(o, &pp->userInformationField, 1) &&
380 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
385 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
389 if (!odr_sequence_begin(o, p, sizeof(**p)))
390 return opt && odr_ok(o);
393 z_ReferenceId(o, &pp->referenceId, 1) &&
394 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
396 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
397 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
399 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
401 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
402 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
404 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
406 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
407 ODR_CONTEXT, 112, 1) &&
408 z_UserInformationField(o, &pp->userInformationField, 1) &&
410 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
415 /* ------------------ RESOURCE CONTROL ----------------*/
417 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
420 if (!odr_sequence_begin(o, p, sizeof(**p)))
421 return opt && odr_ok(o);
423 z_ReferenceId(o, &(*p)->referenceId, 1) &&
424 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
426 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
427 ODR_CONTEXT, 47, 1) &&
428 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
431 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
436 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
438 if (!odr_sequence_begin(o, p, sizeof(**p)))
439 return opt && odr_ok(o);
441 z_ReferenceId(o, &(*p)->referenceId, 1) &&
442 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
443 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
445 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
446 ODR_CONTEXT, 41, 1) &&
447 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
449 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
450 ODR_CONTEXT, 43, 1) &&
452 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
457 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
459 if (!odr_sequence_begin(o, p, sizeof(**p)))
460 return opt && odr_ok(o);
462 z_ReferenceId(o, &(*p)->referenceId, 1) &&
463 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
464 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
467 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
472 /* ------------------------ SEARCH SERVICE ----------------------- */
474 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
476 if (!odr_sequence_begin(o, p, sizeof(**p)))
477 return opt && odr_ok(o);
479 z_DatabaseName(o, &(*p)->databaseName, 0) &&
480 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
484 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
486 if (o->direction == ODR_DECODE)
487 *p = odr_malloc(o, sizeof(**p));
491 odr_implicit_settag(o, ODR_CONTEXT, 1);
492 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
493 &(*p)->num_elements))
499 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
501 static Odr_arm arm[] =
503 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
505 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
510 if (o->direction == ODR_DECODE)
511 *p = odr_malloc(o, sizeof(**p));
513 return opt && odr_ok(o);
515 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
521 /* ----------------------- RPN QUERY -----------------------*/
523 int z_ComplexAttribute(ODR o, Z_ComplexAttribute **p, int opt)
525 if (!odr_sequence_begin(o, p, sizeof(**p)))
526 return opt && odr_ok(o);
528 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
529 odr_sequence_of(o, z_StringOrNumeric, &(*p)->list,
531 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
532 (odr_sequence_of(o, odr_integer, &(*p)->semanticAction,
533 &(*p)->num_semanticAction) || odr_ok(o)) &&
537 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
540 static Odr_arm arm[] =
542 {ODR_IMPLICIT, ODR_CONTEXT, 121, Z_AttributeValue_numeric,
544 {ODR_IMPLICIT, ODR_CONTEXT, 224, Z_AttributeValue_complex,
550 if (!odr_sequence_begin(o, p, sizeof(**p)))
551 return opt && odr_ok(o);
554 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 1, 1) &&
556 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
559 odr_choice(o, arm, &(*p)->value, &(*p)->which) &&
561 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
567 int z_Term(ODR o, Z_Term **p, int opt)
569 static Odr_arm arm[] =
571 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
572 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
573 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
575 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
576 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
577 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, z_External},
578 /* add intUnit here */
579 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
583 if (o->direction ==ODR_DECODE)
584 *p = odr_malloc(o, sizeof(**p));
587 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
590 return opt && odr_ok(o);
593 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
595 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
596 odr_sequence_begin(o, p, sizeof(**p))))
597 return opt && odr_ok(o);
599 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
600 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
601 &(*p)->num_attributes) &&
602 z_Term(o, &(*p)->term, 0) &&
606 int z_ResultSetPlusAttributes(ODR o, Z_ResultSetPlusAttributes **p, int opt)
608 if (!(odr_implicit_settag(o, ODR_CONTEXT, 214) &&
609 odr_sequence_begin(o, p, sizeof(**p))))
610 return opt && odr_ok(o);
612 z_ResultSetId(o, &(*p)->resultSet, 0) &&
613 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
614 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
615 &(*p)->num_attributes) &&
619 int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
621 static Odr_arm arm[] =
623 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, odr_integer},
624 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_private, odr_integer},
628 if (!odr_sequence_begin(o, p, sizeof(**p)))
629 return opt && odr_ok(o);
631 odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
632 odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
633 odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
634 odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
635 odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
636 odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
637 odr_constructed_end(o) &&
641 int z_Operator(ODR o, Z_Operator **p, int opt)
643 static Odr_arm arm[] =
645 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
646 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
647 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
648 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, z_ProximityOperator},
652 if (!*p && o->direction != ODR_DECODE)
654 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
655 return opt && odr_ok(o);
656 if (o->direction == ODR_DECODE)
657 *p = odr_malloc(o, sizeof(**p));
659 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
660 odr_constructed_end(o))
663 return opt && odr_ok(o);
666 int z_Operand(ODR o, Z_Operand **p, int opt)
668 static Odr_arm arm[] =
670 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
671 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
672 {-1, -1, -1, Z_Operand_resultAttr, z_ResultSetPlusAttributes},
676 if (o->direction == ODR_DECODE)
677 *p = odr_malloc(o, sizeof(**p));
680 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
683 return opt && odr_ok(o);
686 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
688 int z_Complex(ODR o, Z_Complex **p, int opt)
690 if (!odr_sequence_begin(o, p, sizeof(**p)))
691 return opt && odr_ok(o);
693 z_RPNStructure(o, &(*p)->s1, 0) &&
694 z_RPNStructure(o, &(*p)->s2, 0) &&
695 z_Operator(o, &(*p)->roperator, 0) &&
699 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
701 static Odr_arm arm[] =
703 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
704 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
708 if (o->direction == ODR_DECODE)
709 *p = odr_malloc(o, sizeof(**p));
712 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
715 return opt && odr_ok(o);
718 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
720 if (!odr_sequence_begin(o, p, sizeof(**p)))
721 return opt && odr_ok(o);
723 odr_oid(o, &(*p)->attributeSetId, 0) &&
724 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
728 /* -----------------------END RPN QUERY ----------------------- */
730 int z_Query(ODR o, Z_Query **p, int opt)
732 static Odr_arm arm[] =
734 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
735 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
736 {ODR_EXPLICIT, ODR_CONTEXT, 101, Z_Query_type_101, z_RPNQuery},
740 if (o->direction == ODR_DECODE)
741 *p = odr_malloc(o, sizeof(**p));
744 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
747 return opt && odr_ok(o);
750 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
754 if (!odr_sequence_begin(o, p, sizeof(**p)))
755 return opt && odr_ok(o);
758 z_ReferenceId(o, &pp->referenceId, 1) &&
759 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
761 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
763 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
765 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
766 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
768 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
769 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
770 &pp->num_databaseNames) &&
771 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
772 ODR_CONTEXT, 100, 1) &&
773 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
774 ODR_CONTEXT, 101, 1) &&
775 odr_implicit(o, odr_oid, &pp->preferredRecordSyntax,
776 ODR_CONTEXT, 104, 1) &&
777 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
779 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
780 ODR_CONTEXT, 203, 1) &&
781 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
786 /* ------------------------ RECORD ------------------------- */
788 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
790 return z_External(o, (Z_External **) p, opt);
795 int z_DefaultDiagFormat(ODR o, Z_DefaultDiagFormat **p, int opt)
797 static Odr_arm arm[] =
799 {-1, -1, -1, Z_DiagForm_v2AddInfo, odr_visiblestring},
800 {-1, -1, -1, Z_DiagForm_v3AddInfo, z_InternationalString},
801 {ODR_IMPLICIT, ODR_CONTEXT, ODR_VISIBLESTRING, Z_DiagForm_v2AddInfo,
802 odr_visiblestring}, /* To cater to a bug in the CNIDR servers */
805 if (!odr_sequence_begin(o, p, sizeof(**p)))
806 return opt && odr_ok(o);
808 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
809 odr_integer(o, &(*p)->condition, 0) &&
811 * I no longer recall what server tagged the addinfo.. but it isn't
812 * hurting anyone, so...
813 * We need to turn it into a choice, or something, because of
814 * that damn generalstring in v3.
816 odr_choice(o, arm, &(*p)->addinfo, &(*p)->which) &&
820 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
822 static Odr_arm arm[] =
824 {-1, -1, -1, Z_DiagRec_defaultFormat, z_DefaultDiagFormat},
825 {-1, -1, -1, Z_DiagRec_externallyDefined, z_External},
829 if (o->direction == ODR_DECODE)
830 *p = odr_malloc(o, sizeof(**p));
833 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
836 return opt && odr_ok(o);
841 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
843 if (!odr_sequence_begin(o, p, sizeof(**p)))
844 return opt && odr_ok(o);
846 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
847 odr_integer(o, &(*p)->condition, 0) &&
849 * I no longer recall what server tagged the addinfo.. but it isn't
850 * hurting anyone, so...
851 * We need to turn it into a choice, or something, because of
852 * that damn generalstring in v3.
854 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
855 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT,
856 ODR_VISIBLESTRING, 1)) &&
862 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
864 if (o->direction == ODR_DECODE)
865 *p = odr_malloc(o, sizeof(**p));
869 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
870 &(*p)->num_diagRecs))
876 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
878 static Odr_arm arm[] =
880 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
882 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
887 if (!odr_sequence_begin(o, p, sizeof(**p)))
888 return opt && odr_ok(o);
890 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
892 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
893 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
894 odr_constructed_end(o) &&
898 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
900 if (o->direction == ODR_DECODE)
901 *p = odr_malloc(o, sizeof(**p));
904 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
911 int z_Records(ODR o, Z_Records **p, int opt)
913 static Odr_arm arm[] =
915 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
916 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
917 {ODR_IMPLICIT, ODR_CONTEXT, 205, Z_Records_multipleNSD,
922 if (o->direction == ODR_DECODE)
923 *p = odr_malloc(o, sizeof(**p));
926 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
929 return opt && odr_ok(o);
932 /* ------------------------ ACCESS CTRL SERVICE ----------------------- */
934 int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
936 static Odr_arm arm[] =
938 {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
940 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
944 if (!odr_sequence_begin(o, p, sizeof(**p)))
945 return opt && odr_ok(o);
947 z_ReferenceId(o, &(*p)->referenceId, 1) &&
948 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
950 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
955 int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
957 static Odr_arm arm[] =
959 {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
961 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
965 if (!odr_sequence_begin(o, p, sizeof(**p)))
966 return opt && odr_ok(o);
968 z_ReferenceId(o, &(*p)->referenceId, 1) &&
969 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
970 odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
972 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
977 /* ------------------------ SCAN SERVICE -------------------- */
979 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
981 if (o->direction == ODR_DECODE)
982 *p = odr_malloc(o, sizeof(**p));
986 odr_implicit_settag(o, ODR_CONTEXT, 44);
987 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
988 &(*p)->num_attributes))
991 return opt && odr_ok(o);
995 * This is a temporary hack. We don't know just *what* old version of the
996 * protocol willow uses, so we'll just patiently wait for them to update
998 static int willow_scan = 0;
1000 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
1002 if (!*p && o->direction != ODR_DECODE)
1004 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
1007 return opt && odr_ok(o);
1009 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
1011 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
1013 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
1015 if (o->direction == ODR_DECODE)
1016 *p = odr_malloc(o, sizeof(**p));
1017 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
1018 &(*p)->num_attributes))
1020 if (!odr_sequence_end(o) || !odr_sequence_end(o))
1022 if (!z_Term(o, &(*p)->term, 0))
1024 if (!odr_constructed_end(o))
1030 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
1032 if (o->direction == ODR_DECODE)
1033 *p = odr_malloc(o, sizeof(**p));
1037 return opt && odr_ok(o);
1040 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
1044 return opt && !o->error;
1049 int z_ByDatabase(ODR o, Z_ByDatabase **p, int opt)
1051 if (!odr_sequence_begin(o, p, sizeof(**p)))
1052 return opt && odr_ok(o);
1054 z_DatabaseName(o, &(*p)->db, 1) &&
1055 odr_implicit(o, odr_integer, &(*p)->num, ODR_CONTEXT, 1, 1) &&
1056 z_OtherInformation(o, &(*p)->otherDbInfo, 1) &&
1057 odr_sequence_end(o);
1060 int z_ByDatabaseList(ODR o, Z_ByDatabaseList **p, int opt)
1062 if (!odr_initmember(o, p, sizeof(**p)))
1063 return opt && odr_ok(o);
1064 if (odr_sequence_of(o, z_ByDatabase, &(*p)->elements, &(*p)->num_elements))
1067 return opt && odr_ok(o);
1070 int z_ScanOccurrences(ODR o, Z_ScanOccurrences **p, int opt)
1074 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_ScanOccurrences_global, odr_integer},
1075 {ODR_EXPLICIT, ODR_CONTEXT, 3, Z_ScanOccurrences_byDatabase,
1080 if (!odr_initmember(o, p, sizeof(**p)))
1081 return opt && odr_ok(o);
1082 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1085 return opt && odr_ok(o);
1088 int z_OccurrenceByAttributesElem(ODR o, Z_OccurrenceByAttributesElem **p,
1091 if (!odr_sequence_begin(o, p, sizeof(**p)))
1092 return opt && odr_ok(o);
1094 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT,
1096 z_ScanOccurrences(o, &(*p)->occurrences, 1) &&
1097 z_OtherInformation(o, &(*p)->otherOccurInfo, 1) &&
1098 odr_sequence_end(o);
1101 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1103 if (!odr_initmember(o, p, sizeof(**p)))
1104 return opt && odr_ok(o);
1105 if (!odr_sequence_of(o, z_OccurrenceByAttributesElem, &(*p)->elements,
1106 &(*p)->num_elements))
1109 return opt && odr_ok(o);
1115 * Incomplete definition of occurencebyattributes.
1118 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1120 if (!odr_sequence_begin(o, p, sizeof(**p)))
1121 return opt && odr_ok(o);
1123 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
1124 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
1125 odr_sequence_end(o);
1130 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
1132 if (!odr_sequence_begin(o, p, sizeof(**p)))
1133 return opt && odr_ok(o);
1136 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
1137 z_Term(o, &(*p)->term, 0)) &&
1138 odr_implicit(o, z_InternationalString, &(*p)->displayTerm, ODR_CONTEXT,
1140 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
1141 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
1142 ODR_CONTEXT, 4, 1) &&
1143 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
1145 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
1146 ODR_CONTEXT, 3, 1) &&
1147 z_OtherInformation(o, &(*p)->otherTermInfo, 1) &&
1148 odr_sequence_end(o);
1151 int z_Entry(ODR o, Z_Entry **p, int opt)
1153 static Odr_arm arm[] =
1155 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
1156 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
1161 if (o->direction == ODR_DECODE)
1162 *p = odr_malloc(o, sizeof(**p));
1166 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1169 return opt && odr_ok(o);
1172 int z_Entries(ODR o, Z_Entries **p, int opt)
1174 if (o->direction == ODR_DECODE)
1175 *p = odr_malloc(o, sizeof(**p));
1179 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
1180 &(*p)->num_entries))
1186 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
1188 static Odr_arm arm[] =
1190 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
1191 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
1196 if (o->direction == ODR_DECODE)
1197 *p = odr_malloc(o, sizeof(**p));
1201 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1204 return opt && odr_ok(o);
1207 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
1209 if (!odr_sequence_begin(o, p, sizeof(**p)))
1210 return opt && odr_ok(o);
1213 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1214 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1215 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
1216 &(*p)->num_databaseNames) &&
1217 odr_oid(o, &(*p)->attributeSet, 1) &&
1218 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
1219 ((*p)->termListAndStartPoint ? 1 :
1220 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
1221 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
1222 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
1223 ODR_CONTEXT, 6, 0) &&
1224 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
1225 ODR_CONTEXT, 7, 1) &&
1226 odr_sequence_end(o);
1229 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
1231 if (!odr_sequence_begin(o, p, sizeof(**p)))
1232 return opt && odr_ok(o);
1234 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1235 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
1236 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
1237 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
1238 ODR_CONTEXT, 5, 0) &&
1239 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
1240 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
1241 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
1242 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1243 odr_sequence_end(o);
1246 /* ------------------------ SEARCHRESPONSE ----------------*/
1248 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
1250 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
1253 int z_NextResultSetPosition(ODR o, int **p, int opt)
1255 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
1258 int z_PresentStatus(ODR o, int **p, int opt)
1260 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
1263 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
1265 Z_SearchResponse *pp;
1267 if (!odr_sequence_begin(o, p, sizeof(**p)))
1268 return opt && odr_ok(o);
1271 z_ReferenceId(o, &pp->referenceId, 1) &&
1272 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
1273 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1274 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1275 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
1276 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26,
1278 z_PresentStatus(o, &pp->presentStatus, 1) &&
1279 z_Records(o, &pp->records, 1) &&
1281 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
1282 ODR_CONTEXT, 203, 1) &&
1283 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1285 odr_sequence_end(o);
1288 /* --------------------- PRESENT SERVICE ---------------------- */
1290 int z_ElementSpec(ODR o, Z_ElementSpec **p, int opt)
1292 static Odr_arm arm[] =
1294 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSpec_elementSetName,
1296 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ElementSpec_externalSpec,
1301 if (o->direction == ODR_DECODE)
1302 *p = odr_malloc(o, sizeof(**p));
1306 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1309 return opt && odr_ok(o);
1312 int z_Specification(ODR o, Z_Specification **p, int opt)
1314 if (!odr_sequence_begin(o, p, sizeof(**p)))
1315 return opt && odr_ok(o);
1317 odr_implicit(o, odr_oid, &(*p)->schema, ODR_CONTEXT, 1, 1) &&
1318 z_ElementSpec(o, &(*p)->elementSpec, 1) &&
1319 odr_sequence_end(o);
1322 int z_DbSpecific(ODR o, Z_DbSpecific **p, int opt)
1324 if (!odr_sequence_begin(o, p, sizeof(**p)))
1325 return opt && odr_ok(o);
1327 odr_explicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
1329 odr_implicit(o, z_Specification, &(*p)->spec, ODR_CONTEXT, 2, 0) &&
1330 odr_sequence_end(o);
1333 int z_CompSpec(ODR o, Z_CompSpec **p, int opt)
1335 if (!odr_sequence_begin(o, p, sizeof(**p)))
1336 return opt && odr_ok(o);
1338 odr_implicit(o, odr_bool, &(*p)->selectAlternativeSyntax, ODR_CONTEXT,
1340 odr_implicit(o, z_Specification, &(*p)->generic, ODR_CONTEXT, 2, 1) &&
1341 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1342 (odr_sequence_of(o, z_DbSpecific, &(*p)->dbSpecific,
1343 &(*p)->num_dbSpecific) || odr_ok(o)) &&
1344 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1345 (odr_sequence_of(o, odr_oid, &(*p)->recordSyntax,
1346 &(*p)->num_recordSyntax) || odr_ok(o)) &&
1347 odr_sequence_end(o);
1350 int z_RecordComposition(ODR o, Z_RecordComposition **p, int opt)
1352 static Odr_arm arm[] =
1354 {ODR_EXPLICIT, ODR_CONTEXT, 19, Z_RecordComp_simple,
1356 {ODR_IMPLICIT, ODR_CONTEXT, 209, Z_RecordComp_complex,
1361 if (o->direction == ODR_DECODE)
1362 *p = odr_malloc(o, sizeof(**p));
1366 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1369 return opt && odr_ok(o);
1372 int z_Range(ODR o, Z_Range **p, int opt)
1374 if (!odr_sequence_begin(o, p, sizeof(**p)))
1375 return opt && odr_ok(o);
1377 odr_implicit(o, odr_integer, &(*p)->startingPosition, ODR_CONTEXT,
1379 odr_implicit(o, odr_integer, &(*p)->numberOfRecords, ODR_CONTEXT,
1381 odr_sequence_end(o);
1384 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
1386 Z_PresentRequest *pp;
1388 if (!odr_sequence_begin(o, p, sizeof(**p)))
1389 return opt && odr_ok(o);
1392 z_ReferenceId(o, &pp->referenceId, 1) &&
1393 z_ResultSetId(o, &pp->resultSetId, 0) &&
1394 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
1396 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
1399 odr_implicit_settag(o, ODR_CONTEXT, 212) &&
1400 (odr_sequence_of(o, z_Range, &(*p)->additionalRanges,
1401 &(*p)->num_ranges) || odr_ok(o)) &&
1402 z_RecordComposition(o, &(*p)->recordComposition, 1) &&
1404 odr_explicit(o, z_ElementSetNames, &pp->elementSetNames, ODR_CONTEXT,
1407 odr_implicit(o, odr_oid, &(*p)->preferredRecordSyntax, ODR_CONTEXT,
1410 odr_implicit(o, odr_integer, &(*p)->maxSegmentCount, ODR_CONTEXT,
1412 odr_implicit(o, odr_integer, &(*p)->maxRecordSize, ODR_CONTEXT,
1414 odr_implicit(o, odr_integer, &(*p)->maxSegmentSize, ODR_CONTEXT,
1416 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1418 odr_sequence_end(o);
1421 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
1423 Z_PresentResponse *pp;
1425 if (!odr_sequence_begin(o, p, sizeof(**p)))
1426 return opt && odr_ok(o);
1429 z_ReferenceId(o, &pp->referenceId, 1) &&
1430 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1431 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1432 z_PresentStatus(o, &pp->presentStatus, 0) &&
1433 z_Records(o, &pp->records, 1) &&
1435 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1437 odr_sequence_end(o);
1440 /* ----------------------DELETE -------------------------- */
1442 int z_DeleteSetStatus(ODR o, int **p, int opt)
1444 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
1447 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
1449 if (!odr_sequence_begin(o, p, sizeof(**p)))
1450 return opt && odr_ok(o);
1452 z_ResultSetId(o, &(*p)->id, 0) &&
1453 z_DeleteSetStatus(o, &(*p)->status, 0) &&
1454 odr_sequence_end(o);
1457 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
1459 if (!odr_sequence_begin(o, p, sizeof(**p)))
1460 return opt && odr_ok(o);
1462 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1463 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
1465 (odr_sequence_of(o, z_ListStatus, &(*p)->resultSetList,
1466 &(*p)->num_ids) || odr_ok(o)) &&
1468 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1470 odr_sequence_end(o);
1473 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
1475 if (!odr_sequence_begin(o, p, sizeof(**p)))
1476 return opt && odr_ok(o);
1478 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1479 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
1480 ODR_CONTEXT, 0, 1) &&
1481 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
1482 (odr_sequence_of(o, z_ListStatus, &(*p)->deleteListStatuses,
1483 &(*p)->num_statuses) || odr_ok(o)) &&
1484 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
1486 odr_implicit_settag(o, ODR_CONTEXT, 35) &&
1487 (odr_sequence_of(o, z_ListStatus, &(*p)->bulkStatuses,
1488 &(*p)->num_bulkStatuses) || odr_ok(o)) &&
1489 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
1492 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1494 odr_sequence_end(o);
1497 /* ------------------------ SEGMENT SERVICE -------------- */
1499 int z_Segment(ODR o, Z_Segment **p, int opt)
1501 if (!odr_sequence_begin(o, p, sizeof(**p)))
1502 return opt && odr_ok(o);
1504 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1505 odr_implicit(o, odr_integer, &(*p)->numberOfRecordsReturned,
1506 ODR_CONTEXT, 24, 0) &&
1507 odr_implicit_settag(o, ODR_CONTEXT, 0) &&
1508 odr_sequence_of(o, z_NamePlusRecord, &(*p)->segmentRecords,
1509 &(*p)->num_segmentRecords) &&
1510 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1511 odr_sequence_end(o);
1514 /* ------------------------ CLOSE SERVICE ---------------- */
1516 int z_Close(ODR o, Z_Close **p, int opt)
1518 if (!odr_sequence_begin(o, p, sizeof(**p)))
1519 return opt && odr_ok(o);
1521 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1522 odr_implicit(o, odr_integer, &(*p)->closeReason, ODR_CONTEXT, 211, 0) &&
1523 odr_implicit(o, odr_visiblestring, &(*p)->diagnosticInformation,
1524 ODR_CONTEXT, 3, 1) &&
1525 odr_implicit(o, odr_oid, &(*p)->resourceReportFormat, ODR_CONTEXT,
1527 odr_implicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1530 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1532 odr_sequence_end(o);
1535 /* ------------------------ APDU ------------------------- */
1537 int z_Permissions(ODR o, Z_Permissions **p, int opt)
1539 if (!odr_sequence_begin(o, p, sizeof(**p)))
1540 return opt && odr_ok(o);
1542 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT,
1544 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
1545 odr_sequence_of(o, odr_integer, &(*p)->allowableFunctions,
1546 &(*p)->num_allowableFunctions) &&
1547 odr_sequence_end(o);
1550 int z_ExtendedServicesRequest(ODR o, Z_ExtendedServicesRequest **p, int opt)
1552 if (!odr_sequence_begin(o, p, sizeof(**p)))
1553 return opt && odr_ok(o);
1555 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1556 odr_implicit(o, odr_integer, &(*p)->function, ODR_CONTEXT, 3, 0) &&
1557 odr_implicit(o, odr_oid, &(*p)->packageType, ODR_CONTEXT, 4, 0) &&
1558 odr_implicit(o, z_InternationalString, &(*p)->packageName, ODR_CONTEXT, 5, 1) &&
1559 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT, 6, 1) &&
1560 odr_implicit(o, z_IntUnit, &(*p)->retentionTime, ODR_CONTEXT, 7, 1) &&
1561 odr_implicit(o, z_Permissions, &(*p)->permissions, ODR_CONTEXT, 8, 1) &&
1562 odr_implicit(o, z_InternationalString, &(*p)->description, ODR_CONTEXT, 9, 1) &&
1563 odr_implicit(o, z_External, &(*p)->taskSpecificParameters, ODR_CONTEXT, 10, 1) &&
1564 odr_implicit(o, odr_integer, &(*p)->waitAction, ODR_CONTEXT, 11, 0) &&
1565 z_ElementSetName(o, &(*p)->elements, 1) &&
1566 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1567 odr_sequence_end(o);
1570 int z_ExtendedServicesResponse(ODR o, Z_ExtendedServicesResponse **p, int opt)
1572 if (!odr_sequence_begin(o, p, sizeof(**p)))
1573 return opt && odr_ok(o);
1575 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1576 odr_implicit(o, odr_integer, &(*p)->operationStatus, ODR_CONTEXT, 3, 0) &&
1577 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1578 (odr_sequence_of(o, z_DiagRec, &(*p)->diagnostics,
1579 &(*p)->num_diagnostics) || odr_ok(o)) &&
1580 odr_implicit(o, z_External, &(*p)->taskPackage, ODR_CONTEXT, 5, 1) &&
1581 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1582 odr_sequence_end(o);
1585 /* ------------------------ SORT ------------------------- */
1587 int z_SortAttributes(ODR o, Z_SortAttributes **p, int opt)
1589 if (!odr_sequence_begin(o, p, sizeof(**p)))
1590 return opt && odr_ok(o);
1592 odr_oid(o, &(*p)->id, 0) &&
1593 z_AttributeList(o, &(*p)->list, 0) &&
1594 odr_sequence_end(o);
1597 int z_SortKey(ODR o, Z_SortKey **p, int opt)
1599 static Odr_arm arm[] =
1601 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_SortKey_sortField,
1602 z_InternationalString},
1603 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortKey_elementSpec, z_Specification},
1604 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortKey_sortAttributes,
1609 if (!odr_initmember(o, p, sizeof(**p)))
1610 return opt && odr_ok(o);
1611 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1614 return opt && odr_ok(o);
1617 int z_SortDbSpecific(ODR o, Z_SortDbSpecific **p, int opt)
1619 if (!odr_sequence_begin(o, p, sizeof(**p)))
1620 return opt && odr_ok(o);
1622 z_DatabaseName(o, &(*p)->databaseName, 0) &&
1623 z_SortKey(o, &(*p)->dbSort, 0) &&
1624 odr_sequence_end(o);
1627 int z_SortDbSpecificList(ODR o, Z_SortDbSpecificList **p, int opt)
1629 if (!odr_initmember(o, p, sizeof(**p)))
1630 return opt && odr_ok(o);
1631 if (odr_sequence_of(o, z_SortDbSpecific, &(*p)->dbSpecific,
1632 &(*p)->num_dbSpecific))
1635 return opt && odr_ok(o);
1638 int z_SortElement(ODR o, Z_SortElement **p, int opt)
1640 static Odr_arm arm[] =
1642 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_SortElement_generic, z_SortKey},
1643 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortElement_databaseSpecific,
1644 z_SortDbSpecificList},
1648 if (!odr_initmember(o, p, sizeof(**p)))
1649 return opt && odr_ok(o);
1650 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1653 return opt && odr_ok(o);
1656 int z_SortMissingValueAction(ODR o, Z_SortMissingValueAction **p, int opt)
1658 static Odr_arm arm[] =
1660 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortMissingValAct_abort, odr_null},
1661 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortMissingValAct_null, odr_null},
1662 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_SortMissingValAct_valData,
1667 if (!odr_initmember(o, p, sizeof(**p)))
1668 return opt && odr_ok(o);
1669 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1672 return opt && odr_ok(o);
1675 int z_SortKeySpec(ODR o, Z_SortKeySpec **p, int opt)
1677 if (!odr_sequence_begin(o, p, sizeof(**p)))
1678 return opt && odr_ok(o);
1680 z_SortElement(o, &(*p)->sortElement, 0) &&
1681 odr_implicit(o, odr_integer, &(*p)->sortRelation, ODR_CONTEXT, 1, 0) &&
1682 odr_implicit(o, odr_integer, &(*p)->caseSensitivity, ODR_CONTEXT,
1684 odr_explicit(o, z_SortMissingValueAction, &(*p)->missingValueAction,
1685 ODR_CONTEXT, 3, 1) &&
1686 odr_sequence_end(o);
1689 int z_SortResponse(ODR o, Z_SortResponse **p, int opt)
1691 if (!odr_sequence_begin(o, p, sizeof(**p)))
1692 return opt && odr_ok(o);
1694 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1695 odr_implicit(o, odr_integer, &(*p)->sortStatus, ODR_CONTEXT,
1697 odr_implicit(o, odr_integer, &(*p)->resultSetStatus, ODR_CONTEXT,
1699 odr_implicit(o, z_DiagRecs, &(*p)->diagnostics, ODR_CONTEXT, 5, 1) &&
1700 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1701 odr_sequence_end(o);
1704 int z_SortKeySpecList(ODR o, Z_SortKeySpecList **p, int opt)
1706 if (!odr_initmember(o, p, sizeof(**p)))
1707 return opt && odr_ok(o);
1708 if (odr_sequence_of(o, z_SortKeySpec, &(*p)->specs, &(*p)->num_specs))
1711 return opt && odr_ok(o);
1714 int z_SortRequest(ODR o, Z_SortRequest **p, int opt)
1716 if (!odr_sequence_begin(o, p, sizeof(**p)))
1717 return opt && odr_ok(o);
1719 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1720 odr_implicit(o, z_StringList, &(*p)->inputResultSetNames,
1721 ODR_CONTEXT, 3, 0) &&
1722 odr_implicit(o, z_InternationalString, &(*p)->sortedResultSetName,
1723 ODR_CONTEXT, 4, 0) &&
1724 odr_implicit(o, z_SortKeySpecList, &(*p)->sortSequence, ODR_CONTEXT,
1726 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1727 odr_sequence_end(o);
1730 /* ------------------------ APDU ------------------------- */
1732 int z_APDU(ODR o, Z_APDU **p, int opt)
1734 static Odr_arm arm[] =
1736 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
1737 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
1738 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
1739 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
1741 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
1743 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
1745 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
1746 z_DeleteResultSetRequest},
1747 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
1748 z_DeleteResultSetResponse},
1749 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_APDU_accessControlRequest,
1750 z_AccessControlRequest},
1751 {ODR_IMPLICIT, ODR_CONTEXT, 29, Z_APDU_accessControlResponse,
1752 z_AccessControlResponse},
1753 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
1754 z_ResourceControlRequest},
1755 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
1756 z_ResourceControlResponse},
1757 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
1758 z_TriggerResourceControlRequest},
1759 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
1760 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
1761 {ODR_IMPLICIT, ODR_CONTEXT, 43, Z_APDU_sortRequest, z_SortRequest},
1762 {ODR_IMPLICIT, ODR_CONTEXT, 44, Z_APDU_sortResponse, z_SortResponse},
1763 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_APDU_segmentRequest, z_Segment},
1764 {ODR_IMPLICIT, ODR_CONTEXT, 46, Z_APDU_extendedServicesRequest,
1765 z_ExtendedServicesRequest},
1766 {ODR_IMPLICIT, ODR_CONTEXT, 47, Z_APDU_extendedServicesResponse,
1767 z_ExtendedServicesResponse},
1768 {ODR_IMPLICIT, ODR_CONTEXT, 48, Z_APDU_close, z_Close},
1773 if (o->direction == ODR_DECODE)
1774 *p = odr_malloc(o, sizeof(**p));
1775 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
1777 if (o->direction == ODR_DECODE)
1779 return opt && odr_ok(o);