2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.27 1995-06-07 14:36:22 quinn
10 * Revision 1.26 1995/06/02 09:49:13 quinn
11 * Adding access control
13 * Revision 1.25 1995/05/25 11:00:08 quinn
14 * *** empty log message ***
16 * Revision 1.24 1995/05/22 13:58:18 quinn
17 * Fixed an ODR_NULLVAL.
19 * Revision 1.23 1995/05/22 11:30:18 quinn
20 * Adding Z39.50-1992 stuff to proto.c. Adding zget.c
22 * Revision 1.22 1995/05/17 08:40:56 quinn
23 * Added delete. Fixed some sequence_begins. Smallish.
25 * Revision 1.21 1995/05/16 08:50:24 quinn
26 * License, documentation, and memory fixes
28 * Revision 1.20 1995/05/15 11:55:25 quinn
31 * Revision 1.19 1995/04/11 11:58:35 quinn
34 * Revision 1.18 1995/04/11 11:52:02 quinn
35 * Fixed possible buf in proto.c
37 * Revision 1.17 1995/04/10 10:22:22 quinn
40 * Revision 1.16 1995/03/30 10:26:43 quinn
41 * Added Term structure
43 * Revision 1.15 1995/03/30 09:08:39 quinn
44 * Added Resource control protocol
46 * Revision 1.14 1995/03/29 08:06:13 quinn
47 * Added a few v3 elements
49 * Revision 1.13 1995/03/20 11:26:52 quinn
50 * *** empty log message ***
52 * Revision 1.12 1995/03/20 09:45:09 quinn
55 * Revision 1.11 1995/03/17 10:17:25 quinn
56 * Added memory management.
58 * Revision 1.10 1995/03/15 11:17:40 quinn
59 * Fixed some return-checks from choice.. need better ay to handle those..
61 * Revision 1.9 1995/03/15 08:37:06 quinn
62 * Fixed protocol bugs.
64 * Revision 1.8 1995/03/14 16:59:24 quinn
65 * Fixed OPTIONAL flag in attributeelement
67 * Revision 1.7 1995/03/07 16:29:33 quinn
68 * Added authentication stuff.
70 * Revision 1.6 1995/03/01 14:46:03 quinn
71 * Fixed protocol bug in 8777query.
73 * Revision 1.5 1995/02/14 11:54:22 quinn
76 * Revision 1.4 1995/02/10 15:54:30 quinn
79 * Revision 1.3 1995/02/09 15:51:39 quinn
82 * Revision 1.2 1995/02/06 21:26:07 quinn
83 * Repaired this evening's damages..
85 * Revision 1.1 1995/02/06 16:44:47 quinn
86 * First hack at Z/SR protocol
94 /* ---------------------- GLOBAL DEFS ------------------- */
96 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
98 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
101 int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt)
103 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 105,
107 int z_ResultSetId(ODR o, char **p, int opt)
109 return odr_implicit(o, odr_visiblestring, (char **) p, ODR_CONTEXT, 31,
113 int z_UserInformationField(ODR o, Z_UserInformationField **p, int opt)
115 return odr_explicit(o, odr_external, (Odr_external **)p, ODR_CONTEXT,
119 int z_InfoCategory(ODR o, Z_InfoCategory **p, int opt)
121 if (!odr_sequence_begin(o, p, sizeof(**p)))
122 return opt && odr_ok(o);
124 odr_implicit(o, odr_oid, &(*p)->categoryTypeId, ODR_CONTEXT, 1, 1) &&
125 odr_implicit(o, odr_integer, &(*p)->categoryValue, ODR_CONTEXT, 2, 0) &&
129 int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt)
131 static Odr_arm arm[] =
133 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_OtherInfo_characterInfo,
135 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_OtherInfo_binaryInfo,
137 {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_OtherInfo_externallyDefinedInfo,
139 {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_OtherInfo_oid, odr_oid},
143 if (!odr_sequence_begin(o, p, sizeof(**p)))
144 return opt && odr_ok(o);
146 odr_implicit(o, z_InfoCategory, &(*p)->category, ODR_CONTEXT, 1, 1) &&
147 odr_choice(o, arm, &(*p)->which, &(*p)->information) &&
151 int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt)
153 if (o->direction == ODR_ENCODE)
154 *p = odr_malloc(o, sizeof(**p));
156 odr_implicit_settag(o, ODR_CONTEXT, 201);
157 if (odr_sequence_of(o, z_OtherInformationUnit, &(*p)->list,
158 &(*p)->num_elements))
161 return opt && odr_ok(o);
164 int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt)
166 static Odr_arm arm[] =
168 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_StringOrNumeric_string,
170 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_StringOrNumeric_numeric,
175 if (o->direction == ODR_DECODE)
176 *p = odr_malloc(o, sizeof(**p));
177 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
180 return opt && odr_ok(o);
186 int z_Unit(ODR o, Z_Unit **p, int opt)
188 if (!odr_sequence_begin(o, p, sizeof(**p)))
189 return opt && odr_ok(o);
191 odr_implicit(o, odr_visiblestring, &(*p)->unitSystem, ODR_CONTEXT,
193 odr_explicit(o, z_StringOrNumeric, &(*p)->unitType, ODR_CONTEXT,
195 odr_explicit(o, z_StringOrNumeric, &(*p)->unit, ODR_CONTEXT, 3, 1) &&
196 odr_implicit(o, odr_integer, &(*p)->scaleFactor, ODR_CONTEXT, 4, 1) &&
200 int z_IntUnit(ODR o, Z_IntUnit **p, int opt)
202 if (!odr_sequence_begin(o, p, sizeof(**p)))
203 return opt && odr_ok(o);
205 odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 1, 0) &&
206 odr_implicit(o, z_Unit, &(*p)->unitUsed, ODR_CONTEXT, 2, 0) &&
210 /* ---------------------- INITIALIZE SERVICE ------------------- */
213 int z_NSRAuthentication(ODR o, Z_NSRAuthentication **p, int opt)
215 if (!odr_sequence_begin(o, p, sizeof(**p)))
216 return opt && odr_ok(o);
218 odr_visiblestring(o, &(*p)->user, 0) &&
219 odr_visiblestring(o, &(*p)->password, 0) &&
220 odr_visiblestring(o, &(*p)->account, 0) &&
225 int z_IdPass(ODR o, Z_IdPass **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)->groupId, ODR_CONTEXT, 0, 1) &&
231 odr_implicit(o, odr_visiblestring, &(*p)->userId, ODR_CONTEXT, 1, 1) &&
232 odr_implicit(o, odr_visiblestring, &(*p)->password, ODR_CONTEXT, 2,
237 int z_StrAuthentication(ODR o, char **p, int opt)
239 return odr_visiblestring(o, p, opt);
242 int z_IdAuthentication(ODR o, Z_IdAuthentication **p, int opt)
244 static Odr_arm arm[] =
246 {-1, -1, -1, Z_IdAuthentication_open, z_StrAuthentication},
247 {-1, -1, -1, Z_IdAuthentication_idPass, z_IdPass},
248 {-1, -1, -1, Z_IdAuthentication_anonymous, odr_null},
249 {-1, -1, -1, Z_IdAuthentication_other, odr_external},
253 if (o->direction == ODR_DECODE)
254 *p = odr_malloc(o, sizeof(**p));
256 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
259 return opt && odr_ok(o);
262 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
266 if (!odr_sequence_begin(o, p, sizeof(**p)))
267 return opt && odr_ok(o);
270 z_ReferenceId(o, &pp->referenceId, 1) &&
271 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
273 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
274 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
276 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
278 odr_explicit(o, z_IdAuthentication, &pp->idAuthentication, ODR_CONTEXT,
280 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
282 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
284 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
285 ODR_CONTEXT, 112, 1) &&
286 z_UserInformationField(o, &pp->userInformationField, 1) &&
288 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
293 int z_InitResponse(ODR o, Z_InitResponse **p, int opt)
297 if (!odr_sequence_begin(o, p, sizeof(**p)))
298 return opt && odr_ok(o);
301 z_ReferenceId(o, &pp->referenceId, 1) &&
302 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
304 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
305 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
307 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
309 odr_implicit(o, odr_bool, &pp->result, ODR_CONTEXT, 12, 0) &&
310 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
312 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
314 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
315 ODR_CONTEXT, 112, 1) &&
316 z_UserInformationField(o, &pp->userInformationField, 1) &&
318 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
323 /* ------------------ RESOURCE CONTROL ----------------*/
325 int z_TriggerResourceControlRequest(ODR o, Z_TriggerResourceControlRequest **p,
328 if (!odr_sequence_begin(o, p, sizeof(**p)))
329 return opt && odr_ok(o);
331 z_ReferenceId(o, &(*p)->referenceId, 1) &&
332 odr_implicit(o, odr_integer, &(*p)->requestedAction, ODR_CONTEXT,
334 odr_implicit(o, odr_oid, &(*p)->prefResourceReportFormat,
335 ODR_CONTEXT, 47, 1) &&
336 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
339 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
344 int z_ResourceControlRequest(ODR o, Z_ResourceControlRequest **p, int opt)
346 if (!odr_sequence_begin(o, p, sizeof(**p)))
347 return opt && odr_ok(o);
349 z_ReferenceId(o, &(*p)->referenceId, 1) &&
350 odr_implicit(o, odr_bool, &(*p)->suspendedFlag, ODR_CONTEXT, 39, 1)&&
351 odr_explicit(o, odr_external, &(*p)->resourceReport, ODR_CONTEXT,
353 odr_implicit(o, odr_integer, &(*p)->partialResultsAvailable,
354 ODR_CONTEXT, 41, 1) &&
355 odr_implicit(o, odr_bool, &(*p)->responseRequired, ODR_CONTEXT,
357 odr_implicit(o, odr_bool, &(*p)->triggeredRequestFlag,
358 ODR_CONTEXT, 43, 1) &&
360 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
365 int z_ResourceControlResponse(ODR o, Z_ResourceControlResponse **p, int opt)
367 if (!odr_sequence_begin(o, p, sizeof(**p)))
368 return opt && odr_ok(o);
370 z_ReferenceId(o, &(*p)->referenceId, 1) &&
371 odr_implicit(o, odr_bool, &(*p)->continueFlag, ODR_CONTEXT, 44, 0) &&
372 odr_implicit(o, odr_bool, &(*p)->resultSetWanted, ODR_CONTEXT,
375 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
380 /* ------------------------ SEARCH SERVICE ----------------------- */
382 int z_ElementSetName(ODR o, char **p, int opt)
384 return odr_implicit(o, odr_visiblestring, (char**) p, ODR_CONTEXT, 103,
388 int z_PreferredRecordSyntax(ODR o, Z_PreferredRecordSyntax **p, int opt)
390 return odr_implicit(o, odr_oid, (Odr_oid**) p, ODR_CONTEXT, 104, opt);
393 int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
395 if (!odr_sequence_begin(o, p, sizeof(**p)))
396 return opt && odr_ok(o);
398 z_DatabaseName(o, &(*p)->databaseName, 0) &&
399 z_ElementSetName(o, &(*p)->elementSetName, 0) &&
403 int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
405 if (o->direction == ODR_DECODE)
406 *p = odr_malloc(o, sizeof(**p));
410 odr_implicit_settag(o, ODR_CONTEXT, 1);
411 if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
412 &(*p)->num_elements))
418 int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
420 static Odr_arm arm[] =
422 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
424 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
429 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 19))
430 return opt && odr_ok(o);
432 if (o->direction == ODR_DECODE)
433 *p = odr_malloc(o, sizeof(**p));
435 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
436 odr_constructed_end(o))
442 /* ----------------------- RPN QUERY -----------------------*/
444 int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt)
446 if (!odr_sequence_begin(o, p, sizeof(**p)))
447 return opt && odr_ok(o);
449 odr_implicit(o, odr_integer, &(*p)->attributeType, ODR_CONTEXT,
451 odr_implicit(o, odr_integer, &(*p)->attributeValue, ODR_CONTEXT,
458 int z_Term(ODR o, Z_Term **p, int opt)
460 static Odr_arm arm[] =
462 {ODR_IMPLICIT, ODR_CONTEXT, 45, Z_Term_general, odr_octetstring},
463 {ODR_IMPLICIT, ODR_CONTEXT, 215, Z_Term_numeric, odr_integer},
464 {ODR_IMPLICIT, ODR_CONTEXT, 216, Z_Term_characterString,
466 {ODR_IMPLICIT, ODR_CONTEXT, 217, Z_Term_oid, odr_oid},
467 {ODR_IMPLICIT, ODR_CONTEXT, 218, Z_Term_dateTime, odr_cstring},
468 {ODR_IMPLICIT, ODR_CONTEXT, 219, Z_Term_external, odr_external},
469 /* add intUnit here */
470 {ODR_IMPLICIT, ODR_CONTEXT, 221, Z_Term_null, odr_null},
474 if (o->direction ==ODR_DECODE)
475 *p = odr_malloc(o, sizeof(**p));
478 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
481 return opt && odr_ok(o);
486 int z_AttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
488 if (!(odr_implicit_settag(o, ODR_CONTEXT, 102) &&
489 odr_sequence_begin(o, p, sizeof(**p))))
490 return opt && odr_ok(o);
492 odr_implicit_settag(o, ODR_CONTEXT, 44) &&
493 odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
494 &(*p)->num_attributes) &&
495 z_Term(o, &(*p)->term, 0) &&
499 int z_ProximityOperator(ODR o, Z_ProximityOperator **p, int opt)
501 static Odr_arm arm[] =
503 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_known, odr_integer},
504 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ProxCode_private, odr_integer},
508 if (!odr_sequence_begin(o, p, sizeof(**p)))
509 return opt && odr_ok(o);
511 odr_implicit(o, odr_bool, &(*p)->exclusion, ODR_CONTEXT, 1, 1) &&
512 odr_implicit(o, odr_integer, &(*p)->distance, ODR_CONTEXT, 2, 0) &&
513 odr_implicit(o, odr_bool, &(*p)->ordered, ODR_CONTEXT, 3, 0) &&
514 odr_implicit(o, odr_integer, &(*p)->relationType, ODR_CONTEXT, 4, 0) &&
515 odr_constructed_begin(o, &(*p)->proximityUnitCode, ODR_CONTEXT, 5) &&
516 odr_choice(o, arm, &(*p)->proximityUnitCode, &(*p)->which) &&
517 odr_constructed_end(o) &&
521 int z_Operator(ODR o, Z_Operator **p, int opt)
523 static Odr_arm arm[] =
525 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_Operator_and, odr_null},
526 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Operator_or, odr_null},
527 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Operator_and_not, odr_null},
528 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Operator_prox, z_ProximityOperator},
532 if (!*p && o->direction != ODR_DECODE)
534 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 46))
535 return opt && odr_ok(o);
536 if (o->direction == ODR_DECODE)
537 *p = odr_malloc(o, sizeof(**p));
539 (*p)->u.and = ODR_NULLVAL;
541 if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
542 odr_constructed_end(o))
545 return opt && odr_ok(o);
548 int z_Operand(ODR o, Z_Operand **p, int opt)
550 static Odr_arm arm[] =
552 {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
553 {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
557 if (o->direction ==ODR_DECODE)
558 *p = odr_malloc(o, sizeof(**p));
561 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
564 return opt && odr_ok(o);
567 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt);
569 int z_Complex(ODR o, Z_Complex **p, int opt)
571 if (!odr_sequence_begin(o, p, sizeof(**p)))
572 return opt && odr_ok(o);
574 z_RPNStructure(o, &(*p)->s1, 0) &&
575 z_RPNStructure(o, &(*p)->s2, 0) &&
576 z_Operator(o, &(*p)->operator, 0) &&
580 int z_RPNStructure(ODR o, Z_RPNStructure **p, int opt)
582 static Odr_arm arm[] =
584 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand},
585 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
589 if (o->direction == ODR_DECODE)
590 *p = odr_malloc(o, sizeof(**p));
593 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
596 return opt && odr_ok(o);
599 int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
601 if (!odr_sequence_begin(o, p, sizeof(**p)))
602 return opt && odr_ok(o);
604 odr_oid(o, &(*p)->attributeSetId, 0) &&
605 z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
609 /* -----------------------END RPN QUERY ----------------------- */
611 int z_Query(ODR o, Z_Query **p, int opt)
613 static Odr_arm arm[] =
615 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
616 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_octetstring},
620 if (o->direction == ODR_DECODE)
621 *p = odr_malloc(o, sizeof(**p));
624 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
627 return opt && odr_ok(o);
630 int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
634 if (!odr_sequence_begin(o, p, sizeof(**p)))
635 return opt && odr_ok(o);
638 z_ReferenceId(o, &pp->referenceId, 1) &&
639 odr_implicit(o, odr_integer, &pp->smallSetUpperBound, ODR_CONTEXT,
641 odr_implicit(o, odr_integer, &pp->largeSetLowerBound, ODR_CONTEXT,
643 odr_implicit(o, odr_integer, &pp->mediumSetPresentNumber, ODR_CONTEXT,
645 odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
646 odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
648 odr_implicit_settag(o, ODR_CONTEXT, 18) &&
649 odr_sequence_of(o, z_DatabaseName, &pp->databaseNames,
650 &pp->num_databaseNames) &&
651 odr_explicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
652 ODR_CONTEXT, 100, 1) &&
653 odr_explicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
654 ODR_CONTEXT, 101, 1) &&
655 odr_implicit(o, z_PreferredRecordSyntax, &pp->preferredRecordSyntax,
656 ODR_CONTEXT, 104, 1) &&
657 odr_explicit(o, z_Query, &pp->query, ODR_CONTEXT, 21, 0) &&
659 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
660 ODR_CONTEXT, 203, 1) &&
661 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
666 /* ------------------------ RECORD ------------------------- */
668 int z_DatabaseRecord(ODR o, Z_DatabaseRecord **p, int opt)
670 return odr_external(o, (Odr_external **) p, opt);
673 int z_DiagRec(ODR o, Z_DiagRec **p, int opt)
675 if (!odr_sequence_begin(o, p, sizeof(**p)))
676 return opt && odr_ok(o);
678 odr_oid(o, &(*p)->diagnosticSetId, 1) && /* SHOULD NOT BE OPT */
679 odr_integer(o, &(*p)->condition, 0) &&
680 (odr_visiblestring(o, &(*p)->addinfo, 0) ||
681 odr_implicit(o, odr_cstring, &(*p)->addinfo, ODR_CONTEXT, ODR_VISIBLESTRING, 1)) &&
685 int z_NamePlusRecord(ODR o, Z_NamePlusRecord **p, int opt)
687 static Odr_arm arm[] =
689 {ODR_EXPLICIT, ODR_CONTEXT, 1, Z_NamePlusRecord_databaseRecord,
691 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_NamePlusRecord_surrogateDiagnostic,
696 if (!odr_sequence_begin(o, p, sizeof(**p)))
697 return opt && odr_ok(o);
699 odr_implicit(o, z_DatabaseName, &(*p)->databaseName, ODR_CONTEXT,
701 odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1) &&
702 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
703 odr_constructed_end(o) &&
707 int z_NamePlusRecordList(ODR o, Z_NamePlusRecordList **p, int opt)
709 if (o->direction == ODR_DECODE)
710 *p = odr_malloc(o, sizeof(**p));
711 if (odr_sequence_of(o, z_NamePlusRecord, &(*p)->records,
718 int z_Records(ODR o, Z_Records **p, int opt)
722 {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD, z_NamePlusRecordList},
723 {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD, z_DiagRec},
727 if (o->direction == ODR_DECODE)
728 *p = odr_malloc(o, sizeof(**p));
731 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
734 return opt && odr_ok(o);
737 /* ------------------------ ACCESS CTRL SERVICE ----------------------- */
739 int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt)
741 static Odr_arm arm[] =
743 {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
745 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
749 if (!odr_sequence_begin(o, p, sizeof(**p)))
750 return opt && odr_ok(o);
752 z_ReferenceId(o, &(*p)->referenceId, 1) &&
753 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
755 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
760 int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt)
762 static Odr_arm arm[] =
764 {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
766 {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
770 if (!odr_sequence_begin(o, p, sizeof(**p)))
771 return opt && odr_ok(o);
773 z_ReferenceId(o, &(*p)->referenceId, 1) &&
774 odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
775 odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
777 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
782 /* ------------------------ SCAN SERVICE -------------------- */
784 int z_AttributeList(ODR o, Z_AttributeList **p, int opt)
786 if (o->direction == ODR_DECODE)
787 *p = odr_malloc(o, sizeof(**p));
791 odr_implicit_settag(o, ODR_CONTEXT, 44);
792 if (odr_sequence_of(o, z_AttributeElement, &(*p)->attributes,
793 &(*p)->num_attributes))
796 return opt && odr_ok(o);
800 * This is a temporary hack. We don't know just *what* old version of the
801 * protocol willow uses, so we'll just patiently wait for them to update
803 static int willow_scan = 0;
805 int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt)
807 if (!*p && o->direction != ODR_DECODE)
809 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4))
812 return opt && odr_ok(o);
814 if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1))
816 if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE))
818 if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
820 if (o->direction == ODR_DECODE)
821 *p = odr_malloc(o, sizeof(**p));
822 if (!odr_sequence_of(o, z_AttributeElement, &(*p)->attributeList,
823 &(*p)->num_attributes))
825 if (!odr_sequence_end(o) || !odr_sequence_end(o))
827 if (!z_Term(o, &(*p)->term, 0))
829 if (!odr_constructed_end(o))
835 int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
837 if (o->direction == ODR_DECODE)
838 *p = odr_malloc(o, sizeof(**p));
842 return opt && odr_ok(o);
845 if (odr_sequence_of(o, z_AttributesPlusTerm, &(*p)->terms,
849 return opt && !o->error;
852 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
854 if (!odr_sequence_begin(o, p, sizeof(**p)))
855 return opt && odr_ok(o);
857 odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT, 1, 1)&&
858 odr_explicit(o, odr_integer, &(*p)->global, ODR_CONTEXT, 2, 1) &&
862 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
864 if (!odr_sequence_begin(o, p, sizeof(**p)))
865 return opt && odr_ok(o);
868 odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
869 z_Term(o, &(*p)->term, 0)) &&
870 z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
871 odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
872 ODR_CONTEXT, 4, 1) &&
873 odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
875 odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
876 ODR_CONTEXT, 3, 1) &&
880 int z_Entry(ODR o, Z_Entry **p, int opt)
882 static Odr_arm arm[] =
884 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Entry_termInfo, z_TermInfo},
885 {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_Entry_surrogateDiagnostic,
890 if (o->direction == ODR_DECODE)
891 *p = odr_malloc(o, sizeof(**p));
893 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
896 return opt && odr_ok(o);
899 int z_Entries(ODR o, Z_Entries **p, int opt)
901 if (o->direction == ODR_DECODE)
902 *p = odr_malloc(o, sizeof(**p));
906 if (odr_sequence_of(o, z_Entry, &(*p)->entries,
913 int z_DiagRecs(ODR o, Z_DiagRecs **p, int opt)
915 if (o->direction == ODR_DECODE)
916 *p = odr_malloc(o, sizeof(**p));
920 if (odr_sequence_of(o, z_DiagRec, &(*p)->diagRecs,
921 &(*p)->num_diagRecs))
927 int z_ListEntries(ODR o, Z_ListEntries **p, int opt)
929 static Odr_arm arm[] =
931 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ListEntries_entries, z_Entries},
932 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ListEntries_nonSurrogateDiagnostics,
937 if (o->direction == ODR_DECODE)
938 *p = odr_malloc(o, sizeof(**p));
940 if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
943 return opt && odr_ok(o);
946 int z_ScanRequest(ODR o, Z_ScanRequest **p, int opt)
948 if (!odr_sequence_begin(o, p, sizeof(**p)))
949 return opt && odr_ok(o);
952 z_ReferenceId(o, &(*p)->referenceId, 1) &&
953 odr_implicit_settag(o, ODR_CONTEXT, 3) &&
954 odr_sequence_of(o, z_DatabaseName, &(*p)->databaseNames,
955 &(*p)->num_databaseNames) &&
956 odr_oid(o, &(*p)->attributeSet, 1) &&
957 (z_AttributesPlusTerm(o, &(*p)->termListAndStartPoint, 1) ?
958 ((*p)->termListAndStartPoint ? 1 :
959 z_WillowAttributesPlusTerm(o, &(*p)->termListAndStartPoint, 0)) : 0) &&
960 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 5, 1) &&
961 odr_implicit(o, odr_integer, &(*p)->numberOfTermsRequested,
962 ODR_CONTEXT, 6, 0) &&
963 odr_implicit(o, odr_integer, &(*p)->preferredPositionInResponse,
964 ODR_CONTEXT, 7, 1) &&
968 int z_ScanResponse(ODR o, Z_ScanResponse **p, int opt)
970 if (!odr_sequence_begin(o, p, sizeof(**p)))
971 return opt && odr_ok(o);
973 z_ReferenceId(o, &(*p)->referenceId, 1) &&
974 odr_implicit(o, odr_integer, &(*p)->stepSize, ODR_CONTEXT, 3, 1) &&
975 odr_implicit(o, odr_integer, &(*p)->scanStatus, ODR_CONTEXT, 4, 0) &&
976 odr_implicit(o, odr_integer, &(*p)->numberOfEntriesReturned,
977 ODR_CONTEXT, 5, 0) &&
978 odr_implicit(o, odr_integer, &(*p)->positionOfTerm, ODR_CONTEXT, 6, 1)&&
979 odr_explicit(o, z_ListEntries, &(*p)->entries, ODR_CONTEXT, 7, 1) &&
980 odr_implicit(o, odr_oid, &(*p)->attributeSet, ODR_CONTEXT, 8, 1) &&
984 /* ------------------------ SEARCHRESPONSE ----------------*/
986 int z_NumberOfRecordsReturned(ODR o, int **p, int opt)
988 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 24, opt);
991 int z_NextResultSetPosition(ODR o, int **p, int opt)
993 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 25, opt);
996 int z_PresentStatus(ODR o, int **p, int opt)
998 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 27, opt);
1001 int z_SearchResponse(ODR o, Z_SearchResponse **p, int opt)
1003 Z_SearchResponse *pp;
1005 if (!odr_sequence_begin(o, p, sizeof(**p)))
1006 return opt && odr_ok(o);
1009 z_ReferenceId(o, &pp->referenceId, 1) &&
1010 odr_implicit(o, odr_integer, &pp->resultCount, ODR_CONTEXT, 23, 0) &&
1011 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1012 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1013 odr_implicit(o, odr_bool, &pp->searchStatus, ODR_CONTEXT, 22, 0) &&
1014 odr_implicit(o, odr_integer, &pp->resultSetStatus, ODR_CONTEXT, 26, 1) &&
1015 z_PresentStatus(o, &pp->presentStatus, 1) &&
1016 z_Records(o, &pp->records, 1) &&
1018 odr_implicit(o, z_OtherInformation, &(*p)->additionalSearchInfo,
1019 ODR_CONTEXT, 203, 1) &&
1020 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1022 odr_sequence_end(o);
1025 /* --------------------- PRESENT SERVICE ---------------------- */
1027 int z_PresentRequest(ODR o, Z_PresentRequest **p, int opt)
1029 Z_PresentRequest *pp;
1031 if (!odr_sequence_begin(o, p, sizeof(**p)))
1032 return opt && odr_ok(o);
1035 z_ReferenceId(o, &pp->referenceId, 1) &&
1036 z_ResultSetId(o, &pp->resultSetId, 0) &&
1037 odr_implicit(o, odr_integer, &pp->resultSetStartPoint, ODR_CONTEXT,
1039 odr_implicit(o, odr_integer, &pp->numberOfRecordsRequested, ODR_CONTEXT,
1041 z_ElementSetNames(o, &pp->elementSetNames, 1) &&
1042 z_PreferredRecordSyntax(o, &pp->preferredRecordSyntax, 1) &&
1043 odr_sequence_end(o);
1046 int z_PresentResponse(ODR o, Z_PresentResponse **p, int opt)
1048 Z_PresentResponse *pp;
1050 if (!odr_sequence_begin(o, p, sizeof(**p)))
1051 return opt && odr_ok(o);
1054 z_ReferenceId(o, &pp->referenceId, 1) &&
1055 z_NumberOfRecordsReturned(o, &pp->numberOfRecordsReturned, 0) &&
1056 z_NextResultSetPosition(o, &pp->nextResultSetPosition, 0) &&
1057 z_PresentStatus(o, &pp->presentStatus, 0) &&
1058 z_Records(o, &pp->records, 1) &&
1059 odr_sequence_end(o);
1062 /* ----------------------DELETE -------------------------- */
1064 int z_DeleteSetStatus(ODR o, int **p, int opt)
1066 return odr_implicit(o, odr_integer, p, ODR_CONTEXT, 33, opt);
1069 int z_ListStatus(ODR o, Z_ListStatus **p, int opt)
1071 if (!odr_sequence_begin(o, p, sizeof(**p)))
1072 return opt && odr_ok(o);
1074 z_ResultSetId(o, &(*p)->id, 0) &&
1075 z_DeleteSetStatus(o, &(*p)->status, 0) &&
1076 odr_sequence_end(o);
1079 int z_DeleteResultSetRequest(ODR o, Z_DeleteResultSetRequest **p, int opt)
1081 if (!odr_sequence_begin(o, p, sizeof(**p)))
1082 return opt && odr_ok(o);
1084 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1085 odr_implicit(o, odr_integer, &(*p)->deleteFunction, ODR_CONTEXT, 32,
1087 (odr_sequence_of(o, z_ListStatus, &(*p)->resultSetList,
1088 &(*p)->num_ids) || odr_ok(o)) &&
1090 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1092 odr_sequence_end(o);
1095 int z_DeleteResultSetResponse(ODR o, Z_DeleteResultSetResponse **p, int opt)
1097 if (!odr_sequence_begin(o, p, sizeof(**p)))
1098 return opt && odr_ok(o);
1100 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1101 odr_implicit(o, z_DeleteSetStatus, &(*p)->deleteOperationStatus,
1102 ODR_CONTEXT, 0, 1) &&
1103 odr_implicit_settag(o, ODR_CONTEXT, 1) &&
1104 (odr_sequence_of(o, z_ListStatus, &(*p)->deleteListStatuses,
1105 &(*p)->num_statuses) || odr_ok(o)) &&
1106 odr_implicit(o, odr_integer, &(*p)->numberNotDeleted, ODR_CONTEXT,
1108 odr_implicit_settag(o, ODR_CONTEXT, 35) &&
1109 (odr_sequence_of(o, z_ListStatus, &(*p)->bulkStatuses,
1110 &(*p)->num_bulkStatuses) || odr_ok(o)) &&
1111 odr_implicit(o, odr_visiblestring, &(*p)->deleteMessage, ODR_CONTEXT,
1114 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1116 odr_sequence_end(o);
1119 /* ------------------------ CLOSE SERVICE ---------------- */
1121 int z_Close(ODR o, Z_Close **p, int opt)
1123 if (!odr_sequence_begin(o, p, sizeof(**p)))
1124 return opt && odr_ok(o);
1126 z_ReferenceId(o, &(*p)->referenceId, 1) &&
1127 odr_implicit(o, odr_integer, &(*p)->closeReason, ODR_CONTEXT, 211, 0) &&
1128 odr_implicit(o, odr_visiblestring, &(*p)->diagnosticInformation,
1129 ODR_CONTEXT, 3, 1) &&
1130 odr_implicit(o, odr_oid, &(*p)->resourceReportFormat, ODR_CONTEXT,
1132 odr_implicit(o, odr_external, &(*p)->resourceReport, ODR_CONTEXT,
1135 z_OtherInformation(o, &(*p)->otherInfo, 1) &&
1137 odr_sequence_end(o);
1140 /* ------------------------ APDU ------------------------- */
1142 int z_APDU(ODR o, Z_APDU **p, int opt)
1144 static Odr_arm arm[] =
1146 {ODR_IMPLICIT, ODR_CONTEXT, 20, Z_APDU_initRequest, z_InitRequest},
1147 {ODR_IMPLICIT, ODR_CONTEXT, 21, Z_APDU_initResponse, z_InitResponse},
1148 {ODR_IMPLICIT, ODR_CONTEXT, 22, Z_APDU_searchRequest, z_SearchRequest},
1149 {ODR_IMPLICIT, ODR_CONTEXT, 23, Z_APDU_searchResponse,
1151 {ODR_IMPLICIT, ODR_CONTEXT, 24, Z_APDU_presentRequest,
1153 {ODR_IMPLICIT, ODR_CONTEXT, 25, Z_APDU_presentResponse,
1155 {ODR_IMPLICIT, ODR_CONTEXT, 26, Z_APDU_deleteResultSetRequest,
1156 z_DeleteResultSetRequest},
1157 {ODR_IMPLICIT, ODR_CONTEXT, 27, Z_APDU_deleteResultSetResponse,
1158 z_DeleteResultSetResponse},
1159 {ODR_IMPLICIT, ODR_CONTEXT, 30, Z_APDU_resourceControlRequest,
1160 z_ResourceControlRequest},
1161 {ODR_IMPLICIT, ODR_CONTEXT, 31, Z_APDU_resourceControlResponse,
1162 z_ResourceControlResponse},
1163 {ODR_IMPLICIT, ODR_CONTEXT, 32, Z_APDU_triggerResourceControlRequest,
1164 z_TriggerResourceControlRequest},
1165 {ODR_IMPLICIT, ODR_CONTEXT, 35, Z_APDU_scanRequest, z_ScanRequest},
1166 {ODR_IMPLICIT, ODR_CONTEXT, 36, Z_APDU_scanResponse, z_ScanResponse},
1167 {ODR_IMPLICIT, ODR_CONTEXT, 48, Z_APDU_close, z_Close},
1172 if (o->direction == ODR_DECODE)
1173 *p = odr_malloc(o, sizeof(**p));
1174 if (!odr_choice(o, arm, &(*p)->u, &(*p)->which))
1176 if (o->direction == ODR_DECODE)
1178 return opt && odr_ok(o);