+ Z_ProximitySupport *res = (Z_ProximitySupport *)
+ odr_malloc (eh->o, sizeof(*res));
+ res->anySupport = eh->false_value;
+ res->num_unitsSupported = 0;
+ res->unitsSupported = 0;
+ return res;
+}
+
+Z_RpnCapabilities *f_rpnCapabilities (ExpHandle *eh, data1_node *n)
+{
+ Z_RpnCapabilities *res = (Z_RpnCapabilities *)
+ odr_malloc (eh->o, sizeof(*res));
+ data1_node *c;
+
+ res->num_operators = 0;
+ res->operators = NULL;
+ res->resultSetAsOperandSupported = eh->false_value;
+ res->restrictionOperandSupported = eh->false_value;
+ res->proximity = NULL;
+
+ for (c = n->child; c; c = c->next)
+ {
+ int i = 0;
+ switch (is_numeric_tag(eh, c))
+ {
+ case 550:
+ for (n = c->child; n; n = n->next)
+ {
+ if (is_numeric_tag(eh, n) != 551)
+ continue;
+ (res->num_operators)++;
+ }
+ if (res->num_operators)
+ res->operators = (int **)
+ odr_malloc (eh->o, res->num_operators
+ * sizeof(*res->operators));
+ for (n = c->child; n; n = n->next)
+ {
+ if (is_numeric_tag(eh, n) != 551)
+ continue;
+ res->operators[i++] = f_integer (eh, n);
+ }
+ break;
+ case 552:
+ res->resultSetAsOperandSupported = f_bool (eh, c);
+ break;
+ case 553:
+ res->restrictionOperandSupported = f_bool (eh, c);
+ break;
+ case 554:
+ res->proximity = f_proximitySupport (eh, c);
+ break;
+ }
+ }
+ return res;
+}
+
+Z_QueryTypeDetails *f_queryTypeDetails (ExpHandle *eh, data1_node *n)
+{
+ Z_QueryTypeDetails *res = (Z_QueryTypeDetails *)
+ odr_malloc(eh->o, sizeof(*res));
+ data1_node *c;
+
+ res->which = Z_QueryTypeDetails_rpn;
+ res->u.rpn = 0;
+ for (c = n->child; c; c = c->next)
+ {
+ switch (is_numeric_tag(eh, c))
+ {
+ case 519:
+ res->which = Z_QueryTypeDetails_rpn;
+ res->u.rpn = f_rpnCapabilities (eh, c);
+ break;
+ case 520:
+ break;
+ case 521:
+ break;
+ }
+ }
+ return res;
+}
+
+static Z_AccessInfo *f_accessInfo(ExpHandle *eh, data1_node *n)
+{
+ Z_AccessInfo *res = (Z_AccessInfo *)odr_malloc(eh->o, sizeof(*res));
+ data1_node *c;
+
+ res->num_queryTypesSupported = 0;
+ res->queryTypesSupported = 0;
+ res->num_diagnosticsSets = 0;
+ res->diagnosticsSets = 0;
+ res->num_attributeSetIds = 0;
+ res->attributeSetIds = 0;
+ res->num_schemas = 0;
+ res->schemas = 0;
+ res->num_recordSyntaxes = 0;
+ res->recordSyntaxes = 0;
+ res->num_resourceChallenges = 0;
+ res->resourceChallenges = 0;
+ res->restrictedAccess = 0;
+ res->costInfo = 0;
+ res->num_variantSets = 0;
+ res->variantSets = 0;
+ res->num_elementSetNames = 0;
+ res->elementSetNames = 0;
+ res->num_unitSystems = 0;
+ res->unitSystems = 0;
+
+ for (c = n->child; c; c = c->next)
+ {
+ int i = 0;
+ switch (is_numeric_tag (eh, c))
+ {
+ case 501:
+ for (n = c->child; n; n = n->next)
+ {
+ if (is_numeric_tag(eh, n) != 518)
+ continue;
+ (res->num_queryTypesSupported)++;
+ }
+ if (res->num_queryTypesSupported)
+ res->queryTypesSupported =
+ (Z_QueryTypeDetails **)
+ odr_malloc (eh->o, res->num_queryTypesSupported
+ * sizeof(*res->queryTypesSupported));
+ for (n = c->child; n; n = n->next)
+ {
+ if (is_numeric_tag(eh, n) != 518)
+ continue;
+ res->queryTypesSupported[i++] = f_queryTypeDetails (eh, n);
+ }
+ break;
+ case 503:
+ res->diagnosticsSets =
+ f_oid_seq(eh, c, &res->num_diagnosticsSets, CLASS_DIAGSET);
+ break;
+ case 505:
+ res->attributeSetIds =
+ f_oid_seq(eh, c, &res->num_attributeSetIds, CLASS_ATTSET);
+ break;
+ case 507:
+ res->schemas =
+ f_oid_seq(eh, c, &res->num_schemas, CLASS_SCHEMA);
+ break;
+ case 509:
+ res->recordSyntaxes =
+ f_oid_seq (eh, c, &res->num_recordSyntaxes, CLASS_RECSYN);
+ break;
+ case 511:
+ res->resourceChallenges =
+ f_oid_seq (eh, c, &res->num_resourceChallenges, CLASS_RESFORM);
+ break;
+ case 513: res->restrictedAccess = NULL; break; /* fix */
+ case 514: res->costInfo = NULL; break; /* fix */
+ case 515:
+ res->variantSets =
+ f_oid_seq (eh, c, &res->num_variantSets, CLASS_VARSET);
+ break;
+ case 516:
+ res->elementSetNames =
+ f_string_seq (eh, c, &res->num_elementSetNames);
+ break;
+ case 517:
+ res->unitSystems = f_string_seq (eh, c, &res->num_unitSystems);
+ break;
+ }
+ }
+ return res;
+}
+
+static int *f_recordCount(ExpHandle *eh, data1_node *c, int *which)
+{
+ int *r= (int *)odr_malloc(eh->o, sizeof(*r));
+ int *wp = which;
+ char intbuf[64];
+
+ c = c->child;
+ if (!is_numeric_tag (eh, c))
+ return 0;
+ if (c->u.tag.element->tag->value.numeric == 210)
+ *wp = Z_DatabaseInfo_actualNumber;
+ else if (c->u.tag.element->tag->value.numeric == 211)
+ *wp = Z_DatabaseInfo_approxNumber;
+ else
+ return 0;
+ if (!c->child || c->child->which != DATA1N_data)
+ return 0;
+ sprintf(intbuf, "%.*s", c->child->u.data.len, c->child->u.data.data);
+ *r = atoi(intbuf);
+ return r;
+}
+
+static Z_ContactInfo *f_contactInfo(ExpHandle *eh, data1_node *n)
+{
+ Z_ContactInfo *res = (Z_ContactInfo *)
+ odr_malloc (eh->o, sizeof(*res));
+ data1_node *c;
+
+ res->name = 0;
+ res->description = 0;
+ res->address = 0;
+ res->email = 0;
+ res->phone = 0;
+
+ for (c = n->child; c; c = c->next)
+ {
+ switch (is_numeric_tag (eh, c))
+ {
+ case 102: res->name = f_string (eh, c); break;
+ case 113: res->description = f_humstring (eh, c); break;
+ case 127: res->address = f_humstring (eh, c); break;
+ case 128: res->email = f_string (eh, c); break;
+ case 129: res->phone = f_string (eh, c); break;
+ }
+ }
+ return res;
+}
+
+static Z_DatabaseList *f_databaseList(ExpHandle *eh, data1_node *n)
+{
+ data1_node *c;
+ Z_DatabaseList *res;
+ int i = 0;
+
+ for (c = n->child; c; c = c->next)
+ {
+ if (!is_numeric_tag (eh, c) != 102)
+ continue;
+ ++i;
+ }
+ if (!i)
+ return NULL;
+
+ res = (Z_DatabaseList *)odr_malloc (eh->o, sizeof(*res));
+
+ res->num_databases = i;
+ res->databases = (char **)odr_malloc (eh->o, sizeof(*res->databases) * i);
+ i = 0;
+ for (c = n->child; c; c = c->next)
+ {
+ if (!is_numeric_tag (eh, c) != 102)
+ continue;
+ res->databases[i++] = f_string (eh, c);
+ }
+ return res;
+}
+
+static Z_NetworkAddressIA *f_networkAddressIA(ExpHandle *eh, data1_node *n)
+{
+ Z_NetworkAddressIA *res = (Z_NetworkAddressIA *)
+ odr_malloc (eh->o, sizeof(*res));
+ data1_node *c;
+
+ res->hostAddress = 0;
+ res->port = 0;
+
+ for (c = n->child; c; c = c->next)
+ {
+ switch (is_numeric_tag (eh, c))
+ {
+ case 121: res->hostAddress = f_string (eh, c); break;
+ case 122: res->port = f_integer (eh, c); break;
+ }
+ }
+ return res;
+}
+
+static Z_NetworkAddressOther *f_networkAddressOther(ExpHandle *eh,
+ data1_node *n)
+{
+ Z_NetworkAddressOther *res = (Z_NetworkAddressOther *)
+ odr_malloc (eh->o, sizeof(*res));
+ data1_node *c;
+
+ res->type = 0;
+ res->address = 0;
+
+ for (c = n->child; c; c = c->next)
+ {
+ switch (is_numeric_tag (eh, c))
+ {
+ case 124: res->type = f_string (eh, c); break;
+ case 121: res->address = f_string (eh, c); break;
+ }
+ }
+ return res;
+}
+
+static Z_NetworkAddress **f_networkAddresses(ExpHandle *eh, data1_node *n,
+ int *num)
+{
+ Z_NetworkAddress **res = NULL;
+ data1_node *c;
+ int i = 0;
+
+ *num = 0;
+ for (c = n->child; c; c = c->next)
+ {
+ switch (is_numeric_tag (eh, c))
+ {
+ case 120:
+ case 123:
+ (*num)++;
+ break;
+ }
+ }
+
+ if (*num)
+ res = (Z_NetworkAddress **) odr_malloc (eh->o, sizeof(*res) * (*num));
+
+ for (c = n->child; c; c = c->next)
+ {
+ switch (is_numeric_tag (eh, c))
+ {
+ case 120:
+ res[i] = (Z_NetworkAddress *) odr_malloc (eh->o, sizeof(**res));
+ res[i]->which = Z_NetworkAddress_iA;
+ res[i]->u.internetAddress = f_networkAddressIA(eh, c);
+ i++;
+ break;
+ case 123:
+ res[i] = (Z_NetworkAddress *) odr_malloc (eh->o, sizeof(**res));
+ res[i]->which = Z_NetworkAddress_other;
+ res[i]->u.other = f_networkAddressOther(eh, c);
+ i++;
+ break;
+ }
+ }
+ return res;
+}
+
+static Z_CategoryInfo *f_categoryInfo(ExpHandle *eh, data1_node *n)
+{
+ Z_CategoryInfo *res = (Z_CategoryInfo *)odr_malloc(eh->o, sizeof(*res));
+ data1_node *c;
+
+ res->category = 0;
+ res->originalCategory = 0;
+ res->description = 0;
+ res->asn1Module = 0;
+ for (c = n->child; c; c = c->next)
+ {
+ switch (is_numeric_tag (eh, c))
+ {
+ case 102: res->category = f_string(eh, c); break;
+ case 302: res->originalCategory = f_string(eh, c); break;
+ case 113: res->description = f_humstring(eh, c); break;
+ case 303: res->asn1Module = f_string (eh, c); break;
+ }
+ }
+ return res;
+}
+
+static Z_CategoryList *f_categoryList(ExpHandle *eh, data1_node *n)
+{
+ Z_CategoryList *res = (Z_CategoryList *)odr_malloc(eh->o, sizeof(*res));
+ data1_node *c;
+
+ res->commonInfo = 0;
+ res->num_categories = 0;
+ res->categories = NULL;
+
+ for (c = n->child; c; c = c->next)
+ {
+ int i = 0;
+
+ switch (is_numeric_tag (eh, c))
+ {
+ case 600: res->commonInfo = f_commonInfo(eh, c); break;
+ case 300:
+ for (n = c->child; n; n = n->next)
+ {
+ if (is_numeric_tag(eh, n) != 301)
+ continue;
+ (res->num_categories)++;
+ }
+ if (res->num_categories)
+ res->categories =
+ (Z_CategoryInfo **)odr_malloc (eh->o, res->num_categories
+ * sizeof(*res->categories));
+ for (n = c->child; n; n = n->next)
+ {
+ if (is_numeric_tag(eh, n) != 301)
+ continue;
+ res->categories[i++] = f_categoryInfo (eh, n);
+ }
+ break;
+ }
+ }
+ assert (res->num_categories && res->categories);
+ return res;