2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.25 1995-05-25 11:00:08 quinn
8 * *** empty log message ***
10 * Revision 1.24 1995/05/22 13:58:18 quinn
11 * Fixed an ODR_NULLVAL.
13 * Revision 1.23 1995/05/22 11:30:18 quinn
14 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
16 * Revision 1.22 1995/05/17 08:40:56 quinn
17 * Added delete. Fixed some sequence_begins. Smallish.
19 * Revision 1.21 1995/05/16 08:50:24 quinn
20 * License, documentation, and memory fixes
22 * Revision 1.20 1995/05/15 11:55:25 quinn
25 * Revision 1.19 1995/04/11 11:58:35 quinn
28 * Revision 1.18 1995/04/11 11:52:02 quinn
29 * Fixed possible buf in proto.c
31 * Revision 1.17 1995/04/10 10:22:22 quinn
34 * Revision 1.16 1995/03/30 10:26:43 quinn
35 * Added Term structure
37 * Revision 1.15 1995/03/30 09:08:39 quinn
38 * Added Resource control protocol
40 * Revision 1.14 1995/03/29 08:06:13 quinn
41 * Added a few v3 elements
43 * Revision 1.13 1995/03/20 11:26:52 quinn
44 * *** empty log message ***
46 * Revision 1.12 1995/03/20 09:45:09 quinn
49 * Revision 1.11 1995/03/17 10:17:25 quinn
50 * Added memory management.
52 * Revision 1.10 1995/03/15 11:17:40 quinn
53 * Fixed some return-checks from choice.. need better ay to handle those..
55 * Revision 1.9 1995/03/15 08:37:06 quinn
56 * Fixed protocol bugs.
58 * Revision 1.8 1995/03/14 16:59:24 quinn
59 * Fixed OPTIONAL flag in attributeelement
61 * Revision 1.7 1995/03/07 16:29:33 quinn
62 * Added authentication stuff.
64 * Revision 1.6 1995/03/01 14:46:03 quinn
65 * Fixed protocol bug in 8777query.
67 * Revision 1.5 1995/02/14 11:54:22 quinn
70 * Revision 1.4 1995/02/10 15:54:30 quinn
73 * Revision 1.3 1995/02/09 15:51:39 quinn
76 * Revision 1.2 1995/02/06 21:26:07 quinn
77 * Repaired this evening's damages..
79 * Revision 1.1 1995/02/06 16:44:47 quinn
80 * First hack at Z/SR protocol
88 /* ---------------------- GLOBAL DEFS ------------------- */
90 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
92 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
95 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
97 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
101 int z_ResultSetId(ODR o, char **p, int opt)
103 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
107 int z_UserInformationField(ODR o, Z_UserInformationField **p, int opt)
109 return odr_explicit(o, odr_external, (Odr_external **)p, ODR_CONTEXT,
113 /* ---------------------- INITIALIZE SERVICE ------------------- */
116 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
118 if (!odr_sequence_begin(o, p, sizeof(**p)))
119 return opt && odr_ok(o);
121 odr_visiblestring(o, &(*p)->user, 0) &&
122 odr_visiblestring(o, &(*p)->password, 0) &&
123 odr_visiblestring(o, &(*p)->account, 0) &&
128 int z_IdPass(ODR o, Z_IdPass **p, int opt)
130 if (!odr_sequence_begin(o, p, sizeof(**p)))
131 return opt && odr_ok(o);
133 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 1) &&
134 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 1) &&
135 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
140 int z_StrAuthentication(ODR o, char **p, int opt)
142 return odr_visiblestring(o, p, opt);
145 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
147 static Odr_arm arm[] =
149 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
150 {-1, -1, -1, Z_IdAuthentication_idPass, z_IdPass},
151 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
152 {-1, -1, -1, Z_IdAuthentication_other, odr_external},
156 if (o->direction == ODR_DECODE)
157 *p = odr_malloc(o, sizeof(**p));
159 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
162 return opt && odr_ok(o);
165 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
169 if (!odr_sequence_begin(o, p, sizeof(**p)))
170 return opt && odr_ok(o);
173 z_ReferenceId(o, &pp->referenceId, 1) &&
174 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
176 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
177 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
179 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
181 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
183 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
185 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
187 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
188 ODR_CONTEXT, 112, 1) &&
189 z_UserInformationField(o, &pp->userInformationField, 1) &&
191 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
196 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
200 if (!odr_sequence_begin(o, p, sizeof(**p)))
201 return opt && odr_ok(o);
204 z_ReferenceId(o, &pp->referenceId, 1) &&
205 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
207 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
208 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
210 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
212 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
213 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
215 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
217 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
218 ODR_CONTEXT, 112, 1) &&
219 z_UserInformationField(o, &pp->userInformationField, 1) &&
221 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
226 /* ------------------ RESOURCE CONTROL ----------------*/
228 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
231 if (!odr_sequence_begin(o, p, sizeof(**p)))
232 return opt && odr_ok(o);
234 z_ReferenceId(o, &(*p)->referenceId, 1) &&
235 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
237 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
238 ODR_CONTEXT, 47, 1) &&
239 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
242 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
247 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
249 if (!odr_sequence_begin(o, p, sizeof(**p)))
250 return opt && odr_ok(o);
252 z_ReferenceId(o, &(*p)->referenceId, 1) &&
253 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
254 odr_explicit(o, odr_external, &(*p)->resourceReport, ODR_CONTEXT,
256 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
257 ODR_CONTEXT, 41, 1) &&
258 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
260 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
261 ODR_CONTEXT, 43, 1) &&
263 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
268 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
270 if (!odr_sequence_begin(o, p, sizeof(**p)))
271 return opt && odr_ok(o);
273 z_ReferenceId(o, &(*p)->referenceId, 1) &&
274 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
275 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
278 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
283 /* ------------------------ SEARCH SERVICE ----------------------- */
285 int z_ElementSetName(ODR o, char **p, int opt)
287 return odr_implicit(o, odr_visiblestring, (char**) p, ODR_CONTEXT, 103,
291 int z_PreferredRecordSyntax(ODR o, Z_PreferredRecordSyntax **p, int opt)
293 return odr_implicit(o, odr_oid, (Odr_oid**) p, ODR_CONTEXT, 104, opt);
296 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
298 if (!odr_sequence_begin(o, p, sizeof(**p)))
299 return opt && odr_ok(o);
301 z_DatabaseName(o, &(*p)->databaseName, 0) &&
302 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
306 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
308 if (o->direction == ODR_DECODE)
309 *p = odr_malloc(o, sizeof(**p));
313 odr_implicit_settag(o, ODR_CONTEXT, 1);
314 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
315 &(*p)->num_elements))
321 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
323 static Odr_arm arm[] =
325 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
327 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
332 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 19))
333 return opt && odr_ok(o);
335 if (o->direction == ODR_DECODE)
336 *p = odr_malloc(o, sizeof(**p));
338 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
339 odr_constructed_end(o))
345 /* ----------------------- RPN QUERY -----------------------*/
347 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
349 if (!odr_sequence_begin(o, p, sizeof(**p)))
350 return opt && odr_ok(o);
352 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
354 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
361 int z_Term(ODR o, Z_Term **p, int opt)
363 static Odr_arm arm[] =
365 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
366 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
367 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
369 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
370 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
371 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, odr_external},
372 /* add intUnit here */
373 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
377 if (o->direction ==ODR_DECODE)
378 *p = odr_malloc(o, sizeof(**p));
381 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
384 return opt && odr_ok(o);
389 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
391 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
392 odr_sequence_begin(o, p, sizeof(**p))))
393 return opt && odr_ok(o);
395 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
396 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
397 &(*p)->num_attributes) &&
398 z_Term(o, &(*p)->term, 0) &&
402 int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
404 static Odr_arm arm[] =
406 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, odr_integer},
407 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_private, odr_integer},
411 if (!odr_sequence_begin(o, p, sizeof(**p)))
412 return opt && odr_ok(o);
414 odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
415 odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
416 odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
417 odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
418 odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
419 odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
420 odr_constructed_end(o) &&
424 int z_Operator(ODR o, Z_Operator **p, int opt)
426 static Odr_arm arm[] =
428 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
429 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
430 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
431 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, z_ProximityOperator},
435 if (!*p && o->direction != ODR_DECODE)
437 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
438 return opt && odr_ok(o);
439 if (o->direction == ODR_DECODE)
440 *p = odr_malloc(o, sizeof(**p));
442 (*p)->u.and = ODR_NULLVAL;
444 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
445 odr_constructed_end(o))
448 return opt && odr_ok(o);
451 int z_Operand(ODR o, Z_Operand **p, int opt)
453 static Odr_arm arm[] =
455 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
456 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
460 if (o->direction ==ODR_DECODE)
461 *p = odr_malloc(o, sizeof(**p));
464 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
467 return opt && odr_ok(o);
470 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
472 int z_Complex(ODR o, Z_Complex **p, int opt)
474 if (!odr_sequence_begin(o, p, sizeof(**p)))
475 return opt && odr_ok(o);
477 z_RPNStructure(o, &(*p)->s1, 0) &&
478 z_RPNStructure(o, &(*p)->s2, 0) &&
479 z_Operator(o, &(*p)->operator, 0) &&
483 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
485 static Odr_arm arm[] =
487 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
488 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
492 if (o->direction == ODR_DECODE)
493 *p = odr_malloc(o, sizeof(**p));
496 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
499 return opt && odr_ok(o);
502 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
504 if (!odr_sequence_begin(o, p, sizeof(**p)))
505 return opt && odr_ok(o);
507 odr_oid(o, &(*p)->attributeSetId, 0) &&
508 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
512 /* -----------------------END RPN QUERY ----------------------- */
514 int z_Query(ODR o, Z_Query **p, int opt)
516 static Odr_arm arm[] =
518 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
519 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
523 if (o->direction == ODR_DECODE)
524 *p = odr_malloc(o, sizeof(**p));
527 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
530 return opt && odr_ok(o);
533 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
537 if (!odr_sequence_begin(o, p, sizeof(**p)))
538 return opt && odr_ok(o);
541 z_ReferenceId(o, &pp->referenceId, 1) &&
542 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
544 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
546 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
548 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
549 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
551 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
552 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
553 &pp->num_databaseNames) &&
554 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
555 ODR_CONTEXT, 100, 1) &&
556 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
557 ODR_CONTEXT, 101, 1) &&
558 odr_implicit(o, z_PreferredRecordSyntax, &pp->preferredRecordSyntax,
559 ODR_CONTEXT, 104, 1) &&
560 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
562 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
563 ODR_CONTEXT, 203, 1) &&
564 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
569 /* ------------------------ RECORD ------------------------- */
571 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
573 return odr_external(o, (Odr_external **) p, opt);
576 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
578 if (!odr_sequence_begin(o, p, sizeof(**p)))
579 return opt && odr_ok(o);
581 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT */
582 odr_integer(o, &(*p)->condition, 0) &&
583 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
584 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT, ODR_VISIBLESTRING, 1)) &&
588 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
590 static Odr_arm arm[] =
592 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
594 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
599 if (!odr_sequence_begin(o, p, sizeof(**p)))
600 return opt && odr_ok(o);
602 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
604 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
605 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
606 odr_constructed_end(o) &&
610 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
612 if (o->direction == ODR_DECODE)
613 *p = odr_malloc(o, sizeof(**p));
614 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
621 int z_Records(ODR o, Z_Records **p, int opt)
625 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
626 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
630 if (o->direction == ODR_DECODE)
631 *p = odr_malloc(o, sizeof(**p));
634 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
637 return opt && odr_ok(o);
640 /* ------------------------ ACCESS CTRL SERVICE ----------------------- */
642 int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
644 static Odr_arm arm[] =
646 {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
648 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
652 if (!odr_sequence_begin(o, p, sizeof(**p)))
653 return opt && odr_ok(o);
655 z_ReferenceId(o, &(*p)->referenceId, 1) &&
656 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
658 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
663 int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
665 static Odr_arm arm[] =
667 {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
669 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
673 if (!odr_sequence_begin(o, p, sizeof(**p)))
674 return opt && odr_ok(o);
676 z_ReferenceId(o, &(*p)->referenceId, 1) &&
677 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
678 odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
680 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
685 /* ------------------------ SCAN SERVICE -------------------- */
687 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
689 if (o->direction == ODR_DECODE)
690 *p = odr_malloc(o, sizeof(**p));
694 odr_implicit_settag(o, ODR_CONTEXT, 44);
695 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
696 &(*p)->num_attributes))
699 return opt && odr_ok(o);
703 * This is a temporary hack. We don't know just *what* old version of the
704 * protocol willow uses, so we'll just patiently wait for them to update
706 static int willow_scan = 0;
708 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
710 if (!*p && o->direction != ODR_DECODE)
712 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
715 return opt && odr_ok(o);
717 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
719 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
721 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
723 if (o->direction == ODR_DECODE)
724 *p = odr_malloc(o, sizeof(**p));
725 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
726 &(*p)->num_attributes))
728 if (!odr_sequence_end(o) || !odr_sequence_end(o))
730 if (!z_Term(o, &(*p)->term, 0))
732 if (!odr_constructed_end(o))
738 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
740 if (o->direction == ODR_DECODE)
741 *p = odr_malloc(o, sizeof(**p));
745 return opt && odr_ok(o);
748 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
752 return opt && !o->error;
755 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
757 if (!odr_sequence_begin(o, p, sizeof(**p)))
758 return opt && odr_ok(o);
760 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
761 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
765 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
767 if (!odr_sequence_begin(o, p, sizeof(**p)))
768 return opt && odr_ok(o);
771 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
772 z_Term(o, &(*p)->term, 0)) &&
773 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
774 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
775 ODR_CONTEXT, 4, 1) &&
776 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
778 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
779 ODR_CONTEXT, 3, 1) &&
783 int z_Entry(ODR o, Z_Entry **p, int opt)
785 static Odr_arm arm[] =
787 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
788 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
793 if (o->direction == ODR_DECODE)
794 *p = odr_malloc(o, sizeof(**p));
796 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
799 return opt && odr_ok(o);
802 int z_Entries(ODR o, Z_Entries **p, int opt)
804 if (o->direction == ODR_DECODE)
805 *p = odr_malloc(o, sizeof(**p));
809 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
816 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
818 if (o->direction == ODR_DECODE)
819 *p = odr_malloc(o, sizeof(**p));
823 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
824 &(*p)->num_diagRecs))
830 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
832 static Odr_arm arm[] =
834 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
835 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
840 if (o->direction == ODR_DECODE)
841 *p = odr_malloc(o, sizeof(**p));
843 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
846 return opt && odr_ok(o);
849 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
851 if (!odr_sequence_begin(o, p, sizeof(**p)))
852 return opt && odr_ok(o);
855 z_ReferenceId(o, &(*p)->referenceId, 1) &&
856 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
857 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
858 &(*p)->num_databaseNames) &&
859 odr_oid(o, &(*p)->attributeSet, 1) &&
860 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
861 ((*p)->termListAndStartPoint ? 1 :
862 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
863 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
864 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
865 ODR_CONTEXT, 6, 0) &&
866 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
867 ODR_CONTEXT, 7, 1) &&
871 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
873 if (!odr_sequence_begin(o, p, sizeof(**p)))
874 return opt && odr_ok(o);
876 z_ReferenceId(o, &(*p)->referenceId, 1) &&
877 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
878 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
879 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
880 ODR_CONTEXT, 5, 0) &&
881 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
882 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
883 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
887 /* ------------------------ SEARCHRESPONSE ----------------*/
889 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
891 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
894 int z_NextResultSetPosition(ODR o, int **p, int opt)
896 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
899 int z_PresentStatus(ODR o, int **p, int opt)
901 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
904 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
906 Z_SearchResponse *pp;
908 if (!odr_sequence_begin(o, p, sizeof(**p)))
909 return opt && odr_ok(o);
912 z_ReferenceId(o, &pp->referenceId, 1) &&
913 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
914 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
915 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
916 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
917 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26, 1) &&
918 z_PresentStatus(o, &pp->presentStatus, 1) &&
919 z_Records(o, &pp->records, 1) &&
921 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
922 ODR_CONTEXT, 203, 1) &&
923 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
928 /* --------------------- PRESENT SERVICE ---------------------- */
930 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
932 Z_PresentRequest *pp;
934 if (!odr_sequence_begin(o, p, sizeof(**p)))
935 return opt && odr_ok(o);
938 z_ReferenceId(o, &pp->referenceId, 1) &&
939 z_ResultSetId(o, &pp->resultSetId, 0) &&
940 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
942 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
944 z_ElementSetNames(o, &pp->elementSetNames, 1) &&
945 z_PreferredRecordSyntax(o, &pp->preferredRecordSyntax, 1) &&
949 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
951 Z_PresentResponse *pp;
953 if (!odr_sequence_begin(o, p, sizeof(**p)))
954 return opt && odr_ok(o);
957 z_ReferenceId(o, &pp->referenceId, 1) &&
958 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
959 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
960 z_PresentStatus(o, &pp->presentStatus, 0) &&
961 z_Records(o, &pp->records, 1) &&
965 /* ----------------------DELETE -------------------------- */
967 int z_DeleteSetStatus(ODR o, int **p, int opt)
969 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
972 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
974 if (!odr_sequence_begin(o, p, sizeof(**p)))
975 return opt && odr_ok(o);
977 z_ResultSetId(o, &(*p)->id, 0) &&
978 z_DeleteSetStatus(o, &(*p)->status, 0) &&
982 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
984 if (!odr_sequence_begin(o, p, sizeof(**p)))
985 return opt && odr_ok(o);
987 z_ReferenceId(o, &(*p)->referenceId, 1) &&
988 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
990 (odr_sequence_of(o, z_ListStatus, &(*p)->resultSetList,
991 &(*p)->num_ids) || odr_ok(o)) &&
993 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
998 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
1000 if (!odr_sequence_begin(o, p, sizeof(**p)))
1001 return opt && odr_ok(o);
1003 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1004 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
1005 ODR_CONTEXT, 0, 1) &&
1006 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
1007 (odr_sequence_of(o, z_ListStatus, &(*p)->deleteListStatuses,
1008 &(*p)->num_statuses) || odr_ok(o)) &&
1009 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
1011 odr_implicit_settag(o, ODR_CONTEXT, 35) &&
1012 (odr_sequence_of(o, z_ListStatus, &(*p)->bulkStatuses,
1013 &(*p)->num_bulkStatuses) || odr_ok(o)) &&
1014 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
1017 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1019 odr_sequence_end(o);
1022 /* ------------------------ APDU ------------------------- */
1024 int z_APDU(ODR o, Z_APDU **p, int opt)
1026 static Odr_arm arm[] =
1028 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
1029 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
1030 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
1031 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
1033 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
1035 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
1037 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
1038 z_DeleteResultSetRequest},
1039 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
1040 z_DeleteResultSetResponse},
1041 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
1042 z_ResourceControlRequest},
1043 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
1044 z_ResourceControlResponse},
1045 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
1046 z_TriggerResourceControlRequest},
1047 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
1048 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
1053 if (o->direction == ODR_DECODE)
1054 *p = odr_malloc(o, sizeof(**p));
1055 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
1057 if (o->direction == ODR_DECODE)
1059 return opt && odr_ok(o);