2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.49 1996-07-06 19:58:28 quinn
8 * System headerfiles gathered in yconfig
10 * Revision 1.48 1996/06/10 08:53:33 quinn
11 * Added Summary,OPAC,ResourceReport
13 * Revision 1.47 1996/05/29 15:47:50 quinn
14 * Fixed in bug DiagRecs decoder. Thanks to Linda Harris.
16 * Revision 1.46 1996/04/10 11:39:42 quinn
17 * Fixed bug in UserInfo
19 * Revision 1.45 1996/02/23 10:00:25 quinn
22 * Revision 1.44 1996/02/20 12:51:41 quinn
23 * Completed SCAN. Fixed problems with EXTERNAL.
25 * Revision 1.43 1996/02/10 12:22:49 quinn
28 * Revision 1.42 1996/01/22 09:46:31 quinn
29 * Added Sort PDU. Moved StringList to main protocol file.
31 * Revision 1.41 1996/01/10 15:21:24 quinn
32 * Added links to access control PDUs
34 * Revision 1.40 1996/01/02 11:46:40 quinn
35 * Changed 'operator' to 'roperator' to avoid C++ conflict.
37 * Revision 1.39 1995/09/29 17:11:53 quinn
40 * Revision 1.38 1995/09/27 15:02:40 quinn
41 * Modified function heads & prototypes.
43 * Revision 1.37 1995/08/21 09:10:15 quinn
44 * Smallish fixes to suppport new formats.
46 * Revision 1.36 1995/08/15 11:59:39 quinn
49 * Revision 1.35 1995/08/10 08:53:59 quinn
52 * Revision 1.34 1995/06/19 17:01:48 quinn
53 * This should bring us in sync with the version distributed as 1.0b
55 * Revision 1.33 1995/06/19 13:39:56 quinn
56 * *** empty log message ***
58 * Revision 1.32 1995/06/19 12:37:28 quinn
59 * Fixed a bug in the compspec.
61 * Revision 1.31 1995/06/16 13:15:56 quinn
62 * Fixed Defaultdiagformat.
64 * Revision 1.30 1995/06/15 15:42:01 quinn
67 * Revision 1.29 1995/06/15 07:44:49 quinn
70 * Revision 1.28 1995/06/14 15:26:35 quinn
71 * *** empty log message ***
73 * Revision 1.27 1995/06/07 14:36:22 quinn
76 * Revision 1.26 1995/06/02 09:49:13 quinn
77 * Adding access control
79 * Revision 1.25 1995/05/25 11:00:08 quinn
80 * *** empty log message ***
82 * Revision 1.24 1995/05/22 13:58:18 quinn
83 * Fixed an ODR_NULLVAL.
85 * Revision 1.23 1995/05/22 11:30:18 quinn
86 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
88 * Revision 1.22 1995/05/17 08:40:56 quinn
89 * Added delete. Fixed some sequence_begins. Smallish.
91 * Revision 1.21 1995/05/16 08:50:24 quinn
92 * License, documentation, and memory fixes
94 * Revision 1.20 1995/05/15 11:55:25 quinn
97 * Revision 1.19 1995/04/11 11:58:35 quinn
100 * Revision 1.18 1995/04/11 11:52:02 quinn
101 * Fixed possible buf in proto.c
103 * Revision 1.17 1995/04/10 10:22:22 quinn
106 * Revision 1.16 1995/03/30 10:26:43 quinn
107 * Added Term structure
109 * Revision 1.15 1995/03/30 09:08:39 quinn
110 * Added Resource control protocol
112 * Revision 1.14 1995/03/29 08:06:13 quinn
113 * Added a few v3 elements
115 * Revision 1.13 1995/03/20 11:26:52 quinn
116 * *** empty log message ***
118 * Revision 1.12 1995/03/20 09:45:09 quinn
121 * Revision 1.11 1995/03/17 10:17:25 quinn
122 * Added memory management.
124 * Revision 1.10 1995/03/15 11:17:40 quinn
125 * Fixed some return-checks from choice.. need better ay to handle those..
127 * Revision 1.9 1995/03/15 08:37:06 quinn
128 * Fixed protocol bugs.
130 * Revision 1.8 1995/03/14 16:59:24 quinn
131 * Fixed OPTIONAL flag in attributeelement
133 * Revision 1.7 1995/03/07 16:29:33 quinn
134 * Added authentication stuff.
136 * Revision 1.6 1995/03/01 14:46:03 quinn
137 * Fixed protocol bug in 8777query.
139 * Revision 1.5 1995/02/14 11:54:22 quinn
142 * Revision 1.4 1995/02/10 15:54:30 quinn
145 * Revision 1.3 1995/02/09 15:51:39 quinn
148 * Revision 1.2 1995/02/06 21:26:07 quinn
149 * Repaired this evening's damages..
151 * Revision 1.1 1995/02/06 16:44:47 quinn
152 * First hack at Z/SR protocol
160 /* ---------------------- GLOBAL DEFS ------------------- */
163 * We'll use a general octetstring here, since string operations are
164 * clumsy on long strings.
166 int z_SUTRS(ODR o, Odr_oct **p, int opt)
168 return odr_implicit(o, odr_octetstring, p, ODR_UNIVERSAL,
169 ODR_GENERALSTRING, opt);
172 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
174 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
177 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
179 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
183 int z_ResultSetId(ODR o, char **p, int opt)
185 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
189 int z_ElementSetName(ODR o, char **p, int opt)
191 return odr_implicit(o, odr_visiblestring, p, ODR_CONTEXT, 103, opt);
194 int z_UserInformationField(ODR o, Z_External **p, int opt)
196 return odr_explicit(o, z_External, (Z_External **)p, ODR_CONTEXT,
200 int z_InternationalString(ODR o, char **p, int opt)
202 return odr_generalstring(o, p, opt);
205 int z_InfoCategory(ODR o, Z_InfoCategory **p, int opt)
207 if (!odr_sequence_begin(o, p, sizeof(**p)))
208 return opt && odr_ok(o);
210 odr_implicit(o, odr_oid, &(*p)->categoryTypeId, ODR_CONTEXT, 1, 1) &&
211 odr_implicit(o, odr_integer, &(*p)->categoryValue, ODR_CONTEXT, 2, 0) &&
215 int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt)
217 static Odr_arm arm[] =
219 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_OtherInfo_characterInfo,
221 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_OtherInfo_binaryInfo,
223 {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_OtherInfo_externallyDefinedInfo,
225 {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_OtherInfo_oid, odr_oid},
229 if (!odr_sequence_begin(o, p, sizeof(**p)))
230 return opt && odr_ok(o);
232 odr_implicit(o, z_InfoCategory, &(*p)->category, ODR_CONTEXT, 1, 1) &&
233 odr_choice(o, arm, &(*p)->information, &(*p)->which) &&
237 int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt)
239 if (o->direction == ODR_DECODE)
240 *p = odr_malloc(o, sizeof(**p));
243 odr_implicit_settag(o, ODR_CONTEXT, 201);
244 if (odr_sequence_of(o, z_OtherInformationUnit, &(*p)->list,
245 &(*p)->num_elements))
248 return opt && odr_ok(o);
251 int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt)
253 static Odr_arm arm[] =
255 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_StringOrNumeric_string,
257 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_StringOrNumeric_numeric,
262 if (o->direction == ODR_DECODE)
263 *p = odr_malloc(o, sizeof(**p));
266 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
269 return opt && odr_ok(o);
275 int z_Unit(ODR o, Z_Unit **p, int opt)
277 if (!odr_sequence_begin(o, p, sizeof(**p)))
278 return opt && odr_ok(o);
280 odr_explicit(o, odr_visiblestring, &(*p)->unitSystem, ODR_CONTEXT,
282 odr_explicit(o, z_StringOrNumeric, &(*p)->unitType, ODR_CONTEXT,
284 odr_explicit(o, z_StringOrNumeric, &(*p)->unit, ODR_CONTEXT, 3, 1) &&
285 odr_implicit(o, odr_integer, &(*p)->scaleFactor, ODR_CONTEXT, 4, 1) &&
289 int z_IntUnit(ODR o, Z_IntUnit **p, int opt)
291 if (!odr_sequence_begin(o, p, sizeof(**p)))
292 return opt && odr_ok(o);
294 odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 1, 0) &&
295 odr_implicit(o, z_Unit, &(*p)->unitUsed, ODR_CONTEXT, 2, 0) &&
299 int z_StringList(ODR o, Z_StringList **p, int opt)
301 if (o->direction == ODR_DECODE)
302 *p = odr_malloc(o, sizeof(**p));
305 if (odr_sequence_of(o, z_InternationalString, &(*p)->strings,
309 return opt && odr_ok(o);
312 /* ---------------------- INITIALIZE SERVICE ------------------- */
315 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
317 if (!odr_sequence_begin(o, p, sizeof(**p)))
318 return opt && odr_ok(o);
320 odr_visiblestring(o, &(*p)->user, 0) &&
321 odr_visiblestring(o, &(*p)->password, 0) &&
322 odr_visiblestring(o, &(*p)->account, 0) &&
327 int z_IdPass(ODR o, Z_IdPass **p, int opt)
329 if (!odr_sequence_begin(o, p, sizeof(**p)))
330 return opt && odr_ok(o);
332 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 1) &&
333 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 1) &&
334 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
339 int z_StrAuthentication(ODR o, char **p, int opt)
341 return odr_visiblestring(o, p, opt);
344 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
346 static Odr_arm arm[] =
348 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
349 {-1, -1, -1, Z_IdAuthentication_idPass, z_IdPass},
350 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
351 {-1, -1, -1, Z_IdAuthentication_other, z_External},
355 if (o->direction == ODR_DECODE)
356 *p = odr_malloc(o, sizeof(**p));
360 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
363 return opt && odr_ok(o);
366 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
370 if (!odr_sequence_begin(o, p, sizeof(**p)))
371 return opt && odr_ok(o);
374 z_ReferenceId(o, &pp->referenceId, 1) &&
375 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
377 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
378 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
380 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
382 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
384 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
386 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
388 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
389 ODR_CONTEXT, 112, 1) &&
390 z_UserInformationField(o, &pp->userInformationField, 1) &&
392 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
397 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
401 if (!odr_sequence_begin(o, p, sizeof(**p)))
402 return opt && odr_ok(o);
405 z_ReferenceId(o, &pp->referenceId, 1) &&
406 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
408 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
409 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
411 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
413 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
414 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
416 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
418 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
419 ODR_CONTEXT, 112, 1) &&
420 z_UserInformationField(o, &pp->userInformationField, 1) &&
422 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
427 /* ------------------ RESOURCE CONTROL ----------------*/
429 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
432 if (!odr_sequence_begin(o, p, sizeof(**p)))
433 return opt && odr_ok(o);
435 z_ReferenceId(o, &(*p)->referenceId, 1) &&
436 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
438 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
439 ODR_CONTEXT, 47, 1) &&
440 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
443 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
448 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
450 if (!odr_sequence_begin(o, p, sizeof(**p)))
451 return opt && odr_ok(o);
453 z_ReferenceId(o, &(*p)->referenceId, 1) &&
454 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
455 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
457 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
458 ODR_CONTEXT, 41, 1) &&
459 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
461 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
462 ODR_CONTEXT, 43, 1) &&
464 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
469 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
471 if (!odr_sequence_begin(o, p, sizeof(**p)))
472 return opt && odr_ok(o);
474 z_ReferenceId(o, &(*p)->referenceId, 1) &&
475 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
476 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
479 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
484 /* ------------------------ SEARCH SERVICE ----------------------- */
486 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
488 if (!odr_sequence_begin(o, p, sizeof(**p)))
489 return opt && odr_ok(o);
491 z_DatabaseName(o, &(*p)->databaseName, 0) &&
492 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
496 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
498 if (o->direction == ODR_DECODE)
499 *p = odr_malloc(o, sizeof(**p));
503 odr_implicit_settag(o, ODR_CONTEXT, 1);
504 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
505 &(*p)->num_elements))
511 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
513 static Odr_arm arm[] =
515 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
517 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
522 if (o->direction == ODR_DECODE)
523 *p = odr_malloc(o, sizeof(**p));
525 return opt && odr_ok(o);
527 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
533 /* ----------------------- RPN QUERY -----------------------*/
535 int z_ComplexAttribute(ODR o, Z_ComplexAttribute **p, int opt)
537 if (!odr_sequence_begin(o, p, sizeof(**p)))
538 return opt && odr_ok(o);
540 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
541 odr_sequence_of(o, z_StringOrNumeric, &(*p)->list,
543 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
544 (odr_sequence_of(o, odr_integer, &(*p)->semanticAction,
545 &(*p)->num_semanticAction) || odr_ok(o)) &&
549 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
552 static Odr_arm arm[] =
554 {ODR_IMPLICIT, ODR_CONTEXT, 121, Z_AttributeValue_numeric,
556 {ODR_IMPLICIT, ODR_CONTEXT, 224, Z_AttributeValue_complex,
562 if (!odr_sequence_begin(o, p, sizeof(**p)))
563 return opt && odr_ok(o);
566 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 1, 1) &&
568 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
571 odr_choice(o, arm, &(*p)->value, &(*p)->which) &&
573 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
579 int z_Term(ODR o, Z_Term **p, int opt)
581 static Odr_arm arm[] =
583 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
584 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
585 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
587 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
588 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
589 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, z_External},
590 /* add intUnit here */
591 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
595 if (o->direction ==ODR_DECODE)
596 *p = odr_malloc(o, sizeof(**p));
599 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
602 return opt && odr_ok(o);
605 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
607 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
608 odr_sequence_begin(o, p, sizeof(**p))))
609 return opt && odr_ok(o);
611 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
612 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
613 &(*p)->num_attributes) &&
614 z_Term(o, &(*p)->term, 0) &&
618 int z_ResultSetPlusAttributes(ODR o, Z_ResultSetPlusAttributes **p, int opt)
620 if (!(odr_implicit_settag(o, ODR_CONTEXT, 214) &&
621 odr_sequence_begin(o, p, sizeof(**p))))
622 return opt && odr_ok(o);
624 z_ResultSetId(o, &(*p)->resultSet, 0) &&
625 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
626 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
627 &(*p)->num_attributes) &&
631 int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
633 static Odr_arm arm[] =
635 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, odr_integer},
636 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_private, odr_integer},
640 if (!odr_sequence_begin(o, p, sizeof(**p)))
641 return opt && odr_ok(o);
643 odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
644 odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
645 odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
646 odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
647 odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
648 odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
649 odr_constructed_end(o) &&
653 int z_Operator(ODR o, Z_Operator **p, int opt)
655 static Odr_arm arm[] =
657 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
658 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
659 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
660 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, z_ProximityOperator},
664 if (!*p && o->direction != ODR_DECODE)
666 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
667 return opt && odr_ok(o);
668 if (o->direction == ODR_DECODE)
669 *p = odr_malloc(o, sizeof(**p));
671 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
672 odr_constructed_end(o))
675 return opt && odr_ok(o);
678 int z_Operand(ODR o, Z_Operand **p, int opt)
680 static Odr_arm arm[] =
682 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
683 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
684 {-1, -1, -1, Z_Operand_resultAttr, z_ResultSetPlusAttributes},
688 if (o->direction == ODR_DECODE)
689 *p = odr_malloc(o, sizeof(**p));
692 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
695 return opt && odr_ok(o);
698 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
700 int z_Complex(ODR o, Z_Complex **p, int opt)
702 if (!odr_sequence_begin(o, p, sizeof(**p)))
703 return opt && odr_ok(o);
705 z_RPNStructure(o, &(*p)->s1, 0) &&
706 z_RPNStructure(o, &(*p)->s2, 0) &&
707 z_Operator(o, &(*p)->roperator, 0) &&
711 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
713 static Odr_arm arm[] =
715 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
716 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
720 if (o->direction == ODR_DECODE)
721 *p = odr_malloc(o, sizeof(**p));
724 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
727 return opt && odr_ok(o);
730 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
732 if (!odr_sequence_begin(o, p, sizeof(**p)))
733 return opt && odr_ok(o);
735 odr_oid(o, &(*p)->attributeSetId, 0) &&
736 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
740 /* -----------------------END RPN QUERY ----------------------- */
742 int z_Query(ODR o, Z_Query **p, int opt)
744 static Odr_arm arm[] =
746 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
747 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
748 {ODR_EXPLICIT, ODR_CONTEXT, 101, Z_Query_type_101, z_RPNQuery},
752 if (o->direction == ODR_DECODE)
753 *p = odr_malloc(o, sizeof(**p));
756 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
759 return opt && odr_ok(o);
762 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
766 if (!odr_sequence_begin(o, p, sizeof(**p)))
767 return opt && odr_ok(o);
770 z_ReferenceId(o, &pp->referenceId, 1) &&
771 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
773 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
775 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
777 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
778 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
780 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
781 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
782 &pp->num_databaseNames) &&
783 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
784 ODR_CONTEXT, 100, 1) &&
785 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
786 ODR_CONTEXT, 101, 1) &&
787 odr_implicit(o, odr_oid, &pp->preferredRecordSyntax,
788 ODR_CONTEXT, 104, 1) &&
789 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
791 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
792 ODR_CONTEXT, 203, 1) &&
793 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
798 /* ------------------------ RECORD ------------------------- */
800 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
802 return z_External(o, (Z_External **) p, opt);
807 int z_DefaultDiagFormat(ODR o, Z_DefaultDiagFormat **p, int opt)
809 static Odr_arm arm[] =
811 {-1, -1, -1, Z_DiagForm_v2AddInfo, odr_visiblestring},
812 {-1, -1, -1, Z_DiagForm_v3AddInfo, z_InternationalString},
813 {ODR_IMPLICIT, ODR_CONTEXT, ODR_VISIBLESTRING, Z_DiagForm_v2AddInfo,
814 odr_visiblestring}, /* To cater to a bug in the CNIDR servers */
817 if (!odr_sequence_begin(o, p, sizeof(**p)))
818 return opt && odr_ok(o);
820 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
821 odr_integer(o, &(*p)->condition, 0) &&
823 * I no longer recall what server tagged the addinfo.. but it isn't
824 * hurting anyone, so...
825 * We need to turn it into a choice, or something, because of
826 * that damn generalstring in v3.
828 odr_choice(o, arm, &(*p)->addinfo, &(*p)->which) &&
832 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
834 static Odr_arm arm[] =
836 {-1, -1, -1, Z_DiagRec_defaultFormat, z_DefaultDiagFormat},
837 {-1, -1, -1, Z_DiagRec_externallyDefined, z_External},
841 if (o->direction == ODR_DECODE)
842 *p = odr_malloc(o, sizeof(**p));
845 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
848 return opt && odr_ok(o);
853 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
855 if (!odr_sequence_begin(o, p, sizeof(**p)))
856 return opt && odr_ok(o);
858 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
859 odr_integer(o, &(*p)->condition, 0) &&
861 * I no longer recall what server tagged the addinfo.. but it isn't
862 * hurting anyone, so...
863 * We need to turn it into a choice, or something, because of
864 * that damn generalstring in v3.
866 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
867 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT,
868 ODR_VISIBLESTRING, 1)) &&
874 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
876 if (o->direction == ODR_DECODE)
877 *p = odr_malloc(o, sizeof(**p));
881 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
882 &(*p)->num_diagRecs))
885 return opt && odr_ok(o);
888 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
890 static Odr_arm arm[] =
892 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
894 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
899 if (!odr_sequence_begin(o, p, sizeof(**p)))
900 return opt && odr_ok(o);
902 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
904 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
905 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
906 odr_constructed_end(o) &&
910 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
912 if (o->direction == ODR_DECODE)
913 *p = odr_malloc(o, sizeof(**p));
916 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
923 int z_Records(ODR o, Z_Records **p, int opt)
925 static Odr_arm arm[] =
927 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
928 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
929 {ODR_IMPLICIT, ODR_CONTEXT, 205, Z_Records_multipleNSD,
934 if (o->direction == ODR_DECODE)
935 *p = odr_malloc(o, sizeof(**p));
938 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
941 return opt && odr_ok(o);
944 /* ------------------------ ACCESS CTRL SERVICE ----------------------- */
946 int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
948 static Odr_arm arm[] =
950 {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
952 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
956 if (!odr_sequence_begin(o, p, sizeof(**p)))
957 return opt && odr_ok(o);
959 z_ReferenceId(o, &(*p)->referenceId, 1) &&
960 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
962 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
967 int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
969 static Odr_arm arm[] =
971 {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
973 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
977 if (!odr_sequence_begin(o, p, sizeof(**p)))
978 return opt && odr_ok(o);
980 z_ReferenceId(o, &(*p)->referenceId, 1) &&
981 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
982 odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
984 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
989 /* ------------------------ SCAN SERVICE -------------------- */
991 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
993 if (o->direction == ODR_DECODE)
994 *p = odr_malloc(o, sizeof(**p));
998 odr_implicit_settag(o, ODR_CONTEXT, 44);
999 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
1000 &(*p)->num_attributes))
1003 return opt && odr_ok(o);
1007 * This is a temporary hack. We don't know just *what* old version of the
1008 * protocol willow uses, so we'll just patiently wait for them to update
1010 static int willow_scan = 0;
1012 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
1014 if (!*p && o->direction != ODR_DECODE)
1016 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
1019 return opt && odr_ok(o);
1021 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
1023 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
1025 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
1027 if (o->direction == ODR_DECODE)
1028 *p = odr_malloc(o, sizeof(**p));
1029 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
1030 &(*p)->num_attributes))
1032 if (!odr_sequence_end(o) || !odr_sequence_end(o))
1034 if (!z_Term(o, &(*p)->term, 0))
1036 if (!odr_constructed_end(o))
1042 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
1044 if (o->direction == ODR_DECODE)
1045 *p = odr_malloc(o, sizeof(**p));
1049 return opt && odr_ok(o);
1052 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
1056 return opt && !o->error;
1061 int z_ByDatabase(ODR o, Z_ByDatabase **p, int opt)
1063 if (!odr_sequence_begin(o, p, sizeof(**p)))
1064 return opt && odr_ok(o);
1066 z_DatabaseName(o, &(*p)->db, 1) &&
1067 odr_implicit(o, odr_integer, &(*p)->num, ODR_CONTEXT, 1, 1) &&
1068 z_OtherInformation(o, &(*p)->otherDbInfo, 1) &&
1069 odr_sequence_end(o);
1072 int z_ByDatabaseList(ODR o, Z_ByDatabaseList **p, int opt)
1074 if (!odr_initmember(o, p, sizeof(**p)))
1075 return opt && odr_ok(o);
1076 if (odr_sequence_of(o, z_ByDatabase, &(*p)->elements, &(*p)->num_elements))
1079 return opt && odr_ok(o);
1082 int z_ScanOccurrences(ODR o, Z_ScanOccurrences **p, int opt)
1086 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_ScanOccurrences_global, odr_integer},
1087 {ODR_EXPLICIT, ODR_CONTEXT, 3, Z_ScanOccurrences_byDatabase,
1092 if (!odr_initmember(o, p, sizeof(**p)))
1093 return opt && odr_ok(o);
1094 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1097 return opt && odr_ok(o);
1100 int z_OccurrenceByAttributesElem(ODR o, Z_OccurrenceByAttributesElem **p,
1103 if (!odr_sequence_begin(o, p, sizeof(**p)))
1104 return opt && odr_ok(o);
1106 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT,
1108 z_ScanOccurrences(o, &(*p)->occurrences, 1) &&
1109 z_OtherInformation(o, &(*p)->otherOccurInfo, 1) &&
1110 odr_sequence_end(o);
1113 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1115 if (!odr_initmember(o, p, sizeof(**p)))
1116 return opt && odr_ok(o);
1117 if (!odr_sequence_of(o, z_OccurrenceByAttributesElem, &(*p)->elements,
1118 &(*p)->num_elements))
1121 return opt && odr_ok(o);
1127 * Incomplete definition of occurencebyattributes.
1130 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1132 if (!odr_sequence_begin(o, p, sizeof(**p)))
1133 return opt && odr_ok(o);
1135 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
1136 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
1137 odr_sequence_end(o);
1142 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
1144 if (!odr_sequence_begin(o, p, sizeof(**p)))
1145 return opt && odr_ok(o);
1148 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
1149 z_Term(o, &(*p)->term, 0)) &&
1150 odr_implicit(o, z_InternationalString, &(*p)->displayTerm, ODR_CONTEXT,
1152 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
1153 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
1154 ODR_CONTEXT, 4, 1) &&
1155 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
1157 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
1158 ODR_CONTEXT, 3, 1) &&
1159 z_OtherInformation(o, &(*p)->otherTermInfo, 1) &&
1160 odr_sequence_end(o);
1163 int z_Entry(ODR o, Z_Entry **p, int opt)
1165 static Odr_arm arm[] =
1167 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
1168 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
1173 if (o->direction == ODR_DECODE)
1174 *p = odr_malloc(o, sizeof(**p));
1178 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1181 return opt && odr_ok(o);
1184 int z_Entries(ODR o, Z_Entries **p, int opt)
1186 if (o->direction == ODR_DECODE)
1187 *p = odr_malloc(o, sizeof(**p));
1191 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
1192 &(*p)->num_entries))
1198 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
1200 static Odr_arm arm[] =
1202 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
1203 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
1208 if (o->direction == ODR_DECODE)
1209 *p = odr_malloc(o, sizeof(**p));
1213 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1216 return opt && odr_ok(o);
1219 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
1221 if (!odr_sequence_begin(o, p, sizeof(**p)))
1222 return opt && odr_ok(o);
1225 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1226 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1227 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
1228 &(*p)->num_databaseNames) &&
1229 odr_oid(o, &(*p)->attributeSet, 1) &&
1230 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
1231 ((*p)->termListAndStartPoint ? 1 :
1232 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
1233 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
1234 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
1235 ODR_CONTEXT, 6, 0) &&
1236 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
1237 ODR_CONTEXT, 7, 1) &&
1238 odr_sequence_end(o);
1241 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
1243 if (!odr_sequence_begin(o, p, sizeof(**p)))
1244 return opt && odr_ok(o);
1246 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1247 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
1248 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
1249 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
1250 ODR_CONTEXT, 5, 0) &&
1251 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
1252 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
1253 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
1254 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1255 odr_sequence_end(o);
1258 /* ------------------------ SEARCHRESPONSE ----------------*/
1260 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
1262 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
1265 int z_NextResultSetPosition(ODR o, int **p, int opt)
1267 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
1270 int z_PresentStatus(ODR o, int **p, int opt)
1272 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
1275 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
1277 Z_SearchResponse *pp;
1279 if (!odr_sequence_begin(o, p, sizeof(**p)))
1280 return opt && odr_ok(o);
1283 z_ReferenceId(o, &pp->referenceId, 1) &&
1284 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
1285 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1286 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1287 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
1288 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26,
1290 z_PresentStatus(o, &pp->presentStatus, 1) &&
1291 z_Records(o, &pp->records, 1) &&
1293 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
1294 ODR_CONTEXT, 203, 1) &&
1295 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1297 odr_sequence_end(o);
1300 /* --------------------- PRESENT SERVICE ---------------------- */
1302 int z_ElementSpec(ODR o, Z_ElementSpec **p, int opt)
1304 static Odr_arm arm[] =
1306 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSpec_elementSetName,
1308 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ElementSpec_externalSpec,
1313 if (o->direction == ODR_DECODE)
1314 *p = odr_malloc(o, sizeof(**p));
1318 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1321 return opt && odr_ok(o);
1324 int z_Specification(ODR o, Z_Specification **p, int opt)
1326 if (!odr_sequence_begin(o, p, sizeof(**p)))
1327 return opt && odr_ok(o);
1329 odr_implicit(o, odr_oid, &(*p)->schema, ODR_CONTEXT, 1, 1) &&
1330 z_ElementSpec(o, &(*p)->elementSpec, 1) &&
1331 odr_sequence_end(o);
1334 int z_DbSpecific(ODR o, Z_DbSpecific **p, int opt)
1336 if (!odr_sequence_begin(o, p, sizeof(**p)))
1337 return opt && odr_ok(o);
1339 odr_explicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
1341 odr_implicit(o, z_Specification, &(*p)->spec, ODR_CONTEXT, 2, 0) &&
1342 odr_sequence_end(o);
1345 int z_CompSpec(ODR o, Z_CompSpec **p, int opt)
1347 if (!odr_sequence_begin(o, p, sizeof(**p)))
1348 return opt && odr_ok(o);
1350 odr_implicit(o, odr_bool, &(*p)->selectAlternativeSyntax, ODR_CONTEXT,
1352 odr_implicit(o, z_Specification, &(*p)->generic, ODR_CONTEXT, 2, 1) &&
1353 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1354 (odr_sequence_of(o, z_DbSpecific, &(*p)->dbSpecific,
1355 &(*p)->num_dbSpecific) || odr_ok(o)) &&
1356 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1357 (odr_sequence_of(o, odr_oid, &(*p)->recordSyntax,
1358 &(*p)->num_recordSyntax) || odr_ok(o)) &&
1359 odr_sequence_end(o);
1362 int z_RecordComposition(ODR o, Z_RecordComposition **p, int opt)
1364 static Odr_arm arm[] =
1366 {ODR_EXPLICIT, ODR_CONTEXT, 19, Z_RecordComp_simple,
1368 {ODR_IMPLICIT, ODR_CONTEXT, 209, Z_RecordComp_complex,
1373 if (o->direction == ODR_DECODE)
1374 *p = odr_malloc(o, sizeof(**p));
1378 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1381 return opt && odr_ok(o);
1384 int z_Range(ODR o, Z_Range **p, int opt)
1386 if (!odr_sequence_begin(o, p, sizeof(**p)))
1387 return opt && odr_ok(o);
1389 odr_implicit(o, odr_integer, &(*p)->startingPosition, ODR_CONTEXT,
1391 odr_implicit(o, odr_integer, &(*p)->numberOfRecords, ODR_CONTEXT,
1393 odr_sequence_end(o);
1396 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
1398 Z_PresentRequest *pp;
1400 if (!odr_sequence_begin(o, p, sizeof(**p)))
1401 return opt && odr_ok(o);
1404 z_ReferenceId(o, &pp->referenceId, 1) &&
1405 z_ResultSetId(o, &pp->resultSetId, 0) &&
1406 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
1408 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
1411 odr_implicit_settag(o, ODR_CONTEXT, 212) &&
1412 (odr_sequence_of(o, z_Range, &(*p)->additionalRanges,
1413 &(*p)->num_ranges) || odr_ok(o)) &&
1414 z_RecordComposition(o, &(*p)->recordComposition, 1) &&
1416 odr_explicit(o, z_ElementSetNames, &pp->elementSetNames, ODR_CONTEXT,
1419 odr_implicit(o, odr_oid, &(*p)->preferredRecordSyntax, ODR_CONTEXT,
1422 odr_implicit(o, odr_integer, &(*p)->maxSegmentCount, ODR_CONTEXT,
1424 odr_implicit(o, odr_integer, &(*p)->maxRecordSize, ODR_CONTEXT,
1426 odr_implicit(o, odr_integer, &(*p)->maxSegmentSize, ODR_CONTEXT,
1428 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1430 odr_sequence_end(o);
1433 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
1435 Z_PresentResponse *pp;
1437 if (!odr_sequence_begin(o, p, sizeof(**p)))
1438 return opt && odr_ok(o);
1441 z_ReferenceId(o, &pp->referenceId, 1) &&
1442 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1443 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1444 z_PresentStatus(o, &pp->presentStatus, 0) &&
1445 z_Records(o, &pp->records, 1) &&
1447 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1449 odr_sequence_end(o);
1452 /* ----------------------DELETE -------------------------- */
1454 int z_DeleteSetStatus(ODR o, int **p, int opt)
1456 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
1459 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
1461 if (!odr_sequence_begin(o, p, sizeof(**p)))
1462 return opt && odr_ok(o);
1464 z_ResultSetId(o, &(*p)->id, 0) &&
1465 z_DeleteSetStatus(o, &(*p)->status, 0) &&
1466 odr_sequence_end(o);
1469 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
1471 if (!odr_sequence_begin(o, p, sizeof(**p)))
1472 return opt && odr_ok(o);
1474 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1475 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
1477 (odr_sequence_of(o, z_ListStatus, &(*p)->resultSetList,
1478 &(*p)->num_ids) || odr_ok(o)) &&
1480 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1482 odr_sequence_end(o);
1485 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
1487 if (!odr_sequence_begin(o, p, sizeof(**p)))
1488 return opt && odr_ok(o);
1490 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1491 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
1492 ODR_CONTEXT, 0, 1) &&
1493 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
1494 (odr_sequence_of(o, z_ListStatus, &(*p)->deleteListStatuses,
1495 &(*p)->num_statuses) || odr_ok(o)) &&
1496 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
1498 odr_implicit_settag(o, ODR_CONTEXT, 35) &&
1499 (odr_sequence_of(o, z_ListStatus, &(*p)->bulkStatuses,
1500 &(*p)->num_bulkStatuses) || odr_ok(o)) &&
1501 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
1504 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1506 odr_sequence_end(o);
1509 /* ------------------------ SEGMENT SERVICE -------------- */
1511 int z_Segment(ODR o, Z_Segment **p, int opt)
1513 if (!odr_sequence_begin(o, p, sizeof(**p)))
1514 return opt && odr_ok(o);
1516 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1517 odr_implicit(o, odr_integer, &(*p)->numberOfRecordsReturned,
1518 ODR_CONTEXT, 24, 0) &&
1519 odr_implicit_settag(o, ODR_CONTEXT, 0) &&
1520 odr_sequence_of(o, z_NamePlusRecord, &(*p)->segmentRecords,
1521 &(*p)->num_segmentRecords) &&
1522 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1523 odr_sequence_end(o);
1526 /* ------------------------ CLOSE SERVICE ---------------- */
1528 int z_Close(ODR o, Z_Close **p, int opt)
1530 if (!odr_sequence_begin(o, p, sizeof(**p)))
1531 return opt && odr_ok(o);
1533 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1534 odr_implicit(o, odr_integer, &(*p)->closeReason, ODR_CONTEXT, 211, 0) &&
1535 odr_implicit(o, odr_visiblestring, &(*p)->diagnosticInformation,
1536 ODR_CONTEXT, 3, 1) &&
1537 odr_implicit(o, odr_oid, &(*p)->resourceReportFormat, ODR_CONTEXT,
1539 odr_implicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1542 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1544 odr_sequence_end(o);
1547 /* ------------------------ APDU ------------------------- */
1549 int z_Permissions(ODR o, Z_Permissions **p, int opt)
1551 if (!odr_sequence_begin(o, p, sizeof(**p)))
1552 return opt && odr_ok(o);
1554 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT,
1556 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
1557 odr_sequence_of(o, odr_integer, &(*p)->allowableFunctions,
1558 &(*p)->num_allowableFunctions) &&
1559 odr_sequence_end(o);
1562 int z_ExtendedServicesRequest(ODR o, Z_ExtendedServicesRequest **p, int opt)
1564 if (!odr_sequence_begin(o, p, sizeof(**p)))
1565 return opt && odr_ok(o);
1567 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1568 odr_implicit(o, odr_integer, &(*p)->function, ODR_CONTEXT, 3, 0) &&
1569 odr_implicit(o, odr_oid, &(*p)->packageType, ODR_CONTEXT, 4, 0) &&
1570 odr_implicit(o, z_InternationalString, &(*p)->packageName, ODR_CONTEXT, 5, 1) &&
1571 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT, 6, 1) &&
1572 odr_implicit(o, z_IntUnit, &(*p)->retentionTime, ODR_CONTEXT, 7, 1) &&
1573 odr_implicit(o, z_Permissions, &(*p)->permissions, ODR_CONTEXT, 8, 1) &&
1574 odr_implicit(o, z_InternationalString, &(*p)->description, ODR_CONTEXT, 9, 1) &&
1575 odr_implicit(o, z_External, &(*p)->taskSpecificParameters, ODR_CONTEXT, 10, 1) &&
1576 odr_implicit(o, odr_integer, &(*p)->waitAction, ODR_CONTEXT, 11, 0) &&
1577 z_ElementSetName(o, &(*p)->elements, 1) &&
1578 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1579 odr_sequence_end(o);
1582 int z_ExtendedServicesResponse(ODR o, Z_ExtendedServicesResponse **p, int opt)
1584 if (!odr_sequence_begin(o, p, sizeof(**p)))
1585 return opt && odr_ok(o);
1587 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1588 odr_implicit(o, odr_integer, &(*p)->operationStatus, ODR_CONTEXT, 3, 0) &&
1589 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1590 (odr_sequence_of(o, z_DiagRec, &(*p)->diagnostics,
1591 &(*p)->num_diagnostics) || odr_ok(o)) &&
1592 odr_implicit(o, z_External, &(*p)->taskPackage, ODR_CONTEXT, 5, 1) &&
1593 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1594 odr_sequence_end(o);
1597 /* ------------------------ SORT ------------------------- */
1599 int z_SortAttributes(ODR o, Z_SortAttributes **p, int opt)
1601 if (!odr_sequence_begin(o, p, sizeof(**p)))
1602 return opt && odr_ok(o);
1604 odr_oid(o, &(*p)->id, 0) &&
1605 z_AttributeList(o, &(*p)->list, 0) &&
1606 odr_sequence_end(o);
1609 int z_SortKey(ODR o, Z_SortKey **p, int opt)
1611 static Odr_arm arm[] =
1613 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_SortKey_sortField,
1614 z_InternationalString},
1615 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortKey_elementSpec, z_Specification},
1616 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortKey_sortAttributes,
1621 if (!odr_initmember(o, p, sizeof(**p)))
1622 return opt && odr_ok(o);
1623 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1626 return opt && odr_ok(o);
1629 int z_SortDbSpecific(ODR o, Z_SortDbSpecific **p, int opt)
1631 if (!odr_sequence_begin(o, p, sizeof(**p)))
1632 return opt && odr_ok(o);
1634 z_DatabaseName(o, &(*p)->databaseName, 0) &&
1635 z_SortKey(o, &(*p)->dbSort, 0) &&
1636 odr_sequence_end(o);
1639 int z_SortDbSpecificList(ODR o, Z_SortDbSpecificList **p, int opt)
1641 if (!odr_initmember(o, p, sizeof(**p)))
1642 return opt && odr_ok(o);
1643 if (odr_sequence_of(o, z_SortDbSpecific, &(*p)->dbSpecific,
1644 &(*p)->num_dbSpecific))
1647 return opt && odr_ok(o);
1650 int z_SortElement(ODR o, Z_SortElement **p, int opt)
1652 static Odr_arm arm[] =
1654 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_SortElement_generic, z_SortKey},
1655 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortElement_databaseSpecific,
1656 z_SortDbSpecificList},
1660 if (!odr_initmember(o, p, sizeof(**p)))
1661 return opt && odr_ok(o);
1662 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1665 return opt && odr_ok(o);
1668 int z_SortMissingValueAction(ODR o, Z_SortMissingValueAction **p, int opt)
1670 static Odr_arm arm[] =
1672 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortMissingValAct_abort, odr_null},
1673 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortMissingValAct_null, odr_null},
1674 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_SortMissingValAct_valData,
1679 if (!odr_initmember(o, p, sizeof(**p)))
1680 return opt && odr_ok(o);
1681 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1684 return opt && odr_ok(o);
1687 int z_SortKeySpec(ODR o, Z_SortKeySpec **p, int opt)
1689 if (!odr_sequence_begin(o, p, sizeof(**p)))
1690 return opt && odr_ok(o);
1692 z_SortElement(o, &(*p)->sortElement, 0) &&
1693 odr_implicit(o, odr_integer, &(*p)->sortRelation, ODR_CONTEXT, 1, 0) &&
1694 odr_implicit(o, odr_integer, &(*p)->caseSensitivity, ODR_CONTEXT,
1696 odr_explicit(o, z_SortMissingValueAction, &(*p)->missingValueAction,
1697 ODR_CONTEXT, 3, 1) &&
1698 odr_sequence_end(o);
1701 int z_SortResponse(ODR o, Z_SortResponse **p, int opt)
1703 if (!odr_sequence_begin(o, p, sizeof(**p)))
1704 return opt && odr_ok(o);
1706 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1707 odr_implicit(o, odr_integer, &(*p)->sortStatus, ODR_CONTEXT,
1709 odr_implicit(o, odr_integer, &(*p)->resultSetStatus, ODR_CONTEXT,
1711 odr_implicit(o, z_DiagRecs, &(*p)->diagnostics, ODR_CONTEXT, 5, 1) &&
1712 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1713 odr_sequence_end(o);
1716 int z_SortKeySpecList(ODR o, Z_SortKeySpecList **p, int opt)
1718 if (!odr_initmember(o, p, sizeof(**p)))
1719 return opt && odr_ok(o);
1720 if (odr_sequence_of(o, z_SortKeySpec, &(*p)->specs, &(*p)->num_specs))
1723 return opt && odr_ok(o);
1726 int z_SortRequest(ODR o, Z_SortRequest **p, int opt)
1728 if (!odr_sequence_begin(o, p, sizeof(**p)))
1729 return opt && odr_ok(o);
1731 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1732 odr_implicit(o, z_StringList, &(*p)->inputResultSetNames,
1733 ODR_CONTEXT, 3, 0) &&
1734 odr_implicit(o, z_InternationalString, &(*p)->sortedResultSetName,
1735 ODR_CONTEXT, 4, 0) &&
1736 odr_implicit(o, z_SortKeySpecList, &(*p)->sortSequence, ODR_CONTEXT,
1738 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1739 odr_sequence_end(o);
1742 /* ---------------------- Resource Report ---------------- */
1744 int z_ResourceReportRequest(ODR o, Z_ResourceReportRequest **p, int opt)
1746 if (!odr_sequence_begin(o, p, sizeof(**p)))
1747 return opt && odr_ok(o);
1749 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1750 odr_implicit(o, z_ReferenceId, &(*p)->opId, ODR_CONTEXT, 210, 1) &&
1751 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat, ODR_CONTEXT,
1753 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1754 odr_sequence_end(o);
1757 int z_ResourceReportResponse(ODR o, Z_ResourceReportResponse **p, int opt)
1759 if (!odr_sequence_begin(o, p, sizeof(**p)))
1760 return opt && odr_ok(o);
1762 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1763 odr_implicit(o, odr_integer, &(*p)->resourceReportStatus,
1764 ODR_CONTEXT, 50, 0) &&
1765 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1767 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1768 odr_sequence_end(o);
1771 /* ------------------------ APDU ------------------------- */
1773 int z_APDU(ODR o, Z_APDU **p, int opt)
1775 static Odr_arm arm[] =
1777 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
1778 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
1779 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
1780 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
1782 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
1784 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
1786 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
1787 z_DeleteResultSetRequest},
1788 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
1789 z_DeleteResultSetResponse},
1790 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_APDU_accessControlRequest,
1791 z_AccessControlRequest},
1792 {ODR_IMPLICIT, ODR_CONTEXT, 29, Z_APDU_accessControlResponse,
1793 z_AccessControlResponse},
1794 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
1795 z_ResourceControlRequest},
1796 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
1797 z_ResourceControlResponse},
1798 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
1799 z_TriggerResourceControlRequest},
1800 {ODR_IMPLICIT, ODR_CONTEXT, 33, Z_APDU_resourceReportRequest,
1801 z_ResourceReportRequest},
1802 {ODR_IMPLICIT, ODR_CONTEXT, 34, Z_APDU_resourceReportResponse,
1803 z_ResourceReportResponse},
1804 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
1805 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
1806 {ODR_IMPLICIT, ODR_CONTEXT, 43, Z_APDU_sortRequest, z_SortRequest},
1807 {ODR_IMPLICIT, ODR_CONTEXT, 44, Z_APDU_sortResponse, z_SortResponse},
1808 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_APDU_segmentRequest, z_Segment},
1809 {ODR_IMPLICIT, ODR_CONTEXT, 46, Z_APDU_extendedServicesRequest,
1810 z_ExtendedServicesRequest},
1811 {ODR_IMPLICIT, ODR_CONTEXT, 47, Z_APDU_extendedServicesResponse,
1812 z_ExtendedServicesResponse},
1813 {ODR_IMPLICIT, ODR_CONTEXT, 48, Z_APDU_close, z_Close},
1818 if (o->direction == ODR_DECODE)
1819 *p = odr_malloc(o, sizeof(**p));
1820 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
1822 if (o->direction == ODR_DECODE)
1824 return opt && odr_ok(o);