2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.22 1995-05-17 08:40:56 quinn
8 * Added delete. Fixed some sequence_begins. Smallish.
10 * Revision 1.21 1995/05/16 08:50:24 quinn
11 * License, documentation, and memory fixes
13 * Revision 1.20 1995/05/15 11:55:25 quinn
16 * Revision 1.19 1995/04/11 11:58:35 quinn
19 * Revision 1.18 1995/04/11 11:52:02 quinn
20 * Fixed possible buf in proto.c
22 * Revision 1.17 1995/04/10 10:22:22 quinn
25 * Revision 1.16 1995/03/30 10:26:43 quinn
26 * Added Term structure
28 * Revision 1.15 1995/03/30 09:08:39 quinn
29 * Added Resource control protocol
31 * Revision 1.14 1995/03/29 08:06:13 quinn
32 * Added a few v3 elements
34 * Revision 1.13 1995/03/20 11:26:52 quinn
35 * *** empty log message ***
37 * Revision 1.12 1995/03/20 09:45:09 quinn
40 * Revision 1.11 1995/03/17 10:17:25 quinn
41 * Added memory management.
43 * Revision 1.10 1995/03/15 11:17:40 quinn
44 * Fixed some return-checks from choice.. need better ay to handle those..
46 * Revision 1.9 1995/03/15 08:37:06 quinn
47 * Fixed protocol bugs.
49 * Revision 1.8 1995/03/14 16:59:24 quinn
50 * Fixed OPTIONAL flag in attributeelement
52 * Revision 1.7 1995/03/07 16:29:33 quinn
53 * Added authentication stuff.
55 * Revision 1.6 1995/03/01 14:46:03 quinn
56 * Fixed protocol bug in 8777query.
58 * Revision 1.5 1995/02/14 11:54:22 quinn
61 * Revision 1.4 1995/02/10 15:54:30 quinn
64 * Revision 1.3 1995/02/09 15:51:39 quinn
67 * Revision 1.2 1995/02/06 21:26:07 quinn
68 * Repaired this evening's damages..
70 * Revision 1.1 1995/02/06 16:44:47 quinn
71 * First hack at Z/SR protocol
79 /* ---------------------- GLOBAL DEFS ------------------- */
81 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
83 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
86 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
88 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
92 int z_ResultSetId(ODR o, char **p, int opt)
94 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
98 int z_UserInformationField(ODR o, Z_UserInformationField **p, int opt)
100 return odr_explicit(o, odr_external, (Odr_external **)p, ODR_CONTEXT,
104 /* ---------------------- INITIALIZE SERVICE ------------------- */
106 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
108 if (!odr_sequence_begin(o, p, sizeof(**p)))
109 return opt && odr_ok(o);
111 odr_visiblestring(o, &(*p)->user, 0) &&
112 odr_visiblestring(o, &(*p)->password, 0) &&
113 odr_visiblestring(o, &(*p)->account, 0) &&
117 int z_IdPass(ODR o, Z_IdPass **p, int opt)
119 if (!odr_sequence_begin(o, p, sizeof(**p)))
120 return opt && odr_ok(o);
122 odr_implicit(o, odr_visiblestring, &(*p)->groupId, ODR_CONTEXT, 0, 0) &&
123 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 0) &&
124 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
129 int z_StrAuthentication(ODR o, char **p, int opt)
131 return odr_visiblestring(o, p, opt);
134 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
136 static Odr_arm arm[] =
138 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
139 {-1, -1, -1, Z_IdAuthentication_idPass, z_NSRAuthentication},
140 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
141 {-1, -1, -1, Z_IdAuthentication_other, odr_external},
145 if (o->direction == ODR_DECODE)
146 *p = odr_malloc(o, sizeof(**p));
148 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
151 return opt && odr_ok(o);
154 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
158 if (!odr_sequence_begin(o, p, sizeof(**p)))
159 return opt && odr_ok(o);
162 z_ReferenceId(o, &pp->referenceId, 1) &&
163 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
165 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
166 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
168 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
170 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
172 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
174 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
176 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
177 ODR_CONTEXT, 112, 1) &&
178 z_UserInformationField(o, &pp->userInformationField, 1) &&
180 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
185 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
189 if (!odr_sequence_begin(o, p, sizeof(**p)))
190 return opt && odr_ok(o);
193 z_ReferenceId(o, &pp->referenceId, 1) &&
194 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
196 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
197 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
199 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
201 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
202 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
204 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
206 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
207 ODR_CONTEXT, 112, 1) &&
208 z_UserInformationField(o, &pp->userInformationField, 1) &&
210 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
215 /* ------------------ RESOURCE CONTROL ----------------*/
217 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
220 if (!odr_sequence_begin(o, p, sizeof(**p)))
221 return opt && odr_ok(o);
223 z_ReferenceId(o, &(*p)->referenceId, 1) &&
224 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
226 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
227 ODR_CONTEXT, 47, 1) &&
228 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
231 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
236 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
238 if (!odr_sequence_begin(o, p, sizeof(**p)))
239 return opt && odr_ok(o);
241 z_ReferenceId(o, &(*p)->referenceId, 1) &&
242 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
243 odr_explicit(o, odr_external, &(*p)->resourceReport, ODR_CONTEXT,
245 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
246 ODR_CONTEXT, 41, 1) &&
247 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
249 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
250 ODR_CONTEXT, 43, 1) &&
252 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
257 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
259 if (!odr_sequence_begin(o, p, sizeof(**p)))
260 return opt && odr_ok(o);
262 z_ReferenceId(o, &(*p)->referenceId, 1) &&
263 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
264 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
267 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
272 /* ------------------------ SEARCH SERVICE ----------------------- */
274 int z_ElementSetName(ODR o, char **p, int opt)
276 return odr_implicit(o, odr_visiblestring, (char**) p, ODR_CONTEXT, 103,
280 int z_PreferredRecordSyntax(ODR o, Z_PreferredRecordSyntax **p, int opt)
282 return odr_implicit(o, odr_oid, (Odr_oid**) p, ODR_CONTEXT, 104, opt);
285 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
287 if (!odr_sequence_begin(o, p, sizeof(**p)))
288 return opt && odr_ok(o);
290 z_DatabaseName(o, &(*p)->databaseName, 0) &&
291 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
295 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
297 if (o->direction == ODR_DECODE)
298 *p = odr_malloc(o, sizeof(**p));
302 odr_implicit_settag(o, ODR_CONTEXT, 1);
303 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
304 &(*p)->num_elements))
310 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
312 static Odr_arm arm[] =
314 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
316 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
321 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 19))
322 return opt && odr_ok(o);
324 if (o->direction == ODR_DECODE)
325 *p = odr_malloc(o, sizeof(**p));
327 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
328 odr_constructed_end(o))
334 /* ----------------------- RPN QUERY -----------------------*/
336 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
338 if (!odr_sequence_begin(o, p, sizeof(**p)))
339 return opt && odr_ok(o);
341 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
343 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
350 int z_Term(ODR o, Z_Term **p, int opt)
352 static Odr_arm arm[] =
354 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
355 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
356 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
358 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
359 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
360 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, odr_external},
361 /* add intUnit here */
362 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
366 if (o->direction ==ODR_DECODE)
367 *p = odr_malloc(o, sizeof(**p));
370 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
373 return opt && odr_ok(o);
378 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
380 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
381 odr_sequence_begin(o, p, sizeof(**p))))
382 return opt && odr_ok(o);
384 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
385 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
386 &(*p)->num_attributes) &&
387 z_Term(o, &(*p)->term, 0) &&
391 int z_Operator(ODR o, Z_Operator **p, int opt)
393 static Odr_arm arm[] =
395 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
396 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
397 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
402 if (!*p && o->direction != ODR_DECODE)
404 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
405 return opt && odr_ok(o);
406 if (o->direction == ODR_DECODE)
407 *p = odr_malloc(o, sizeof(**p));
409 (*p)->u.and = &dummy;
411 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
412 odr_constructed_end(o))
415 return opt && odr_ok(o);
418 int z_Operand(ODR o, Z_Operand **p, int opt)
420 static Odr_arm arm[] =
422 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
423 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
427 if (o->direction ==ODR_DECODE)
428 *p = odr_malloc(o, sizeof(**p));
431 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
434 return opt && odr_ok(o);
437 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
439 int z_Complex(ODR o, Z_Complex **p, int opt)
441 if (!odr_sequence_begin(o, p, sizeof(**p)))
442 return opt && odr_ok(o);
444 z_RPNStructure(o, &(*p)->s1, 0) &&
445 z_RPNStructure(o, &(*p)->s2, 0) &&
446 z_Operator(o, &(*p)->operator, 0) &&
450 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
452 static Odr_arm arm[] =
454 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
455 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
459 if (o->direction == ODR_DECODE)
460 *p = odr_malloc(o, sizeof(**p));
463 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
466 return opt && odr_ok(o);
469 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
471 if (!odr_sequence_begin(o, p, sizeof(**p)))
472 return opt && odr_ok(o);
474 odr_oid(o, &(*p)->attributeSetId, 0) &&
475 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
479 /* -----------------------END RPN QUERY ----------------------- */
481 int z_Query(ODR o, Z_Query **p, int opt)
483 static Odr_arm arm[] =
485 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
486 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
490 if (o->direction == ODR_DECODE)
491 *p = odr_malloc(o, sizeof(**p));
494 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
497 return opt && odr_ok(o);
500 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
504 if (!odr_sequence_begin(o, p, sizeof(**p)))
505 return opt && odr_ok(o);
508 z_ReferenceId(o, &pp->referenceId, 1) &&
509 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
511 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
513 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
515 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
516 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
518 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
519 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
520 &pp->num_databaseNames) &&
521 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
522 ODR_CONTEXT, 100, 1) &&
523 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
524 ODR_CONTEXT, 101, 1) &&
525 odr_implicit(o, z_PreferredRecordSyntax, &pp->preferredRecordSyntax,
526 ODR_CONTEXT, 104, 1) &&
527 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
529 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
530 ODR_CONTEXT, 203, 1) &&
531 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
536 /* ------------------------ RECORD ------------------------- */
538 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
540 return odr_external(o, (Odr_external **) p, opt);
543 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
545 if (!odr_sequence_begin(o, p, sizeof(**p)))
546 return opt && odr_ok(o);
548 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT */
549 odr_integer(o, &(*p)->condition, 0) &&
550 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
551 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT, ODR_VISIBLESTRING, 1)) &&
555 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
557 static Odr_arm arm[] =
559 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
561 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
566 if (!odr_sequence_begin(o, p, sizeof(**p)))
567 return opt && odr_ok(o);
569 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
571 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
572 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
573 odr_constructed_end(o) &&
577 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
579 if (o->direction == ODR_DECODE)
580 *p = odr_malloc(o, sizeof(**p));
581 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
588 int z_Records(ODR o, Z_Records **p, int opt)
592 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
593 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
597 if (o->direction == ODR_DECODE)
598 *p = odr_malloc(o, sizeof(**p));
601 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
604 return opt && odr_ok(o);
607 /* ------------------------ SCAN SERVICE -------------------- */
609 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
611 if (o->direction == ODR_DECODE)
612 *p = odr_malloc(o, sizeof(**p));
616 odr_implicit_settag(o, ODR_CONTEXT, 44);
617 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
618 &(*p)->num_attributes))
621 return opt && odr_ok(o);
625 * This is a temporary hack. We don't know just *what* old version of the
626 * protocol willow uses, so we'll just patiently wait for them to update
628 static int willow_scan = 0;
630 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
632 if (!*p && o->direction != ODR_DECODE)
634 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
637 return opt && odr_ok(o);
639 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
641 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
643 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
645 if (o->direction == ODR_DECODE)
646 *p = odr_malloc(o, sizeof(**p));
647 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
648 &(*p)->num_attributes))
650 if (!odr_sequence_end(o) || !odr_sequence_end(o))
652 if (!z_Term(o, &(*p)->term, 0))
654 if (!odr_constructed_end(o))
660 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
662 if (o->direction == ODR_DECODE)
663 *p = odr_malloc(o, sizeof(**p));
667 return opt && odr_ok(o);
670 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
674 return opt && !o->error;
677 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
679 if (!odr_sequence_begin(o, p, sizeof(**p)))
680 return opt && odr_ok(o);
682 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
683 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
687 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
689 if (!odr_sequence_begin(o, p, sizeof(**p)))
690 return opt && odr_ok(o);
693 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
694 z_Term(o, &(*p)->term, 0)) &&
695 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
696 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
697 ODR_CONTEXT, 4, 1) &&
698 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
700 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
701 ODR_CONTEXT, 3, 1) &&
705 int z_Entry(ODR o, Z_Entry **p, int opt)
707 static Odr_arm arm[] =
709 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
710 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
715 if (o->direction == ODR_DECODE)
716 *p = odr_malloc(o, sizeof(**p));
718 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
721 return opt && odr_ok(o);
724 int z_Entries(ODR o, Z_Entries **p, int opt)
726 if (o->direction == ODR_DECODE)
727 *p = odr_malloc(o, sizeof(**p));
731 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
738 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
740 if (o->direction == ODR_DECODE)
741 *p = odr_malloc(o, sizeof(**p));
745 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
746 &(*p)->num_diagRecs))
752 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
754 static Odr_arm arm[] =
756 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
757 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
762 if (o->direction == ODR_DECODE)
763 *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_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
773 if (!odr_sequence_begin(o, p, sizeof(**p)))
774 return opt && odr_ok(o);
777 z_ReferenceId(o, &(*p)->referenceId, 1) &&
778 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
779 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
780 &(*p)->num_databaseNames) &&
781 odr_oid(o, &(*p)->attributeSet, 1) &&
782 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
783 ((*p)->termListAndStartPoint ? 1 :
784 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
785 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
786 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
787 ODR_CONTEXT, 6, 0) &&
788 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
789 ODR_CONTEXT, 7, 1) &&
793 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
795 if (!odr_sequence_begin(o, p, sizeof(**p)))
796 return opt && odr_ok(o);
798 z_ReferenceId(o, &(*p)->referenceId, 1) &&
799 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
800 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
801 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
802 ODR_CONTEXT, 5, 0) &&
803 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
804 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
805 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
809 /* ------------------------ SEARCHRESPONSE ----------------*/
811 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
813 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
816 int z_NextResultSetPosition(ODR o, int **p, int opt)
818 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
821 int z_PresentStatus(ODR o, int **p, int opt)
823 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
826 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
828 Z_SearchResponse *pp;
830 if (!odr_sequence_begin(o, p, sizeof(**p)))
831 return opt && odr_ok(o);
834 z_ReferenceId(o, &pp->referenceId, 1) &&
835 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
836 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
837 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
838 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
839 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26, 1) &&
840 z_PresentStatus(o, &pp->presentStatus, 1) &&
841 z_Records(o, &pp->records, 1) &&
843 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
844 ODR_CONTEXT, 203, 1) &&
845 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
850 /* --------------------- PRESENT SERVICE ---------------------- */
852 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
854 Z_PresentRequest *pp;
856 if (!odr_sequence_begin(o, p, sizeof(**p)))
857 return opt && odr_ok(o);
860 z_ReferenceId(o, &pp->referenceId, 1) &&
861 z_ResultSetId(o, &pp->resultSetId, 0) &&
862 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
864 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
866 z_ElementSetNames(o, &pp->elementSetNames, 1) &&
867 z_PreferredRecordSyntax(o, &pp->preferredRecordSyntax, 1) &&
871 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
873 Z_PresentResponse *pp;
875 if (!odr_sequence_begin(o, p, sizeof(**p)))
876 return opt && odr_ok(o);
879 z_ReferenceId(o, &pp->referenceId, 1) &&
880 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
881 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
882 z_PresentStatus(o, &pp->presentStatus, 0) &&
883 z_Records(o, &pp->records, 1) &&
887 /* ----------------------DELETE -------------------------- */
889 int z_DeleteSetStatus(ODR o, int **p, int opt)
891 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
894 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
896 if (!odr_sequence_begin(o, p, sizeof(**p)))
897 return opt && odr_ok(o);
899 z_ResultSetId(o, &(*p)->id, 0) &&
900 z_DeleteSetStatus(o, &(*p)->status, 0) &&
904 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
906 if (!odr_sequence_begin(o, p, sizeof(**p)))
907 return opt && odr_ok(o);
909 z_ReferenceId(o, &(*p)->referenceId, 1) &&
910 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
912 (odr_sequence_of(o, z_ListStatus, &(*p)->resultSetList,
913 &(*p)->num_ids) || odr_ok(o)) &&
915 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
920 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
922 if (!odr_sequence_begin(o, p, sizeof(**p)))
923 return opt && odr_ok(o);
925 z_ReferenceId(o, &(*p)->referenceId, 1) &&
926 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
927 ODR_CONTEXT, 0, 1) &&
928 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
929 (odr_sequence_of(o, z_ListStatus, &(*p)->deleteListStatuses,
930 &(*p)->num_statuses) || odr_ok(o)) &&
931 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
933 odr_implicit_settag(o, ODR_CONTEXT, 35) &&
934 (odr_sequence_of(o, z_ListStatus, &(*p)->bulkStatuses,
935 &(*p)->num_bulkStatuses) || odr_ok(o)) &&
936 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
939 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
944 /* ------------------------ APDU ------------------------- */
946 int z_APDU(ODR o, Z_APDU **p, int opt)
948 static Odr_arm arm[] =
950 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
951 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
952 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
953 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
955 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
957 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
959 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
960 z_DeleteResultSetRequest},
961 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
962 z_DeleteResultSetResponse},
963 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
964 z_ResourceControlRequest},
965 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
966 z_ResourceControlResponse},
967 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
968 z_TriggerResourceControlRequest},
969 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
970 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
975 if (o->direction == ODR_DECODE)
976 *p = odr_malloc(o, sizeof(**p));
977 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
979 if (o->direction == ODR_DECODE)
981 return opt && odr_ok(o);