2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.44 1996-02-20 12:51:41 quinn
8 * Completed SCAN. Fixed problems with EXTERNAL.
10 * Revision 1.43 1996/02/10 12:22:49 quinn
13 * Revision 1.42 1996/01/22 09:46:31 quinn
14 * Added Sort PDU. Moved StringList to main protocol file.
16 * Revision 1.41 1996/01/10 15:21:24 quinn
17 * Added links to access control PDUs
19 * Revision 1.40 1996/01/02 11:46:40 quinn
20 * Changed 'operator' to 'roperator' to avoid C++ conflict.
22 * Revision 1.39 1995/09/29 17:11:53 quinn
25 * Revision 1.38 1995/09/27 15:02:40 quinn
26 * Modified function heads & prototypes.
28 * Revision 1.37 1995/08/21 09:10:15 quinn
29 * Smallish fixes to suppport new formats.
31 * Revision 1.36 1995/08/15 11:59:39 quinn
34 * Revision 1.35 1995/08/10 08:53:59 quinn
37 * Revision 1.34 1995/06/19 17:01:48 quinn
38 * This should bring us in sync with the version distributed as 1.0b
40 * Revision 1.33 1995/06/19 13:39:56 quinn
41 * *** empty log message ***
43 * Revision 1.32 1995/06/19 12:37:28 quinn
44 * Fixed a bug in the compspec.
46 * Revision 1.31 1995/06/16 13:15:56 quinn
47 * Fixed Defaultdiagformat.
49 * Revision 1.30 1995/06/15 15:42:01 quinn
52 * Revision 1.29 1995/06/15 07:44:49 quinn
55 * Revision 1.28 1995/06/14 15:26:35 quinn
56 * *** empty log message ***
58 * Revision 1.27 1995/06/07 14:36:22 quinn
61 * Revision 1.26 1995/06/02 09:49:13 quinn
62 * Adding access control
64 * Revision 1.25 1995/05/25 11:00:08 quinn
65 * *** empty log message ***
67 * Revision 1.24 1995/05/22 13:58:18 quinn
68 * Fixed an ODR_NULLVAL.
70 * Revision 1.23 1995/05/22 11:30:18 quinn
71 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
73 * Revision 1.22 1995/05/17 08:40:56 quinn
74 * Added delete. Fixed some sequence_begins. Smallish.
76 * Revision 1.21 1995/05/16 08:50:24 quinn
77 * License, documentation, and memory fixes
79 * Revision 1.20 1995/05/15 11:55:25 quinn
82 * Revision 1.19 1995/04/11 11:58:35 quinn
85 * Revision 1.18 1995/04/11 11:52:02 quinn
86 * Fixed possible buf in proto.c
88 * Revision 1.17 1995/04/10 10:22:22 quinn
91 * Revision 1.16 1995/03/30 10:26:43 quinn
92 * Added Term structure
94 * Revision 1.15 1995/03/30 09:08:39 quinn
95 * Added Resource control protocol
97 * Revision 1.14 1995/03/29 08:06:13 quinn
98 * Added a few v3 elements
100 * Revision 1.13 1995/03/20 11:26:52 quinn
101 * *** empty log message ***
103 * Revision 1.12 1995/03/20 09:45:09 quinn
106 * Revision 1.11 1995/03/17 10:17:25 quinn
107 * Added memory management.
109 * Revision 1.10 1995/03/15 11:17:40 quinn
110 * Fixed some return-checks from choice.. need better ay to handle those..
112 * Revision 1.9 1995/03/15 08:37:06 quinn
113 * Fixed protocol bugs.
115 * Revision 1.8 1995/03/14 16:59:24 quinn
116 * Fixed OPTIONAL flag in attributeelement
118 * Revision 1.7 1995/03/07 16:29:33 quinn
119 * Added authentication stuff.
121 * Revision 1.6 1995/03/01 14:46:03 quinn
122 * Fixed protocol bug in 8777query.
124 * Revision 1.5 1995/02/14 11:54:22 quinn
127 * Revision 1.4 1995/02/10 15:54:30 quinn
130 * Revision 1.3 1995/02/09 15:51:39 quinn
133 * Revision 1.2 1995/02/06 21:26:07 quinn
134 * Repaired this evening's damages..
136 * Revision 1.1 1995/02/06 16:44:47 quinn
137 * First hack at Z/SR protocol
145 /* ---------------------- GLOBAL DEFS ------------------- */
148 * We'll use a general octetstring here, since string operations are
149 * clumsy on long strings.
151 int z_SUTRS(ODR o, Odr_oct **p, int opt)
153 return odr_implicit(o, odr_octetstring, p, ODR_UNIVERSAL,
154 ODR_GENERALSTRING, opt);
157 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
159 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
162 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
164 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
168 int z_ResultSetId(ODR o, char **p, int opt)
170 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
174 int z_ElementSetName(ODR o, char **p, int opt)
176 return odr_implicit(o, odr_visiblestring, p, ODR_CONTEXT, 103, opt);
179 int z_UserInformationField(ODR o, Z_External **p, int opt)
181 return odr_explicit(o, z_External, (Z_External **)p, ODR_CONTEXT,
185 int z_InternationalString(ODR o, char **p, int opt)
187 return odr_generalstring(o, p, opt);
190 int z_InfoCategory(ODR o, Z_InfoCategory **p, int opt)
192 if (!odr_sequence_begin(o, p, sizeof(**p)))
193 return opt && odr_ok(o);
195 odr_implicit(o, odr_oid, &(*p)->categoryTypeId, ODR_CONTEXT, 1, 1) &&
196 odr_implicit(o, odr_integer, &(*p)->categoryValue, ODR_CONTEXT, 2, 0) &&
200 int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt)
202 static Odr_arm arm[] =
204 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_OtherInfo_characterInfo,
206 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_OtherInfo_binaryInfo,
208 {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_OtherInfo_externallyDefinedInfo,
210 {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_OtherInfo_oid, odr_oid},
214 if (!odr_sequence_begin(o, p, sizeof(**p)))
215 return opt && odr_ok(o);
217 odr_implicit(o, z_InfoCategory, &(*p)->category, ODR_CONTEXT, 1, 1) &&
218 odr_choice(o, arm, &(*p)->which, &(*p)->information) &&
222 int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt)
224 if (o->direction == ODR_DECODE)
225 *p = odr_malloc(o, sizeof(**p));
228 odr_implicit_settag(o, ODR_CONTEXT, 201);
229 if (odr_sequence_of(o, z_OtherInformationUnit, &(*p)->list,
230 &(*p)->num_elements))
233 return opt && odr_ok(o);
236 int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt)
238 static Odr_arm arm[] =
240 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_StringOrNumeric_string,
242 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_StringOrNumeric_numeric,
247 if (o->direction == ODR_DECODE)
248 *p = odr_malloc(o, sizeof(**p));
251 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
254 return opt && odr_ok(o);
260 int z_Unit(ODR o, Z_Unit **p, int opt)
262 if (!odr_sequence_begin(o, p, sizeof(**p)))
263 return opt && odr_ok(o);
265 odr_implicit(o, odr_visiblestring, &(*p)->unitSystem, ODR_CONTEXT,
267 odr_explicit(o, z_StringOrNumeric, &(*p)->unitType, ODR_CONTEXT,
269 odr_explicit(o, z_StringOrNumeric, &(*p)->unit, ODR_CONTEXT, 3, 1) &&
270 odr_implicit(o, odr_integer, &(*p)->scaleFactor, ODR_CONTEXT, 4, 1) &&
274 int z_IntUnit(ODR o, Z_IntUnit **p, int opt)
276 if (!odr_sequence_begin(o, p, sizeof(**p)))
277 return opt && odr_ok(o);
279 odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 1, 0) &&
280 odr_implicit(o, z_Unit, &(*p)->unitUsed, ODR_CONTEXT, 2, 0) &&
284 int z_StringList(ODR o, Z_StringList **p, int opt)
286 if (o->direction == ODR_DECODE)
287 *p = odr_malloc(o, sizeof(**p));
290 if (odr_sequence_of(o, z_InternationalString, &(*p)->strings,
294 return opt && odr_ok(o);
297 /* ---------------------- INITIALIZE SERVICE ------------------- */
300 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
302 if (!odr_sequence_begin(o, p, sizeof(**p)))
303 return opt && odr_ok(o);
305 odr_visiblestring(o, &(*p)->user, 0) &&
306 odr_visiblestring(o, &(*p)->password, 0) &&
307 odr_visiblestring(o, &(*p)->account, 0) &&
312 int z_IdPass(ODR o, Z_IdPass **p, int opt)
314 if (!odr_sequence_begin(o, p, sizeof(**p)))
315 return opt && odr_ok(o);
317 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 1) &&
318 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 1) &&
319 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
324 int z_StrAuthentication(ODR o, char **p, int opt)
326 return odr_visiblestring(o, p, opt);
329 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
331 static Odr_arm arm[] =
333 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
334 {-1, -1, -1, Z_IdAuthentication_idPass, z_IdPass},
335 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
336 {-1, -1, -1, Z_IdAuthentication_other, z_External},
340 if (o->direction == ODR_DECODE)
341 *p = odr_malloc(o, sizeof(**p));
345 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
348 return opt && odr_ok(o);
351 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
355 if (!odr_sequence_begin(o, p, sizeof(**p)))
356 return opt && odr_ok(o);
359 z_ReferenceId(o, &pp->referenceId, 1) &&
360 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
362 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
363 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
365 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
367 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
369 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
371 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
373 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
374 ODR_CONTEXT, 112, 1) &&
375 z_UserInformationField(o, &pp->userInformationField, 1) &&
377 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
382 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
386 if (!odr_sequence_begin(o, p, sizeof(**p)))
387 return opt && odr_ok(o);
390 z_ReferenceId(o, &pp->referenceId, 1) &&
391 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
393 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
394 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
396 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
398 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
399 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
401 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
403 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
404 ODR_CONTEXT, 112, 1) &&
405 z_UserInformationField(o, &pp->userInformationField, 1) &&
407 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
412 /* ------------------ RESOURCE CONTROL ----------------*/
414 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
417 if (!odr_sequence_begin(o, p, sizeof(**p)))
418 return opt && odr_ok(o);
420 z_ReferenceId(o, &(*p)->referenceId, 1) &&
421 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
423 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
424 ODR_CONTEXT, 47, 1) &&
425 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
428 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
433 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
435 if (!odr_sequence_begin(o, p, sizeof(**p)))
436 return opt && odr_ok(o);
438 z_ReferenceId(o, &(*p)->referenceId, 1) &&
439 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
440 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
442 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
443 ODR_CONTEXT, 41, 1) &&
444 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
446 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
447 ODR_CONTEXT, 43, 1) &&
449 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
454 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
456 if (!odr_sequence_begin(o, p, sizeof(**p)))
457 return opt && odr_ok(o);
459 z_ReferenceId(o, &(*p)->referenceId, 1) &&
460 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
461 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
464 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
469 /* ------------------------ SEARCH SERVICE ----------------------- */
471 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
473 if (!odr_sequence_begin(o, p, sizeof(**p)))
474 return opt && odr_ok(o);
476 z_DatabaseName(o, &(*p)->databaseName, 0) &&
477 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
481 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
483 if (o->direction == ODR_DECODE)
484 *p = odr_malloc(o, sizeof(**p));
488 odr_implicit_settag(o, ODR_CONTEXT, 1);
489 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
490 &(*p)->num_elements))
496 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
498 static Odr_arm arm[] =
500 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
502 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
507 if (o->direction == ODR_DECODE)
508 *p = odr_malloc(o, sizeof(**p));
510 return opt && odr_ok(o);
512 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
518 /* ----------------------- RPN QUERY -----------------------*/
520 int z_ComplexAttribute(ODR o, Z_ComplexAttribute **p, int opt)
522 if (!odr_sequence_begin(o, p, sizeof(**p)))
523 return opt && odr_ok(o);
525 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
526 odr_sequence_of(o, z_StringOrNumeric, &(*p)->list,
528 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
529 (odr_sequence_of(o, odr_integer, &(*p)->semanticAction,
530 &(*p)->num_semanticAction) || odr_ok(o)) &&
534 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
537 static Odr_arm arm[] =
539 {ODR_IMPLICIT, ODR_CONTEXT, 121, Z_AttributeValue_numeric,
541 {ODR_IMPLICIT, ODR_CONTEXT, 224, Z_AttributeValue_complex,
547 if (!odr_sequence_begin(o, p, sizeof(**p)))
548 return opt && odr_ok(o);
551 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 1, 1) &&
553 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
556 odr_choice(o, arm, &(*p)->value, &(*p)->which) &&
558 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
564 int z_Term(ODR o, Z_Term **p, int opt)
566 static Odr_arm arm[] =
568 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
569 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
570 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
572 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
573 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
574 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, z_External},
575 /* add intUnit here */
576 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
580 if (o->direction ==ODR_DECODE)
581 *p = odr_malloc(o, sizeof(**p));
584 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
587 return opt && odr_ok(o);
590 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
592 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
593 odr_sequence_begin(o, p, sizeof(**p))))
594 return opt && odr_ok(o);
596 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
597 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
598 &(*p)->num_attributes) &&
599 z_Term(o, &(*p)->term, 0) &&
603 int z_ResultSetPlusAttributes(ODR o, Z_ResultSetPlusAttributes **p, int opt)
605 if (!(odr_implicit_settag(o, ODR_CONTEXT, 214) &&
606 odr_sequence_begin(o, p, sizeof(**p))))
607 return opt && odr_ok(o);
609 z_ResultSetId(o, &(*p)->resultSet, 0) &&
610 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
611 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
612 &(*p)->num_attributes) &&
616 int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
618 static Odr_arm arm[] =
620 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, odr_integer},
621 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_private, odr_integer},
625 if (!odr_sequence_begin(o, p, sizeof(**p)))
626 return opt && odr_ok(o);
628 odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
629 odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
630 odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
631 odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
632 odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
633 odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
634 odr_constructed_end(o) &&
638 int z_Operator(ODR o, Z_Operator **p, int opt)
640 static Odr_arm arm[] =
642 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
643 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
644 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
645 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, z_ProximityOperator},
649 if (!*p && o->direction != ODR_DECODE)
651 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
652 return opt && odr_ok(o);
653 if (o->direction == ODR_DECODE)
654 *p = odr_malloc(o, sizeof(**p));
656 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
657 odr_constructed_end(o))
660 return opt && odr_ok(o);
663 int z_Operand(ODR o, Z_Operand **p, int opt)
665 static Odr_arm arm[] =
667 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
668 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
669 {-1, -1, -1, Z_Operand_resultAttr, z_ResultSetPlusAttributes},
673 if (o->direction == ODR_DECODE)
674 *p = odr_malloc(o, sizeof(**p));
677 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
680 return opt && odr_ok(o);
683 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
685 int z_Complex(ODR o, Z_Complex **p, int opt)
687 if (!odr_sequence_begin(o, p, sizeof(**p)))
688 return opt && odr_ok(o);
690 z_RPNStructure(o, &(*p)->s1, 0) &&
691 z_RPNStructure(o, &(*p)->s2, 0) &&
692 z_Operator(o, &(*p)->roperator, 0) &&
696 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
698 static Odr_arm arm[] =
700 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
701 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
705 if (o->direction == ODR_DECODE)
706 *p = odr_malloc(o, sizeof(**p));
709 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
712 return opt && odr_ok(o);
715 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
717 if (!odr_sequence_begin(o, p, sizeof(**p)))
718 return opt && odr_ok(o);
720 odr_oid(o, &(*p)->attributeSetId, 0) &&
721 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
725 /* -----------------------END RPN QUERY ----------------------- */
727 int z_Query(ODR o, Z_Query **p, int opt)
729 static Odr_arm arm[] =
731 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
732 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
733 {ODR_EXPLICIT, ODR_CONTEXT, 101, Z_Query_type_101, z_RPNQuery},
737 if (o->direction == ODR_DECODE)
738 *p = odr_malloc(o, sizeof(**p));
741 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
744 return opt && odr_ok(o);
747 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
751 if (!odr_sequence_begin(o, p, sizeof(**p)))
752 return opt && odr_ok(o);
755 z_ReferenceId(o, &pp->referenceId, 1) &&
756 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
758 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
760 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
762 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
763 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
765 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
766 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
767 &pp->num_databaseNames) &&
768 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
769 ODR_CONTEXT, 100, 1) &&
770 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
771 ODR_CONTEXT, 101, 1) &&
772 odr_implicit(o, odr_oid, &pp->preferredRecordSyntax,
773 ODR_CONTEXT, 104, 1) &&
774 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
776 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
777 ODR_CONTEXT, 203, 1) &&
778 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
783 /* ------------------------ RECORD ------------------------- */
785 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
787 return z_External(o, (Z_External **) p, opt);
792 int z_DefaultDiagFormat(ODR o, Z_DefaultDiagFormat **p, int opt)
794 static Odr_arm arm[] =
796 {-1, -1, -1, Z_DiagForm_v2AddInfo, odr_visiblestring},
797 {-1, -1, -1, Z_DiagForm_v3AddInfo, z_InternationalString},
798 {ODR_IMPLICIT, ODR_CONTEXT, ODR_VISIBLESTRING, Z_DiagForm_v2AddInfo,
799 odr_visiblestring}, /* To cater to a bug in the CNIDR servers */
802 if (!odr_sequence_begin(o, p, sizeof(**p)))
803 return opt && odr_ok(o);
805 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
806 odr_integer(o, &(*p)->condition, 0) &&
808 * I no longer recall what server tagged the addinfo.. but it isn't
809 * hurting anyone, so...
810 * We need to turn it into a choice, or something, because of
811 * that damn generalstring in v3.
813 odr_choice(o, arm, &(*p)->addinfo, &(*p)->which) &&
817 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
819 static Odr_arm arm[] =
821 {-1, -1, -1, Z_DiagRec_defaultFormat, z_DefaultDiagFormat},
822 {-1, -1, -1, Z_DiagRec_externallyDefined, z_External},
826 if (o->direction == ODR_DECODE)
827 *p = odr_malloc(o, sizeof(**p));
830 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
833 return opt && odr_ok(o);
838 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
840 if (!odr_sequence_begin(o, p, sizeof(**p)))
841 return opt && odr_ok(o);
843 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
844 odr_integer(o, &(*p)->condition, 0) &&
846 * I no longer recall what server tagged the addinfo.. but it isn't
847 * hurting anyone, so...
848 * We need to turn it into a choice, or something, because of
849 * that damn generalstring in v3.
851 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
852 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT,
853 ODR_VISIBLESTRING, 1)) &&
859 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
861 if (o->direction == ODR_DECODE)
862 *p = odr_malloc(o, sizeof(**p));
866 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
867 &(*p)->num_diagRecs))
873 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
875 static Odr_arm arm[] =
877 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
879 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
884 if (!odr_sequence_begin(o, p, sizeof(**p)))
885 return opt && odr_ok(o);
887 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
889 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
890 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
891 odr_constructed_end(o) &&
895 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
897 if (o->direction == ODR_DECODE)
898 *p = odr_malloc(o, sizeof(**p));
901 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
908 int z_Records(ODR o, Z_Records **p, int opt)
910 static Odr_arm arm[] =
912 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
913 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
914 {ODR_IMPLICIT, ODR_CONTEXT, 205, Z_Records_multipleNSD,
919 if (o->direction == ODR_DECODE)
920 *p = odr_malloc(o, sizeof(**p));
923 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
926 return opt && odr_ok(o);
929 /* ------------------------ ACCESS CTRL SERVICE ----------------------- */
931 int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
933 static Odr_arm arm[] =
935 {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
937 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
941 if (!odr_sequence_begin(o, p, sizeof(**p)))
942 return opt && odr_ok(o);
944 z_ReferenceId(o, &(*p)->referenceId, 1) &&
945 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
947 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
952 int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
954 static Odr_arm arm[] =
956 {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
958 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
962 if (!odr_sequence_begin(o, p, sizeof(**p)))
963 return opt && odr_ok(o);
965 z_ReferenceId(o, &(*p)->referenceId, 1) &&
966 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
967 odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
969 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
974 /* ------------------------ SCAN SERVICE -------------------- */
976 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
978 if (o->direction == ODR_DECODE)
979 *p = odr_malloc(o, sizeof(**p));
983 odr_implicit_settag(o, ODR_CONTEXT, 44);
984 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
985 &(*p)->num_attributes))
988 return opt && odr_ok(o);
992 * This is a temporary hack. We don't know just *what* old version of the
993 * protocol willow uses, so we'll just patiently wait for them to update
995 static int willow_scan = 0;
997 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
999 if (!*p && o->direction != ODR_DECODE)
1001 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
1004 return opt && odr_ok(o);
1006 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
1008 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
1010 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
1012 if (o->direction == ODR_DECODE)
1013 *p = odr_malloc(o, sizeof(**p));
1014 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
1015 &(*p)->num_attributes))
1017 if (!odr_sequence_end(o) || !odr_sequence_end(o))
1019 if (!z_Term(o, &(*p)->term, 0))
1021 if (!odr_constructed_end(o))
1027 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
1029 if (o->direction == ODR_DECODE)
1030 *p = odr_malloc(o, sizeof(**p));
1034 return opt && odr_ok(o);
1037 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
1041 return opt && !o->error;
1046 int z_ByDatabase(ODR o, Z_ByDatabase **p, int opt)
1048 if (!odr_sequence_begin(o, p, sizeof(**p)))
1049 return opt && odr_ok(o);
1051 z_DatabaseName(o, &(*p)->db, 1) &&
1052 odr_implicit(o, odr_integer, &(*p)->num, ODR_CONTEXT, 1, 1) &&
1053 z_OtherInformation(o, &(*p)->otherDbInfo, 1) &&
1054 odr_sequence_end(o);
1057 int z_ByDatabaseList(ODR o, Z_ByDatabaseList **p, int opt)
1059 if (!odr_initmember(o, p, sizeof(**p)))
1060 return opt && odr_ok(o);
1061 if (odr_sequence_of(o, z_ByDatabase, &(*p)->elements, &(*p)->num_elements))
1064 return opt && odr_ok(o);
1067 int z_ScanOccurrences(ODR o, Z_ScanOccurrences **p, int opt)
1071 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_ScanOccurrences_global, odr_integer},
1072 {ODR_EXPLICIT, ODR_CONTEXT, 3, Z_ScanOccurrences_byDatabase,
1077 if (!odr_initmember(o, p, sizeof(**p)))
1078 return opt && odr_ok(o);
1079 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1082 return opt && odr_ok(o);
1085 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1087 if (!odr_sequence_begin(o, p, sizeof(**p)))
1088 return opt && odr_ok(o);
1090 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT,
1092 z_ScanOccurrences(o, &(*p)->occurrences, 1) &&
1093 z_OtherInformation(o, &(*p)->otherOccurInfo, 1) &&
1094 odr_sequence_end(o);
1100 * Incomplete definition of occurencebyattributes.
1103 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1105 if (!odr_sequence_begin(o, p, sizeof(**p)))
1106 return opt && odr_ok(o);
1108 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
1109 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
1110 odr_sequence_end(o);
1115 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
1117 if (!odr_sequence_begin(o, p, sizeof(**p)))
1118 return opt && odr_ok(o);
1121 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
1122 z_Term(o, &(*p)->term, 0)) &&
1123 odr_implicit(o, z_InternationalString, &(*p)->displayTerm, ODR_CONTEXT,
1125 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
1126 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
1127 ODR_CONTEXT, 4, 1) &&
1128 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
1130 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
1131 ODR_CONTEXT, 3, 1) &&
1132 z_OtherInformation(o, &(*p)->otherTermInfo, 1) &&
1133 odr_sequence_end(o);
1136 int z_Entry(ODR o, Z_Entry **p, int opt)
1138 static Odr_arm arm[] =
1140 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
1141 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
1146 if (o->direction == ODR_DECODE)
1147 *p = odr_malloc(o, sizeof(**p));
1151 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1154 return opt && odr_ok(o);
1157 int z_Entries(ODR o, Z_Entries **p, int opt)
1159 if (o->direction == ODR_DECODE)
1160 *p = odr_malloc(o, sizeof(**p));
1164 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
1165 &(*p)->num_entries))
1171 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
1173 static Odr_arm arm[] =
1175 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
1176 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
1181 if (o->direction == ODR_DECODE)
1182 *p = odr_malloc(o, sizeof(**p));
1186 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1189 return opt && odr_ok(o);
1192 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
1194 if (!odr_sequence_begin(o, p, sizeof(**p)))
1195 return opt && odr_ok(o);
1198 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1199 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1200 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
1201 &(*p)->num_databaseNames) &&
1202 odr_oid(o, &(*p)->attributeSet, 1) &&
1203 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
1204 ((*p)->termListAndStartPoint ? 1 :
1205 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
1206 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
1207 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
1208 ODR_CONTEXT, 6, 0) &&
1209 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
1210 ODR_CONTEXT, 7, 1) &&
1211 odr_sequence_end(o);
1214 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
1216 if (!odr_sequence_begin(o, p, sizeof(**p)))
1217 return opt && odr_ok(o);
1219 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1220 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
1221 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
1222 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
1223 ODR_CONTEXT, 5, 0) &&
1224 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
1225 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
1226 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
1227 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1228 odr_sequence_end(o);
1231 /* ------------------------ SEARCHRESPONSE ----------------*/
1233 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
1235 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
1238 int z_NextResultSetPosition(ODR o, int **p, int opt)
1240 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
1243 int z_PresentStatus(ODR o, int **p, int opt)
1245 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
1248 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
1250 Z_SearchResponse *pp;
1252 if (!odr_sequence_begin(o, p, sizeof(**p)))
1253 return opt && odr_ok(o);
1256 z_ReferenceId(o, &pp->referenceId, 1) &&
1257 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
1258 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1259 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1260 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
1261 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26,
1263 z_PresentStatus(o, &pp->presentStatus, 1) &&
1264 z_Records(o, &pp->records, 1) &&
1266 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
1267 ODR_CONTEXT, 203, 1) &&
1268 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1270 odr_sequence_end(o);
1273 /* --------------------- PRESENT SERVICE ---------------------- */
1275 int z_ElementSpec(ODR o, Z_ElementSpec **p, int opt)
1277 static Odr_arm arm[] =
1279 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSpec_elementSetName,
1281 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ElementSpec_externalSpec,
1286 if (o->direction == ODR_DECODE)
1287 *p = odr_malloc(o, sizeof(**p));
1291 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1294 return opt && odr_ok(o);
1297 int z_Specification(ODR o, Z_Specification **p, int opt)
1299 if (!odr_sequence_begin(o, p, sizeof(**p)))
1300 return opt && odr_ok(o);
1302 odr_implicit(o, odr_oid, &(*p)->schema, ODR_CONTEXT, 1, 1) &&
1303 z_ElementSpec(o, &(*p)->elementSpec, 1) &&
1304 odr_sequence_end(o);
1307 int z_DbSpecific(ODR o, Z_DbSpecific **p, int opt)
1309 if (!odr_sequence_begin(o, p, sizeof(**p)))
1310 return opt && odr_ok(o);
1312 odr_explicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
1314 odr_implicit(o, z_Specification, &(*p)->spec, ODR_CONTEXT, 2, 0) &&
1315 odr_sequence_end(o);
1318 int z_CompSpec(ODR o, Z_CompSpec **p, int opt)
1320 if (!odr_sequence_begin(o, p, sizeof(**p)))
1321 return opt && odr_ok(o);
1323 odr_implicit(o, odr_bool, &(*p)->selectAlternativeSyntax, ODR_CONTEXT,
1325 odr_implicit(o, z_Specification, &(*p)->generic, ODR_CONTEXT, 2, 1) &&
1326 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1327 (odr_sequence_of(o, z_DbSpecific, &(*p)->dbSpecific,
1328 &(*p)->num_dbSpecific) || odr_ok(o)) &&
1329 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1330 (odr_sequence_of(o, odr_oid, &(*p)->recordSyntax,
1331 &(*p)->num_recordSyntax) || odr_ok(o)) &&
1332 odr_sequence_end(o);
1335 int z_RecordComposition(ODR o, Z_RecordComposition **p, int opt)
1337 static Odr_arm arm[] =
1339 {ODR_EXPLICIT, ODR_CONTEXT, 19, Z_RecordComp_simple,
1341 {ODR_IMPLICIT, ODR_CONTEXT, 209, Z_RecordComp_complex,
1346 if (o->direction == ODR_DECODE)
1347 *p = odr_malloc(o, sizeof(**p));
1351 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1354 return opt && odr_ok(o);
1357 int z_Range(ODR o, Z_Range **p, int opt)
1359 if (!odr_sequence_begin(o, p, sizeof(**p)))
1360 return opt && odr_ok(o);
1362 odr_implicit(o, odr_integer, &(*p)->startingPosition, ODR_CONTEXT,
1364 odr_implicit(o, odr_integer, &(*p)->numberOfRecords, ODR_CONTEXT,
1366 odr_sequence_end(o);
1369 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
1371 Z_PresentRequest *pp;
1373 if (!odr_sequence_begin(o, p, sizeof(**p)))
1374 return opt && odr_ok(o);
1377 z_ReferenceId(o, &pp->referenceId, 1) &&
1378 z_ResultSetId(o, &pp->resultSetId, 0) &&
1379 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
1381 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
1384 odr_implicit_settag(o, ODR_CONTEXT, 212) &&
1385 (odr_sequence_of(o, z_Range, &(*p)->additionalRanges,
1386 &(*p)->num_ranges) || odr_ok(o)) &&
1387 z_RecordComposition(o, &(*p)->recordComposition, 1) &&
1389 odr_explicit(o, z_ElementSetNames, &pp->elementSetNames, ODR_CONTEXT,
1392 odr_implicit(o, odr_oid, &(*p)->preferredRecordSyntax, ODR_CONTEXT,
1395 odr_implicit(o, odr_integer, &(*p)->maxSegmentCount, ODR_CONTEXT,
1397 odr_implicit(o, odr_integer, &(*p)->maxRecordSize, ODR_CONTEXT,
1399 odr_implicit(o, odr_integer, &(*p)->maxSegmentSize, ODR_CONTEXT,
1401 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1403 odr_sequence_end(o);
1406 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
1408 Z_PresentResponse *pp;
1410 if (!odr_sequence_begin(o, p, sizeof(**p)))
1411 return opt && odr_ok(o);
1414 z_ReferenceId(o, &pp->referenceId, 1) &&
1415 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1416 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1417 z_PresentStatus(o, &pp->presentStatus, 0) &&
1418 z_Records(o, &pp->records, 1) &&
1420 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1422 odr_sequence_end(o);
1425 /* ----------------------DELETE -------------------------- */
1427 int z_DeleteSetStatus(ODR o, int **p, int opt)
1429 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
1432 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
1434 if (!odr_sequence_begin(o, p, sizeof(**p)))
1435 return opt && odr_ok(o);
1437 z_ResultSetId(o, &(*p)->id, 0) &&
1438 z_DeleteSetStatus(o, &(*p)->status, 0) &&
1439 odr_sequence_end(o);
1442 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
1444 if (!odr_sequence_begin(o, p, sizeof(**p)))
1445 return opt && odr_ok(o);
1447 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1448 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
1450 (odr_sequence_of(o, z_ListStatus, &(*p)->resultSetList,
1451 &(*p)->num_ids) || odr_ok(o)) &&
1453 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1455 odr_sequence_end(o);
1458 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
1460 if (!odr_sequence_begin(o, p, sizeof(**p)))
1461 return opt && odr_ok(o);
1463 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1464 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
1465 ODR_CONTEXT, 0, 1) &&
1466 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
1467 (odr_sequence_of(o, z_ListStatus, &(*p)->deleteListStatuses,
1468 &(*p)->num_statuses) || odr_ok(o)) &&
1469 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
1471 odr_implicit_settag(o, ODR_CONTEXT, 35) &&
1472 (odr_sequence_of(o, z_ListStatus, &(*p)->bulkStatuses,
1473 &(*p)->num_bulkStatuses) || odr_ok(o)) &&
1474 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
1477 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1479 odr_sequence_end(o);
1482 /* ------------------------ SEGMENT SERVICE -------------- */
1484 int z_Segment(ODR o, Z_Segment **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)->numberOfRecordsReturned,
1491 ODR_CONTEXT, 24, 0) &&
1492 odr_implicit_settag(o, ODR_CONTEXT, 0) &&
1493 odr_sequence_of(o, z_NamePlusRecord, &(*p)->segmentRecords,
1494 &(*p)->num_segmentRecords) &&
1495 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1496 odr_sequence_end(o);
1499 /* ------------------------ CLOSE SERVICE ---------------- */
1501 int z_Close(ODR o, Z_Close **p, int opt)
1503 if (!odr_sequence_begin(o, p, sizeof(**p)))
1504 return opt && odr_ok(o);
1506 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1507 odr_implicit(o, odr_integer, &(*p)->closeReason, ODR_CONTEXT, 211, 0) &&
1508 odr_implicit(o, odr_visiblestring, &(*p)->diagnosticInformation,
1509 ODR_CONTEXT, 3, 1) &&
1510 odr_implicit(o, odr_oid, &(*p)->resourceReportFormat, ODR_CONTEXT,
1512 odr_implicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1515 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1517 odr_sequence_end(o);
1520 /* ------------------------ APDU ------------------------- */
1522 int z_Permissions(ODR o, Z_Permissions **p, int opt)
1524 if (!odr_sequence_begin(o, p, sizeof(**p)))
1525 return opt && odr_ok(o);
1527 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT,
1529 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
1530 odr_sequence_of(o, odr_integer, &(*p)->allowableFunctions,
1531 &(*p)->num_allowableFunctions) &&
1532 odr_sequence_end(o);
1535 int z_ExtendedServicesRequest(ODR o, Z_ExtendedServicesRequest **p, int opt)
1537 if (!odr_sequence_begin(o, p, sizeof(**p)))
1538 return opt && odr_ok(o);
1540 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1541 odr_implicit(o, odr_integer, &(*p)->function, ODR_CONTEXT, 3, 0) &&
1542 odr_implicit(o, odr_oid, &(*p)->packageType, ODR_CONTEXT, 4, 0) &&
1543 odr_implicit(o, z_InternationalString, &(*p)->packageName, ODR_CONTEXT, 5, 1) &&
1544 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT, 6, 1) &&
1545 odr_implicit(o, z_IntUnit, &(*p)->retentionTime, ODR_CONTEXT, 7, 1) &&
1546 odr_implicit(o, z_Permissions, &(*p)->permissions, ODR_CONTEXT, 8, 1) &&
1547 odr_implicit(o, z_InternationalString, &(*p)->description, ODR_CONTEXT, 9, 1) &&
1548 odr_implicit(o, z_External, &(*p)->taskSpecificParameters, ODR_CONTEXT, 10, 1) &&
1549 odr_implicit(o, odr_integer, &(*p)->waitAction, ODR_CONTEXT, 11, 0) &&
1550 z_ElementSetName(o, &(*p)->elements, 1) &&
1551 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1552 odr_sequence_end(o);
1555 int z_ExtendedServicesResponse(ODR o, Z_ExtendedServicesResponse **p, int opt)
1557 if (!odr_sequence_begin(o, p, sizeof(**p)))
1558 return opt && odr_ok(o);
1560 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1561 odr_implicit(o, odr_integer, &(*p)->operationStatus, ODR_CONTEXT, 3, 0) &&
1562 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1563 (odr_sequence_of(o, z_DiagRec, &(*p)->diagnostics,
1564 &(*p)->num_diagnostics) || odr_ok(o)) &&
1565 odr_implicit(o, z_External, &(*p)->taskPackage, ODR_CONTEXT, 5, 1) &&
1566 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1567 odr_sequence_end(o);
1570 /* ------------------------ SORT ------------------------- */
1572 int z_SortAttributes(ODR o, Z_SortAttributes **p, int opt)
1574 if (!odr_sequence_begin(o, p, sizeof(**p)))
1575 return opt && odr_ok(o);
1577 odr_oid(o, &(*p)->id, 0) &&
1578 z_AttributeList(o, &(*p)->list, 0) &&
1579 odr_sequence_end(o);
1582 int z_SortKey(ODR o, Z_SortKey **p, int opt)
1584 static Odr_arm arm[] =
1586 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_SortKey_sortField,
1587 z_InternationalString},
1588 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortKey_elementSpec, z_Specification},
1589 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortKey_sortAttributes,
1594 if (!odr_initmember(o, p, sizeof(**p)))
1595 return opt && odr_ok(o);
1596 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1599 return opt && odr_ok(o);
1602 int z_SortDbSpecific(ODR o, Z_SortDbSpecific **p, int opt)
1604 if (!odr_sequence_begin(o, p, sizeof(**p)))
1605 return opt && odr_ok(o);
1607 z_DatabaseName(o, &(*p)->databaseName, 0) &&
1608 z_SortKey(o, &(*p)->dbSort, 0) &&
1609 odr_sequence_end(o);
1612 int z_SortDbSpecificList(ODR o, Z_SortDbSpecificList **p, int opt)
1614 if (!odr_initmember(o, p, sizeof(**p)))
1615 return opt && odr_ok(o);
1616 if (odr_sequence_of(o, z_SortDbSpecific, &(*p)->dbSpecific,
1617 &(*p)->num_dbSpecific))
1620 return opt && odr_ok(o);
1623 int z_SortElement(ODR o, Z_SortElement **p, int opt)
1625 static Odr_arm arm[] =
1627 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_SortElement_generic, z_SortKey},
1628 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortElement_databaseSpecific,
1629 z_SortDbSpecificList},
1633 if (!odr_initmember(o, p, sizeof(**p)))
1634 return opt && odr_ok(o);
1635 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1638 return opt && odr_ok(o);
1641 int z_SortMissingValueAction(ODR o, Z_SortMissingValueAction **p, int opt)
1643 static Odr_arm arm[] =
1645 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortMissingValAct_abort, odr_null},
1646 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortMissingValAct_null, odr_null},
1647 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_SortMissingValAct_valData,
1652 if (!odr_initmember(o, p, sizeof(**p)))
1653 return opt && odr_ok(o);
1654 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1657 return opt && odr_ok(o);
1660 int z_SortKeySpec(ODR o, Z_SortKeySpec **p, int opt)
1662 if (!odr_sequence_begin(o, p, sizeof(**p)))
1663 return opt && odr_ok(o);
1665 z_SortElement(o, &(*p)->sortElement, 0) &&
1666 odr_implicit(o, odr_integer, &(*p)->sortRelation, ODR_CONTEXT, 1, 0) &&
1667 odr_implicit(o, odr_integer, &(*p)->caseSensitivity, ODR_CONTEXT,
1669 odr_explicit(o, z_SortMissingValueAction, &(*p)->missingValueAction,
1670 ODR_CONTEXT, 3, 1) &&
1671 odr_sequence_end(o);
1674 int z_SortResponse(ODR o, Z_SortResponse **p, int opt)
1676 if (!odr_sequence_begin(o, p, sizeof(**p)))
1677 return opt && odr_ok(o);
1679 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1680 odr_implicit(o, odr_integer, &(*p)->sortStatus, ODR_CONTEXT,
1682 odr_implicit(o, odr_integer, &(*p)->resultSetStatus, ODR_CONTEXT,
1684 odr_implicit(o, z_DiagRecs, &(*p)->diagnostics, ODR_CONTEXT, 5, 1) &&
1685 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1686 odr_sequence_end(o);
1689 int z_SortKeySpecList(ODR o, Z_SortKeySpecList **p, int opt)
1691 if (!odr_initmember(o, p, sizeof(**p)))
1692 return opt && odr_ok(o);
1693 if (odr_sequence_of(o, z_SortKeySpec, &(*p)->specs, &(*p)->num_specs))
1696 return opt && odr_ok(o);
1699 int z_SortRequest(ODR o, Z_SortRequest **p, int opt)
1701 if (!odr_sequence_begin(o, p, sizeof(**p)))
1702 return opt && odr_ok(o);
1704 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1705 odr_implicit(o, z_StringList, &(*p)->inputResultSetNames,
1706 ODR_CONTEXT, 3, 0) &&
1707 odr_implicit(o, z_InternationalString, &(*p)->sortedResultSetName,
1708 ODR_CONTEXT, 4, 0) &&
1709 odr_implicit(o, z_SortKeySpecList, &(*p)->sortSequence, ODR_CONTEXT,
1711 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1712 odr_sequence_end(o);
1715 /* ------------------------ APDU ------------------------- */
1717 int z_APDU(ODR o, Z_APDU **p, int opt)
1719 static Odr_arm arm[] =
1721 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
1722 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
1723 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
1724 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
1726 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
1728 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
1730 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
1731 z_DeleteResultSetRequest},
1732 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
1733 z_DeleteResultSetResponse},
1734 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_APDU_accessControlRequest,
1735 z_AccessControlRequest},
1736 {ODR_IMPLICIT, ODR_CONTEXT, 29, Z_APDU_accessControlResponse,
1737 z_AccessControlResponse},
1738 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
1739 z_ResourceControlRequest},
1740 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
1741 z_ResourceControlResponse},
1742 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
1743 z_TriggerResourceControlRequest},
1744 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
1745 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
1746 {ODR_IMPLICIT, ODR_CONTEXT, 43, Z_APDU_sortRequest, z_SortRequest},
1747 {ODR_IMPLICIT, ODR_CONTEXT, 44, Z_APDU_sortResponse, z_SortResponse},
1748 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_APDU_segmentRequest, z_Segment},
1749 {ODR_IMPLICIT, ODR_CONTEXT, 46, Z_APDU_extendedServicesRequest,
1750 z_ExtendedServicesRequest},
1751 {ODR_IMPLICIT, ODR_CONTEXT, 47, Z_APDU_extendedServicesResponse,
1752 z_ExtendedServicesResponse},
1753 {ODR_IMPLICIT, ODR_CONTEXT, 48, Z_APDU_close, z_Close},
1758 if (o->direction == ODR_DECODE)
1759 *p = odr_malloc(o, sizeof(**p));
1760 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
1762 if (o->direction == ODR_DECODE)
1764 return opt && odr_ok(o);