+int z_Records(ODR o, Z_Records **p, int opt, const char *name)
+{
+ static Odr_arm arm[] =
+ {
+ {ODR_IMPLICIT, ODR_CONTEXT, 28, Z_Records_DBOSD,
+ (Odr_fun)z_NamePlusRecordList, 0},
+ {ODR_IMPLICIT, ODR_CONTEXT, 130, Z_Records_NSD,
+ (Odr_fun)z_DiagRec, 0},
+ {ODR_IMPLICIT, ODR_CONTEXT, 205, Z_Records_multipleNSD,
+ (Odr_fun)z_DiagRecs, 0},
+ {-1, -1, -1, -1, 0, 0}
+ };
+
+ if (o->direction == ODR_DECODE)
+ *p = (Z_Records *)odr_malloc(o, sizeof(**p));
+ else if (!*p)
+ return opt;
+ if (odr_choice(o, arm, &(*p)->u, &(*p)->which, 0))
+ return 1;
+ *p = 0;
+ return opt && odr_ok(o);
+}
+
+/* ------------------------ ACCESS CTRL SERVICE ----------------------- */
+
+int z_AccessControlRequest(ODR o, Z_AccessControlRequest **p, int opt,
+ const char *name)
+{
+ static Odr_arm arm[] =
+ {
+ {ODR_IMPLICIT, ODR_CONTEXT, 37, Z_AccessRequest_simpleForm,
+ (Odr_fun)odr_octetstring, 0},
+ {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessRequest_externallyDefined,
+ (Odr_fun)z_External, 0},
+ {-1, -1, -1, -1, 0, 0}
+ };
+ if (!odr_sequence_begin(o, p, sizeof(**p), 0))
+ return opt && odr_ok(o);
+ return
+ z_ReferenceId(o, &(*p)->referenceId, 1, 0) &&
+ odr_choice(o, arm, &(*p)->u, &(*p)->which, 0) &&
+ z_OtherInformation(o, &(*p)->otherInfo, 1, 0) &&
+ odr_sequence_end(o);
+}
+
+int z_AccessControlResponse(ODR o, Z_AccessControlResponse **p, int opt,
+ const char *name)
+{
+ static Odr_arm arm[] =
+ {
+ {ODR_IMPLICIT, ODR_CONTEXT, 38, Z_AccessResponse_simpleForm,
+ (Odr_fun)odr_octetstring, 0},
+ {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_AccessResponse_externallyDefined,
+ (Odr_fun)z_External, 0},
+ {-1, -1, -1, -1, 0, 0}
+ };
+ if (!odr_sequence_begin(o, p, sizeof(**p), 0))
+ return opt && odr_ok(o);
+ return
+ z_ReferenceId(o, &(*p)->referenceId, 1, 0) &&
+ odr_choice(o, arm, &(*p)->u, &(*p)->which, 0) &&
+ odr_explicit(o, z_DiagRec, &(*p)->diagnostic, ODR_CONTEXT, 223, 1) &&
+ z_OtherInformation(o, &(*p)->otherInfo, 1, 0) &&
+ odr_sequence_end(o);
+}
+
+/* ------------------------ SCAN SERVICE -------------------- */
+
+int z_AttributeList(ODR o, Z_AttributeList **p, int opt, const char *name)
+{
+ if (o->direction == ODR_DECODE)
+ *p = (Z_AttributeList *)odr_malloc(o, sizeof(**p));
+ else if (!*p)
+ return opt;
+
+ odr_implicit_settag(o, ODR_CONTEXT, 44);
+ if (odr_sequence_of(o, (Odr_fun)z_AttributeElement, &(*p)->attributes,
+ &(*p)->num_attributes, 0))
+ return 1;
+ *p = 0;
+ return opt && odr_ok(o);
+}
+
+/*
+ * This is a temporary hack. We don't know just *what* old version of the
+ * protocol willow uses, so we'll just patiently wait for them to update
+ */
+static int willow_scan = 0;
+
+int z_WillowAttributesPlusTerm(ODR o, Z_AttributesPlusTerm **p, int opt,
+ const char *name)
+{
+ if (!*p && o->direction != ODR_DECODE)
+ return opt;
+ if (!odr_constructed_begin(o, p, ODR_CONTEXT, 4, 0))
+ {
+ o->t_class = -1;
+ return opt && odr_ok(o);
+ }
+ if (!odr_constructed_begin(o, p, ODR_CONTEXT, 1, 0))
+ return 0;
+ if (!odr_constructed_begin(o, p, ODR_UNIVERSAL, ODR_SEQUENCE, 0))
+ return 0;
+ if (!odr_implicit_settag(o, ODR_CONTEXT, 44))
+ return 0;
+ if (o->direction == ODR_DECODE)
+ *p = (Z_AttributesPlusTerm*)odr_malloc(o, sizeof(**p));
+ if (!odr_sequence_of(o, (Odr_fun)z_AttributeElement, &(*p)->attributeList,
+ &(*p)->num_attributes, 0))
+ return 0;
+ if (!odr_sequence_end(o) || !odr_sequence_end(o))
+ return 0;
+ if (!z_Term(o, &(*p)->term, 0, 0))
+ return 0;
+ if (!odr_constructed_end(o))
+ return 0;
+ willow_scan = 1;
+ return 1;
+}
+
+int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt, const char *name)
+{
+ if (o->direction == ODR_DECODE)
+ *p = (Z_AlternativeTerm *)odr_malloc(o, sizeof(**p));
+ else if (!*p)
+ {
+ o->t_class = -1;
+ return opt && odr_ok(o);
+ }
+
+ if (odr_sequence_of(o, (Odr_fun)z_AttributesPlusTerm, &(*p)->terms,
+ &(*p)->num_terms, 0))
+ return 1;
+ *p = 0;
+ return opt && !o->error;
+}
+
+int z_ByDatabase(ODR o, Z_ByDatabase **p, int opt, const char *name)
+{
+ if (!odr_sequence_begin(o, p, sizeof(**p), 0))
+ return opt && odr_ok(o);
+ return
+ z_DatabaseName(o, &(*p)->db, 1, 0) &&
+ odr_implicit(o, odr_integer, &(*p)->num, ODR_CONTEXT, 1, 1) &&
+ z_OtherInformation(o, &(*p)->otherDbInfo, 1, 0) &&
+ odr_sequence_end(o);
+}
+
+int z_ByDatabaseList(ODR o, Z_ByDatabaseList **p, int opt, const char *name)
+{
+ if (!odr_initmember(o, p, sizeof(**p)))
+ return opt && odr_ok(o);
+ if (odr_sequence_of(o, (Odr_fun)z_ByDatabase, &(*p)->elements,
+ &(*p)->num_elements, 0))
+ return 1;
+ *p = 0;
+ return opt && odr_ok(o);
+}
+
+int z_ScanOccurrences(ODR o, Z_ScanOccurrences **p, int opt, const char *name)
+{
+ Odr_arm arm[] =
+ {
+ {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_ScanOccurrences_global,
+ (Odr_fun)odr_integer, 0},
+ {ODR_EXPLICIT, ODR_CONTEXT, 3, Z_ScanOccurrences_byDatabase,
+ (Odr_fun)z_ByDatabaseList, 0},
+ {-1, -1, -1, -1, 0, 0}
+ };
+
+ if (!odr_initmember(o, p, sizeof(**p)))
+ return opt && odr_ok(o);
+ if (odr_choice(o, arm, &(*p)->u, &(*p)->which, 0))
+ return 1;
+ *p = 0;
+ return opt && odr_ok(o);
+}
+
+int z_OccurrenceByAttributesElem(ODR o, Z_OccurrenceByAttributesElem **p,
+ int opt, const char *name)
+{
+ if (!odr_sequence_begin(o, p, sizeof(**p), 0))
+ return opt && odr_ok(o);
+ return
+ odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT,
+ 1, 1) &&
+ z_ScanOccurrences(o, &(*p)->occurrences, 1, 0) &&
+ z_OtherInformation(o, &(*p)->otherOccurInfo, 1, 0) &&
+ odr_sequence_end(o);
+}
+
+int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt, const char *name)
+{
+ if (!odr_initmember(o, p, sizeof(**p)))
+ return opt && odr_ok(o);
+ if (!odr_sequence_of(o, (Odr_fun)z_OccurrenceByAttributesElem,
+ &(*p)->elements, &(*p)->num_elements, 0))
+ return 1;
+ *p = 0;
+ return opt && odr_ok(o);
+}
+
+int z_TermInfo(ODR o, Z_TermInfo **p, int opt, const char *name)
+{
+ if (!odr_sequence_begin(o, p, sizeof(**p), 0))
+ return opt && odr_ok(o);
+ return
+ (willow_scan ?
+ odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
+ z_Term(o, &(*p)->term, 0, 0)) &&
+ odr_implicit(o, z_InternationalString, &(*p)->displayTerm, ODR_CONTEXT,
+ 0, 1) &&
+ z_AttributeList(o, &(*p)->suggestedAttributes, 1, 0) &&
+ odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
+ ODR_CONTEXT, 4, 1) &&
+ odr_implicit(o, odr_integer, &(*p)->globalOccurrences, ODR_CONTEXT,
+ 2, 1) &&
+ odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
+ ODR_CONTEXT, 3, 1) &&
+ z_OtherInformation(o, &(*p)->otherTermInfo, 1, 0) &&
+ odr_sequence_end(o);
+}
+
+int z_Entry(ODR o, Z_Entry **p, int opt, const char *name)