2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.52 1996-10-08 12:56:57 adam
8 * Bug fix: tagging of type 101 query.
10 * Revision 1.51 1996/07/26 14:07:21 quinn
13 * Revision 1.50 1996/07/26 13:36:15 quinn
16 * Revision 1.49 1996/07/06 19:58:28 quinn
17 * System headerfiles gathered in yconfig
19 * Revision 1.48 1996/06/10 08:53:33 quinn
20 * Added Summary,OPAC,ResourceReport
22 * Revision 1.47 1996/05/29 15:47:50 quinn
23 * Fixed in bug DiagRecs decoder. Thanks to Linda Harris.
25 * Revision 1.46 1996/04/10 11:39:42 quinn
26 * Fixed bug in UserInfo
28 * Revision 1.45 1996/02/23 10:00:25 quinn
31 * Revision 1.44 1996/02/20 12:51:41 quinn
32 * Completed SCAN. Fixed problems with EXTERNAL.
34 * Revision 1.43 1996/02/10 12:22:49 quinn
37 * Revision 1.42 1996/01/22 09:46:31 quinn
38 * Added Sort PDU. Moved StringList to main protocol file.
40 * Revision 1.41 1996/01/10 15:21:24 quinn
41 * Added links to access control PDUs
43 * Revision 1.40 1996/01/02 11:46:40 quinn
44 * Changed 'operator' to 'roperator' to avoid C++ conflict.
46 * Revision 1.39 1995/09/29 17:11:53 quinn
49 * Revision 1.38 1995/09/27 15:02:40 quinn
50 * Modified function heads & prototypes.
52 * Revision 1.37 1995/08/21 09:10:15 quinn
53 * Smallish fixes to suppport new formats.
55 * Revision 1.36 1995/08/15 11:59:39 quinn
58 * Revision 1.35 1995/08/10 08:53:59 quinn
61 * Revision 1.34 1995/06/19 17:01:48 quinn
62 * This should bring us in sync with the version distributed as 1.0b
64 * Revision 1.33 1995/06/19 13:39:56 quinn
65 * *** empty log message ***
67 * Revision 1.32 1995/06/19 12:37:28 quinn
68 * Fixed a bug in the compspec.
70 * Revision 1.31 1995/06/16 13:15:56 quinn
71 * Fixed Defaultdiagformat.
73 * Revision 1.30 1995/06/15 15:42:01 quinn
76 * Revision 1.29 1995/06/15 07:44:49 quinn
79 * Revision 1.28 1995/06/14 15:26:35 quinn
80 * *** empty log message ***
82 * Revision 1.27 1995/06/07 14:36:22 quinn
85 * Revision 1.26 1995/06/02 09:49:13 quinn
86 * Adding access control
88 * Revision 1.25 1995/05/25 11:00:08 quinn
89 * *** empty log message ***
91 * Revision 1.24 1995/05/22 13:58:18 quinn
92 * Fixed an ODR_NULLVAL.
94 * Revision 1.23 1995/05/22 11:30:18 quinn
95 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
97 * Revision 1.22 1995/05/17 08:40:56 quinn
98 * Added delete. Fixed some sequence_begins. Smallish.
100 * Revision 1.21 1995/05/16 08:50:24 quinn
101 * License, documentation, and memory fixes
103 * Revision 1.20 1995/05/15 11:55:25 quinn
106 * Revision 1.19 1995/04/11 11:58:35 quinn
109 * Revision 1.18 1995/04/11 11:52:02 quinn
110 * Fixed possible buf in proto.c
112 * Revision 1.17 1995/04/10 10:22:22 quinn
115 * Revision 1.16 1995/03/30 10:26:43 quinn
116 * Added Term structure
118 * Revision 1.15 1995/03/30 09:08:39 quinn
119 * Added Resource control protocol
121 * Revision 1.14 1995/03/29 08:06:13 quinn
122 * Added a few v3 elements
124 * Revision 1.13 1995/03/20 11:26:52 quinn
125 * *** empty log message ***
127 * Revision 1.12 1995/03/20 09:45:09 quinn
130 * Revision 1.11 1995/03/17 10:17:25 quinn
131 * Added memory management.
133 * Revision 1.10 1995/03/15 11:17:40 quinn
134 * Fixed some return-checks from choice.. need better ay to handle those..
136 * Revision 1.9 1995/03/15 08:37:06 quinn
137 * Fixed protocol bugs.
139 * Revision 1.8 1995/03/14 16:59:24 quinn
140 * Fixed OPTIONAL flag in attributeelement
142 * Revision 1.7 1995/03/07 16:29:33 quinn
143 * Added authentication stuff.
145 * Revision 1.6 1995/03/01 14:46:03 quinn
146 * Fixed protocol bug in 8777query.
148 * Revision 1.5 1995/02/14 11:54:22 quinn
151 * Revision 1.4 1995/02/10 15:54:30 quinn
154 * Revision 1.3 1995/02/09 15:51:39 quinn
157 * Revision 1.2 1995/02/06 21:26:07 quinn
158 * Repaired this evening's damages..
160 * Revision 1.1 1995/02/06 16:44:47 quinn
161 * First hack at Z/SR protocol
169 /* ---------------------- GLOBAL DEFS ------------------- */
172 * We'll use a general octetstring here, since string operations are
173 * clumsy on long strings.
175 int z_SUTRS(ODR o, Odr_oct **p, int opt)
177 return odr_implicit(o, odr_octetstring, p, ODR_UNIVERSAL,
178 ODR_GENERALSTRING, opt);
181 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
183 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
186 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
188 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
192 int z_ResultSetId(ODR o, char **p, int opt)
194 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
198 int z_ElementSetName(ODR o, char **p, int opt)
200 return odr_implicit(o, odr_visiblestring, p, ODR_CONTEXT, 103, opt);
203 int z_UserInformationField(ODR o, Z_External **p, int opt)
205 return odr_explicit(o, z_External, (Z_External **)p, ODR_CONTEXT,
209 int z_InternationalString(ODR o, char **p, int opt)
211 return odr_generalstring(o, p, opt);
214 int z_InfoCategory(ODR o, Z_InfoCategory **p, int opt)
216 if (!odr_sequence_begin(o, p, sizeof(**p)))
217 return opt && odr_ok(o);
219 odr_implicit(o, odr_oid, &(*p)->categoryTypeId, ODR_CONTEXT, 1, 1) &&
220 odr_implicit(o, odr_integer, &(*p)->categoryValue, ODR_CONTEXT, 2, 0) &&
224 int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt)
226 static Odr_arm arm[] =
228 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_OtherInfo_characterInfo,
230 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_OtherInfo_binaryInfo,
232 {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_OtherInfo_externallyDefinedInfo,
234 {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_OtherInfo_oid, odr_oid},
238 if (!odr_sequence_begin(o, p, sizeof(**p)))
239 return opt && odr_ok(o);
241 odr_implicit(o, z_InfoCategory, &(*p)->category, ODR_CONTEXT, 1, 1) &&
242 odr_choice(o, arm, &(*p)->information, &(*p)->which) &&
246 int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt)
248 if (o->direction == ODR_DECODE)
249 *p = odr_malloc(o, sizeof(**p));
252 odr_implicit_settag(o, ODR_CONTEXT, 201);
253 if (odr_sequence_of(o, z_OtherInformationUnit, &(*p)->list,
254 &(*p)->num_elements))
257 return opt && odr_ok(o);
260 int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt)
262 static Odr_arm arm[] =
264 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_StringOrNumeric_string,
266 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_StringOrNumeric_numeric,
271 if (o->direction == ODR_DECODE)
272 *p = odr_malloc(o, sizeof(**p));
275 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
278 return opt && odr_ok(o);
284 int z_Unit(ODR o, Z_Unit **p, int opt)
286 if (!odr_sequence_begin(o, p, sizeof(**p)))
287 return opt && odr_ok(o);
289 odr_explicit(o, z_InternationalString, &(*p)->unitSystem, ODR_CONTEXT,
291 odr_explicit(o, z_StringOrNumeric, &(*p)->unitType, ODR_CONTEXT,
293 odr_explicit(o, z_StringOrNumeric, &(*p)->unit, ODR_CONTEXT, 3, 1) &&
294 odr_implicit(o, odr_integer, &(*p)->scaleFactor, ODR_CONTEXT, 4, 1) &&
298 int z_IntUnit(ODR o, Z_IntUnit **p, int opt)
300 if (!odr_sequence_begin(o, p, sizeof(**p)))
301 return opt && odr_ok(o);
303 odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 1, 0) &&
304 odr_implicit(o, z_Unit, &(*p)->unitUsed, ODR_CONTEXT, 2, 0) &&
308 int z_StringList(ODR o, Z_StringList **p, int opt)
310 if (o->direction == ODR_DECODE)
311 *p = odr_malloc(o, sizeof(**p));
314 if (odr_sequence_of(o, z_InternationalString, &(*p)->strings,
318 return opt && odr_ok(o);
321 /* ---------------------- INITIALIZE SERVICE ------------------- */
324 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
326 if (!odr_sequence_begin(o, p, sizeof(**p)))
327 return opt && odr_ok(o);
329 odr_visiblestring(o, &(*p)->user, 0) &&
330 odr_visiblestring(o, &(*p)->password, 0) &&
331 odr_visiblestring(o, &(*p)->account, 0) &&
336 int z_IdPass(ODR o, Z_IdPass **p, int opt)
338 if (!odr_sequence_begin(o, p, sizeof(**p)))
339 return opt && odr_ok(o);
341 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 1) &&
342 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 1) &&
343 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
348 int z_StrAuthentication(ODR o, char **p, int opt)
350 return odr_visiblestring(o, p, opt);
353 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
355 static Odr_arm arm[] =
357 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
358 {-1, -1, -1, Z_IdAuthentication_idPass, z_IdPass},
359 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
360 {-1, -1, -1, Z_IdAuthentication_other, z_External},
364 if (o->direction == ODR_DECODE)
365 *p = odr_malloc(o, sizeof(**p));
369 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
372 return opt && odr_ok(o);
375 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
379 if (!odr_sequence_begin(o, p, sizeof(**p)))
380 return opt && odr_ok(o);
383 z_ReferenceId(o, &pp->referenceId, 1) &&
384 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
386 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
387 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
389 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
391 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
393 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
395 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
397 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
398 ODR_CONTEXT, 112, 1) &&
399 z_UserInformationField(o, &pp->userInformationField, 1) &&
401 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
406 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
410 if (!odr_sequence_begin(o, p, sizeof(**p)))
411 return opt && odr_ok(o);
414 z_ReferenceId(o, &pp->referenceId, 1) &&
415 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
417 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
418 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
420 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
422 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
423 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
425 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
427 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
428 ODR_CONTEXT, 112, 1) &&
429 z_UserInformationField(o, &pp->userInformationField, 1) &&
431 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
436 /* ------------------ RESOURCE CONTROL ----------------*/
438 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
441 if (!odr_sequence_begin(o, p, sizeof(**p)))
442 return opt && odr_ok(o);
444 z_ReferenceId(o, &(*p)->referenceId, 1) &&
445 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
447 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
448 ODR_CONTEXT, 47, 1) &&
449 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
452 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
457 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
459 if (!odr_sequence_begin(o, p, sizeof(**p)))
460 return opt && odr_ok(o);
462 z_ReferenceId(o, &(*p)->referenceId, 1) &&
463 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
464 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
466 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
467 ODR_CONTEXT, 41, 1) &&
468 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
470 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
471 ODR_CONTEXT, 43, 1) &&
473 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
478 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
480 if (!odr_sequence_begin(o, p, sizeof(**p)))
481 return opt && odr_ok(o);
483 z_ReferenceId(o, &(*p)->referenceId, 1) &&
484 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
485 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
488 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
493 /* ------------------------ SEARCH SERVICE ----------------------- */
495 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
497 if (!odr_sequence_begin(o, p, sizeof(**p)))
498 return opt && odr_ok(o);
500 z_DatabaseName(o, &(*p)->databaseName, 0) &&
501 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
505 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
507 if (o->direction == ODR_DECODE)
508 *p = odr_malloc(o, sizeof(**p));
512 odr_implicit_settag(o, ODR_CONTEXT, 1);
513 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
514 &(*p)->num_elements))
520 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
522 static Odr_arm arm[] =
524 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
526 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
531 if (o->direction == ODR_DECODE)
532 *p = odr_malloc(o, sizeof(**p));
534 return opt && odr_ok(o);
536 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
542 /* ----------------------- RPN QUERY -----------------------*/
544 int z_ComplexAttribute(ODR o, Z_ComplexAttribute **p, int opt)
546 if (!odr_sequence_begin(o, p, sizeof(**p)))
547 return opt && odr_ok(o);
549 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
550 odr_sequence_of(o, z_StringOrNumeric, &(*p)->list,
552 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
553 (odr_sequence_of(o, odr_integer, &(*p)->semanticAction,
554 &(*p)->num_semanticAction) || odr_ok(o)) &&
558 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
561 static Odr_arm arm[] =
563 {ODR_IMPLICIT, ODR_CONTEXT, 121, Z_AttributeValue_numeric,
565 {ODR_IMPLICIT, ODR_CONTEXT, 224, Z_AttributeValue_complex,
571 if (!odr_sequence_begin(o, p, sizeof(**p)))
572 return opt && odr_ok(o);
575 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 1, 1) &&
577 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
580 odr_choice(o, arm, &(*p)->value, &(*p)->which) &&
582 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
588 int z_Term(ODR o, Z_Term **p, int opt)
590 static Odr_arm arm[] =
592 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
593 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
594 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
596 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
597 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
598 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, z_External},
599 /* add intUnit here */
600 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
604 if (o->direction ==ODR_DECODE)
605 *p = odr_malloc(o, sizeof(**p));
608 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
611 return opt && odr_ok(o);
614 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
616 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
617 odr_sequence_begin(o, p, sizeof(**p))))
618 return opt && odr_ok(o);
620 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
621 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
622 &(*p)->num_attributes) &&
623 z_Term(o, &(*p)->term, 0) &&
627 int z_ResultSetPlusAttributes(ODR o, Z_ResultSetPlusAttributes **p, int opt)
629 if (!(odr_implicit_settag(o, ODR_CONTEXT, 214) &&
630 odr_sequence_begin(o, p, sizeof(**p))))
631 return opt && odr_ok(o);
633 z_ResultSetId(o, &(*p)->resultSet, 0) &&
634 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
635 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
636 &(*p)->num_attributes) &&
640 int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
642 static Odr_arm arm[] =
644 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, odr_integer},
645 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_private, odr_integer},
649 if (!odr_sequence_begin(o, p, sizeof(**p)))
650 return opt && odr_ok(o);
652 odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
653 odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
654 odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
655 odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
656 odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
657 odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
658 odr_constructed_end(o) &&
662 int z_Operator(ODR o, Z_Operator **p, int opt)
664 static Odr_arm arm[] =
666 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
667 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
668 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
669 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, z_ProximityOperator},
673 if (!*p && o->direction != ODR_DECODE)
675 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
676 return opt && odr_ok(o);
677 if (o->direction == ODR_DECODE)
678 *p = odr_malloc(o, sizeof(**p));
680 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
681 odr_constructed_end(o))
684 return opt && odr_ok(o);
687 int z_Operand(ODR o, Z_Operand **p, int opt)
689 static Odr_arm arm[] =
691 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
692 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
693 {-1, -1, -1, Z_Operand_resultAttr, z_ResultSetPlusAttributes},
697 if (o->direction == ODR_DECODE)
698 *p = odr_malloc(o, sizeof(**p));
701 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
704 return opt && odr_ok(o);
707 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
709 int z_Complex(ODR o, Z_Complex **p, int opt)
711 if (!odr_sequence_begin(o, p, sizeof(**p)))
712 return opt && odr_ok(o);
714 z_RPNStructure(o, &(*p)->s1, 0) &&
715 z_RPNStructure(o, &(*p)->s2, 0) &&
716 z_Operator(o, &(*p)->roperator, 0) &&
720 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
722 static Odr_arm arm[] =
724 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
725 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
729 if (o->direction == ODR_DECODE)
730 *p = odr_malloc(o, sizeof(**p));
733 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
736 return opt && odr_ok(o);
739 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
741 if (!odr_sequence_begin(o, p, sizeof(**p)))
742 return opt && odr_ok(o);
744 odr_oid(o, &(*p)->attributeSetId, 0) &&
745 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
749 /* -----------------------END RPN QUERY ----------------------- */
751 int z_Query(ODR o, Z_Query **p, int opt)
753 static Odr_arm arm[] =
755 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
756 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
757 {ODR_IMPLICIT, ODR_CONTEXT, 101, Z_Query_type_101, z_RPNQuery},
761 if (o->direction == ODR_DECODE)
762 *p = odr_malloc(o, sizeof(**p));
765 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
768 return opt && odr_ok(o);
771 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
775 if (!odr_sequence_begin(o, p, sizeof(**p)))
776 return opt && odr_ok(o);
779 z_ReferenceId(o, &pp->referenceId, 1) &&
780 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
782 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
784 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
786 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
787 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
789 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
790 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
791 &pp->num_databaseNames) &&
792 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
793 ODR_CONTEXT, 100, 1) &&
794 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
795 ODR_CONTEXT, 101, 1) &&
796 odr_implicit(o, odr_oid, &pp->preferredRecordSyntax,
797 ODR_CONTEXT, 104, 1) &&
798 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
800 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
801 ODR_CONTEXT, 203, 1) &&
802 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
807 /* ------------------------ RECORD ------------------------- */
809 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
811 return z_External(o, (Z_External **) p, opt);
816 int z_DefaultDiagFormat(ODR o, Z_DefaultDiagFormat **p, int opt)
818 static Odr_arm arm[] =
820 {-1, -1, -1, Z_DiagForm_v2AddInfo, odr_visiblestring},
821 {-1, -1, -1, Z_DiagForm_v3AddInfo, z_InternationalString},
822 {ODR_IMPLICIT, ODR_CONTEXT, ODR_VISIBLESTRING, Z_DiagForm_v2AddInfo,
823 odr_visiblestring}, /* To cater to a bug in the CNIDR servers */
826 if (!odr_sequence_begin(o, p, sizeof(**p)))
827 return opt && odr_ok(o);
829 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
830 odr_integer(o, &(*p)->condition, 0) &&
832 * I no longer recall what server tagged the addinfo.. but it isn't
833 * hurting anyone, so...
834 * We need to turn it into a choice, or something, because of
835 * that damn generalstring in v3.
837 odr_choice(o, arm, &(*p)->addinfo, &(*p)->which) &&
841 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
843 static Odr_arm arm[] =
845 {-1, -1, -1, Z_DiagRec_defaultFormat, z_DefaultDiagFormat},
846 {-1, -1, -1, Z_DiagRec_externallyDefined, z_External},
850 if (o->direction == ODR_DECODE)
851 *p = odr_malloc(o, sizeof(**p));
854 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
857 return opt && odr_ok(o);
862 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
864 if (!odr_sequence_begin(o, p, sizeof(**p)))
865 return opt && odr_ok(o);
867 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
868 odr_integer(o, &(*p)->condition, 0) &&
870 * I no longer recall what server tagged the addinfo.. but it isn't
871 * hurting anyone, so...
872 * We need to turn it into a choice, or something, because of
873 * that damn generalstring in v3.
875 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
876 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT,
877 ODR_VISIBLESTRING, 1)) &&
883 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
885 if (o->direction == ODR_DECODE)
886 *p = odr_malloc(o, sizeof(**p));
890 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
891 &(*p)->num_diagRecs))
894 return opt && odr_ok(o);
897 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
899 static Odr_arm arm[] =
901 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
903 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
908 if (!odr_sequence_begin(o, p, sizeof(**p)))
909 return opt && odr_ok(o);
911 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
913 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
914 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
915 odr_constructed_end(o) &&
919 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
921 if (o->direction == ODR_DECODE)
922 *p = odr_malloc(o, sizeof(**p));
925 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
932 int z_Records(ODR o, Z_Records **p, int opt)
934 static Odr_arm arm[] =
936 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
937 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
938 {ODR_IMPLICIT, ODR_CONTEXT, 205, Z_Records_multipleNSD,
943 if (o->direction == ODR_DECODE)
944 *p = odr_malloc(o, sizeof(**p));
947 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
950 return opt && odr_ok(o);
953 /* ------------------------ ACCESS CTRL SERVICE ----------------------- */
955 int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
957 static Odr_arm arm[] =
959 {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
961 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
965 if (!odr_sequence_begin(o, p, sizeof(**p)))
966 return opt && odr_ok(o);
968 z_ReferenceId(o, &(*p)->referenceId, 1) &&
969 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
971 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
976 int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
978 static Odr_arm arm[] =
980 {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
982 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
986 if (!odr_sequence_begin(o, p, sizeof(**p)))
987 return opt && odr_ok(o);
989 z_ReferenceId(o, &(*p)->referenceId, 1) &&
990 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
991 odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
993 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
998 /* ------------------------ SCAN SERVICE -------------------- */
1000 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
1002 if (o->direction == ODR_DECODE)
1003 *p = odr_malloc(o, sizeof(**p));
1007 odr_implicit_settag(o, ODR_CONTEXT, 44);
1008 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
1009 &(*p)->num_attributes))
1012 return opt && odr_ok(o);
1016 * This is a temporary hack. We don't know just *what* old version of the
1017 * protocol willow uses, so we'll just patiently wait for them to update
1019 static int willow_scan = 0;
1021 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
1023 if (!*p && o->direction != ODR_DECODE)
1025 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
1028 return opt && odr_ok(o);
1030 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
1032 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
1034 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
1036 if (o->direction == ODR_DECODE)
1037 *p = odr_malloc(o, sizeof(**p));
1038 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
1039 &(*p)->num_attributes))
1041 if (!odr_sequence_end(o) || !odr_sequence_end(o))
1043 if (!z_Term(o, &(*p)->term, 0))
1045 if (!odr_constructed_end(o))
1051 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
1053 if (o->direction == ODR_DECODE)
1054 *p = odr_malloc(o, sizeof(**p));
1058 return opt && odr_ok(o);
1061 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
1065 return opt && !o->error;
1070 int z_ByDatabase(ODR o, Z_ByDatabase **p, int opt)
1072 if (!odr_sequence_begin(o, p, sizeof(**p)))
1073 return opt && odr_ok(o);
1075 z_DatabaseName(o, &(*p)->db, 1) &&
1076 odr_implicit(o, odr_integer, &(*p)->num, ODR_CONTEXT, 1, 1) &&
1077 z_OtherInformation(o, &(*p)->otherDbInfo, 1) &&
1078 odr_sequence_end(o);
1081 int z_ByDatabaseList(ODR o, Z_ByDatabaseList **p, int opt)
1083 if (!odr_initmember(o, p, sizeof(**p)))
1084 return opt && odr_ok(o);
1085 if (odr_sequence_of(o, z_ByDatabase, &(*p)->elements, &(*p)->num_elements))
1088 return opt && odr_ok(o);
1091 int z_ScanOccurrences(ODR o, Z_ScanOccurrences **p, int opt)
1095 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_ScanOccurrences_global, odr_integer},
1096 {ODR_EXPLICIT, ODR_CONTEXT, 3, Z_ScanOccurrences_byDatabase,
1101 if (!odr_initmember(o, p, sizeof(**p)))
1102 return opt && odr_ok(o);
1103 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1106 return opt && odr_ok(o);
1109 int z_OccurrenceByAttributesElem(ODR o, Z_OccurrenceByAttributesElem **p,
1112 if (!odr_sequence_begin(o, p, sizeof(**p)))
1113 return opt && odr_ok(o);
1115 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT,
1117 z_ScanOccurrences(o, &(*p)->occurrences, 1) &&
1118 z_OtherInformation(o, &(*p)->otherOccurInfo, 1) &&
1119 odr_sequence_end(o);
1122 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1124 if (!odr_initmember(o, p, sizeof(**p)))
1125 return opt && odr_ok(o);
1126 if (!odr_sequence_of(o, z_OccurrenceByAttributesElem, &(*p)->elements,
1127 &(*p)->num_elements))
1130 return opt && odr_ok(o);
1136 * Incomplete definition of occurencebyattributes.
1139 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1141 if (!odr_sequence_begin(o, p, sizeof(**p)))
1142 return opt && odr_ok(o);
1144 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
1145 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
1146 odr_sequence_end(o);
1151 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
1153 if (!odr_sequence_begin(o, p, sizeof(**p)))
1154 return opt && odr_ok(o);
1157 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
1158 z_Term(o, &(*p)->term, 0)) &&
1159 odr_implicit(o, z_InternationalString, &(*p)->displayTerm, ODR_CONTEXT,
1161 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
1162 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
1163 ODR_CONTEXT, 4, 1) &&
1164 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
1166 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
1167 ODR_CONTEXT, 3, 1) &&
1168 z_OtherInformation(o, &(*p)->otherTermInfo, 1) &&
1169 odr_sequence_end(o);
1172 int z_Entry(ODR o, Z_Entry **p, int opt)
1174 static Odr_arm arm[] =
1176 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
1177 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
1182 if (o->direction == ODR_DECODE)
1183 *p = odr_malloc(o, sizeof(**p));
1187 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1190 return opt && odr_ok(o);
1193 int z_Entries(ODR o, Z_Entries **p, int opt)
1195 if (o->direction == ODR_DECODE)
1196 *p = odr_malloc(o, sizeof(**p));
1200 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
1201 &(*p)->num_entries))
1207 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
1209 static Odr_arm arm[] =
1211 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
1212 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
1217 if (o->direction == ODR_DECODE)
1218 *p = odr_malloc(o, sizeof(**p));
1222 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1225 return opt && odr_ok(o);
1228 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
1230 if (!odr_sequence_begin(o, p, sizeof(**p)))
1231 return opt && odr_ok(o);
1234 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1235 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1236 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
1237 &(*p)->num_databaseNames) &&
1238 odr_oid(o, &(*p)->attributeSet, 1) &&
1239 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
1240 ((*p)->termListAndStartPoint ? 1 :
1241 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
1242 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
1243 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
1244 ODR_CONTEXT, 6, 0) &&
1245 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
1246 ODR_CONTEXT, 7, 1) &&
1247 odr_sequence_end(o);
1250 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
1252 if (!odr_sequence_begin(o, p, sizeof(**p)))
1253 return opt && odr_ok(o);
1255 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1256 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
1257 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
1258 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
1259 ODR_CONTEXT, 5, 0) &&
1260 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
1261 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
1262 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
1263 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1264 odr_sequence_end(o);
1267 /* ------------------------ SEARCHRESPONSE ----------------*/
1269 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
1271 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
1274 int z_NextResultSetPosition(ODR o, int **p, int opt)
1276 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
1279 int z_PresentStatus(ODR o, int **p, int opt)
1281 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
1284 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
1286 Z_SearchResponse *pp;
1288 if (!odr_sequence_begin(o, p, sizeof(**p)))
1289 return opt && odr_ok(o);
1292 z_ReferenceId(o, &pp->referenceId, 1) &&
1293 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
1294 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1295 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1296 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
1297 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26,
1299 z_PresentStatus(o, &pp->presentStatus, 1) &&
1300 z_Records(o, &pp->records, 1) &&
1302 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
1303 ODR_CONTEXT, 203, 1) &&
1304 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1306 odr_sequence_end(o);
1309 /* --------------------- PRESENT SERVICE ---------------------- */
1311 int z_ElementSpec(ODR o, Z_ElementSpec **p, int opt)
1313 static Odr_arm arm[] =
1315 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSpec_elementSetName,
1317 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ElementSpec_externalSpec,
1322 if (o->direction == ODR_DECODE)
1323 *p = odr_malloc(o, sizeof(**p));
1327 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1330 return opt && odr_ok(o);
1333 int z_Specification(ODR o, Z_Specification **p, int opt)
1335 if (!odr_sequence_begin(o, p, sizeof(**p)))
1336 return opt && odr_ok(o);
1338 odr_implicit(o, odr_oid, &(*p)->schema, ODR_CONTEXT, 1, 1) &&
1339 z_ElementSpec(o, &(*p)->elementSpec, 1) &&
1340 odr_sequence_end(o);
1343 int z_DbSpecific(ODR o, Z_DbSpecific **p, int opt)
1345 if (!odr_sequence_begin(o, p, sizeof(**p)))
1346 return opt && odr_ok(o);
1348 odr_explicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
1350 odr_implicit(o, z_Specification, &(*p)->spec, ODR_CONTEXT, 2, 0) &&
1351 odr_sequence_end(o);
1354 int z_CompSpec(ODR o, Z_CompSpec **p, int opt)
1356 if (!odr_sequence_begin(o, p, sizeof(**p)))
1357 return opt && odr_ok(o);
1359 odr_implicit(o, odr_bool, &(*p)->selectAlternativeSyntax, ODR_CONTEXT,
1361 odr_implicit(o, z_Specification, &(*p)->generic, ODR_CONTEXT, 2, 1) &&
1362 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1363 (odr_sequence_of(o, z_DbSpecific, &(*p)->dbSpecific,
1364 &(*p)->num_dbSpecific) || odr_ok(o)) &&
1365 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1366 (odr_sequence_of(o, odr_oid, &(*p)->recordSyntax,
1367 &(*p)->num_recordSyntax) || odr_ok(o)) &&
1368 odr_sequence_end(o);
1371 int z_RecordComposition(ODR o, Z_RecordComposition **p, int opt)
1373 static Odr_arm arm[] =
1375 {ODR_EXPLICIT, ODR_CONTEXT, 19, Z_RecordComp_simple,
1377 {ODR_IMPLICIT, ODR_CONTEXT, 209, Z_RecordComp_complex,
1382 if (o->direction == ODR_DECODE)
1383 *p = odr_malloc(o, sizeof(**p));
1387 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1390 return opt && odr_ok(o);
1393 int z_Range(ODR o, Z_Range **p, int opt)
1395 if (!odr_sequence_begin(o, p, sizeof(**p)))
1396 return opt && odr_ok(o);
1398 odr_implicit(o, odr_integer, &(*p)->startingPosition, ODR_CONTEXT,
1400 odr_implicit(o, odr_integer, &(*p)->numberOfRecords, ODR_CONTEXT,
1402 odr_sequence_end(o);
1405 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
1407 Z_PresentRequest *pp;
1409 if (!odr_sequence_begin(o, p, sizeof(**p)))
1410 return opt && odr_ok(o);
1413 z_ReferenceId(o, &pp->referenceId, 1) &&
1414 z_ResultSetId(o, &pp->resultSetId, 0) &&
1415 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
1417 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
1420 odr_implicit_settag(o, ODR_CONTEXT, 212) &&
1421 (odr_sequence_of(o, z_Range, &(*p)->additionalRanges,
1422 &(*p)->num_ranges) || odr_ok(o)) &&
1423 z_RecordComposition(o, &(*p)->recordComposition, 1) &&
1425 odr_explicit(o, z_ElementSetNames, &pp->elementSetNames, ODR_CONTEXT,
1428 odr_implicit(o, odr_oid, &(*p)->preferredRecordSyntax, ODR_CONTEXT,
1431 odr_implicit(o, odr_integer, &(*p)->maxSegmentCount, ODR_CONTEXT,
1433 odr_implicit(o, odr_integer, &(*p)->maxRecordSize, ODR_CONTEXT,
1435 odr_implicit(o, odr_integer, &(*p)->maxSegmentSize, ODR_CONTEXT,
1437 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1439 odr_sequence_end(o);
1442 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
1444 Z_PresentResponse *pp;
1446 if (!odr_sequence_begin(o, p, sizeof(**p)))
1447 return opt && odr_ok(o);
1450 z_ReferenceId(o, &pp->referenceId, 1) &&
1451 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1452 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1453 z_PresentStatus(o, &pp->presentStatus, 0) &&
1454 z_Records(o, &pp->records, 1) &&
1456 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1458 odr_sequence_end(o);
1461 /* ----------------------DELETE -------------------------- */
1463 int z_DeleteSetStatus(ODR o, int **p, int opt)
1465 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
1468 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
1470 if (!odr_sequence_begin(o, p, sizeof(**p)))
1471 return opt && odr_ok(o);
1473 z_ResultSetId(o, &(*p)->id, 0) &&
1474 z_DeleteSetStatus(o, &(*p)->status, 0) &&
1475 odr_sequence_end(o);
1478 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
1480 if (!odr_sequence_begin(o, p, sizeof(**p)))
1481 return opt && odr_ok(o);
1483 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1484 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
1486 (odr_sequence_of(o, z_ListStatus, &(*p)->resultSetList,
1487 &(*p)->num_ids) || odr_ok(o)) &&
1489 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1491 odr_sequence_end(o);
1494 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
1496 if (!odr_sequence_begin(o, p, sizeof(**p)))
1497 return opt && odr_ok(o);
1499 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1500 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
1501 ODR_CONTEXT, 0, 1) &&
1502 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
1503 (odr_sequence_of(o, z_ListStatus, &(*p)->deleteListStatuses,
1504 &(*p)->num_statuses) || odr_ok(o)) &&
1505 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
1507 odr_implicit_settag(o, ODR_CONTEXT, 35) &&
1508 (odr_sequence_of(o, z_ListStatus, &(*p)->bulkStatuses,
1509 &(*p)->num_bulkStatuses) || odr_ok(o)) &&
1510 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
1513 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1515 odr_sequence_end(o);
1518 /* ------------------------ SEGMENT SERVICE -------------- */
1520 int z_Segment(ODR o, Z_Segment **p, int opt)
1522 if (!odr_sequence_begin(o, p, sizeof(**p)))
1523 return opt && odr_ok(o);
1525 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1526 odr_implicit(o, odr_integer, &(*p)->numberOfRecordsReturned,
1527 ODR_CONTEXT, 24, 0) &&
1528 odr_implicit_settag(o, ODR_CONTEXT, 0) &&
1529 odr_sequence_of(o, z_NamePlusRecord, &(*p)->segmentRecords,
1530 &(*p)->num_segmentRecords) &&
1531 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1532 odr_sequence_end(o);
1535 /* ------------------------ CLOSE SERVICE ---------------- */
1537 int z_Close(ODR o, Z_Close **p, int opt)
1539 if (!odr_sequence_begin(o, p, sizeof(**p)))
1540 return opt && odr_ok(o);
1542 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1543 odr_implicit(o, odr_integer, &(*p)->closeReason, ODR_CONTEXT, 211, 0) &&
1544 odr_implicit(o, odr_visiblestring, &(*p)->diagnosticInformation,
1545 ODR_CONTEXT, 3, 1) &&
1546 odr_implicit(o, odr_oid, &(*p)->resourceReportFormat, ODR_CONTEXT,
1548 odr_implicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1551 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1553 odr_sequence_end(o);
1556 /* ------------------------ APDU ------------------------- */
1558 int z_Permissions(ODR o, Z_Permissions **p, int opt)
1560 if (!odr_sequence_begin(o, p, sizeof(**p)))
1561 return opt && odr_ok(o);
1563 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT,
1565 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
1566 odr_sequence_of(o, odr_integer, &(*p)->allowableFunctions,
1567 &(*p)->num_allowableFunctions) &&
1568 odr_sequence_end(o);
1571 int z_ExtendedServicesRequest(ODR o, Z_ExtendedServicesRequest **p, int opt)
1573 if (!odr_sequence_begin(o, p, sizeof(**p)))
1574 return opt && odr_ok(o);
1576 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1577 odr_implicit(o, odr_integer, &(*p)->function, ODR_CONTEXT, 3, 0) &&
1578 odr_implicit(o, odr_oid, &(*p)->packageType, ODR_CONTEXT, 4, 0) &&
1579 odr_implicit(o, z_InternationalString, &(*p)->packageName, ODR_CONTEXT, 5, 1) &&
1580 odr_implicit(o, z_InternationalString, &(*p)->userId, ODR_CONTEXT, 6, 1) &&
1581 odr_implicit(o, z_IntUnit, &(*p)->retentionTime, ODR_CONTEXT, 7, 1) &&
1582 odr_implicit(o, z_Permissions, &(*p)->permissions, ODR_CONTEXT, 8, 1) &&
1583 odr_implicit(o, z_InternationalString, &(*p)->description, ODR_CONTEXT, 9, 1) &&
1584 odr_implicit(o, z_External, &(*p)->taskSpecificParameters, ODR_CONTEXT, 10, 1) &&
1585 odr_implicit(o, odr_integer, &(*p)->waitAction, ODR_CONTEXT, 11, 0) &&
1586 z_ElementSetName(o, &(*p)->elements, 1) &&
1587 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1588 odr_sequence_end(o);
1591 int z_ExtendedServicesResponse(ODR o, Z_ExtendedServicesResponse **p, int opt)
1593 if (!odr_sequence_begin(o, p, sizeof(**p)))
1594 return opt && odr_ok(o);
1596 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1597 odr_implicit(o, odr_integer, &(*p)->operationStatus, ODR_CONTEXT, 3, 0) &&
1598 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1599 (odr_sequence_of(o, z_DiagRec, &(*p)->diagnostics,
1600 &(*p)->num_diagnostics) || odr_ok(o)) &&
1601 odr_implicit(o, z_External, &(*p)->taskPackage, ODR_CONTEXT, 5, 1) &&
1602 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1603 odr_sequence_end(o);
1606 /* ------------------------ SORT ------------------------- */
1608 int z_SortAttributes(ODR o, Z_SortAttributes **p, int opt)
1610 if (!odr_sequence_begin(o, p, sizeof(**p)))
1611 return opt && odr_ok(o);
1613 odr_oid(o, &(*p)->id, 0) &&
1614 z_AttributeList(o, &(*p)->list, 0) &&
1615 odr_sequence_end(o);
1618 int z_SortKey(ODR o, Z_SortKey **p, int opt)
1620 static Odr_arm arm[] =
1622 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_SortKey_sortField,
1623 z_InternationalString},
1624 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortKey_elementSpec, z_Specification},
1625 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortKey_sortAttributes,
1630 if (!odr_initmember(o, p, sizeof(**p)))
1631 return opt && odr_ok(o);
1632 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1635 return opt && odr_ok(o);
1638 int z_SortDbSpecific(ODR o, Z_SortDbSpecific **p, int opt)
1640 if (!odr_sequence_begin(o, p, sizeof(**p)))
1641 return opt && odr_ok(o);
1643 z_DatabaseName(o, &(*p)->databaseName, 0) &&
1644 z_SortKey(o, &(*p)->dbSort, 0) &&
1645 odr_sequence_end(o);
1648 int z_SortDbSpecificList(ODR o, Z_SortDbSpecificList **p, int opt)
1650 if (!odr_initmember(o, p, sizeof(**p)))
1651 return opt && odr_ok(o);
1652 if (odr_sequence_of(o, z_SortDbSpecific, &(*p)->dbSpecific,
1653 &(*p)->num_dbSpecific))
1656 return opt && odr_ok(o);
1659 int z_SortElement(ODR o, Z_SortElement **p, int opt)
1661 static Odr_arm arm[] =
1663 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_SortElement_generic, z_SortKey},
1664 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortElement_databaseSpecific,
1665 z_SortDbSpecificList},
1669 if (!odr_initmember(o, p, sizeof(**p)))
1670 return opt && odr_ok(o);
1671 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1674 return opt && odr_ok(o);
1677 int z_SortMissingValueAction(ODR o, Z_SortMissingValueAction **p, int opt)
1679 static Odr_arm arm[] =
1681 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_SortMissingValAct_abort, odr_null},
1682 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_SortMissingValAct_null, odr_null},
1683 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_SortMissingValAct_valData,
1688 if (!odr_initmember(o, p, sizeof(**p)))
1689 return opt && odr_ok(o);
1690 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1693 return opt && odr_ok(o);
1696 int z_SortKeySpec(ODR o, Z_SortKeySpec **p, int opt)
1698 if (!odr_sequence_begin(o, p, sizeof(**p)))
1699 return opt && odr_ok(o);
1701 z_SortElement(o, &(*p)->sortElement, 0) &&
1702 odr_implicit(o, odr_integer, &(*p)->sortRelation, ODR_CONTEXT, 1, 0) &&
1703 odr_implicit(o, odr_integer, &(*p)->caseSensitivity, ODR_CONTEXT,
1705 odr_explicit(o, z_SortMissingValueAction, &(*p)->missingValueAction,
1706 ODR_CONTEXT, 3, 1) &&
1707 odr_sequence_end(o);
1710 int z_SortResponse(ODR o, Z_SortResponse **p, int opt)
1712 if (!odr_sequence_begin(o, p, sizeof(**p)))
1713 return opt && odr_ok(o);
1715 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1716 odr_implicit(o, odr_integer, &(*p)->sortStatus, ODR_CONTEXT,
1718 odr_implicit(o, odr_integer, &(*p)->resultSetStatus, ODR_CONTEXT,
1720 odr_implicit(o, z_DiagRecs, &(*p)->diagnostics, ODR_CONTEXT, 5, 1) &&
1721 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1722 odr_sequence_end(o);
1725 int z_SortKeySpecList(ODR o, Z_SortKeySpecList **p, int opt)
1727 if (!odr_initmember(o, p, sizeof(**p)))
1728 return opt && odr_ok(o);
1729 if (odr_sequence_of(o, z_SortKeySpec, &(*p)->specs, &(*p)->num_specs))
1732 return opt && odr_ok(o);
1735 int z_SortRequest(ODR o, Z_SortRequest **p, int opt)
1737 if (!odr_sequence_begin(o, p, sizeof(**p)))
1738 return opt && odr_ok(o);
1740 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1741 odr_implicit(o, z_StringList, &(*p)->inputResultSetNames,
1742 ODR_CONTEXT, 3, 0) &&
1743 odr_implicit(o, z_InternationalString, &(*p)->sortedResultSetName,
1744 ODR_CONTEXT, 4, 0) &&
1745 odr_implicit(o, z_SortKeySpecList, &(*p)->sortSequence, ODR_CONTEXT,
1747 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1748 odr_sequence_end(o);
1751 /* ---------------------- Resource Report ---------------- */
1753 int z_ResourceReportRequest(ODR o, Z_ResourceReportRequest **p, int opt)
1755 if (!odr_sequence_begin(o, p, sizeof(**p)))
1756 return opt && odr_ok(o);
1758 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1759 odr_implicit(o, z_ReferenceId, &(*p)->opId, ODR_CONTEXT, 210, 1) &&
1760 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat, ODR_CONTEXT,
1762 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1763 odr_sequence_end(o);
1766 int z_ResourceReportResponse(ODR o, Z_ResourceReportResponse **p, int opt)
1768 if (!odr_sequence_begin(o, p, sizeof(**p)))
1769 return opt && odr_ok(o);
1771 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1772 odr_implicit(o, odr_integer, &(*p)->resourceReportStatus,
1773 ODR_CONTEXT, 50, 0) &&
1774 odr_explicit(o, z_External, &(*p)->resourceReport, ODR_CONTEXT,
1776 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1777 odr_sequence_end(o);
1780 /* ------------------------ APDU ------------------------- */
1782 int z_APDU(ODR o, Z_APDU **p, int opt)
1784 static Odr_arm arm[] =
1786 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
1787 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
1788 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
1789 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
1791 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
1793 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
1795 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
1796 z_DeleteResultSetRequest},
1797 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
1798 z_DeleteResultSetResponse},
1799 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_APDU_accessControlRequest,
1800 z_AccessControlRequest},
1801 {ODR_IMPLICIT, ODR_CONTEXT, 29, Z_APDU_accessControlResponse,
1802 z_AccessControlResponse},
1803 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
1804 z_ResourceControlRequest},
1805 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
1806 z_ResourceControlResponse},
1807 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
1808 z_TriggerResourceControlRequest},
1809 {ODR_IMPLICIT, ODR_CONTEXT, 33, Z_APDU_resourceReportRequest,
1810 z_ResourceReportRequest},
1811 {ODR_IMPLICIT, ODR_CONTEXT, 34, Z_APDU_resourceReportResponse,
1812 z_ResourceReportResponse},
1813 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
1814 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
1815 {ODR_IMPLICIT, ODR_CONTEXT, 43, Z_APDU_sortRequest, z_SortRequest},
1816 {ODR_IMPLICIT, ODR_CONTEXT, 44, Z_APDU_sortResponse, z_SortResponse},
1817 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_APDU_segmentRequest, z_Segment},
1818 {ODR_IMPLICIT, ODR_CONTEXT, 46, Z_APDU_extendedServicesRequest,
1819 z_ExtendedServicesRequest},
1820 {ODR_IMPLICIT, ODR_CONTEXT, 47, Z_APDU_extendedServicesResponse,
1821 z_ExtendedServicesResponse},
1822 {ODR_IMPLICIT, ODR_CONTEXT, 48, Z_APDU_close, z_Close},
1827 if (o->direction == ODR_DECODE)
1828 *p = odr_malloc(o, sizeof(**p));
1829 odr_setlenlen(o, 5);
1830 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
1832 if (o->direction == ODR_DECODE)
1834 return opt && odr_ok(o);