2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.55 1998-02-11 11:53:32 adam
8 * Changed code so that it compiles as C++.
10 * Revision 1.54 1996/11/11 13:14:46 adam
11 * Fixed tagging bug in z_ProximityOperator.
13 * Revision 1.53 1996/10/09 15:54:55 quinn
14 * Added SearchInfoReport
16 * Revision 1.52 1996/10/08 12:56:57 adam
17 * Bug fix: tagging of type 101 query.
19 * Revision 1.51 1996/07/26 14:07:21 quinn
22 * Revision 1.50 1996/07/26 13:36:15 quinn
25 * Revision 1.49 1996/07/06 19:58:28 quinn
26 * System headerfiles gathered in yconfig
28 * Revision 1.48 1996/06/10 08:53:33 quinn
29 * Added Summary,OPAC,ResourceReport
31 * Revision 1.47 1996/05/29 15:47:50 quinn
32 * Fixed in bug DiagRecs decoder. Thanks to Linda Harris.
34 * Revision 1.46 1996/04/10 11:39:42 quinn
35 * Fixed bug in UserInfo
37 * Revision 1.45 1996/02/23 10:00:25 quinn
40 * Revision 1.44 1996/02/20 12:51:41 quinn
41 * Completed SCAN. Fixed problems with EXTERNAL.
43 * Revision 1.43 1996/02/10 12:22:49 quinn
46 * Revision 1.42 1996/01/22 09:46:31 quinn
47 * Added Sort PDU. Moved StringList to main protocol file.
49 * Revision 1.41 1996/01/10 15:21:24 quinn
50 * Added links to access control PDUs
52 * Revision 1.40 1996/01/02 11:46:40 quinn
53 * Changed 'operator' to 'roperator' to avoid C++ conflict.
55 * Revision 1.39 1995/09/29 17:11:53 quinn
58 * Revision 1.38 1995/09/27 15:02:40 quinn
59 * Modified function heads & prototypes.
61 * Revision 1.37 1995/08/21 09:10:15 quinn
62 * Smallish fixes to suppport new formats.
64 * Revision 1.36 1995/08/15 11:59:39 quinn
67 * Revision 1.35 1995/08/10 08:53:59 quinn
70 * Revision 1.34 1995/06/19 17:01:48 quinn
71 * This should bring us in sync with the version distributed as 1.0b
73 * Revision 1.33 1995/06/19 13:39:56 quinn
74 * *** empty log message ***
76 * Revision 1.32 1995/06/19 12:37:28 quinn
77 * Fixed a bug in the compspec.
79 * Revision 1.31 1995/06/16 13:15:56 quinn
80 * Fixed Defaultdiagformat.
82 * Revision 1.30 1995/06/15 15:42:01 quinn
85 * Revision 1.29 1995/06/15 07:44:49 quinn
88 * Revision 1.28 1995/06/14 15:26:35 quinn
89 * *** empty log message ***
91 * Revision 1.27 1995/06/07 14:36:22 quinn
94 * Revision 1.26 1995/06/02 09:49:13 quinn
95 * Adding access control
97 * Revision 1.25 1995/05/25 11:00:08 quinn
98 * *** empty log message ***
100 * Revision 1.24 1995/05/22 13:58:18 quinn
101 * Fixed an ODR_NULLVAL.
103 * Revision 1.23 1995/05/22 11:30:18 quinn
104 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
106 * Revision 1.22 1995/05/17 08:40:56 quinn
107 * Added delete. Fixed some sequence_begins. Smallish.
109 * Revision 1.21 1995/05/16 08:50:24 quinn
110 * License, documentation, and memory fixes
112 * Revision 1.20 1995/05/15 11:55:25 quinn
115 * Revision 1.19 1995/04/11 11:58:35 quinn
118 * Revision 1.18 1995/04/11 11:52:02 quinn
119 * Fixed possible buf in proto.c
121 * Revision 1.17 1995/04/10 10:22:22 quinn
124 * Revision 1.16 1995/03/30 10:26:43 quinn
125 * Added Term structure
127 * Revision 1.15 1995/03/30 09:08:39 quinn
128 * Added Resource control protocol
130 * Revision 1.14 1995/03/29 08:06:13 quinn
131 * Added a few v3 elements
133 * Revision 1.13 1995/03/20 11:26:52 quinn
134 * *** empty log message ***
136 * Revision 1.12 1995/03/20 09:45:09 quinn
139 * Revision 1.11 1995/03/17 10:17:25 quinn
140 * Added memory management.
142 * Revision 1.10 1995/03/15 11:17:40 quinn
143 * Fixed some return-checks from choice.. need better ay to handle those..
145 * Revision 1.9 1995/03/15 08:37:06 quinn
146 * Fixed protocol bugs.
148 * Revision 1.8 1995/03/14 16:59:24 quinn
149 * Fixed OPTIONAL flag in attributeelement
151 * Revision 1.7 1995/03/07 16:29:33 quinn
152 * Added authentication stuff.
154 * Revision 1.6 1995/03/01 14:46:03 quinn
155 * Fixed protocol bug in 8777query.
157 * Revision 1.5 1995/02/14 11:54:22 quinn
160 * Revision 1.4 1995/02/10 15:54:30 quinn
163 * Revision 1.3 1995/02/09 15:51:39 quinn
166 * Revision 1.2 1995/02/06 21:26:07 quinn
167 * Repaired this evening's damages..
169 * Revision 1.1 1995/02/06 16:44:47 quinn
170 * First hack at Z/SR protocol
178 /* ---------------------- GLOBAL DEFS ------------------- */
181 * We'll use a general octetstring here, since string operations are
182 * clumsy on long strings.
184 int z_SUTRS(ODR o, Odr_oct **p, int opt)
186 return odr_implicit(o, odr_octetstring, p, ODR_UNIVERSAL,
187 ODR_GENERALSTRING, opt);
190 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
192 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
195 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
197 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
201 int z_ResultSetId(ODR o, char **p, int opt)
203 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
207 int z_ElementSetName(ODR o, char **p, int opt)
209 return odr_implicit(o, odr_visiblestring, p, ODR_CONTEXT, 103, opt);
212 int z_UserInformationField(ODR o, Z_External **p, int opt)
214 return odr_explicit(o, z_External, (Z_External **)p, ODR_CONTEXT,
218 int z_InternationalString(ODR o, char **p, int opt)
220 return odr_generalstring(o, p, opt);
223 int z_InfoCategory(ODR o, Z_InfoCategory **p, int opt)
225 if (!odr_sequence_begin(o, p, sizeof(**p)))
226 return opt && odr_ok(o);
228 odr_implicit(o, odr_oid, &(*p)->categoryTypeId, ODR_CONTEXT, 1, 1) &&
229 odr_implicit(o, odr_integer, &(*p)->categoryValue, ODR_CONTEXT, 2, 0) &&
233 int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt)
235 static Odr_arm arm[] =
237 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_OtherInfo_characterInfo,
239 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_OtherInfo_binaryInfo,
240 (Odr_fun)odr_octetstring},
241 {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_OtherInfo_externallyDefinedInfo,
242 (Odr_fun)z_External},
243 {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_OtherInfo_oid, (Odr_fun)odr_oid},
247 if (!odr_sequence_begin(o, p, sizeof(**p)))
248 return opt && odr_ok(o);
250 odr_implicit(o, z_InfoCategory, &(*p)->category, ODR_CONTEXT, 1, 1) &&
251 odr_choice(o, arm, &(*p)->information, &(*p)->which) &&
255 int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt)
257 if (o->direction == ODR_DECODE)
258 *p = (Z_OtherInformation *)odr_malloc(o, sizeof(**p));
261 odr_implicit_settag(o, ODR_CONTEXT, 201);
262 if (odr_sequence_of(o, (Odr_fun)z_OtherInformationUnit, &(*p)->list,
263 &(*p)->num_elements))
266 return opt && odr_ok(o);
269 int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt)
271 static Odr_arm arm[] =
273 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_StringOrNumeric_string,
275 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_StringOrNumeric_numeric,
276 (Odr_fun)odr_integer},
280 if (o->direction == ODR_DECODE)
281 *p = (Z_StringOrNumeric *)odr_malloc(o, sizeof(**p));
284 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
287 return opt && odr_ok(o);
293 int z_Unit(ODR o, Z_Unit **p, int opt)
295 if (!odr_sequence_begin(o, p, sizeof(**p)))
296 return opt && odr_ok(o);
298 odr_explicit(o, z_InternationalString, &(*p)->unitSystem, ODR_CONTEXT,
300 odr_explicit(o, z_StringOrNumeric, &(*p)->unitType, ODR_CONTEXT,
302 odr_explicit(o, z_StringOrNumeric, &(*p)->unit, ODR_CONTEXT, 3, 1) &&
303 odr_implicit(o, odr_integer, &(*p)->scaleFactor, ODR_CONTEXT, 4, 1) &&
307 int z_IntUnit(ODR o, Z_IntUnit **p, int opt)
309 if (!odr_sequence_begin(o, p, sizeof(**p)))
310 return opt && odr_ok(o);
312 odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 1, 0) &&
313 odr_implicit(o, z_Unit, &(*p)->unitUsed, ODR_CONTEXT, 2, 0) &&
317 int z_StringList(ODR o, Z_StringList **p, int opt)
319 if (o->direction == ODR_DECODE)
320 *p = (Z_StringList *)odr_malloc(o, sizeof(**p));
323 if (odr_sequence_of(o, (Odr_fun)z_InternationalString, &(*p)->strings,
327 return opt && odr_ok(o);
330 /* ---------------------- INITIALIZE SERVICE ------------------- */
333 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
335 if (!odr_sequence_begin(o, p, sizeof(**p)))
336 return opt && odr_ok(o);
338 odr_visiblestring(o, &(*p)->user, 0) &&
339 odr_visiblestring(o, &(*p)->password, 0) &&
340 odr_visiblestring(o, &(*p)->account, 0) &&
345 int z_IdPass(ODR o, Z_IdPass **p, int opt)
347 if (!odr_sequence_begin(o, p, sizeof(**p)))
348 return opt && odr_ok(o);
350 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 1) &&
351 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 1) &&
352 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
357 int z_StrAuthentication(ODR o, char **p, int opt)
359 return odr_visiblestring(o, p, opt);
362 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
364 static Odr_arm arm[] =
366 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
367 {-1, -1, -1, Z_IdAuthentication_idPass, (Odr_fun)z_IdPass},
368 {-1, -1, -1, Z_IdAuthentication_anonymous, (Odr_fun)odr_null},
369 {-1, -1, -1, Z_IdAuthentication_other, (Odr_fun)z_External},
373 if (o->direction == ODR_DECODE)
374 *p = (Z_IdAuthentication *)odr_malloc(o, sizeof(**p));
378 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
381 return opt && odr_ok(o);
384 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
388 if (!odr_sequence_begin(o, p, sizeof(**p)))
389 return opt && odr_ok(o);
392 z_ReferenceId(o, &pp->referenceId, 1) &&
393 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
395 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
396 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
398 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
400 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
402 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
404 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
406 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
407 ODR_CONTEXT, 112, 1) &&
408 z_UserInformationField(o, &pp->userInformationField, 1) &&
410 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
415 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
419 if (!odr_sequence_begin(o, p, sizeof(**p)))
420 return opt && odr_ok(o);
423 z_ReferenceId(o, &pp->referenceId, 1) &&
424 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
426 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
427 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
429 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
431 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
432 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
434 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
436 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
437 ODR_CONTEXT, 112, 1) &&
438 z_UserInformationField(o, &pp->userInformationField, 1) &&
440 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
445 /* ------------------ RESOURCE CONTROL ----------------*/
447 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
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_integer, &(*p)->requestedAction, ODR_CONTEXT,
456 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
457 ODR_CONTEXT, 47, 1) &&
458 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
461 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
466 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
468 if (!odr_sequence_begin(o, p, sizeof(**p)))
469 return opt && odr_ok(o);
471 z_ReferenceId(o, &(*p)->referenceId, 1) &&
472 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
473 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
475 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
476 ODR_CONTEXT, 41, 1) &&
477 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
479 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
480 ODR_CONTEXT, 43, 1) &&
482 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
487 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
489 if (!odr_sequence_begin(o, p, sizeof(**p)))
490 return opt && odr_ok(o);
492 z_ReferenceId(o, &(*p)->referenceId, 1) &&
493 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
494 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
497 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
502 /* ------------------------ SEARCH SERVICE ----------------------- */
504 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
506 if (!odr_sequence_begin(o, p, sizeof(**p)))
507 return opt && odr_ok(o);
509 z_DatabaseName(o, &(*p)->databaseName, 0) &&
510 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
514 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
516 if (o->direction == ODR_DECODE)
517 *p = (Z_DatabaseSpecific *)odr_malloc(o, sizeof(**p));
521 odr_implicit_settag(o, ODR_CONTEXT, 1);
522 if (odr_sequence_of(o, (Odr_fun)z_DatabaseSpecificUnit, &(*p)->elements,
523 &(*p)->num_elements))
529 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
531 static Odr_arm arm[] =
533 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
535 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
536 (Odr_fun)z_DatabaseSpecific},
540 if (o->direction == ODR_DECODE)
541 *p = (Z_ElementSetNames *)odr_malloc(o, sizeof(**p));
543 return opt && odr_ok(o);
545 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
551 /* ----------------------- RPN QUERY -----------------------*/
553 int z_ComplexAttribute(ODR o, Z_ComplexAttribute **p, int opt)
555 if (!odr_sequence_begin(o, p, sizeof(**p)))
556 return opt && odr_ok(o);
558 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
559 odr_sequence_of(o, (Odr_fun)z_StringOrNumeric, &(*p)->list,
561 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
562 (odr_sequence_of(o, (Odr_fun)odr_integer, &(*p)->semanticAction,
563 &(*p)->num_semanticAction) || odr_ok(o)) &&
567 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
570 static Odr_arm arm[] =
572 {ODR_IMPLICIT, ODR_CONTEXT, 121, Z_AttributeValue_numeric,
573 (Odr_fun)odr_integer},
574 {ODR_IMPLICIT, ODR_CONTEXT, 224, Z_AttributeValue_complex,
575 (Odr_fun)z_ComplexAttribute},
580 if (!odr_sequence_begin(o, p, sizeof(**p)))
581 return opt && odr_ok(o);
584 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 1, 1) &&
586 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
589 odr_choice(o, arm, &(*p)->value, &(*p)->which) &&
591 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
597 int z_Term(ODR o, Z_Term **p, int opt)
599 static Odr_arm arm[] =
601 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, (Odr_fun)odr_octetstring},
602 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, (Odr_fun)odr_integer},
603 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
605 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, (Odr_fun)odr_oid},
606 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
607 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, (Odr_fun)z_External},
608 /* add intUnit here */
609 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, (Odr_fun)odr_null},
613 if (o->direction ==ODR_DECODE)
614 *p = (Z_Term *)odr_malloc(o, sizeof(**p));
617 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
620 return opt && odr_ok(o);
623 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
625 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
626 odr_sequence_begin(o, p, sizeof(**p))))
627 return opt && odr_ok(o);
629 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
630 odr_sequence_of(o, (Odr_fun)z_AttributeElement, &(*p)->attributeList,
631 &(*p)->num_attributes) &&
632 z_Term(o, &(*p)->term, 0) &&
636 int z_ResultSetPlusAttributes(ODR o, Z_ResultSetPlusAttributes **p, int opt)
638 if (!(odr_implicit_settag(o, ODR_CONTEXT, 214) &&
639 odr_sequence_begin(o, p, sizeof(**p))))
640 return opt && odr_ok(o);
642 z_ResultSetId(o, &(*p)->resultSet, 0) &&
643 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
644 odr_sequence_of(o, (Odr_fun)z_AttributeElement, &(*p)->attributeList,
645 &(*p)->num_attributes) &&
649 int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
651 static Odr_arm arm[] =
653 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, (Odr_fun)odr_integer},
654 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ProxCode_private, (Odr_fun)odr_integer},
658 if (!odr_sequence_begin(o, p, sizeof(**p)))
659 return opt && odr_ok(o);
661 odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
662 odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
663 odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
664 odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
665 odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
666 odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
667 odr_constructed_end(o) &&
671 int z_Operator(ODR o, Z_Operator **p, int opt)
673 static Odr_arm arm[] =
675 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, (Odr_fun)odr_null},
676 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, (Odr_fun)odr_null},
677 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, (Odr_fun)odr_null},
678 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, (Odr_fun)z_ProximityOperator},
682 if (!*p && o->direction != ODR_DECODE)
684 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
685 return opt && odr_ok(o);
686 if (o->direction == ODR_DECODE)
687 *p = (Z_Operator *)odr_malloc(o, sizeof(**p));
689 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
690 odr_constructed_end(o))
693 return opt && odr_ok(o);
696 int z_Operand(ODR o, Z_Operand **p, int opt)
698 static Odr_arm arm[] =
700 {-1, -1, -1, Z_Operand_APT, (Odr_fun)z_AttributesPlusTerm},
701 {-1, -1, -1, Z_Operand_resultSetId, (Odr_fun)z_ResultSetId},
702 {-1, -1, -1, Z_Operand_resultAttr, (Odr_fun)z_ResultSetPlusAttributes},
706 if (o->direction == ODR_DECODE)
707 *p = (Z_Operand *)odr_malloc(o, sizeof(**p));
710 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
713 return opt && odr_ok(o);
716 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
718 int z_Complex(ODR o, Z_Complex **p, int opt)
720 if (!odr_sequence_begin(o, p, sizeof(**p)))
721 return opt && odr_ok(o);
723 z_RPNStructure(o, &(*p)->s1, 0) &&
724 z_RPNStructure(o, &(*p)->s2, 0) &&
725 z_Operator(o, &(*p)->roperator, 0) &&
729 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
731 static Odr_arm arm[] =
733 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, (Odr_fun)z_Operand},
734 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, (Odr_fun)z_Complex},
738 if (o->direction == ODR_DECODE)
739 *p = (Z_RPNStructure *)odr_malloc(o, sizeof(**p));
742 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
745 return opt && odr_ok(o);
748 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
750 if (!odr_sequence_begin(o, p, sizeof(**p)))
751 return opt && odr_ok(o);
753 odr_oid(o, &(*p)->attributeSetId, 0) &&
754 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
758 /* -----------------------END RPN QUERY ----------------------- */
760 int z_Query(ODR o, Z_Query **p, int opt)
762 static Odr_arm arm[] =
764 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, (Odr_fun)z_RPNQuery},
765 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, (Odr_fun)odr_octetstring},
766 {ODR_IMPLICIT, ODR_CONTEXT, 101, Z_Query_type_101, (Odr_fun)z_RPNQuery},
770 if (o->direction == ODR_DECODE)
771 *p = (Z_Query *)odr_malloc(o, sizeof(**p));
774 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
777 return opt && odr_ok(o);
780 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
784 if (!odr_sequence_begin(o, p, sizeof(**p)))
785 return opt && odr_ok(o);
788 z_ReferenceId(o, &pp->referenceId, 1) &&
789 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
791 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
793 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
795 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
796 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
798 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
799 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
800 &pp->num_databaseNames) &&
801 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
802 ODR_CONTEXT, 100, 1) &&
803 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
804 ODR_CONTEXT, 101, 1) &&
805 odr_implicit(o, odr_oid, &pp->preferredRecordSyntax,
806 ODR_CONTEXT, 104, 1) &&
807 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
809 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
810 ODR_CONTEXT, 203, 1) &&
811 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
816 /* ------------------------ RECORD ------------------------- */
818 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
820 return z_External(o, (Z_External **) p, opt);
825 int z_DefaultDiagFormat(ODR o, Z_DefaultDiagFormat **p, int opt)
827 static Odr_arm arm[] =
829 {-1, -1, -1, Z_DiagForm_v2AddInfo, odr_visiblestring},
830 {-1, -1, -1, Z_DiagForm_v3AddInfo, z_InternationalString},
831 {ODR_IMPLICIT, ODR_CONTEXT, ODR_VISIBLESTRING, Z_DiagForm_v2AddInfo,
832 odr_visiblestring}, /* To cater to a bug in the CNIDR servers */
835 if (!odr_sequence_begin(o, p, sizeof(**p)))
836 return opt && odr_ok(o);
838 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
839 odr_integer(o, &(*p)->condition, 0) &&
841 * I no longer recall what server tagged the addinfo.. but it isn't
842 * hurting anyone, so...
843 * We need to turn it into a choice, or something, because of
844 * that damn generalstring in v3.
846 odr_choice(o, arm, &(*p)->addinfo, &(*p)->which) &&
850 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
852 static Odr_arm arm[] =
854 {-1, -1, -1, Z_DiagRec_defaultFormat, (Odr_fun)z_DefaultDiagFormat},
855 {-1, -1, -1, Z_DiagRec_externallyDefined, (Odr_fun)z_External},
859 if (o->direction == ODR_DECODE)
860 *p = (Z_DiagRec *)odr_malloc(o, sizeof(**p));
863 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
866 return opt && odr_ok(o);
871 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
873 if (!odr_sequence_begin(o, p, sizeof(**p)))
874 return opt && odr_ok(o);
876 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
877 odr_integer(o, &(*p)->condition, 0) &&
879 * I no longer recall what server tagged the addinfo.. but it isn't
880 * hurting anyone, so...
881 * We need to turn it into a choice, or something, because of
882 * that damn generalstring in v3.
884 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
885 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT,
886 ODR_VISIBLESTRING, 1)) &&
892 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
894 if (o->direction == ODR_DECODE)
895 *p = (Z_DiagRecs *)odr_malloc(o, sizeof(**p));
899 if (odr_sequence_of(o, (Odr_fun)z_DiagRec, &(*p)->diagRecs,
900 &(*p)->num_diagRecs))
903 return opt && odr_ok(o);
906 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
908 static Odr_arm arm[] =
910 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
911 (Odr_fun)z_DatabaseRecord},
912 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
917 if (!odr_sequence_begin(o, p, sizeof(**p)))
918 return opt && odr_ok(o);
920 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
922 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
923 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
924 odr_constructed_end(o) &&
928 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
930 if (o->direction == ODR_DECODE)
931 *p = (Z_NamePlusRecordList *)odr_malloc(o, sizeof(**p));
934 if (odr_sequence_of(o, (Odr_fun)z_NamePlusRecord, &(*p)->records,
941 int z_Records(ODR o, Z_Records **p, int opt)
943 static Odr_arm arm[] =
945 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, (Odr_fun)z_NamePlusRecordList},
946 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, (Odr_fun)z_DiagRec},
947 {ODR_IMPLICIT, ODR_CONTEXT, 205, Z_Records_multipleNSD,
948 (Odr_fun)z_DiagRecs},
952 if (o->direction == ODR_DECODE)
953 *p = (Z_Records *)odr_malloc(o, sizeof(**p));
956 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
959 return opt && odr_ok(o);
962 /* ------------------------ ACCESS CTRL SERVICE ----------------------- */
964 int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
966 static Odr_arm arm[] =
968 {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
969 (Odr_fun)odr_octetstring},
970 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
971 (Odr_fun)z_External},
974 if (!odr_sequence_begin(o, p, sizeof(**p)))
975 return opt && odr_ok(o);
977 z_ReferenceId(o, &(*p)->referenceId, 1) &&
978 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
980 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
985 int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
987 static Odr_arm arm[] =
989 {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
990 (Odr_fun)odr_octetstring},
991 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
992 (Odr_fun)z_External},
995 if (!odr_sequence_begin(o, p, sizeof(**p)))
996 return opt && odr_ok(o);
998 z_ReferenceId(o, &(*p)->referenceId, 1) &&
999 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
1000 odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
1002 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1004 odr_sequence_end(o);
1007 /* ------------------------ SCAN SERVICE -------------------- */
1009 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
1011 if (o->direction == ODR_DECODE)
1012 *p = (Z_AttributeList *)odr_malloc(o, sizeof(**p));
1016 odr_implicit_settag(o, ODR_CONTEXT, 44);
1017 if (odr_sequence_of(o, (Odr_fun)z_AttributeElement, &(*p)->attributes,
1018 &(*p)->num_attributes))
1021 return opt && odr_ok(o);
1025 * This is a temporary hack. We don't know just *what* old version of the
1026 * protocol willow uses, so we'll just patiently wait for them to update
1028 static int willow_scan = 0;
1030 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
1032 if (!*p && o->direction != ODR_DECODE)
1034 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
1037 return opt && odr_ok(o);
1039 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
1041 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
1043 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
1045 if (o->direction == ODR_DECODE)
1046 *p = (Z_AttributesPlusTerm*)odr_malloc(o, sizeof(**p));
1047 if (!odr_sequence_of(o, (Odr_fun)z_AttributeElement, &(*p)->attributeList,
1048 &(*p)->num_attributes))
1050 if (!odr_sequence_end(o) || !odr_sequence_end(o))
1052 if (!z_Term(o, &(*p)->term, 0))
1054 if (!odr_constructed_end(o))
1060 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
1062 if (o->direction == ODR_DECODE)
1063 *p = (Z_AlternativeTerm *)odr_malloc(o, sizeof(**p));
1067 return opt && odr_ok(o);
1070 if (odr_sequence_of(o, (Odr_fun)z_AttributesPlusTerm, &(*p)->terms,
1074 return opt && !o->error;
1079 int z_ByDatabase(ODR o, Z_ByDatabase **p, int opt)
1081 if (!odr_sequence_begin(o, p, sizeof(**p)))
1082 return opt && odr_ok(o);
1084 z_DatabaseName(o, &(*p)->db, 1) &&
1085 odr_implicit(o, odr_integer, &(*p)->num, ODR_CONTEXT, 1, 1) &&
1086 z_OtherInformation(o, &(*p)->otherDbInfo, 1) &&
1087 odr_sequence_end(o);
1090 int z_ByDatabaseList(ODR o, Z_ByDatabaseList **p, int opt)
1092 if (!odr_initmember(o, p, sizeof(**p)))
1093 return opt && odr_ok(o);
1094 if (odr_sequence_of(o, (Odr_fun)z_ByDatabase, &(*p)->elements, &(*p)->num_elements))
1097 return opt && odr_ok(o);
1100 int z_ScanOccurrences(ODR o, Z_ScanOccurrences **p, int opt)
1104 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_ScanOccurrences_global, (Odr_fun)odr_integer},
1105 {ODR_EXPLICIT, ODR_CONTEXT, 3, Z_ScanOccurrences_byDatabase,
1106 (Odr_fun)z_ByDatabaseList},
1110 if (!odr_initmember(o, p, sizeof(**p)))
1111 return opt && odr_ok(o);
1112 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1115 return opt && odr_ok(o);
1118 int z_OccurrenceByAttributesElem(ODR o, Z_OccurrenceByAttributesElem **p,
1121 if (!odr_sequence_begin(o, p, sizeof(**p)))
1122 return opt && odr_ok(o);
1124 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT,
1126 z_ScanOccurrences(o, &(*p)->occurrences, 1) &&
1127 z_OtherInformation(o, &(*p)->otherOccurInfo, 1) &&
1128 odr_sequence_end(o);
1131 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1133 if (!odr_initmember(o, p, sizeof(**p)))
1134 return opt && odr_ok(o);
1135 if (!odr_sequence_of(o, (Odr_fun)z_OccurrenceByAttributesElem, &(*p)->elements,
1136 &(*p)->num_elements))
1139 return opt && odr_ok(o);
1145 * Incomplete definition of occurencebyattributes.
1148 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1150 if (!odr_sequence_begin(o, p, sizeof(**p)))
1151 return opt && odr_ok(o);
1153 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
1154 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
1155 odr_sequence_end(o);
1160 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
1162 if (!odr_sequence_begin(o, p, sizeof(**p)))
1163 return opt && odr_ok(o);
1166 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
1167 z_Term(o, &(*p)->term, 0)) &&
1168 odr_implicit(o, z_InternationalString, &(*p)->displayTerm, ODR_CONTEXT,
1170 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
1171 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
1172 ODR_CONTEXT, 4, 1) &&
1173 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
1175 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
1176 ODR_CONTEXT, 3, 1) &&
1177 z_OtherInformation(o, &(*p)->otherTermInfo, 1) &&
1178 odr_sequence_end(o);
1181 int z_Entry(ODR o, Z_Entry **p, int opt)
1183 static Odr_arm arm[] =
1185 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, (Odr_fun)z_TermInfo},
1186 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
1187 (Odr_fun)z_DiagRec},
1191 if (o->direction == ODR_DECODE)
1192 *p = (Z_Entry *)odr_malloc(o, sizeof(**p));
1196 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1199 return opt && odr_ok(o);
1202 int z_Entries(ODR o, Z_Entries **p, int opt)
1204 if (o->direction == ODR_DECODE)
1205 *p = (Z_Entries *)odr_malloc(o, sizeof(**p));
1209 if (odr_sequence_of(o, (Odr_fun)z_Entry, &(*p)->entries,
1210 &(*p)->num_entries))
1216 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
1218 static Odr_arm arm[] =
1220 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, (Odr_fun)z_Entries},
1221 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
1222 (Odr_fun)z_DiagRecs},
1226 if (o->direction == ODR_DECODE)
1227 *p = (Z_ListEntries *)odr_malloc(o, sizeof(**p));
1231 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1234 return opt && odr_ok(o);
1237 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
1239 if (!odr_sequence_begin(o, p, sizeof(**p)))
1240 return opt && odr_ok(o);
1243 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1244 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1245 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
1246 &(*p)->num_databaseNames) &&
1247 odr_oid(o, &(*p)->attributeSet, 1) &&
1248 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
1249 ((*p)->termListAndStartPoint ? 1 :
1250 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
1251 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
1252 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
1253 ODR_CONTEXT, 6, 0) &&
1254 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
1255 ODR_CONTEXT, 7, 1) &&
1256 odr_sequence_end(o);
1259 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
1261 if (!odr_sequence_begin(o, p, sizeof(**p)))
1262 return opt && odr_ok(o);
1264 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1265 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
1266 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
1267 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
1268 ODR_CONTEXT, 5, 0) &&
1269 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
1270 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
1271 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
1272 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1273 odr_sequence_end(o);
1276 /* ------------------------ SEARCHRESPONSE ----------------*/
1278 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
1280 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
1283 int z_NextResultSetPosition(ODR o, int **p, int opt)
1285 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
1288 int z_PresentStatus(ODR o, int **p, int opt)
1290 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
1293 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
1295 Z_SearchResponse *pp;
1297 if (!odr_sequence_begin(o, p, sizeof(**p)))
1298 return opt && odr_ok(o);
1301 z_ReferenceId(o, &pp->referenceId, 1) &&
1302 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
1303 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1304 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1305 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
1306 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26,
1308 z_PresentStatus(o, &pp->presentStatus, 1) &&
1309 z_Records(o, &pp->records, 1) &&
1311 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
1312 ODR_CONTEXT, 203, 1) &&
1313 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1315 odr_sequence_end(o);
1318 /* --------------------- PRESENT SERVICE ---------------------- */
1320 int z_ElementSpec(ODR o, Z_ElementSpec **p, int opt)
1322 static Odr_arm arm[] =
1324 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSpec_elementSetName,
1326 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ElementSpec_externalSpec,
1327 (Odr_fun)z_External},
1331 if (o->direction == ODR_DECODE)
1332 *p = (Z_ElementSpec *)odr_malloc(o, sizeof(**p));
1336 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1339 return opt && odr_ok(o);
1342 int z_Specification(ODR o, Z_Specification **p, int opt)
1344 if (!odr_sequence_begin(o, p, sizeof(**p)))
1345 return opt && odr_ok(o);
1347 odr_implicit(o, odr_oid, &(*p)->schema, ODR_CONTEXT, 1, 1) &&
1348 z_ElementSpec(o, &(*p)->elementSpec, 1) &&
1349 odr_sequence_end(o);
1352 int z_DbSpecific(ODR o, Z_DbSpecific **p, int opt)
1354 if (!odr_sequence_begin(o, p, sizeof(**p)))
1355 return opt && odr_ok(o);
1357 odr_explicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
1359 odr_implicit(o, z_Specification, &(*p)->spec, ODR_CONTEXT, 2, 0) &&
1360 odr_sequence_end(o);
1363 int z_CompSpec(ODR o, Z_CompSpec **p, int opt)
1365 if (!odr_sequence_begin(o, p, sizeof(**p)))
1366 return opt && odr_ok(o);
1368 odr_implicit(o, odr_bool, &(*p)->selectAlternativeSyntax, ODR_CONTEXT,
1370 odr_implicit(o, z_Specification, &(*p)->generic, ODR_CONTEXT, 2, 1) &&
1371 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1372 (odr_sequence_of(o, (Odr_fun)z_DbSpecific, &(*p)->dbSpecific,
1373 &(*p)->num_dbSpecific) || odr_ok(o)) &&
1374 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1375 (odr_sequence_of(o, (Odr_fun)odr_oid, &(*p)->recordSyntax,
1376 &(*p)->num_recordSyntax) || odr_ok(o)) &&
1377 odr_sequence_end(o);
1380 int z_RecordComposition(ODR o, Z_RecordComposition **p, int opt)
1382 static Odr_arm arm[] =
1384 {ODR_EXPLICIT, ODR_CONTEXT, 19, Z_RecordComp_simple,
1385 (Odr_fun)z_ElementSetNames},
1386 {ODR_IMPLICIT, ODR_CONTEXT, 209, Z_RecordComp_complex,
1387 (Odr_fun)z_CompSpec},
1391 if (o->direction == ODR_DECODE)
1392 *p = (Z_RecordComposition *)odr_malloc(o, sizeof(**p));
1396 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1399 return opt && odr_ok(o);
1402 int z_Range(ODR o, Z_Range **p, int opt)
1404 if (!odr_sequence_begin(o, p, sizeof(**p)))
1405 return opt && odr_ok(o);
1407 odr_implicit(o, odr_integer, &(*p)->startingPosition, ODR_CONTEXT,
1409 odr_implicit(o, odr_integer, &(*p)->numberOfRecords, ODR_CONTEXT,
1411 odr_sequence_end(o);
1414 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
1416 Z_PresentRequest *pp;
1418 if (!odr_sequence_begin(o, p, sizeof(**p)))
1419 return opt && odr_ok(o);
1422 z_ReferenceId(o, &pp->referenceId, 1) &&
1423 z_ResultSetId(o, &pp->resultSetId, 0) &&
1424 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
1426 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
1429 odr_implicit_settag(o, ODR_CONTEXT, 212) &&
1430 (odr_sequence_of(o, (Odr_fun)z_Range, &(*p)->additionalRanges,
1431 &(*p)->num_ranges) || odr_ok(o)) &&
1432 z_RecordComposition(o, &(*p)->recordComposition, 1) &&
1434 odr_explicit(o, z_ElementSetNames, &pp->elementSetNames, ODR_CONTEXT,
1437 odr_implicit(o, odr_oid, &(*p)->preferredRecordSyntax, ODR_CONTEXT,
1440 odr_implicit(o, odr_integer, &(*p)->maxSegmentCount, ODR_CONTEXT,
1442 odr_implicit(o, odr_integer, &(*p)->maxRecordSize, ODR_CONTEXT,
1444 odr_implicit(o, odr_integer, &(*p)->maxSegmentSize, ODR_CONTEXT,
1446 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1448 odr_sequence_end(o);
1451 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
1453 Z_PresentResponse *pp;
1455 if (!odr_sequence_begin(o, p, sizeof(**p)))
1456 return opt && odr_ok(o);
1459 z_ReferenceId(o, &pp->referenceId, 1) &&
1460 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1461 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1462 z_PresentStatus(o, &pp->presentStatus, 0) &&
1463 z_Records(o, &pp->records, 1) &&
1465 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1467 odr_sequence_end(o);
1470 /* ----------------------DELETE -------------------------- */
1472 int z_DeleteSetStatus(ODR o, int **p, int opt)
1474 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
1477 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
1479 if (!odr_sequence_begin(o, p, sizeof(**p)))
1480 return opt && odr_ok(o);
1482 z_ResultSetId(o, &(*p)->id, 0) &&
1483 z_DeleteSetStatus(o, &(*p)->status, 0) &&
1484 odr_sequence_end(o);
1487 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
1489 if (!odr_sequence_begin(o, p, sizeof(**p)))
1490 return opt && odr_ok(o);
1492 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1493 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
1495 (odr_sequence_of(o, z_ResultSetId, &(*p)->resultSetList,
1496 &(*p)->num_ids) || odr_ok(o)) &&
1498 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1500 odr_sequence_end(o);
1503 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
1505 if (!odr_sequence_begin(o, p, sizeof(**p)))
1506 return opt && odr_ok(o);
1508 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1509 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
1510 ODR_CONTEXT, 0, 1) &&
1511 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
1512 (odr_sequence_of(o, (Odr_fun)z_ListStatus, &(*p)->deleteListStatuses,
1513 &(*p)->num_statuses) || odr_ok(o)) &&
1514 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
1516 odr_implicit_settag(o, ODR_CONTEXT, 35) &&
1517 (odr_sequence_of(o, (Odr_fun)z_ListStatus, &(*p)->bulkStatuses,
1518 &(*p)->num_bulkStatuses) || odr_ok(o)) &&
1519 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
1522 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1524 odr_sequence_end(o);
1527 /* ------------------------ SEGMENT SERVICE -------------- */
1529 int z_Segment(ODR o, Z_Segment **p, int opt)
1531 if (!odr_sequence_begin(o, p, sizeof(**p)))
1532 return opt && odr_ok(o);
1534 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1535 odr_implicit(o, odr_integer, &(*p)->numberOfRecordsReturned,
1536 ODR_CONTEXT, 24, 0) &&
1537 odr_implicit_settag(o, ODR_CONTEXT, 0) &&
1538 odr_sequence_of(o, (Odr_fun)z_NamePlusRecord, &(*p)->segmentRecords,
1539 &(*p)->num_segmentRecords) &&
1540 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1541 odr_sequence_end(o);
1544 /* ------------------------ CLOSE SERVICE ---------------- */
1546 int z_Close(ODR o, Z_Close **p, int opt)
1548 if (!odr_sequence_begin(o, p, sizeof(**p)))
1549 return opt && odr_ok(o);
1551 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1552 odr_implicit(o, odr_integer, &(*p)->closeReason, ODR_CONTEXT, 211, 0) &&
1553 odr_implicit(o, odr_visiblestring, &(*p)->diagnosticInformation,
1554 ODR_CONTEXT, 3, 1) &&
1555 odr_implicit(o, odr_oid, &(*p)->resourceReportFormat, ODR_CONTEXT,
1557 odr_implicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1560 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1562 odr_sequence_end(o);
1565 /* ------------------------ APDU ------------------------- */
1567 int z_Permissions(ODR o, Z_Permissions **p, int opt)
1569 if (!odr_sequence_begin(o, p, sizeof(**p)))
1570 return opt && odr_ok(o);
1572 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT,
1574 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
1575 odr_sequence_of(o, (Odr_fun)odr_integer, &(*p)->allowableFunctions,
1576 &(*p)->num_allowableFunctions) &&
1577 odr_sequence_end(o);
1580 int z_ExtendedServicesRequest(ODR o, Z_ExtendedServicesRequest **p, int opt)
1582 if (!odr_sequence_begin(o, p, sizeof(**p)))
1583 return opt && odr_ok(o);
1585 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1586 odr_implicit(o, odr_integer, &(*p)->function, ODR_CONTEXT, 3, 0) &&
1587 odr_implicit(o, odr_oid, &(*p)->packageType, ODR_CONTEXT, 4, 0) &&
1588 odr_implicit(o, z_InternationalString, &(*p)->packageName, ODR_CONTEXT, 5, 1) &&
1589 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT, 6, 1) &&
1590 odr_implicit(o, z_IntUnit, &(*p)->retentionTime, ODR_CONTEXT, 7, 1) &&
1591 odr_implicit(o, z_Permissions, &(*p)->permissions, ODR_CONTEXT, 8, 1) &&
1592 odr_implicit(o, z_InternationalString, &(*p)->description, ODR_CONTEXT, 9, 1) &&
1593 odr_implicit(o, z_External, &(*p)->taskSpecificParameters, ODR_CONTEXT, 10, 1) &&
1594 odr_implicit(o, odr_integer, &(*p)->waitAction, ODR_CONTEXT, 11, 0) &&
1595 z_ElementSetName(o, &(*p)->elements, 1) &&
1596 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1597 odr_sequence_end(o);
1600 int z_ExtendedServicesResponse(ODR o, Z_ExtendedServicesResponse **p, int opt)
1602 if (!odr_sequence_begin(o, p, sizeof(**p)))
1603 return opt && odr_ok(o);
1605 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1606 odr_implicit(o, odr_integer, &(*p)->operationStatus, ODR_CONTEXT, 3, 0) &&
1607 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1608 (odr_sequence_of(o, (Odr_fun)z_DiagRec, &(*p)->diagnostics,
1609 &(*p)->num_diagnostics) || odr_ok(o)) &&
1610 odr_implicit(o, z_External, &(*p)->taskPackage, ODR_CONTEXT, 5, 1) &&
1611 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1612 odr_sequence_end(o);
1615 /* ------------------------ SORT ------------------------- */
1617 int z_SortAttributes(ODR o, Z_SortAttributes **p, int opt)
1619 if (!odr_sequence_begin(o, p, sizeof(**p)))
1620 return opt && odr_ok(o);
1622 odr_oid(o, &(*p)->id, 0) &&
1623 z_AttributeList(o, &(*p)->list, 0) &&
1624 odr_sequence_end(o);
1627 int z_SortKey(ODR o, Z_SortKey **p, int opt)
1629 static Odr_arm arm[] =
1631 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_SortKey_sortField,
1632 z_InternationalString},
1633 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortKey_elementSpec, (Odr_fun)z_Specification},
1634 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortKey_sortAttributes,
1635 (Odr_fun)z_SortAttributes},
1639 if (!odr_initmember(o, p, sizeof(**p)))
1640 return opt && odr_ok(o);
1641 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1644 return opt && odr_ok(o);
1647 int z_SortDbSpecific(ODR o, Z_SortDbSpecific **p, int opt)
1649 if (!odr_sequence_begin(o, p, sizeof(**p)))
1650 return opt && odr_ok(o);
1652 z_DatabaseName(o, &(*p)->databaseName, 0) &&
1653 z_SortKey(o, &(*p)->dbSort, 0) &&
1654 odr_sequence_end(o);
1657 int z_SortDbSpecificList(ODR o, Z_SortDbSpecificList **p, int opt)
1659 if (!odr_initmember(o, p, sizeof(**p)))
1660 return opt && odr_ok(o);
1661 if (odr_sequence_of(o, (Odr_fun)z_SortDbSpecific, &(*p)->dbSpecific,
1662 &(*p)->num_dbSpecific))
1665 return opt && odr_ok(o);
1668 int z_SortElement(ODR o, Z_SortElement **p, int opt)
1670 static Odr_arm arm[] =
1672 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_SortElement_generic, (Odr_fun)z_SortKey},
1673 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortElement_databaseSpecific,
1674 (Odr_fun)z_SortDbSpecificList},
1678 if (!odr_initmember(o, p, sizeof(**p)))
1679 return opt && odr_ok(o);
1680 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1683 return opt && odr_ok(o);
1686 int z_SortMissingValueAction(ODR o, Z_SortMissingValueAction **p, int opt)
1688 static Odr_arm arm[] =
1690 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortMissingValAct_abort, (Odr_fun)odr_null},
1691 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortMissingValAct_null, (Odr_fun)odr_null},
1692 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_SortMissingValAct_valData,
1693 (Odr_fun)odr_octetstring},
1697 if (!odr_initmember(o, p, sizeof(**p)))
1698 return opt && odr_ok(o);
1699 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1702 return opt && odr_ok(o);
1705 int z_SortKeySpec(ODR o, Z_SortKeySpec **p, int opt)
1707 if (!odr_sequence_begin(o, p, sizeof(**p)))
1708 return opt && odr_ok(o);
1710 z_SortElement(o, &(*p)->sortElement, 0) &&
1711 odr_implicit(o, odr_integer, &(*p)->sortRelation, ODR_CONTEXT, 1, 0) &&
1712 odr_implicit(o, odr_integer, &(*p)->caseSensitivity, ODR_CONTEXT,
1714 odr_explicit(o, z_SortMissingValueAction, &(*p)->missingValueAction,
1715 ODR_CONTEXT, 3, 1) &&
1716 odr_sequence_end(o);
1719 int z_SortResponse(ODR o, Z_SortResponse **p, int opt)
1721 if (!odr_sequence_begin(o, p, sizeof(**p)))
1722 return opt && odr_ok(o);
1724 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1725 odr_implicit(o, odr_integer, &(*p)->sortStatus, ODR_CONTEXT,
1727 odr_implicit(o, odr_integer, &(*p)->resultSetStatus, ODR_CONTEXT,
1729 odr_implicit(o, z_DiagRecs, &(*p)->diagnostics, ODR_CONTEXT, 5, 1) &&
1730 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1731 odr_sequence_end(o);
1734 int z_SortKeySpecList(ODR o, Z_SortKeySpecList **p, int opt)
1736 if (!odr_initmember(o, p, sizeof(**p)))
1737 return opt && odr_ok(o);
1738 if (odr_sequence_of(o, (Odr_fun)z_SortKeySpec, &(*p)->specs, &(*p)->num_specs))
1741 return opt && odr_ok(o);
1744 int z_SortRequest(ODR o, Z_SortRequest **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_StringList, &(*p)->inputResultSetNames,
1751 ODR_CONTEXT, 3, 0) &&
1752 odr_implicit(o, z_InternationalString, &(*p)->sortedResultSetName,
1753 ODR_CONTEXT, 4, 0) &&
1754 odr_implicit(o, z_SortKeySpecList, &(*p)->sortSequence, ODR_CONTEXT,
1756 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1757 odr_sequence_end(o);
1760 /* ---------------------- Resource Report ---------------- */
1762 int z_ResourceReportRequest(ODR o, Z_ResourceReportRequest **p, int opt)
1764 if (!odr_sequence_begin(o, p, sizeof(**p)))
1765 return opt && odr_ok(o);
1767 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1768 odr_implicit(o, z_ReferenceId, &(*p)->opId, ODR_CONTEXT, 210, 1) &&
1769 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat, ODR_CONTEXT,
1771 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1772 odr_sequence_end(o);
1775 int z_ResourceReportResponse(ODR o, Z_ResourceReportResponse **p, int opt)
1777 if (!odr_sequence_begin(o, p, sizeof(**p)))
1778 return opt && odr_ok(o);
1780 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1781 odr_implicit(o, odr_integer, &(*p)->resourceReportStatus,
1782 ODR_CONTEXT, 50, 0) &&
1783 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1785 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1786 odr_sequence_end(o);
1789 /* ------------------------ APDU ------------------------- */
1791 int z_APDU(ODR o, Z_APDU **p, int opt)
1793 static Odr_arm arm[] =
1795 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, (Odr_fun)z_InitRequest},
1796 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, (Odr_fun)z_InitResponse},
1797 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, (Odr_fun)z_SearchRequest},
1798 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
1799 (Odr_fun)z_SearchResponse},
1800 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
1801 (Odr_fun)z_PresentRequest},
1802 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
1803 (Odr_fun)z_PresentResponse},
1804 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
1805 (Odr_fun)z_DeleteResultSetRequest},
1806 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
1807 (Odr_fun)z_DeleteResultSetResponse},
1808 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_APDU_accessControlRequest,
1809 (Odr_fun)z_AccessControlRequest},
1810 {ODR_IMPLICIT, ODR_CONTEXT, 29, Z_APDU_accessControlResponse,
1811 (Odr_fun)z_AccessControlResponse},
1812 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
1813 (Odr_fun)z_ResourceControlRequest},
1814 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
1815 (Odr_fun)z_ResourceControlResponse},
1816 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
1817 (Odr_fun)z_TriggerResourceControlRequest},
1818 {ODR_IMPLICIT, ODR_CONTEXT, 33, Z_APDU_resourceReportRequest,
1819 (Odr_fun)z_ResourceReportRequest},
1820 {ODR_IMPLICIT, ODR_CONTEXT, 34, Z_APDU_resourceReportResponse,
1821 (Odr_fun)z_ResourceReportResponse},
1822 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, (Odr_fun)z_ScanRequest},
1823 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, (Odr_fun)z_ScanResponse},
1824 {ODR_IMPLICIT, ODR_CONTEXT, 43, Z_APDU_sortRequest, (Odr_fun)z_SortRequest},
1825 {ODR_IMPLICIT, ODR_CONTEXT, 44, Z_APDU_sortResponse, (Odr_fun)z_SortResponse},
1826 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_APDU_segmentRequest, (Odr_fun)z_Segment},
1827 {ODR_IMPLICIT, ODR_CONTEXT, 46, Z_APDU_extendedServicesRequest,
1828 (Odr_fun)z_ExtendedServicesRequest},
1829 {ODR_IMPLICIT, ODR_CONTEXT, 47, Z_APDU_extendedServicesResponse,
1830 (Odr_fun)z_ExtendedServicesResponse},
1831 {ODR_IMPLICIT, ODR_CONTEXT, 48, Z_APDU_close, (Odr_fun)z_Close},
1836 if (o->direction == ODR_DECODE)
1837 *p = (Z_APDU *)odr_malloc(o, sizeof(**p));
1838 odr_setlenlen(o, 5);
1839 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
1841 if (o->direction == ODR_DECODE)
1843 return opt && odr_ok(o);