2 * Copyright (c) 1995-1998, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.56 1998-08-19 16:10:04 adam
8 * Changed som member names of DeleteResultSetRequest/Response.
10 * Revision 1.55 1998/02/11 11:53:32 adam
11 * Changed code so that it compiles as C++.
13 * Revision 1.54 1996/11/11 13:14:46 adam
14 * Fixed tagging bug in z_ProximityOperator.
16 * Revision 1.53 1996/10/09 15:54:55 quinn
17 * Added SearchInfoReport
19 * Revision 1.52 1996/10/08 12:56:57 adam
20 * Bug fix: tagging of type 101 query.
22 * Revision 1.51 1996/07/26 14:07:21 quinn
25 * Revision 1.50 1996/07/26 13:36:15 quinn
28 * Revision 1.49 1996/07/06 19:58:28 quinn
29 * System headerfiles gathered in yconfig
31 * Revision 1.48 1996/06/10 08:53:33 quinn
32 * Added Summary,OPAC,ResourceReport
34 * Revision 1.47 1996/05/29 15:47:50 quinn
35 * Fixed in bug DiagRecs decoder. Thanks to Linda Harris.
37 * Revision 1.46 1996/04/10 11:39:42 quinn
38 * Fixed bug in UserInfo
40 * Revision 1.45 1996/02/23 10:00:25 quinn
43 * Revision 1.44 1996/02/20 12:51:41 quinn
44 * Completed SCAN. Fixed problems with EXTERNAL.
46 * Revision 1.43 1996/02/10 12:22:49 quinn
49 * Revision 1.42 1996/01/22 09:46:31 quinn
50 * Added Sort PDU. Moved StringList to main protocol file.
52 * Revision 1.41 1996/01/10 15:21:24 quinn
53 * Added links to access control PDUs
55 * Revision 1.40 1996/01/02 11:46:40 quinn
56 * Changed 'operator' to 'roperator' to avoid C++ conflict.
58 * Revision 1.39 1995/09/29 17:11:53 quinn
61 * Revision 1.38 1995/09/27 15:02:40 quinn
62 * Modified function heads & prototypes.
64 * Revision 1.37 1995/08/21 09:10:15 quinn
65 * Smallish fixes to suppport new formats.
67 * Revision 1.36 1995/08/15 11:59:39 quinn
70 * Revision 1.35 1995/08/10 08:53:59 quinn
73 * Revision 1.34 1995/06/19 17:01:48 quinn
74 * This should bring us in sync with the version distributed as 1.0b
76 * Revision 1.33 1995/06/19 13:39:56 quinn
77 * *** empty log message ***
79 * Revision 1.32 1995/06/19 12:37:28 quinn
80 * Fixed a bug in the compspec.
82 * Revision 1.31 1995/06/16 13:15:56 quinn
83 * Fixed Defaultdiagformat.
85 * Revision 1.30 1995/06/15 15:42:01 quinn
88 * Revision 1.29 1995/06/15 07:44:49 quinn
91 * Revision 1.28 1995/06/14 15:26:35 quinn
92 * *** empty log message ***
94 * Revision 1.27 1995/06/07 14:36:22 quinn
97 * Revision 1.26 1995/06/02 09:49:13 quinn
98 * Adding access control
100 * Revision 1.25 1995/05/25 11:00:08 quinn
101 * *** empty log message ***
103 * Revision 1.24 1995/05/22 13:58:18 quinn
104 * Fixed an ODR_NULLVAL.
106 * Revision 1.23 1995/05/22 11:30:18 quinn
107 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
109 * Revision 1.22 1995/05/17 08:40:56 quinn
110 * Added delete. Fixed some sequence_begins. Smallish.
112 * Revision 1.21 1995/05/16 08:50:24 quinn
113 * License, documentation, and memory fixes
115 * Revision 1.20 1995/05/15 11:55:25 quinn
118 * Revision 1.19 1995/04/11 11:58:35 quinn
121 * Revision 1.18 1995/04/11 11:52:02 quinn
122 * Fixed possible buf in proto.c
124 * Revision 1.17 1995/04/10 10:22:22 quinn
127 * Revision 1.16 1995/03/30 10:26:43 quinn
128 * Added Term structure
130 * Revision 1.15 1995/03/30 09:08:39 quinn
131 * Added Resource control protocol
133 * Revision 1.14 1995/03/29 08:06:13 quinn
134 * Added a few v3 elements
136 * Revision 1.13 1995/03/20 11:26:52 quinn
137 * *** empty log message ***
139 * Revision 1.12 1995/03/20 09:45:09 quinn
142 * Revision 1.11 1995/03/17 10:17:25 quinn
143 * Added memory management.
145 * Revision 1.10 1995/03/15 11:17:40 quinn
146 * Fixed some return-checks from choice.. need better ay to handle those..
148 * Revision 1.9 1995/03/15 08:37:06 quinn
149 * Fixed protocol bugs.
151 * Revision 1.8 1995/03/14 16:59:24 quinn
152 * Fixed OPTIONAL flag in attributeelement
154 * Revision 1.7 1995/03/07 16:29:33 quinn
155 * Added authentication stuff.
157 * Revision 1.6 1995/03/01 14:46:03 quinn
158 * Fixed protocol bug in 8777query.
160 * Revision 1.5 1995/02/14 11:54:22 quinn
163 * Revision 1.4 1995/02/10 15:54:30 quinn
166 * Revision 1.3 1995/02/09 15:51:39 quinn
169 * Revision 1.2 1995/02/06 21:26:07 quinn
170 * Repaired this evening's damages..
172 * Revision 1.1 1995/02/06 16:44:47 quinn
173 * First hack at Z/SR protocol
181 /* ---------------------- GLOBAL DEFS ------------------- */
184 * We'll use a general octetstring here, since string operations are
185 * clumsy on long strings.
187 int z_SUTRS(ODR o, Odr_oct **p, int opt)
189 return odr_implicit(o, odr_octetstring, p, ODR_UNIVERSAL,
190 ODR_GENERALSTRING, opt);
193 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
195 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
198 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
200 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
204 int z_ResultSetId(ODR o, char **p, int opt)
206 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
210 int z_ElementSetName(ODR o, char **p, int opt)
212 return odr_implicit(o, odr_visiblestring, p, ODR_CONTEXT, 103, opt);
215 int z_UserInformationField(ODR o, Z_External **p, int opt)
217 return odr_explicit(o, z_External, (Z_External **)p, ODR_CONTEXT,
221 int z_InternationalString(ODR o, char **p, int opt)
223 return odr_generalstring(o, p, opt);
226 int z_InfoCategory(ODR o, Z_InfoCategory **p, int opt)
228 if (!odr_sequence_begin(o, p, sizeof(**p)))
229 return opt && odr_ok(o);
231 odr_implicit(o, odr_oid, &(*p)->categoryTypeId, ODR_CONTEXT, 1, 1) &&
232 odr_implicit(o, odr_integer, &(*p)->categoryValue, ODR_CONTEXT, 2, 0) &&
236 int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt)
238 static Odr_arm arm[] =
240 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_OtherInfo_characterInfo,
242 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_OtherInfo_binaryInfo,
243 (Odr_fun)odr_octetstring},
244 {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_OtherInfo_externallyDefinedInfo,
245 (Odr_fun)z_External},
246 {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_OtherInfo_oid, (Odr_fun)odr_oid},
250 if (!odr_sequence_begin(o, p, sizeof(**p)))
251 return opt && odr_ok(o);
253 odr_implicit(o, z_InfoCategory, &(*p)->category, ODR_CONTEXT, 1, 1) &&
254 odr_choice(o, arm, &(*p)->information, &(*p)->which) &&
258 int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt)
260 if (o->direction == ODR_DECODE)
261 *p = (Z_OtherInformation *)odr_malloc(o, sizeof(**p));
264 odr_implicit_settag(o, ODR_CONTEXT, 201);
265 if (odr_sequence_of(o, (Odr_fun)z_OtherInformationUnit, &(*p)->list,
266 &(*p)->num_elements))
269 return opt && odr_ok(o);
272 int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt)
274 static Odr_arm arm[] =
276 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_StringOrNumeric_string,
278 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_StringOrNumeric_numeric,
279 (Odr_fun)odr_integer},
283 if (o->direction == ODR_DECODE)
284 *p = (Z_StringOrNumeric *)odr_malloc(o, sizeof(**p));
287 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
290 return opt && odr_ok(o);
296 int z_Unit(ODR o, Z_Unit **p, int opt)
298 if (!odr_sequence_begin(o, p, sizeof(**p)))
299 return opt && odr_ok(o);
301 odr_explicit(o, z_InternationalString, &(*p)->unitSystem, ODR_CONTEXT,
303 odr_explicit(o, z_StringOrNumeric, &(*p)->unitType, ODR_CONTEXT,
305 odr_explicit(o, z_StringOrNumeric, &(*p)->unit, ODR_CONTEXT, 3, 1) &&
306 odr_implicit(o, odr_integer, &(*p)->scaleFactor, ODR_CONTEXT, 4, 1) &&
310 int z_IntUnit(ODR o, Z_IntUnit **p, int opt)
312 if (!odr_sequence_begin(o, p, sizeof(**p)))
313 return opt && odr_ok(o);
315 odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 1, 0) &&
316 odr_implicit(o, z_Unit, &(*p)->unitUsed, ODR_CONTEXT, 2, 0) &&
320 int z_StringList(ODR o, Z_StringList **p, int opt)
322 if (o->direction == ODR_DECODE)
323 *p = (Z_StringList *)odr_malloc(o, sizeof(**p));
326 if (odr_sequence_of(o, (Odr_fun)z_InternationalString, &(*p)->strings,
330 return opt && odr_ok(o);
333 /* ---------------------- INITIALIZE SERVICE ------------------- */
336 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
338 if (!odr_sequence_begin(o, p, sizeof(**p)))
339 return opt && odr_ok(o);
341 odr_visiblestring(o, &(*p)->user, 0) &&
342 odr_visiblestring(o, &(*p)->password, 0) &&
343 odr_visiblestring(o, &(*p)->account, 0) &&
348 int z_IdPass(ODR o, Z_IdPass **p, int opt)
350 if (!odr_sequence_begin(o, p, sizeof(**p)))
351 return opt && odr_ok(o);
353 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 1) &&
354 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 1) &&
355 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
360 int z_StrAuthentication(ODR o, char **p, int opt)
362 return odr_visiblestring(o, p, opt);
365 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
367 static Odr_arm arm[] =
369 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
370 {-1, -1, -1, Z_IdAuthentication_idPass, (Odr_fun)z_IdPass},
371 {-1, -1, -1, Z_IdAuthentication_anonymous, (Odr_fun)odr_null},
372 {-1, -1, -1, Z_IdAuthentication_other, (Odr_fun)z_External},
376 if (o->direction == ODR_DECODE)
377 *p = (Z_IdAuthentication *)odr_malloc(o, sizeof(**p));
381 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
384 return opt && odr_ok(o);
387 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
391 if (!odr_sequence_begin(o, p, sizeof(**p)))
392 return opt && odr_ok(o);
395 z_ReferenceId(o, &pp->referenceId, 1) &&
396 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
398 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
399 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
401 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
403 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
405 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
407 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
409 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
410 ODR_CONTEXT, 112, 1) &&
411 z_UserInformationField(o, &pp->userInformationField, 1) &&
413 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
418 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
422 if (!odr_sequence_begin(o, p, sizeof(**p)))
423 return opt && odr_ok(o);
426 z_ReferenceId(o, &pp->referenceId, 1) &&
427 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
429 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
430 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
432 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
434 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
435 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
437 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
439 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
440 ODR_CONTEXT, 112, 1) &&
441 z_UserInformationField(o, &pp->userInformationField, 1) &&
443 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
448 /* ------------------ RESOURCE CONTROL ----------------*/
450 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
453 if (!odr_sequence_begin(o, p, sizeof(**p)))
454 return opt && odr_ok(o);
456 z_ReferenceId(o, &(*p)->referenceId, 1) &&
457 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
459 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
460 ODR_CONTEXT, 47, 1) &&
461 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
464 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
469 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **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)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
476 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
478 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
479 ODR_CONTEXT, 41, 1) &&
480 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
482 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
483 ODR_CONTEXT, 43, 1) &&
485 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
490 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
492 if (!odr_sequence_begin(o, p, sizeof(**p)))
493 return opt && odr_ok(o);
495 z_ReferenceId(o, &(*p)->referenceId, 1) &&
496 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
497 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
500 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
505 /* ------------------------ SEARCH SERVICE ----------------------- */
507 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
509 if (!odr_sequence_begin(o, p, sizeof(**p)))
510 return opt && odr_ok(o);
512 z_DatabaseName(o, &(*p)->databaseName, 0) &&
513 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
517 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
519 if (o->direction == ODR_DECODE)
520 *p = (Z_DatabaseSpecific *)odr_malloc(o, sizeof(**p));
524 odr_implicit_settag(o, ODR_CONTEXT, 1);
525 if (odr_sequence_of(o, (Odr_fun)z_DatabaseSpecificUnit, &(*p)->elements,
526 &(*p)->num_elements))
532 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
534 static Odr_arm arm[] =
536 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
538 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
539 (Odr_fun)z_DatabaseSpecific},
543 if (o->direction == ODR_DECODE)
544 *p = (Z_ElementSetNames *)odr_malloc(o, sizeof(**p));
546 return opt && odr_ok(o);
548 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
554 /* ----------------------- RPN QUERY -----------------------*/
556 int z_ComplexAttribute(ODR o, Z_ComplexAttribute **p, int opt)
558 if (!odr_sequence_begin(o, p, sizeof(**p)))
559 return opt && odr_ok(o);
561 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
562 odr_sequence_of(o, (Odr_fun)z_StringOrNumeric, &(*p)->list,
564 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
565 (odr_sequence_of(o, (Odr_fun)odr_integer, &(*p)->semanticAction,
566 &(*p)->num_semanticAction) || odr_ok(o)) &&
570 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
573 static Odr_arm arm[] =
575 {ODR_IMPLICIT, ODR_CONTEXT, 121, Z_AttributeValue_numeric,
576 (Odr_fun)odr_integer},
577 {ODR_IMPLICIT, ODR_CONTEXT, 224, Z_AttributeValue_complex,
578 (Odr_fun)z_ComplexAttribute},
583 if (!odr_sequence_begin(o, p, sizeof(**p)))
584 return opt && odr_ok(o);
587 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 1, 1) &&
589 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
592 odr_choice(o, arm, &(*p)->value, &(*p)->which) &&
594 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
600 int z_Term(ODR o, Z_Term **p, int opt)
602 static Odr_arm arm[] =
604 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, (Odr_fun)odr_octetstring},
605 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, (Odr_fun)odr_integer},
606 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
608 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, (Odr_fun)odr_oid},
609 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
610 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, (Odr_fun)z_External},
611 /* add intUnit here */
612 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, (Odr_fun)odr_null},
616 if (o->direction ==ODR_DECODE)
617 *p = (Z_Term *)odr_malloc(o, sizeof(**p));
620 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
623 return opt && odr_ok(o);
626 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
628 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
629 odr_sequence_begin(o, p, sizeof(**p))))
630 return opt && odr_ok(o);
632 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
633 odr_sequence_of(o, (Odr_fun)z_AttributeElement, &(*p)->attributeList,
634 &(*p)->num_attributes) &&
635 z_Term(o, &(*p)->term, 0) &&
639 int z_ResultSetPlusAttributes(ODR o, Z_ResultSetPlusAttributes **p, int opt)
641 if (!(odr_implicit_settag(o, ODR_CONTEXT, 214) &&
642 odr_sequence_begin(o, p, sizeof(**p))))
643 return opt && odr_ok(o);
645 z_ResultSetId(o, &(*p)->resultSet, 0) &&
646 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
647 odr_sequence_of(o, (Odr_fun)z_AttributeElement, &(*p)->attributeList,
648 &(*p)->num_attributes) &&
652 int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
654 static Odr_arm arm[] =
656 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, (Odr_fun)odr_integer},
657 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ProxCode_private, (Odr_fun)odr_integer},
661 if (!odr_sequence_begin(o, p, sizeof(**p)))
662 return opt && odr_ok(o);
664 odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
665 odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
666 odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
667 odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
668 odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
669 odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
670 odr_constructed_end(o) &&
674 int z_Operator(ODR o, Z_Operator **p, int opt)
676 static Odr_arm arm[] =
678 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, (Odr_fun)odr_null},
679 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, (Odr_fun)odr_null},
680 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, (Odr_fun)odr_null},
681 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, (Odr_fun)z_ProximityOperator},
685 if (!*p && o->direction != ODR_DECODE)
687 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
688 return opt && odr_ok(o);
689 if (o->direction == ODR_DECODE)
690 *p = (Z_Operator *)odr_malloc(o, sizeof(**p));
692 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
693 odr_constructed_end(o))
696 return opt && odr_ok(o);
699 int z_Operand(ODR o, Z_Operand **p, int opt)
701 static Odr_arm arm[] =
703 {-1, -1, -1, Z_Operand_APT, (Odr_fun)z_AttributesPlusTerm},
704 {-1, -1, -1, Z_Operand_resultSetId, (Odr_fun)z_ResultSetId},
705 {-1, -1, -1, Z_Operand_resultAttr, (Odr_fun)z_ResultSetPlusAttributes},
709 if (o->direction == ODR_DECODE)
710 *p = (Z_Operand *)odr_malloc(o, sizeof(**p));
713 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
716 return opt && odr_ok(o);
719 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
721 int z_Complex(ODR o, Z_Complex **p, int opt)
723 if (!odr_sequence_begin(o, p, sizeof(**p)))
724 return opt && odr_ok(o);
726 z_RPNStructure(o, &(*p)->s1, 0) &&
727 z_RPNStructure(o, &(*p)->s2, 0) &&
728 z_Operator(o, &(*p)->roperator, 0) &&
732 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
734 static Odr_arm arm[] =
736 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, (Odr_fun)z_Operand},
737 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, (Odr_fun)z_Complex},
741 if (o->direction == ODR_DECODE)
742 *p = (Z_RPNStructure *)odr_malloc(o, sizeof(**p));
745 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
748 return opt && odr_ok(o);
751 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
753 if (!odr_sequence_begin(o, p, sizeof(**p)))
754 return opt && odr_ok(o);
756 odr_oid(o, &(*p)->attributeSetId, 0) &&
757 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
761 /* -----------------------END RPN QUERY ----------------------- */
763 int z_Query(ODR o, Z_Query **p, int opt)
765 static Odr_arm arm[] =
767 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, (Odr_fun)z_RPNQuery},
768 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, (Odr_fun)odr_octetstring},
769 {ODR_IMPLICIT, ODR_CONTEXT, 101, Z_Query_type_101, (Odr_fun)z_RPNQuery},
773 if (o->direction == ODR_DECODE)
774 *p = (Z_Query *)odr_malloc(o, sizeof(**p));
777 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
780 return opt && odr_ok(o);
783 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
787 if (!odr_sequence_begin(o, p, sizeof(**p)))
788 return opt && odr_ok(o);
791 z_ReferenceId(o, &pp->referenceId, 1) &&
792 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
794 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
796 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
798 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
799 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
801 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
802 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
803 &pp->num_databaseNames) &&
804 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
805 ODR_CONTEXT, 100, 1) &&
806 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
807 ODR_CONTEXT, 101, 1) &&
808 odr_implicit(o, odr_oid, &pp->preferredRecordSyntax,
809 ODR_CONTEXT, 104, 1) &&
810 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
812 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
813 ODR_CONTEXT, 203, 1) &&
814 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
819 /* ------------------------ RECORD ------------------------- */
821 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
823 return z_External(o, (Z_External **) p, opt);
828 int z_DefaultDiagFormat(ODR o, Z_DefaultDiagFormat **p, int opt)
830 static Odr_arm arm[] =
832 {-1, -1, -1, Z_DiagForm_v2AddInfo, odr_visiblestring},
833 {-1, -1, -1, Z_DiagForm_v3AddInfo, z_InternationalString},
834 {ODR_IMPLICIT, ODR_CONTEXT, ODR_VISIBLESTRING, Z_DiagForm_v2AddInfo,
835 odr_visiblestring}, /* To cater to a bug in the CNIDR servers */
838 if (!odr_sequence_begin(o, p, sizeof(**p)))
839 return opt && odr_ok(o);
841 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
842 odr_integer(o, &(*p)->condition, 0) &&
844 * I no longer recall what server tagged the addinfo.. but it isn't
845 * hurting anyone, so...
846 * We need to turn it into a choice, or something, because of
847 * that damn generalstring in v3.
849 odr_choice(o, arm, &(*p)->addinfo, &(*p)->which) &&
853 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
855 static Odr_arm arm[] =
857 {-1, -1, -1, Z_DiagRec_defaultFormat, (Odr_fun)z_DefaultDiagFormat},
858 {-1, -1, -1, Z_DiagRec_externallyDefined, (Odr_fun)z_External},
862 if (o->direction == ODR_DECODE)
863 *p = (Z_DiagRec *)odr_malloc(o, sizeof(**p));
866 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
869 return opt && odr_ok(o);
874 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
876 if (!odr_sequence_begin(o, p, sizeof(**p)))
877 return opt && odr_ok(o);
879 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
880 odr_integer(o, &(*p)->condition, 0) &&
882 * I no longer recall what server tagged the addinfo.. but it isn't
883 * hurting anyone, so...
884 * We need to turn it into a choice, or something, because of
885 * that damn generalstring in v3.
887 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
888 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT,
889 ODR_VISIBLESTRING, 1)) &&
895 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
897 if (o->direction == ODR_DECODE)
898 *p = (Z_DiagRecs *)odr_malloc(o, sizeof(**p));
902 if (odr_sequence_of(o, (Odr_fun)z_DiagRec, &(*p)->diagRecs,
903 &(*p)->num_diagRecs))
906 return opt && odr_ok(o);
909 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
911 static Odr_arm arm[] =
913 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
914 (Odr_fun)z_DatabaseRecord},
915 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
920 if (!odr_sequence_begin(o, p, sizeof(**p)))
921 return opt && odr_ok(o);
923 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
925 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
926 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
927 odr_constructed_end(o) &&
931 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
933 if (o->direction == ODR_DECODE)
934 *p = (Z_NamePlusRecordList *)odr_malloc(o, sizeof(**p));
937 if (odr_sequence_of(o, (Odr_fun)z_NamePlusRecord, &(*p)->records,
944 int z_Records(ODR o, Z_Records **p, int opt)
946 static Odr_arm arm[] =
948 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, (Odr_fun)z_NamePlusRecordList},
949 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, (Odr_fun)z_DiagRec},
950 {ODR_IMPLICIT, ODR_CONTEXT, 205, Z_Records_multipleNSD,
951 (Odr_fun)z_DiagRecs},
955 if (o->direction == ODR_DECODE)
956 *p = (Z_Records *)odr_malloc(o, sizeof(**p));
959 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
962 return opt && odr_ok(o);
965 /* ------------------------ ACCESS CTRL SERVICE ----------------------- */
967 int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
969 static Odr_arm arm[] =
971 {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
972 (Odr_fun)odr_octetstring},
973 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
974 (Odr_fun)z_External},
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) &&
983 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
988 int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
990 static Odr_arm arm[] =
992 {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
993 (Odr_fun)odr_octetstring},
994 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
995 (Odr_fun)z_External},
998 if (!odr_sequence_begin(o, p, sizeof(**p)))
999 return opt && odr_ok(o);
1001 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1002 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
1003 odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
1005 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1007 odr_sequence_end(o);
1010 /* ------------------------ SCAN SERVICE -------------------- */
1012 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
1014 if (o->direction == ODR_DECODE)
1015 *p = (Z_AttributeList *)odr_malloc(o, sizeof(**p));
1019 odr_implicit_settag(o, ODR_CONTEXT, 44);
1020 if (odr_sequence_of(o, (Odr_fun)z_AttributeElement, &(*p)->attributes,
1021 &(*p)->num_attributes))
1024 return opt && odr_ok(o);
1028 * This is a temporary hack. We don't know just *what* old version of the
1029 * protocol willow uses, so we'll just patiently wait for them to update
1031 static int willow_scan = 0;
1033 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
1035 if (!*p && o->direction != ODR_DECODE)
1037 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
1040 return opt && odr_ok(o);
1042 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
1044 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
1046 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
1048 if (o->direction == ODR_DECODE)
1049 *p = (Z_AttributesPlusTerm*)odr_malloc(o, sizeof(**p));
1050 if (!odr_sequence_of(o, (Odr_fun)z_AttributeElement, &(*p)->attributeList,
1051 &(*p)->num_attributes))
1053 if (!odr_sequence_end(o) || !odr_sequence_end(o))
1055 if (!z_Term(o, &(*p)->term, 0))
1057 if (!odr_constructed_end(o))
1063 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
1065 if (o->direction == ODR_DECODE)
1066 *p = (Z_AlternativeTerm *)odr_malloc(o, sizeof(**p));
1070 return opt && odr_ok(o);
1073 if (odr_sequence_of(o, (Odr_fun)z_AttributesPlusTerm, &(*p)->terms,
1077 return opt && !o->error;
1082 int z_ByDatabase(ODR o, Z_ByDatabase **p, int opt)
1084 if (!odr_sequence_begin(o, p, sizeof(**p)))
1085 return opt && odr_ok(o);
1087 z_DatabaseName(o, &(*p)->db, 1) &&
1088 odr_implicit(o, odr_integer, &(*p)->num, ODR_CONTEXT, 1, 1) &&
1089 z_OtherInformation(o, &(*p)->otherDbInfo, 1) &&
1090 odr_sequence_end(o);
1093 int z_ByDatabaseList(ODR o, Z_ByDatabaseList **p, int opt)
1095 if (!odr_initmember(o, p, sizeof(**p)))
1096 return opt && odr_ok(o);
1097 if (odr_sequence_of(o, (Odr_fun)z_ByDatabase, &(*p)->elements, &(*p)->num_elements))
1100 return opt && odr_ok(o);
1103 int z_ScanOccurrences(ODR o, Z_ScanOccurrences **p, int opt)
1107 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_ScanOccurrences_global, (Odr_fun)odr_integer},
1108 {ODR_EXPLICIT, ODR_CONTEXT, 3, Z_ScanOccurrences_byDatabase,
1109 (Odr_fun)z_ByDatabaseList},
1113 if (!odr_initmember(o, p, sizeof(**p)))
1114 return opt && odr_ok(o);
1115 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1118 return opt && odr_ok(o);
1121 int z_OccurrenceByAttributesElem(ODR o, Z_OccurrenceByAttributesElem **p,
1124 if (!odr_sequence_begin(o, p, sizeof(**p)))
1125 return opt && odr_ok(o);
1127 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT,
1129 z_ScanOccurrences(o, &(*p)->occurrences, 1) &&
1130 z_OtherInformation(o, &(*p)->otherOccurInfo, 1) &&
1131 odr_sequence_end(o);
1134 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1136 if (!odr_initmember(o, p, sizeof(**p)))
1137 return opt && odr_ok(o);
1138 if (!odr_sequence_of(o, (Odr_fun)z_OccurrenceByAttributesElem, &(*p)->elements,
1139 &(*p)->num_elements))
1142 return opt && odr_ok(o);
1148 * Incomplete definition of occurencebyattributes.
1151 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1153 if (!odr_sequence_begin(o, p, sizeof(**p)))
1154 return opt && odr_ok(o);
1156 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
1157 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
1158 odr_sequence_end(o);
1163 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
1165 if (!odr_sequence_begin(o, p, sizeof(**p)))
1166 return opt && odr_ok(o);
1169 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
1170 z_Term(o, &(*p)->term, 0)) &&
1171 odr_implicit(o, z_InternationalString, &(*p)->displayTerm, ODR_CONTEXT,
1173 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
1174 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
1175 ODR_CONTEXT, 4, 1) &&
1176 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
1178 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
1179 ODR_CONTEXT, 3, 1) &&
1180 z_OtherInformation(o, &(*p)->otherTermInfo, 1) &&
1181 odr_sequence_end(o);
1184 int z_Entry(ODR o, Z_Entry **p, int opt)
1186 static Odr_arm arm[] =
1188 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, (Odr_fun)z_TermInfo},
1189 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
1190 (Odr_fun)z_DiagRec},
1194 if (o->direction == ODR_DECODE)
1195 *p = (Z_Entry *)odr_malloc(o, sizeof(**p));
1199 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1202 return opt && odr_ok(o);
1205 int z_Entries(ODR o, Z_Entries **p, int opt)
1207 if (o->direction == ODR_DECODE)
1208 *p = (Z_Entries *)odr_malloc(o, sizeof(**p));
1212 if (odr_sequence_of(o, (Odr_fun)z_Entry, &(*p)->entries,
1213 &(*p)->num_entries))
1219 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
1221 static Odr_arm arm[] =
1223 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, (Odr_fun)z_Entries},
1224 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
1225 (Odr_fun)z_DiagRecs},
1229 if (o->direction == ODR_DECODE)
1230 *p = (Z_ListEntries *)odr_malloc(o, sizeof(**p));
1234 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1237 return opt && odr_ok(o);
1240 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
1242 if (!odr_sequence_begin(o, p, sizeof(**p)))
1243 return opt && odr_ok(o);
1246 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1247 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1248 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
1249 &(*p)->num_databaseNames) &&
1250 odr_oid(o, &(*p)->attributeSet, 1) &&
1251 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
1252 ((*p)->termListAndStartPoint ? 1 :
1253 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
1254 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
1255 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
1256 ODR_CONTEXT, 6, 0) &&
1257 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
1258 ODR_CONTEXT, 7, 1) &&
1259 odr_sequence_end(o);
1262 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
1264 if (!odr_sequence_begin(o, p, sizeof(**p)))
1265 return opt && odr_ok(o);
1267 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1268 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
1269 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
1270 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
1271 ODR_CONTEXT, 5, 0) &&
1272 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
1273 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
1274 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
1275 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1276 odr_sequence_end(o);
1279 /* ------------------------ SEARCHRESPONSE ----------------*/
1281 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
1283 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
1286 int z_NextResultSetPosition(ODR o, int **p, int opt)
1288 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
1291 int z_PresentStatus(ODR o, int **p, int opt)
1293 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
1296 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
1298 Z_SearchResponse *pp;
1300 if (!odr_sequence_begin(o, p, sizeof(**p)))
1301 return opt && odr_ok(o);
1304 z_ReferenceId(o, &pp->referenceId, 1) &&
1305 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
1306 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1307 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1308 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
1309 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26,
1311 z_PresentStatus(o, &pp->presentStatus, 1) &&
1312 z_Records(o, &pp->records, 1) &&
1314 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
1315 ODR_CONTEXT, 203, 1) &&
1316 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1318 odr_sequence_end(o);
1321 /* --------------------- PRESENT SERVICE ---------------------- */
1323 int z_ElementSpec(ODR o, Z_ElementSpec **p, int opt)
1325 static Odr_arm arm[] =
1327 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSpec_elementSetName,
1329 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ElementSpec_externalSpec,
1330 (Odr_fun)z_External},
1334 if (o->direction == ODR_DECODE)
1335 *p = (Z_ElementSpec *)odr_malloc(o, sizeof(**p));
1339 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1342 return opt && odr_ok(o);
1345 int z_Specification(ODR o, Z_Specification **p, int opt)
1347 if (!odr_sequence_begin(o, p, sizeof(**p)))
1348 return opt && odr_ok(o);
1350 odr_implicit(o, odr_oid, &(*p)->schema, ODR_CONTEXT, 1, 1) &&
1351 z_ElementSpec(o, &(*p)->elementSpec, 1) &&
1352 odr_sequence_end(o);
1355 int z_DbSpecific(ODR o, Z_DbSpecific **p, int opt)
1357 if (!odr_sequence_begin(o, p, sizeof(**p)))
1358 return opt && odr_ok(o);
1360 odr_explicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
1362 odr_implicit(o, z_Specification, &(*p)->spec, ODR_CONTEXT, 2, 0) &&
1363 odr_sequence_end(o);
1366 int z_CompSpec(ODR o, Z_CompSpec **p, int opt)
1368 if (!odr_sequence_begin(o, p, sizeof(**p)))
1369 return opt && odr_ok(o);
1371 odr_implicit(o, odr_bool, &(*p)->selectAlternativeSyntax, ODR_CONTEXT,
1373 odr_implicit(o, z_Specification, &(*p)->generic, ODR_CONTEXT, 2, 1) &&
1374 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1375 (odr_sequence_of(o, (Odr_fun)z_DbSpecific, &(*p)->dbSpecific,
1376 &(*p)->num_dbSpecific) || odr_ok(o)) &&
1377 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1378 (odr_sequence_of(o, (Odr_fun)odr_oid, &(*p)->recordSyntax,
1379 &(*p)->num_recordSyntax) || odr_ok(o)) &&
1380 odr_sequence_end(o);
1383 int z_RecordComposition(ODR o, Z_RecordComposition **p, int opt)
1385 static Odr_arm arm[] =
1387 {ODR_EXPLICIT, ODR_CONTEXT, 19, Z_RecordComp_simple,
1388 (Odr_fun)z_ElementSetNames},
1389 {ODR_IMPLICIT, ODR_CONTEXT, 209, Z_RecordComp_complex,
1390 (Odr_fun)z_CompSpec},
1394 if (o->direction == ODR_DECODE)
1395 *p = (Z_RecordComposition *)odr_malloc(o, sizeof(**p));
1399 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1402 return opt && odr_ok(o);
1405 int z_Range(ODR o, Z_Range **p, int opt)
1407 if (!odr_sequence_begin(o, p, sizeof(**p)))
1408 return opt && odr_ok(o);
1410 odr_implicit(o, odr_integer, &(*p)->startingPosition, ODR_CONTEXT,
1412 odr_implicit(o, odr_integer, &(*p)->numberOfRecords, ODR_CONTEXT,
1414 odr_sequence_end(o);
1417 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
1419 Z_PresentRequest *pp;
1421 if (!odr_sequence_begin(o, p, sizeof(**p)))
1422 return opt && odr_ok(o);
1425 z_ReferenceId(o, &pp->referenceId, 1) &&
1426 z_ResultSetId(o, &pp->resultSetId, 0) &&
1427 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
1429 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
1432 odr_implicit_settag(o, ODR_CONTEXT, 212) &&
1433 (odr_sequence_of(o, (Odr_fun)z_Range, &(*p)->additionalRanges,
1434 &(*p)->num_ranges) || odr_ok(o)) &&
1435 z_RecordComposition(o, &(*p)->recordComposition, 1) &&
1437 odr_explicit(o, z_ElementSetNames, &pp->elementSetNames, ODR_CONTEXT,
1440 odr_implicit(o, odr_oid, &(*p)->preferredRecordSyntax, ODR_CONTEXT,
1443 odr_implicit(o, odr_integer, &(*p)->maxSegmentCount, ODR_CONTEXT,
1445 odr_implicit(o, odr_integer, &(*p)->maxRecordSize, ODR_CONTEXT,
1447 odr_implicit(o, odr_integer, &(*p)->maxSegmentSize, ODR_CONTEXT,
1449 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1451 odr_sequence_end(o);
1454 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
1456 Z_PresentResponse *pp;
1458 if (!odr_sequence_begin(o, p, sizeof(**p)))
1459 return opt && odr_ok(o);
1462 z_ReferenceId(o, &pp->referenceId, 1) &&
1463 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1464 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1465 z_PresentStatus(o, &pp->presentStatus, 0) &&
1466 z_Records(o, &pp->records, 1) &&
1468 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1470 odr_sequence_end(o);
1473 /* ----------------------DELETE -------------------------- */
1475 int z_DeleteSetStatus(ODR o, int **p, int opt)
1477 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
1480 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
1482 if (!odr_sequence_begin(o, p, sizeof(**p)))
1483 return opt && odr_ok(o);
1485 z_ResultSetId(o, &(*p)->id, 0) &&
1486 z_DeleteSetStatus(o, &(*p)->status, 0) &&
1487 odr_sequence_end(o);
1490 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
1492 if (!odr_sequence_begin(o, p, sizeof(**p)))
1493 return opt && odr_ok(o);
1495 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1496 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
1498 (odr_sequence_of(o, z_ResultSetId, &(*p)->resultSetList,
1499 &(*p)->num_resultSetList) || odr_ok(o)) &&
1501 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1503 odr_sequence_end(o);
1506 int z_ListStatuses (ODR o, Z_ListStatuses **p, int opt)
1508 if (!odr_initmember (o, p, sizeof(**p)))
1509 return opt && odr_ok(o);
1510 if (odr_sequence_of (o, (Odr_fun) z_ListStatus, &(*p)->elements,
1514 return opt && odr_ok(o);
1517 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
1519 if (!odr_sequence_begin(o, p, sizeof(**p)))
1520 return opt && odr_ok(o);
1522 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1523 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
1524 ODR_CONTEXT, 0, 0) &&
1525 odr_implicit (o, z_ListStatuses,
1526 &(*p)->deleteListStatuses, ODR_CONTEXT, 1, 1) &&
1527 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
1529 odr_implicit (o, z_ListStatuses,
1530 &(*p)->bulkStatuses, ODR_CONTEXT, 35, 1) &&
1531 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
1534 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1536 odr_sequence_end(o);
1539 /* ------------------------ SEGMENT SERVICE -------------- */
1541 int z_Segment(ODR o, Z_Segment **p, int opt)
1543 if (!odr_sequence_begin(o, p, sizeof(**p)))
1544 return opt && odr_ok(o);
1546 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1547 odr_implicit(o, odr_integer, &(*p)->numberOfRecordsReturned,
1548 ODR_CONTEXT, 24, 0) &&
1549 odr_implicit_settag(o, ODR_CONTEXT, 0) &&
1550 odr_sequence_of(o, (Odr_fun)z_NamePlusRecord, &(*p)->segmentRecords,
1551 &(*p)->num_segmentRecords) &&
1552 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1553 odr_sequence_end(o);
1556 /* ------------------------ CLOSE SERVICE ---------------- */
1558 int z_Close(ODR o, Z_Close **p, int opt)
1560 if (!odr_sequence_begin(o, p, sizeof(**p)))
1561 return opt && odr_ok(o);
1563 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1564 odr_implicit(o, odr_integer, &(*p)->closeReason, ODR_CONTEXT, 211, 0) &&
1565 odr_implicit(o, odr_visiblestring, &(*p)->diagnosticInformation,
1566 ODR_CONTEXT, 3, 1) &&
1567 odr_implicit(o, odr_oid, &(*p)->resourceReportFormat, ODR_CONTEXT,
1569 odr_implicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1572 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1574 odr_sequence_end(o);
1577 /* ------------------------ APDU ------------------------- */
1579 int z_Permissions(ODR o, Z_Permissions **p, int opt)
1581 if (!odr_sequence_begin(o, p, sizeof(**p)))
1582 return opt && odr_ok(o);
1584 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT,
1586 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
1587 odr_sequence_of(o, (Odr_fun)odr_integer, &(*p)->allowableFunctions,
1588 &(*p)->num_allowableFunctions) &&
1589 odr_sequence_end(o);
1592 int z_ExtendedServicesRequest(ODR o, Z_ExtendedServicesRequest **p, int opt)
1594 if (!odr_sequence_begin(o, p, sizeof(**p)))
1595 return opt && odr_ok(o);
1597 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1598 odr_implicit(o, odr_integer, &(*p)->function, ODR_CONTEXT, 3, 0) &&
1599 odr_implicit(o, odr_oid, &(*p)->packageType, ODR_CONTEXT, 4, 0) &&
1600 odr_implicit(o, z_InternationalString, &(*p)->packageName, ODR_CONTEXT, 5, 1) &&
1601 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT, 6, 1) &&
1602 odr_implicit(o, z_IntUnit, &(*p)->retentionTime, ODR_CONTEXT, 7, 1) &&
1603 odr_implicit(o, z_Permissions, &(*p)->permissions, ODR_CONTEXT, 8, 1) &&
1604 odr_implicit(o, z_InternationalString, &(*p)->description, ODR_CONTEXT, 9, 1) &&
1605 odr_implicit(o, z_External, &(*p)->taskSpecificParameters, ODR_CONTEXT, 10, 1) &&
1606 odr_implicit(o, odr_integer, &(*p)->waitAction, ODR_CONTEXT, 11, 0) &&
1607 z_ElementSetName(o, &(*p)->elements, 1) &&
1608 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1609 odr_sequence_end(o);
1612 int z_ExtendedServicesResponse(ODR o, Z_ExtendedServicesResponse **p, int opt)
1614 if (!odr_sequence_begin(o, p, sizeof(**p)))
1615 return opt && odr_ok(o);
1617 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1618 odr_implicit(o, odr_integer, &(*p)->operationStatus, ODR_CONTEXT, 3, 0) &&
1619 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1620 (odr_sequence_of(o, (Odr_fun)z_DiagRec, &(*p)->diagnostics,
1621 &(*p)->num_diagnostics) || odr_ok(o)) &&
1622 odr_implicit(o, z_External, &(*p)->taskPackage, ODR_CONTEXT, 5, 1) &&
1623 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1624 odr_sequence_end(o);
1627 /* ------------------------ SORT ------------------------- */
1629 int z_SortAttributes(ODR o, Z_SortAttributes **p, int opt)
1631 if (!odr_sequence_begin(o, p, sizeof(**p)))
1632 return opt && odr_ok(o);
1634 odr_oid(o, &(*p)->id, 0) &&
1635 z_AttributeList(o, &(*p)->list, 0) &&
1636 odr_sequence_end(o);
1639 int z_SortKey(ODR o, Z_SortKey **p, int opt)
1641 static Odr_arm arm[] =
1643 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_SortKey_sortField,
1644 z_InternationalString},
1645 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortKey_elementSpec, (Odr_fun)z_Specification},
1646 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortKey_sortAttributes,
1647 (Odr_fun)z_SortAttributes},
1651 if (!odr_initmember(o, p, sizeof(**p)))
1652 return opt && odr_ok(o);
1653 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1656 return opt && odr_ok(o);
1659 int z_SortDbSpecific(ODR o, Z_SortDbSpecific **p, int opt)
1661 if (!odr_sequence_begin(o, p, sizeof(**p)))
1662 return opt && odr_ok(o);
1664 z_DatabaseName(o, &(*p)->databaseName, 0) &&
1665 z_SortKey(o, &(*p)->dbSort, 0) &&
1666 odr_sequence_end(o);
1669 int z_SortDbSpecificList(ODR o, Z_SortDbSpecificList **p, int opt)
1671 if (!odr_initmember(o, p, sizeof(**p)))
1672 return opt && odr_ok(o);
1673 if (odr_sequence_of(o, (Odr_fun)z_SortDbSpecific, &(*p)->dbSpecific,
1674 &(*p)->num_dbSpecific))
1677 return opt && odr_ok(o);
1680 int z_SortElement(ODR o, Z_SortElement **p, int opt)
1682 static Odr_arm arm[] =
1684 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_SortElement_generic, (Odr_fun)z_SortKey},
1685 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortElement_databaseSpecific,
1686 (Odr_fun)z_SortDbSpecificList},
1690 if (!odr_initmember(o, p, sizeof(**p)))
1691 return opt && odr_ok(o);
1692 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1695 return opt && odr_ok(o);
1698 int z_SortMissingValueAction(ODR o, Z_SortMissingValueAction **p, int opt)
1700 static Odr_arm arm[] =
1702 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortMissingValAct_abort, (Odr_fun)odr_null},
1703 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortMissingValAct_null, (Odr_fun)odr_null},
1704 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_SortMissingValAct_valData,
1705 (Odr_fun)odr_octetstring},
1709 if (!odr_initmember(o, p, sizeof(**p)))
1710 return opt && odr_ok(o);
1711 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1714 return opt && odr_ok(o);
1717 int z_SortKeySpec(ODR o, Z_SortKeySpec **p, int opt)
1719 if (!odr_sequence_begin(o, p, sizeof(**p)))
1720 return opt && odr_ok(o);
1722 z_SortElement(o, &(*p)->sortElement, 0) &&
1723 odr_implicit(o, odr_integer, &(*p)->sortRelation, ODR_CONTEXT, 1, 0) &&
1724 odr_implicit(o, odr_integer, &(*p)->caseSensitivity, ODR_CONTEXT,
1726 odr_explicit(o, z_SortMissingValueAction, &(*p)->missingValueAction,
1727 ODR_CONTEXT, 3, 1) &&
1728 odr_sequence_end(o);
1731 int z_SortResponse(ODR o, Z_SortResponse **p, int opt)
1733 if (!odr_sequence_begin(o, p, sizeof(**p)))
1734 return opt && odr_ok(o);
1736 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1737 odr_implicit(o, odr_integer, &(*p)->sortStatus, ODR_CONTEXT,
1739 odr_implicit(o, odr_integer, &(*p)->resultSetStatus, ODR_CONTEXT,
1741 odr_implicit(o, z_DiagRecs, &(*p)->diagnostics, ODR_CONTEXT, 5, 1) &&
1742 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1743 odr_sequence_end(o);
1746 int z_SortKeySpecList(ODR o, Z_SortKeySpecList **p, int opt)
1748 if (!odr_initmember(o, p, sizeof(**p)))
1749 return opt && odr_ok(o);
1750 if (odr_sequence_of(o, (Odr_fun)z_SortKeySpec, &(*p)->specs, &(*p)->num_specs))
1753 return opt && odr_ok(o);
1756 int z_SortRequest(ODR o, Z_SortRequest **p, int opt)
1758 if (!odr_sequence_begin(o, p, sizeof(**p)))
1759 return opt && odr_ok(o);
1761 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1762 odr_implicit(o, z_StringList, &(*p)->inputResultSetNames,
1763 ODR_CONTEXT, 3, 0) &&
1764 odr_implicit(o, z_InternationalString, &(*p)->sortedResultSetName,
1765 ODR_CONTEXT, 4, 0) &&
1766 odr_implicit(o, z_SortKeySpecList, &(*p)->sortSequence, ODR_CONTEXT,
1768 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1769 odr_sequence_end(o);
1772 /* ---------------------- Resource Report ---------------- */
1774 int z_ResourceReportRequest(ODR o, Z_ResourceReportRequest **p, int opt)
1776 if (!odr_sequence_begin(o, p, sizeof(**p)))
1777 return opt && odr_ok(o);
1779 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1780 odr_implicit(o, z_ReferenceId, &(*p)->opId, ODR_CONTEXT, 210, 1) &&
1781 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat, ODR_CONTEXT,
1783 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1784 odr_sequence_end(o);
1787 int z_ResourceReportResponse(ODR o, Z_ResourceReportResponse **p, int opt)
1789 if (!odr_sequence_begin(o, p, sizeof(**p)))
1790 return opt && odr_ok(o);
1792 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1793 odr_implicit(o, odr_integer, &(*p)->resourceReportStatus,
1794 ODR_CONTEXT, 50, 0) &&
1795 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1797 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1798 odr_sequence_end(o);
1801 /* ------------------------ APDU ------------------------- */
1803 int z_APDU(ODR o, Z_APDU **p, int opt)
1805 static Odr_arm arm[] =
1807 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, (Odr_fun)z_InitRequest},
1808 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, (Odr_fun)z_InitResponse},
1809 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, (Odr_fun)z_SearchRequest},
1810 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
1811 (Odr_fun)z_SearchResponse},
1812 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
1813 (Odr_fun)z_PresentRequest},
1814 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
1815 (Odr_fun)z_PresentResponse},
1816 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
1817 (Odr_fun)z_DeleteResultSetRequest},
1818 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
1819 (Odr_fun)z_DeleteResultSetResponse},
1820 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_APDU_accessControlRequest,
1821 (Odr_fun)z_AccessControlRequest},
1822 {ODR_IMPLICIT, ODR_CONTEXT, 29, Z_APDU_accessControlResponse,
1823 (Odr_fun)z_AccessControlResponse},
1824 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
1825 (Odr_fun)z_ResourceControlRequest},
1826 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
1827 (Odr_fun)z_ResourceControlResponse},
1828 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
1829 (Odr_fun)z_TriggerResourceControlRequest},
1830 {ODR_IMPLICIT, ODR_CONTEXT, 33, Z_APDU_resourceReportRequest,
1831 (Odr_fun)z_ResourceReportRequest},
1832 {ODR_IMPLICIT, ODR_CONTEXT, 34, Z_APDU_resourceReportResponse,
1833 (Odr_fun)z_ResourceReportResponse},
1834 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, (Odr_fun)z_ScanRequest},
1835 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, (Odr_fun)z_ScanResponse},
1836 {ODR_IMPLICIT, ODR_CONTEXT, 43, Z_APDU_sortRequest, (Odr_fun)z_SortRequest},
1837 {ODR_IMPLICIT, ODR_CONTEXT, 44, Z_APDU_sortResponse, (Odr_fun)z_SortResponse},
1838 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_APDU_segmentRequest, (Odr_fun)z_Segment},
1839 {ODR_IMPLICIT, ODR_CONTEXT, 46, Z_APDU_extendedServicesRequest,
1840 (Odr_fun)z_ExtendedServicesRequest},
1841 {ODR_IMPLICIT, ODR_CONTEXT, 47, Z_APDU_extendedServicesResponse,
1842 (Odr_fun)z_ExtendedServicesResponse},
1843 {ODR_IMPLICIT, ODR_CONTEXT, 48, Z_APDU_close, (Odr_fun)z_Close},
1848 if (o->direction == ODR_DECODE)
1849 *p = (Z_APDU *)odr_malloc(o, sizeof(**p));
1850 odr_setlenlen(o, 5);
1851 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
1853 if (o->direction == ODR_DECODE)
1855 return opt && odr_ok(o);