2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.34 1995-06-19 17:01:48 quinn
8 * This should bring us in sync with the version distributed as 1.0b
10 * Revision 1.33 1995/06/19 13:39:56 quinn
11 * *** empty log message ***
13 * Revision 1.32 1995/06/19 12:37:28 quinn
14 * Fixed a bug in the compspec.
16 * Revision 1.31 1995/06/16 13:15:56 quinn
17 * Fixed Defaultdiagformat.
19 * Revision 1.30 1995/06/15 15:42:01 quinn
22 * Revision 1.29 1995/06/15 07:44:49 quinn
25 * Revision 1.28 1995/06/14 15:26:35 quinn
26 * *** empty log message ***
28 * Revision 1.27 1995/06/07 14:36:22 quinn
31 * Revision 1.26 1995/06/02 09:49:13 quinn
32 * Adding access control
34 * Revision 1.25 1995/05/25 11:00:08 quinn
35 * *** empty log message ***
37 * Revision 1.24 1995/05/22 13:58:18 quinn
38 * Fixed an ODR_NULLVAL.
40 * Revision 1.23 1995/05/22 11:30:18 quinn
41 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
43 * Revision 1.22 1995/05/17 08:40:56 quinn
44 * Added delete. Fixed some sequence_begins. Smallish.
46 * Revision 1.21 1995/05/16 08:50:24 quinn
47 * License, documentation, and memory fixes
49 * Revision 1.20 1995/05/15 11:55:25 quinn
52 * Revision 1.19 1995/04/11 11:58:35 quinn
55 * Revision 1.18 1995/04/11 11:52:02 quinn
56 * Fixed possible buf in proto.c
58 * Revision 1.17 1995/04/10 10:22:22 quinn
61 * Revision 1.16 1995/03/30 10:26:43 quinn
62 * Added Term structure
64 * Revision 1.15 1995/03/30 09:08:39 quinn
65 * Added Resource control protocol
67 * Revision 1.14 1995/03/29 08:06:13 quinn
68 * Added a few v3 elements
70 * Revision 1.13 1995/03/20 11:26:52 quinn
71 * *** empty log message ***
73 * Revision 1.12 1995/03/20 09:45:09 quinn
76 * Revision 1.11 1995/03/17 10:17:25 quinn
77 * Added memory management.
79 * Revision 1.10 1995/03/15 11:17:40 quinn
80 * Fixed some return-checks from choice.. need better ay to handle those..
82 * Revision 1.9 1995/03/15 08:37:06 quinn
83 * Fixed protocol bugs.
85 * Revision 1.8 1995/03/14 16:59:24 quinn
86 * Fixed OPTIONAL flag in attributeelement
88 * Revision 1.7 1995/03/07 16:29:33 quinn
89 * Added authentication stuff.
91 * Revision 1.6 1995/03/01 14:46:03 quinn
92 * Fixed protocol bug in 8777query.
94 * Revision 1.5 1995/02/14 11:54:22 quinn
97 * Revision 1.4 1995/02/10 15:54:30 quinn
100 * Revision 1.3 1995/02/09 15:51:39 quinn
103 * Revision 1.2 1995/02/06 21:26:07 quinn
104 * Repaired this evening's damages..
106 * Revision 1.1 1995/02/06 16:44:47 quinn
107 * First hack at Z/SR protocol
115 /* ---------------------- GLOBAL DEFS ------------------- */
118 * We'll use a general octetstring here, since string operations are
119 * clumsy on long strings.
121 int z_SUTRS(ODR o, Odr_oct **p, int opt)
123 return odr_implicit(o, odr_octetstring, p, ODR_UNIVERSAL,
124 ODR_GENERALSTRING, opt);
127 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
129 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
132 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
134 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
138 int z_ResultSetId(ODR o, char **p, int opt)
140 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
144 int z_UserInformationField(ODR o, Odr_external **p, int opt)
146 return odr_explicit(o, odr_external, (Odr_external **)p, ODR_CONTEXT,
150 int z_InternationalString(ODR o, char **p, int opt)
152 return odr_generalstring(o, p, opt);
155 int z_InfoCategory(ODR o, Z_InfoCategory **p, int opt)
157 if (!odr_sequence_begin(o, p, sizeof(**p)))
158 return opt && odr_ok(o);
160 odr_implicit(o, odr_oid, &(*p)->categoryTypeId, ODR_CONTEXT, 1, 1) &&
161 odr_implicit(o, odr_integer, &(*p)->categoryValue, ODR_CONTEXT, 2, 0) &&
165 int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt)
167 static Odr_arm arm[] =
169 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_OtherInfo_characterInfo,
171 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_OtherInfo_binaryInfo,
173 {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_OtherInfo_externallyDefinedInfo,
175 {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_OtherInfo_oid, odr_oid},
179 if (!odr_sequence_begin(o, p, sizeof(**p)))
180 return opt && odr_ok(o);
182 odr_implicit(o, z_InfoCategory, &(*p)->category, ODR_CONTEXT, 1, 1) &&
183 odr_choice(o, arm, &(*p)->which, &(*p)->information) &&
187 int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt)
189 if (o->direction == ODR_DECODE)
190 *p = odr_malloc(o, sizeof(**p));
193 odr_implicit_settag(o, ODR_CONTEXT, 201);
194 if (odr_sequence_of(o, z_OtherInformationUnit, &(*p)->list,
195 &(*p)->num_elements))
198 return opt && odr_ok(o);
201 int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt)
203 static Odr_arm arm[] =
205 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_StringOrNumeric_string,
207 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_StringOrNumeric_numeric,
212 if (o->direction == ODR_DECODE)
213 *p = odr_malloc(o, sizeof(**p));
216 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
219 return opt && odr_ok(o);
225 int z_Unit(ODR o, Z_Unit **p, int opt)
227 if (!odr_sequence_begin(o, p, sizeof(**p)))
228 return opt && odr_ok(o);
230 odr_implicit(o, odr_visiblestring, &(*p)->unitSystem, ODR_CONTEXT,
232 odr_explicit(o, z_StringOrNumeric, &(*p)->unitType, ODR_CONTEXT,
234 odr_explicit(o, z_StringOrNumeric, &(*p)->unit, ODR_CONTEXT, 3, 1) &&
235 odr_implicit(o, odr_integer, &(*p)->scaleFactor, ODR_CONTEXT, 4, 1) &&
239 int z_IntUnit(ODR o, Z_IntUnit **p, int opt)
241 if (!odr_sequence_begin(o, p, sizeof(**p)))
242 return opt && odr_ok(o);
244 odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 1, 0) &&
245 odr_implicit(o, z_Unit, &(*p)->unitUsed, ODR_CONTEXT, 2, 0) &&
249 /* ---------------------- INITIALIZE SERVICE ------------------- */
252 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
254 if (!odr_sequence_begin(o, p, sizeof(**p)))
255 return opt && odr_ok(o);
257 odr_visiblestring(o, &(*p)->user, 0) &&
258 odr_visiblestring(o, &(*p)->password, 0) &&
259 odr_visiblestring(o, &(*p)->account, 0) &&
264 int z_IdPass(ODR o, Z_IdPass **p, int opt)
266 if (!odr_sequence_begin(o, p, sizeof(**p)))
267 return opt && odr_ok(o);
269 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 1) &&
270 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 1) &&
271 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
276 int z_StrAuthentication(ODR o, char **p, int opt)
278 return odr_visiblestring(o, p, opt);
281 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
283 static Odr_arm arm[] =
285 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
286 {-1, -1, -1, Z_IdAuthentication_idPass, z_IdPass},
287 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
288 {-1, -1, -1, Z_IdAuthentication_other, odr_external},
292 if (o->direction == ODR_DECODE)
293 *p = odr_malloc(o, sizeof(**p));
297 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
300 return opt && odr_ok(o);
303 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
307 if (!odr_sequence_begin(o, p, sizeof(**p)))
308 return opt && odr_ok(o);
311 z_ReferenceId(o, &pp->referenceId, 1) &&
312 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
314 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
315 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
317 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
319 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
321 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
323 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
325 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
326 ODR_CONTEXT, 112, 1) &&
327 z_UserInformationField(o, &pp->userInformationField, 1) &&
329 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
334 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
338 if (!odr_sequence_begin(o, p, sizeof(**p)))
339 return opt && odr_ok(o);
342 z_ReferenceId(o, &pp->referenceId, 1) &&
343 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
345 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
346 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
348 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
350 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
351 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
353 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
355 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
356 ODR_CONTEXT, 112, 1) &&
357 z_UserInformationField(o, &pp->userInformationField, 1) &&
359 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
364 /* ------------------ RESOURCE CONTROL ----------------*/
366 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
369 if (!odr_sequence_begin(o, p, sizeof(**p)))
370 return opt && odr_ok(o);
372 z_ReferenceId(o, &(*p)->referenceId, 1) &&
373 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
375 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
376 ODR_CONTEXT, 47, 1) &&
377 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
380 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
385 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
387 if (!odr_sequence_begin(o, p, sizeof(**p)))
388 return opt && odr_ok(o);
390 z_ReferenceId(o, &(*p)->referenceId, 1) &&
391 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
392 odr_explicit(o, odr_external, &(*p)->resourceReport, ODR_CONTEXT,
394 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
395 ODR_CONTEXT, 41, 1) &&
396 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
398 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
399 ODR_CONTEXT, 43, 1) &&
401 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
406 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
408 if (!odr_sequence_begin(o, p, sizeof(**p)))
409 return opt && odr_ok(o);
411 z_ReferenceId(o, &(*p)->referenceId, 1) &&
412 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
413 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
416 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
421 /* ------------------------ SEARCH SERVICE ----------------------- */
423 int z_ElementSetName(ODR o, char **p, int opt)
425 return odr_implicit(o, odr_visiblestring, (char**) p, ODR_CONTEXT, 103,
429 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
431 if (!odr_sequence_begin(o, p, sizeof(**p)))
432 return opt && odr_ok(o);
434 z_DatabaseName(o, &(*p)->databaseName, 0) &&
435 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
439 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
441 if (o->direction == ODR_DECODE)
442 *p = odr_malloc(o, sizeof(**p));
446 odr_implicit_settag(o, ODR_CONTEXT, 1);
447 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
448 &(*p)->num_elements))
454 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
456 static Odr_arm arm[] =
458 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
460 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
465 if (o->direction == ODR_DECODE)
466 *p = odr_malloc(o, sizeof(**p));
468 return opt && odr_ok(o);
470 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
476 /* ----------------------- RPN QUERY -----------------------*/
478 int z_ComplexAttribute(ODR o, Z_ComplexAttribute **p, int opt)
480 if (!odr_sequence_begin(o, p, sizeof(**p)))
481 return opt && odr_ok(o);
483 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
484 odr_sequence_of(o, z_StringOrNumeric, &(*p)->list,
486 odr_implicit_settag(o, ODR_CONTEXT, 2) &&
487 (odr_sequence_of(o, odr_integer, &(*p)->semanticAction,
488 &(*p)->num_semanticAction) || odr_ok(o)) &&
492 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
495 static Odr_arm arm[] =
497 {ODR_IMPLICIT, ODR_CONTEXT, 121, Z_AttributeValue_numeric,
499 {ODR_IMPLICIT, ODR_CONTEXT, 224, Z_AttributeValue_complex,
505 if (!odr_sequence_begin(o, p, sizeof(**p)))
506 return opt && odr_ok(o);
509 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 1, 1) &&
511 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
514 odr_choice(o, arm, &(*p)->value, &(*p)->which) &&
516 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
522 int z_Term(ODR o, Z_Term **p, int opt)
524 static Odr_arm arm[] =
526 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
527 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
528 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
530 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
531 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
532 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, odr_external},
533 /* add intUnit here */
534 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
538 if (o->direction ==ODR_DECODE)
539 *p = odr_malloc(o, sizeof(**p));
542 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
545 return opt && odr_ok(o);
548 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
550 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
551 odr_sequence_begin(o, p, sizeof(**p))))
552 return opt && odr_ok(o);
554 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
555 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
556 &(*p)->num_attributes) &&
557 z_Term(o, &(*p)->term, 0) &&
561 int z_ResultSetPlusAttributes(ODR o, Z_ResultSetPlusAttributes **p, int opt)
563 if (!(odr_implicit_settag(o, ODR_CONTEXT, 214) &&
564 odr_sequence_begin(o, p, sizeof(**p))))
565 return opt && odr_ok(o);
567 z_ResultSetId(o, &(*p)->resultSet, 0) &&
568 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
569 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
570 &(*p)->num_attributes) &&
574 int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
576 static Odr_arm arm[] =
578 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, odr_integer},
579 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_private, odr_integer},
583 if (!odr_sequence_begin(o, p, sizeof(**p)))
584 return opt && odr_ok(o);
586 odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
587 odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
588 odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
589 odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
590 odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
591 odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
592 odr_constructed_end(o) &&
596 int z_Operator(ODR o, Z_Operator **p, int opt)
598 static Odr_arm arm[] =
600 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
601 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
602 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
603 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, z_ProximityOperator},
607 if (!*p && o->direction != ODR_DECODE)
609 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
610 return opt && odr_ok(o);
611 if (o->direction == ODR_DECODE)
612 *p = odr_malloc(o, sizeof(**p));
614 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
615 odr_constructed_end(o))
618 return opt && odr_ok(o);
621 int z_Operand(ODR o, Z_Operand **p, int opt)
623 static Odr_arm arm[] =
625 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
626 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
627 {-1, -1, -1, Z_Operand_resultAttr, z_ResultSetPlusAttributes},
631 if (o->direction == ODR_DECODE)
632 *p = odr_malloc(o, sizeof(**p));
635 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
638 return opt && odr_ok(o);
641 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
643 int z_Complex(ODR o, Z_Complex **p, int opt)
645 if (!odr_sequence_begin(o, p, sizeof(**p)))
646 return opt && odr_ok(o);
648 z_RPNStructure(o, &(*p)->s1, 0) &&
649 z_RPNStructure(o, &(*p)->s2, 0) &&
650 z_Operator(o, &(*p)->operator, 0) &&
654 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
656 static Odr_arm arm[] =
658 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
659 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
663 if (o->direction == ODR_DECODE)
664 *p = odr_malloc(o, sizeof(**p));
667 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
670 return opt && odr_ok(o);
673 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
675 if (!odr_sequence_begin(o, p, sizeof(**p)))
676 return opt && odr_ok(o);
678 odr_oid(o, &(*p)->attributeSetId, 0) &&
679 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
683 /* -----------------------END RPN QUERY ----------------------- */
685 int z_Query(ODR o, Z_Query **p, int opt)
687 static Odr_arm arm[] =
689 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
690 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
691 {ODR_EXPLICIT, ODR_CONTEXT, 101, Z_Query_type_101, z_RPNQuery},
695 if (o->direction == ODR_DECODE)
696 *p = odr_malloc(o, sizeof(**p));
699 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
702 return opt && odr_ok(o);
705 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
709 if (!odr_sequence_begin(o, p, sizeof(**p)))
710 return opt && odr_ok(o);
713 z_ReferenceId(o, &pp->referenceId, 1) &&
714 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
716 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
718 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
720 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
721 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
723 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
724 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
725 &pp->num_databaseNames) &&
726 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
727 ODR_CONTEXT, 100, 1) &&
728 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
729 ODR_CONTEXT, 101, 1) &&
730 odr_implicit(o, odr_oid, &pp->preferredRecordSyntax,
731 ODR_CONTEXT, 104, 1) &&
732 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
734 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
735 ODR_CONTEXT, 203, 1) &&
736 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
741 /* ------------------------ RECORD ------------------------- */
743 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
745 return odr_external(o, (Odr_external **) p, opt);
750 int z_DefaultDiagFormat(ODR o, Z_DefaultDiagFormat **p, int opt)
752 static Odr_arm arm[] =
754 {-1, -1, -1, Z_DiagForm_v2AddInfo, odr_visiblestring},
755 {-1, -1, -1, Z_DiagForm_v3AddInfo, z_InternationalString},
756 {ODR_IMPLICIT, ODR_CONTEXT, ODR_VISIBLESTRING, Z_DiagForm_v2AddInfo,
757 odr_visiblestring}, /* To cater to a bug in the CNIDR servers */
760 if (!odr_sequence_begin(o, p, sizeof(**p)))
761 return opt && odr_ok(o);
763 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
764 odr_integer(o, &(*p)->condition, 0) &&
766 * I no longer recall what server tagged the addinfo.. but it isn't
767 * hurting anyone, so...
768 * We need to turn it into a choice, or something, because of
769 * that damn generalstring in v3.
771 odr_choice(o, arm, &(*p)->addinfo, &(*p)->which) &&
775 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
777 static Odr_arm arm[] =
779 {-1, -1, -1, Z_DiagRec_defaultFormat, z_DefaultDiagFormat},
780 {-1, -1, -1, Z_DiagRec_externallyDefined, odr_external},
784 if (o->direction == ODR_DECODE)
785 *p = odr_malloc(o, sizeof(**p));
788 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
791 return opt && odr_ok(o);
796 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
798 if (!odr_sequence_begin(o, p, sizeof(**p)))
799 return opt && odr_ok(o);
801 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT! */
802 odr_integer(o, &(*p)->condition, 0) &&
804 * I no longer recall what server tagged the addinfo.. but it isn't
805 * hurting anyone, so...
806 * We need to turn it into a choice, or something, because of
807 * that damn generalstring in v3.
809 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
810 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT,
811 ODR_VISIBLESTRING, 1)) &&
817 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
819 if (o->direction == ODR_DECODE)
820 *p = odr_malloc(o, sizeof(**p));
824 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
825 &(*p)->num_diagRecs))
831 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
833 static Odr_arm arm[] =
835 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
837 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
842 if (!odr_sequence_begin(o, p, sizeof(**p)))
843 return opt && odr_ok(o);
845 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
847 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
848 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
849 odr_constructed_end(o) &&
853 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
855 if (o->direction == ODR_DECODE)
856 *p = odr_malloc(o, sizeof(**p));
859 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
866 int z_Records(ODR o, Z_Records **p, int opt)
868 static Odr_arm arm[] =
870 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
871 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
872 {ODR_IMPLICIT, ODR_CONTEXT, 205, Z_Records_multipleNSD,
877 if (o->direction == ODR_DECODE)
878 *p = odr_malloc(o, sizeof(**p));
881 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
884 return opt && odr_ok(o);
887 /* ------------------------ ACCESS CTRL SERVICE ----------------------- */
889 int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
891 static Odr_arm arm[] =
893 {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
895 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
899 if (!odr_sequence_begin(o, p, sizeof(**p)))
900 return opt && odr_ok(o);
902 z_ReferenceId(o, &(*p)->referenceId, 1) &&
903 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
905 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
910 int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
912 static Odr_arm arm[] =
914 {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
916 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
920 if (!odr_sequence_begin(o, p, sizeof(**p)))
921 return opt && odr_ok(o);
923 z_ReferenceId(o, &(*p)->referenceId, 1) &&
924 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
925 odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
927 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
932 /* ------------------------ SCAN SERVICE -------------------- */
934 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
936 if (o->direction == ODR_DECODE)
937 *p = odr_malloc(o, sizeof(**p));
941 odr_implicit_settag(o, ODR_CONTEXT, 44);
942 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
943 &(*p)->num_attributes))
946 return opt && odr_ok(o);
950 * This is a temporary hack. We don't know just *what* old version of the
951 * protocol willow uses, so we'll just patiently wait for them to update
953 static int willow_scan = 0;
955 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
957 if (!*p && o->direction != ODR_DECODE)
959 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
962 return opt && odr_ok(o);
964 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
966 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
968 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
970 if (o->direction == ODR_DECODE)
971 *p = odr_malloc(o, sizeof(**p));
972 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
973 &(*p)->num_attributes))
975 if (!odr_sequence_end(o) || !odr_sequence_end(o))
977 if (!z_Term(o, &(*p)->term, 0))
979 if (!odr_constructed_end(o))
985 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
987 if (o->direction == ODR_DECODE)
988 *p = odr_malloc(o, sizeof(**p));
992 return opt && odr_ok(o);
995 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
999 return opt && !o->error;
1002 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
1004 if (!odr_sequence_begin(o, p, sizeof(**p)))
1005 return opt && odr_ok(o);
1007 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
1008 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
1009 odr_sequence_end(o);
1012 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
1014 if (!odr_sequence_begin(o, p, sizeof(**p)))
1015 return opt && odr_ok(o);
1018 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
1019 z_Term(o, &(*p)->term, 0)) &&
1020 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
1021 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
1022 ODR_CONTEXT, 4, 1) &&
1023 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
1025 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
1026 ODR_CONTEXT, 3, 1) &&
1027 odr_sequence_end(o);
1030 int z_Entry(ODR o, Z_Entry **p, int opt)
1032 static Odr_arm arm[] =
1034 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
1035 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
1040 if (o->direction == ODR_DECODE)
1041 *p = odr_malloc(o, sizeof(**p));
1045 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1048 return opt && odr_ok(o);
1051 int z_Entries(ODR o, Z_Entries **p, int opt)
1053 if (o->direction == ODR_DECODE)
1054 *p = odr_malloc(o, sizeof(**p));
1058 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
1059 &(*p)->num_entries))
1065 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
1067 static Odr_arm arm[] =
1069 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
1070 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
1075 if (o->direction == ODR_DECODE)
1076 *p = odr_malloc(o, sizeof(**p));
1080 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1083 return opt && odr_ok(o);
1086 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
1088 if (!odr_sequence_begin(o, p, sizeof(**p)))
1089 return opt && odr_ok(o);
1092 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1093 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1094 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
1095 &(*p)->num_databaseNames) &&
1096 odr_oid(o, &(*p)->attributeSet, 1) &&
1097 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
1098 ((*p)->termListAndStartPoint ? 1 :
1099 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
1100 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
1101 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
1102 ODR_CONTEXT, 6, 0) &&
1103 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
1104 ODR_CONTEXT, 7, 1) &&
1105 odr_sequence_end(o);
1108 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
1110 if (!odr_sequence_begin(o, p, sizeof(**p)))
1111 return opt && odr_ok(o);
1113 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1114 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
1115 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
1116 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
1117 ODR_CONTEXT, 5, 0) &&
1118 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
1119 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
1120 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
1121 odr_sequence_end(o);
1124 /* ------------------------ SEARCHRESPONSE ----------------*/
1126 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
1128 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
1131 int z_NextResultSetPosition(ODR o, int **p, int opt)
1133 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
1136 int z_PresentStatus(ODR o, int **p, int opt)
1138 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
1141 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
1143 Z_SearchResponse *pp;
1145 if (!odr_sequence_begin(o, p, sizeof(**p)))
1146 return opt && odr_ok(o);
1149 z_ReferenceId(o, &pp->referenceId, 1) &&
1150 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
1151 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1152 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1153 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
1154 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26,
1156 z_PresentStatus(o, &pp->presentStatus, 1) &&
1157 z_Records(o, &pp->records, 1) &&
1159 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
1160 ODR_CONTEXT, 203, 1) &&
1161 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1163 odr_sequence_end(o);
1166 /* --------------------- PRESENT SERVICE ---------------------- */
1168 int z_ElementSpec(ODR o, Z_ElementSpec **p, int opt)
1170 static Odr_arm arm[] =
1172 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSpec_elementSetName,
1174 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ElementSpec_externalSpec,
1179 if (o->direction == ODR_DECODE)
1180 *p = odr_malloc(o, sizeof(**p));
1184 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1187 return opt && odr_ok(o);
1190 int z_Specification(ODR o, Z_Specification **p, int opt)
1192 if (!odr_sequence_begin(o, p, sizeof(**p)))
1193 return opt && odr_ok(o);
1195 odr_implicit(o, odr_oid, &(*p)->schema, ODR_CONTEXT, 1, 1) &&
1196 z_ElementSpec(o, &(*p)->elementSpec, 1) &&
1197 odr_sequence_end(o);
1200 int z_DbSpecific(ODR o, Z_DbSpecific **p, int opt)
1202 if (!odr_sequence_begin(o, p, sizeof(**p)))
1203 return opt && odr_ok(o);
1205 odr_explicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
1207 odr_implicit(o, z_Specification, &(*p)->spec, ODR_CONTEXT, 2, 0) &&
1208 odr_sequence_end(o);
1211 int z_CompSpec(ODR o, Z_CompSpec **p, int opt)
1213 if (!odr_sequence_begin(o, p, sizeof(**p)))
1214 return opt && odr_ok(o);
1216 odr_implicit(o, odr_bool, &(*p)->selectAlternativeSyntax, ODR_CONTEXT,
1218 odr_implicit(o, z_Specification, &(*p)->generic, ODR_CONTEXT, 2, 1) &&
1219 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
1220 (odr_sequence_of(o, z_DbSpecific, &(*p)->dbSpecific,
1221 &(*p)->num_dbSpecific) || odr_ok(o)) &&
1222 odr_implicit_settag(o, ODR_CONTEXT, 4) &&
1223 (odr_sequence_of(o, odr_oid, &(*p)->recordSyntax,
1224 &(*p)->num_recordSyntax) || odr_ok(o)) &&
1225 odr_sequence_end(o);
1228 int z_RecordComposition(ODR o, Z_RecordComposition **p, int opt)
1230 static Odr_arm arm[] =
1232 {ODR_EXPLICIT, ODR_CONTEXT, 19, Z_RecordComp_simple,
1234 {ODR_IMPLICIT, ODR_CONTEXT, 209, Z_RecordComp_complex,
1239 if (o->direction == ODR_DECODE)
1240 *p = odr_malloc(o, sizeof(**p));
1244 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
1247 return opt && odr_ok(o);
1250 int z_Range(ODR o, Z_Range **p, int opt)
1252 if (!odr_sequence_begin(o, p, sizeof(**p)))
1253 return opt && odr_ok(o);
1255 odr_implicit(o, odr_integer, &(*p)->startingPosition, ODR_CONTEXT,
1257 odr_implicit(o, odr_integer, &(*p)->numberOfRecords, ODR_CONTEXT,
1259 odr_sequence_end(o);
1262 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
1264 Z_PresentRequest *pp;
1266 if (!odr_sequence_begin(o, p, sizeof(**p)))
1267 return opt && odr_ok(o);
1270 z_ReferenceId(o, &pp->referenceId, 1) &&
1271 z_ResultSetId(o, &pp->resultSetId, 0) &&
1272 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
1274 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
1277 odr_implicit_settag(o, ODR_CONTEXT, 212) &&
1278 (odr_sequence_of(o, z_Range, &(*p)->additionalRanges,
1279 &(*p)->num_ranges) || odr_ok(o)) &&
1280 z_RecordComposition(o, &(*p)->recordComposition, 1) &&
1282 odr_explicit(o, z_ElementSetNames, &pp->elementSetNames, ODR_CONTEXT,
1285 odr_implicit(o, odr_oid, &(*p)->preferredRecordSyntax, ODR_CONTEXT,
1288 odr_implicit(o, odr_integer, &(*p)->maxSegmentCount, ODR_CONTEXT,
1290 odr_implicit(o, odr_integer, &(*p)->maxRecordSize, ODR_CONTEXT,
1292 odr_implicit(o, odr_integer, &(*p)->maxSegmentSize, ODR_CONTEXT,
1294 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1296 odr_sequence_end(o);
1299 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
1301 Z_PresentResponse *pp;
1303 if (!odr_sequence_begin(o, p, sizeof(**p)))
1304 return opt && odr_ok(o);
1307 z_ReferenceId(o, &pp->referenceId, 1) &&
1308 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1309 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1310 z_PresentStatus(o, &pp->presentStatus, 0) &&
1311 z_Records(o, &pp->records, 1) &&
1313 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1315 odr_sequence_end(o);
1318 /* ----------------------DELETE -------------------------- */
1320 int z_DeleteSetStatus(ODR o, int **p, int opt)
1322 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
1325 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
1327 if (!odr_sequence_begin(o, p, sizeof(**p)))
1328 return opt && odr_ok(o);
1330 z_ResultSetId(o, &(*p)->id, 0) &&
1331 z_DeleteSetStatus(o, &(*p)->status, 0) &&
1332 odr_sequence_end(o);
1335 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
1337 if (!odr_sequence_begin(o, p, sizeof(**p)))
1338 return opt && odr_ok(o);
1340 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1341 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
1343 (odr_sequence_of(o, z_ListStatus, &(*p)->resultSetList,
1344 &(*p)->num_ids) || odr_ok(o)) &&
1346 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1348 odr_sequence_end(o);
1351 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
1353 if (!odr_sequence_begin(o, p, sizeof(**p)))
1354 return opt && odr_ok(o);
1356 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1357 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
1358 ODR_CONTEXT, 0, 1) &&
1359 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
1360 (odr_sequence_of(o, z_ListStatus, &(*p)->deleteListStatuses,
1361 &(*p)->num_statuses) || odr_ok(o)) &&
1362 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
1364 odr_implicit_settag(o, ODR_CONTEXT, 35) &&
1365 (odr_sequence_of(o, z_ListStatus, &(*p)->bulkStatuses,
1366 &(*p)->num_bulkStatuses) || odr_ok(o)) &&
1367 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
1370 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1372 odr_sequence_end(o);
1375 /* ------------------------ SEGMENT SERVICE -------------- */
1377 int z_Segment(ODR o, Z_Segment **p, int opt)
1379 if (!odr_sequence_begin(o, p, sizeof(**p)))
1380 return opt && odr_ok(o);
1382 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1383 odr_implicit(o, odr_integer, &(*p)->numberOfRecordsReturned,
1384 ODR_CONTEXT, 24, 0) &&
1385 odr_implicit_settag(o, ODR_CONTEXT, 0) &&
1386 odr_sequence_of(o, z_NamePlusRecord, &(*p)->segmentRecords,
1387 &(*p)->num_segmentRecords) &&
1388 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1389 odr_sequence_end(o);
1392 /* ------------------------ CLOSE SERVICE ---------------- */
1394 int z_Close(ODR o, Z_Close **p, int opt)
1396 if (!odr_sequence_begin(o, p, sizeof(**p)))
1397 return opt && odr_ok(o);
1399 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1400 odr_implicit(o, odr_integer, &(*p)->closeReason, ODR_CONTEXT, 211, 0) &&
1401 odr_implicit(o, odr_visiblestring, &(*p)->diagnosticInformation,
1402 ODR_CONTEXT, 3, 1) &&
1403 odr_implicit(o, odr_oid, &(*p)->resourceReportFormat, ODR_CONTEXT,
1405 odr_implicit(o, odr_external, &(*p)->resourceReport, ODR_CONTEXT,
1408 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1410 odr_sequence_end(o);
1413 /* ------------------------ APDU ------------------------- */
1415 int z_APDU(ODR o, Z_APDU **p, int opt)
1417 static Odr_arm arm[] =
1419 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
1420 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
1421 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
1422 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
1424 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
1426 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
1428 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
1429 z_DeleteResultSetRequest},
1430 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
1431 z_DeleteResultSetResponse},
1432 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
1433 z_ResourceControlRequest},
1434 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
1435 z_ResourceControlResponse},
1436 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
1437 z_TriggerResourceControlRequest},
1438 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
1439 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
1440 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_APDU_segmentRequest, z_Segment},
1441 {ODR_IMPLICIT, ODR_CONTEXT, 48, Z_APDU_close, z_Close},
1446 if (o->direction == ODR_DECODE)
1447 *p = odr_malloc(o, sizeof(**p));
1448 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
1450 if (o->direction == ODR_DECODE)
1452 return opt && odr_ok(o);