2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.23 1995-05-22 11:30:18 quinn
8 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
10 * Revision 1.22 1995/05/17 08:40:56 quinn
11 * Added delete. Fixed some sequence_begins. Smallish.
13 * Revision 1.21 1995/05/16 08:50:24 quinn
14 * License, documentation, and memory fixes
16 * Revision 1.20 1995/05/15 11:55:25 quinn
19 * Revision 1.19 1995/04/11 11:58:35 quinn
22 * Revision 1.18 1995/04/11 11:52:02 quinn
23 * Fixed possible buf in proto.c
25 * Revision 1.17 1995/04/10 10:22:22 quinn
28 * Revision 1.16 1995/03/30 10:26:43 quinn
29 * Added Term structure
31 * Revision 1.15 1995/03/30 09:08:39 quinn
32 * Added Resource control protocol
34 * Revision 1.14 1995/03/29 08:06:13 quinn
35 * Added a few v3 elements
37 * Revision 1.13 1995/03/20 11:26:52 quinn
38 * *** empty log message ***
40 * Revision 1.12 1995/03/20 09:45:09 quinn
43 * Revision 1.11 1995/03/17 10:17:25 quinn
44 * Added memory management.
46 * Revision 1.10 1995/03/15 11:17:40 quinn
47 * Fixed some return-checks from choice.. need better ay to handle those..
49 * Revision 1.9 1995/03/15 08:37:06 quinn
50 * Fixed protocol bugs.
52 * Revision 1.8 1995/03/14 16:59:24 quinn
53 * Fixed OPTIONAL flag in attributeelement
55 * Revision 1.7 1995/03/07 16:29:33 quinn
56 * Added authentication stuff.
58 * Revision 1.6 1995/03/01 14:46:03 quinn
59 * Fixed protocol bug in 8777query.
61 * Revision 1.5 1995/02/14 11:54:22 quinn
64 * Revision 1.4 1995/02/10 15:54:30 quinn
67 * Revision 1.3 1995/02/09 15:51:39 quinn
70 * Revision 1.2 1995/02/06 21:26:07 quinn
71 * Repaired this evening's damages..
73 * Revision 1.1 1995/02/06 16:44:47 quinn
74 * First hack at Z/SR protocol
82 /* ---------------------- GLOBAL DEFS ------------------- */
84 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
86 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
89 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
91 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
95 int z_ResultSetId(ODR o, char **p, int opt)
97 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
101 int z_UserInformationField(ODR o, Z_UserInformationField **p, int opt)
103 return odr_explicit(o, odr_external, (Odr_external **)p, ODR_CONTEXT,
107 /* ---------------------- INITIALIZE SERVICE ------------------- */
110 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
112 if (!odr_sequence_begin(o, p, sizeof(**p)))
113 return opt && odr_ok(o);
115 odr_visiblestring(o, &(*p)->user, 0) &&
116 odr_visiblestring(o, &(*p)->password, 0) &&
117 odr_visiblestring(o, &(*p)->account, 0) &&
122 int z_IdPass(ODR o, Z_IdPass **p, int opt)
124 if (!odr_sequence_begin(o, p, sizeof(**p)))
125 return opt && odr_ok(o);
127 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 0) &&
128 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 0) &&
129 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
134 int z_StrAuthentication(ODR o, char **p, int opt)
136 return odr_visiblestring(o, p, opt);
139 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
141 static Odr_arm arm[] =
143 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
144 {-1, -1, -1, Z_IdAuthentication_idPass, z_IdPass},
145 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
146 {-1, -1, -1, Z_IdAuthentication_other, odr_external},
150 if (o->direction == ODR_DECODE)
151 *p = odr_malloc(o, sizeof(**p));
153 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
156 return opt && odr_ok(o);
159 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
163 if (!odr_sequence_begin(o, p, sizeof(**p)))
164 return opt && odr_ok(o);
167 z_ReferenceId(o, &pp->referenceId, 1) &&
168 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
170 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
171 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
173 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
175 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
177 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
179 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
181 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
182 ODR_CONTEXT, 112, 1) &&
183 z_UserInformationField(o, &pp->userInformationField, 1) &&
185 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
190 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
194 if (!odr_sequence_begin(o, p, sizeof(**p)))
195 return opt && odr_ok(o);
198 z_ReferenceId(o, &pp->referenceId, 1) &&
199 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
201 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
202 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
204 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
206 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
207 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
209 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
211 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
212 ODR_CONTEXT, 112, 1) &&
213 z_UserInformationField(o, &pp->userInformationField, 1) &&
215 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
220 /* ------------------ RESOURCE CONTROL ----------------*/
222 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
225 if (!odr_sequence_begin(o, p, sizeof(**p)))
226 return opt && odr_ok(o);
228 z_ReferenceId(o, &(*p)->referenceId, 1) &&
229 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
231 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
232 ODR_CONTEXT, 47, 1) &&
233 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
236 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
241 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
243 if (!odr_sequence_begin(o, p, sizeof(**p)))
244 return opt && odr_ok(o);
246 z_ReferenceId(o, &(*p)->referenceId, 1) &&
247 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
248 odr_explicit(o, odr_external, &(*p)->resourceReport, ODR_CONTEXT,
250 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
251 ODR_CONTEXT, 41, 1) &&
252 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
254 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
255 ODR_CONTEXT, 43, 1) &&
257 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
262 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
264 if (!odr_sequence_begin(o, p, sizeof(**p)))
265 return opt && odr_ok(o);
267 z_ReferenceId(o, &(*p)->referenceId, 1) &&
268 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
269 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
272 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
277 /* ------------------------ SEARCH SERVICE ----------------------- */
279 int z_ElementSetName(ODR o, char **p, int opt)
281 return odr_implicit(o, odr_visiblestring, (char**) p, ODR_CONTEXT, 103,
285 int z_PreferredRecordSyntax(ODR o, Z_PreferredRecordSyntax **p, int opt)
287 return odr_implicit(o, odr_oid, (Odr_oid**) p, ODR_CONTEXT, 104, opt);
290 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
292 if (!odr_sequence_begin(o, p, sizeof(**p)))
293 return opt && odr_ok(o);
295 z_DatabaseName(o, &(*p)->databaseName, 0) &&
296 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
300 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
302 if (o->direction == ODR_DECODE)
303 *p = odr_malloc(o, sizeof(**p));
307 odr_implicit_settag(o, ODR_CONTEXT, 1);
308 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
309 &(*p)->num_elements))
315 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
317 static Odr_arm arm[] =
319 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
321 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
326 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 19))
327 return opt && odr_ok(o);
329 if (o->direction == ODR_DECODE)
330 *p = odr_malloc(o, sizeof(**p));
332 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
333 odr_constructed_end(o))
339 /* ----------------------- RPN QUERY -----------------------*/
341 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
343 if (!odr_sequence_begin(o, p, sizeof(**p)))
344 return opt && odr_ok(o);
346 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
348 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
355 int z_Term(ODR o, Z_Term **p, int opt)
357 static Odr_arm arm[] =
359 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
360 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
361 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
363 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
364 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
365 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, odr_external},
366 /* add intUnit here */
367 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
371 if (o->direction ==ODR_DECODE)
372 *p = odr_malloc(o, sizeof(**p));
375 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
378 return opt && odr_ok(o);
383 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
385 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
386 odr_sequence_begin(o, p, sizeof(**p))))
387 return opt && odr_ok(o);
389 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
390 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
391 &(*p)->num_attributes) &&
392 z_Term(o, &(*p)->term, 0) &&
396 int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
398 static Odr_arm arm[] =
400 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, odr_integer},
401 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_private, odr_integer},
405 if (!odr_sequence_begin(o, p, sizeof(**p)))
406 return opt && odr_ok(o);
408 odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
409 odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
410 odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
411 odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
412 odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
413 odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
414 odr_constructed_end(o) &&
418 int z_Operator(ODR o, Z_Operator **p, int opt)
420 static Odr_arm arm[] =
422 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
423 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
424 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
425 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, z_ProximityOperator},
430 if (!*p && o->direction != ODR_DECODE)
432 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
433 return opt && odr_ok(o);
434 if (o->direction == ODR_DECODE)
435 *p = odr_malloc(o, sizeof(**p));
437 (*p)->u.and = &dummy;
439 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
440 odr_constructed_end(o))
443 return opt && odr_ok(o);
446 int z_Operand(ODR o, Z_Operand **p, int opt)
448 static Odr_arm arm[] =
450 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
451 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
455 if (o->direction ==ODR_DECODE)
456 *p = odr_malloc(o, sizeof(**p));
459 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
462 return opt && odr_ok(o);
465 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
467 int z_Complex(ODR o, Z_Complex **p, int opt)
469 if (!odr_sequence_begin(o, p, sizeof(**p)))
470 return opt && odr_ok(o);
472 z_RPNStructure(o, &(*p)->s1, 0) &&
473 z_RPNStructure(o, &(*p)->s2, 0) &&
474 z_Operator(o, &(*p)->operator, 0) &&
478 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
480 static Odr_arm arm[] =
482 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
483 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
487 if (o->direction == ODR_DECODE)
488 *p = odr_malloc(o, sizeof(**p));
491 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
494 return opt && odr_ok(o);
497 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
499 if (!odr_sequence_begin(o, p, sizeof(**p)))
500 return opt && odr_ok(o);
502 odr_oid(o, &(*p)->attributeSetId, 0) &&
503 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
507 /* -----------------------END RPN QUERY ----------------------- */
509 int z_Query(ODR o, Z_Query **p, int opt)
511 static Odr_arm arm[] =
513 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
514 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
518 if (o->direction == ODR_DECODE)
519 *p = odr_malloc(o, sizeof(**p));
522 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
525 return opt && odr_ok(o);
528 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
532 if (!odr_sequence_begin(o, p, sizeof(**p)))
533 return opt && odr_ok(o);
536 z_ReferenceId(o, &pp->referenceId, 1) &&
537 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
539 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
541 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
543 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
544 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
546 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
547 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
548 &pp->num_databaseNames) &&
549 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
550 ODR_CONTEXT, 100, 1) &&
551 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
552 ODR_CONTEXT, 101, 1) &&
553 odr_implicit(o, z_PreferredRecordSyntax, &pp->preferredRecordSyntax,
554 ODR_CONTEXT, 104, 1) &&
555 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
557 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
558 ODR_CONTEXT, 203, 1) &&
559 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
564 /* ------------------------ RECORD ------------------------- */
566 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
568 return odr_external(o, (Odr_external **) p, opt);
571 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
573 if (!odr_sequence_begin(o, p, sizeof(**p)))
574 return opt && odr_ok(o);
576 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT */
577 odr_integer(o, &(*p)->condition, 0) &&
578 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
579 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT, ODR_VISIBLESTRING, 1)) &&
583 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
585 static Odr_arm arm[] =
587 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
589 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
594 if (!odr_sequence_begin(o, p, sizeof(**p)))
595 return opt && odr_ok(o);
597 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
599 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
600 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
601 odr_constructed_end(o) &&
605 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
607 if (o->direction == ODR_DECODE)
608 *p = odr_malloc(o, sizeof(**p));
609 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
616 int z_Records(ODR o, Z_Records **p, int opt)
620 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
621 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
625 if (o->direction == ODR_DECODE)
626 *p = odr_malloc(o, sizeof(**p));
629 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
632 return opt && odr_ok(o);
635 /* ------------------------ ACCESS CTRL SERVICE ----------------------- */
637 int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
639 static Odr_arm arm[] =
641 {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
643 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
647 if (!odr_sequence_begin(o, p, sizeof(**p)))
648 return opt && odr_ok(o);
650 z_ReferenceId(o, &(*p)->referenceId, 1) &&
651 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
653 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
658 int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
660 static Odr_arm arm[] =
662 {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
664 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
668 if (!odr_sequence_begin(o, p, sizeof(**p)))
669 return opt && odr_ok(o);
671 z_ReferenceId(o, &(*p)->referenceId, 1) &&
672 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
673 odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
675 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
680 /* ------------------------ SCAN SERVICE -------------------- */
682 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
684 if (o->direction == ODR_DECODE)
685 *p = odr_malloc(o, sizeof(**p));
689 odr_implicit_settag(o, ODR_CONTEXT, 44);
690 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
691 &(*p)->num_attributes))
694 return opt && odr_ok(o);
698 * This is a temporary hack. We don't know just *what* old version of the
699 * protocol willow uses, so we'll just patiently wait for them to update
701 static int willow_scan = 0;
703 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
705 if (!*p && o->direction != ODR_DECODE)
707 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
710 return opt && odr_ok(o);
712 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
714 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
716 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
718 if (o->direction == ODR_DECODE)
719 *p = odr_malloc(o, sizeof(**p));
720 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
721 &(*p)->num_attributes))
723 if (!odr_sequence_end(o) || !odr_sequence_end(o))
725 if (!z_Term(o, &(*p)->term, 0))
727 if (!odr_constructed_end(o))
733 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
735 if (o->direction == ODR_DECODE)
736 *p = odr_malloc(o, sizeof(**p));
740 return opt && odr_ok(o);
743 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
747 return opt && !o->error;
750 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
752 if (!odr_sequence_begin(o, p, sizeof(**p)))
753 return opt && odr_ok(o);
755 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
756 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
760 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
762 if (!odr_sequence_begin(o, p, sizeof(**p)))
763 return opt && odr_ok(o);
766 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
767 z_Term(o, &(*p)->term, 0)) &&
768 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
769 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
770 ODR_CONTEXT, 4, 1) &&
771 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
773 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
774 ODR_CONTEXT, 3, 1) &&
778 int z_Entry(ODR o, Z_Entry **p, int opt)
780 static Odr_arm arm[] =
782 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
783 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
788 if (o->direction == ODR_DECODE)
789 *p = odr_malloc(o, sizeof(**p));
791 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
794 return opt && odr_ok(o);
797 int z_Entries(ODR o, Z_Entries **p, int opt)
799 if (o->direction == ODR_DECODE)
800 *p = odr_malloc(o, sizeof(**p));
804 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
811 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
813 if (o->direction == ODR_DECODE)
814 *p = odr_malloc(o, sizeof(**p));
818 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
819 &(*p)->num_diagRecs))
825 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
827 static Odr_arm arm[] =
829 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
830 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
835 if (o->direction == ODR_DECODE)
836 *p = odr_malloc(o, sizeof(**p));
838 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
841 return opt && odr_ok(o);
844 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
846 if (!odr_sequence_begin(o, p, sizeof(**p)))
847 return opt && odr_ok(o);
850 z_ReferenceId(o, &(*p)->referenceId, 1) &&
851 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
852 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
853 &(*p)->num_databaseNames) &&
854 odr_oid(o, &(*p)->attributeSet, 1) &&
855 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
856 ((*p)->termListAndStartPoint ? 1 :
857 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
858 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
859 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
860 ODR_CONTEXT, 6, 0) &&
861 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
862 ODR_CONTEXT, 7, 1) &&
866 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
868 if (!odr_sequence_begin(o, p, sizeof(**p)))
869 return opt && odr_ok(o);
871 z_ReferenceId(o, &(*p)->referenceId, 1) &&
872 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
873 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
874 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
875 ODR_CONTEXT, 5, 0) &&
876 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
877 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
878 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
882 /* ------------------------ SEARCHRESPONSE ----------------*/
884 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
886 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
889 int z_NextResultSetPosition(ODR o, int **p, int opt)
891 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
894 int z_PresentStatus(ODR o, int **p, int opt)
896 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
899 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
901 Z_SearchResponse *pp;
903 if (!odr_sequence_begin(o, p, sizeof(**p)))
904 return opt && odr_ok(o);
907 z_ReferenceId(o, &pp->referenceId, 1) &&
908 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
909 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
910 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
911 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
912 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26, 1) &&
913 z_PresentStatus(o, &pp->presentStatus, 1) &&
914 z_Records(o, &pp->records, 1) &&
916 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
917 ODR_CONTEXT, 203, 1) &&
918 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
923 /* --------------------- PRESENT SERVICE ---------------------- */
925 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
927 Z_PresentRequest *pp;
929 if (!odr_sequence_begin(o, p, sizeof(**p)))
930 return opt && odr_ok(o);
933 z_ReferenceId(o, &pp->referenceId, 1) &&
934 z_ResultSetId(o, &pp->resultSetId, 0) &&
935 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
937 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
939 z_ElementSetNames(o, &pp->elementSetNames, 1) &&
940 z_PreferredRecordSyntax(o, &pp->preferredRecordSyntax, 1) &&
944 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
946 Z_PresentResponse *pp;
948 if (!odr_sequence_begin(o, p, sizeof(**p)))
949 return opt && odr_ok(o);
952 z_ReferenceId(o, &pp->referenceId, 1) &&
953 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
954 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
955 z_PresentStatus(o, &pp->presentStatus, 0) &&
956 z_Records(o, &pp->records, 1) &&
960 /* ----------------------DELETE -------------------------- */
962 int z_DeleteSetStatus(ODR o, int **p, int opt)
964 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
967 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
969 if (!odr_sequence_begin(o, p, sizeof(**p)))
970 return opt && odr_ok(o);
972 z_ResultSetId(o, &(*p)->id, 0) &&
973 z_DeleteSetStatus(o, &(*p)->status, 0) &&
977 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
979 if (!odr_sequence_begin(o, p, sizeof(**p)))
980 return opt && odr_ok(o);
982 z_ReferenceId(o, &(*p)->referenceId, 1) &&
983 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
985 (odr_sequence_of(o, z_ListStatus, &(*p)->resultSetList,
986 &(*p)->num_ids) || odr_ok(o)) &&
988 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
993 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
995 if (!odr_sequence_begin(o, p, sizeof(**p)))
996 return opt && odr_ok(o);
998 z_ReferenceId(o, &(*p)->referenceId, 1) &&
999 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
1000 ODR_CONTEXT, 0, 1) &&
1001 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
1002 (odr_sequence_of(o, z_ListStatus, &(*p)->deleteListStatuses,
1003 &(*p)->num_statuses) || odr_ok(o)) &&
1004 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
1006 odr_implicit_settag(o, ODR_CONTEXT, 35) &&
1007 (odr_sequence_of(o, z_ListStatus, &(*p)->bulkStatuses,
1008 &(*p)->num_bulkStatuses) || odr_ok(o)) &&
1009 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
1012 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1014 odr_sequence_end(o);
1017 /* ------------------------ APDU ------------------------- */
1019 int z_APDU(ODR o, Z_APDU **p, int opt)
1021 static Odr_arm arm[] =
1023 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
1024 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
1025 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
1026 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
1028 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
1030 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
1032 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
1033 z_DeleteResultSetRequest},
1034 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
1035 z_DeleteResultSetResponse},
1036 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
1037 z_ResourceControlRequest},
1038 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
1039 z_ResourceControlResponse},
1040 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
1041 z_TriggerResourceControlRequest},
1042 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
1043 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
1048 if (o->direction == ODR_DECODE)
1049 *p = odr_malloc(o, sizeof(**p));
1050 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
1052 if (o->direction == ODR_DECODE)
1054 return opt && odr_ok(o);