/*
- * Copyright (c) 1995-1997, Index Data.
+ * Copyright (c) 1995-1998, Index Data.
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: d1_expout.c,v $
- * Revision 1.7 1997-12-09 16:18:16 adam
+ * Revision 1.10 1998-03-31 15:13:20 adam
+ * Development towards compiled ASN.1.
+ *
+ * Revision 1.9 1998/03/05 08:07:58 adam
+ * Make data1 to EXPLAIN ignore local tags in root.
+ *
+ * Revision 1.8 1998/02/11 11:53:35 adam
+ * Changed code so that it compiles as C++.
+ *
+ * Revision 1.7 1997/12/09 16:18:16 adam
* Work on EXPLAIN schema. First implementation of sub-schema facility
* in the *.abs files.
*
c = c->child;
if (!is_data_tag (eh, c) || c->u.data.len > 63)
return 0;
- r = odr_malloc(eh->o, sizeof(*r));
+ r = (int *)odr_malloc(eh->o, sizeof(*r));
sprintf(intbuf, "%.*s", 63, c->u.data.data);
*r = atoi(intbuf);
return r;
c = c->child;
if (!is_data_tag (eh, c))
return 0;
- r = odr_malloc(eh->o, c->u.data.len+1);
+ r = (char *)odr_malloc(eh->o, c->u.data.len+1);
memcpy(r, c->u.data.data, c->u.data.len);
r[c->u.data.len] = '\0';
return r;
c = c->child;
if (!is_data_tag (eh, c) || c->u.data.len > 63)
return 0;
- tf = odr_malloc (eh->o, sizeof(*tf));
+ tf = (int *)odr_malloc (eh->o, sizeof(*tf));
sprintf(intbuf, "%.*s", c->u.data.len, c->u.data.data);
*tf = atoi(intbuf);
return tf;
c = c->child;
if (!is_data_tag (eh, c))
return 0;
- r = odr_malloc(eh->o, sizeof(*r));
+ r = (Z_HumanString *)odr_malloc(eh->o, sizeof(*r));
r->num_strings = 1;
- r->strings = odr_malloc(eh->o, sizeof(Z_HumanStringUnit*));
- r->strings[0] = u = odr_malloc(eh->o, sizeof(*u));
+ r->strings = (Z_HumanStringUnit **)odr_malloc(eh->o, sizeof(Z_HumanStringUnit*));
+ r->strings[0] = u = (Z_HumanStringUnit *)odr_malloc(eh->o, sizeof(*u));
u->language = 0;
- u->text = odr_malloc(eh->o, c->u.data.len+1);
+ u->text = (char *)odr_malloc(eh->o, c->u.data.len+1);
memcpy(u->text, c->u.data.data, c->u.data.len);
u->text[c->u.data.len] = '\0';
return r;
static Z_CommonInfo *f_commonInfo(ExpHandle *eh, data1_node *n)
{
- Z_CommonInfo *res = odr_malloc(eh->o, sizeof(*res));
+ Z_CommonInfo *res = (Z_CommonInfo *)odr_malloc(eh->o, sizeof(*res));
data1_node *c;
res->dateAdded = 0;
}
if (!*num)
return NULL;
- res = odr_malloc (eh->o, sizeof(*res) * (*num));
+ res = (int **)odr_malloc (eh->o, sizeof(*res) * (*num));
for (c = n->child, i = 0 ; c; c = c->next)
{
if (is_numeric_tag (eh, c) != 1000)
}
if (!*num)
return NULL;
- res = odr_malloc (eh->o, sizeof(*res) * (*num));
+ res = (char **)odr_malloc (eh->o, sizeof(*res) * (*num));
for (c = n->child, i = 0 ; c; c = c->next)
{
if (!is_numeric_tag (eh, c) != 1001)
Z_RpnCapabilities *f_rpnCapabilities (ExpHandle *eh, data1_node *c)
{
- Z_RpnCapabilities *res = odr_malloc (eh->o, sizeof(*res));
+ Z_RpnCapabilities *res = (Z_RpnCapabilities *)odr_malloc (eh->o, sizeof(*res));
res->num_operators = 0;
res->operators = NULL;
}
if (!*num)
return NULL;
- res = odr_malloc (eh->o, *num * sizeof(*res));
+ res = (Z_QueryTypeDetails **)odr_malloc (eh->o, *num * sizeof(*res));
i = 0;
for (n = c->child; n; n = n->next)
{
if (is_numeric_tag(eh, n) == 519)
{
- res[i] = odr_malloc (eh->o, sizeof(**res));
+ res[i] = (Z_QueryTypeDetails *)odr_malloc (eh->o, sizeof(**res));
res[i]->which = Z_QueryTypeDetails_rpn;
res[i]->u.rpn = f_rpnCapabilities (eh, n);
i++;
static Z_AccessInfo *f_accessInfo(ExpHandle *eh, data1_node *n)
{
- Z_AccessInfo *res = odr_malloc(eh->o, sizeof(*res));
+ Z_AccessInfo *res = (Z_AccessInfo *)odr_malloc(eh->o, sizeof(*res));
data1_node *c;
res->num_queryTypesSupported = 0;
static int *f_recordCount(ExpHandle *eh, data1_node *c, int *which)
{
- int *r= odr_malloc(eh->o, sizeof(*r));
+ 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;
+#ifdef ASN_COMPILED
+ 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;
+#else
if (c->u.tag.element->tag->value.numeric == 210)
*wp = Z_Exp_RecordCount_actualNumber;
else if (c->u.tag.element->tag->value.numeric == 211)
*wp = Z_Exp_RecordCount_approxNumber;
else
return 0;
+#endif
if (!c->child || c->child->which != DATA1N_data)
return 0;
sprintf(intbuf, "%.*s", 63, c->child->u.data.data);
if (!i)
return NULL;
- res = odr_malloc (eh->o, sizeof(*res));
+ res = (Z_DatabaseList *)odr_malloc (eh->o, sizeof(*res));
res->num_databases = i;
- res->databases = odr_malloc (eh->o, sizeof(*res->databases) * i);
+ res->databases = (char **)odr_malloc (eh->o, sizeof(*res->databases) * i);
i = 0;
for (c = n->child; c; c = c->next)
{
static Z_TargetInfo *f_targetInfo(ExpHandle *eh, data1_node *n)
{
- Z_TargetInfo *res = odr_malloc(eh->o, sizeof(*res));
+ Z_TargetInfo *res = (Z_TargetInfo *)odr_malloc(eh->o, sizeof(*res));
data1_node *c;
res->commonInfo = 0;
}
if (res->num_nicknames)
res->nicknames =
- odr_malloc (eh->o, res->num_nicknames
+ (char **)odr_malloc (eh->o, res->num_nicknames
* sizeof(*res->nicknames));
for (n = c->child; n; n = n->next)
{
}
if (res->num_dbCombinations)
res->dbCombinations =
- odr_malloc (eh->o, res->num_dbCombinations
+ (Z_DatabaseList **)odr_malloc (eh->o, res->num_dbCombinations
* sizeof(*res->dbCombinations));
for (n = c->child; n; n = n->next)
{
static Z_DatabaseInfo *f_databaseInfo(ExpHandle *eh, data1_node *n)
{
- Z_DatabaseInfo *res = odr_malloc(eh->o, sizeof(*res));
+ Z_DatabaseInfo *res = (Z_DatabaseInfo *)odr_malloc(eh->o, sizeof(*res));
data1_node *c;
res->commonInfo = 0;
res->subDbs = 0;
res->disclaimers = 0;
res->news = 0;
+#ifdef ASN_COMPILED
+ res->u.actualNumber = 0;
+#else
res->recordCount = 0;
+#endif
res->defaultOrder = 0;
res->avRecordSize = 0;
res->maxRecordSize = 0;
}
if (res->num_nicknames)
res->nicknames =
- odr_malloc (eh->o, res->num_nicknames
+ (char **)odr_malloc (eh->o, res->num_nicknames
* sizeof(*res->nicknames));
for (n = c->child; n; n = n->next)
{
}
if (res->num_keywords)
res->keywords =
- odr_malloc (eh->o, res->num_keywords
+ (Z_HumanString **)odr_malloc (eh->o, res->num_keywords
* sizeof(*res->keywords));
for (n = c->child; n; n = n->next)
{
break;
case 207: res->disclaimers = f_humstring(eh, c); break;
case 103: res->news = f_humstring(eh, c); break;
+#ifdef ASN_COMPILED
+ case 209: res->u.actualNumber =
+ f_recordCount(eh, c, &res->which); break;
+#else
case 209: res->recordCount =
f_recordCount(eh, c, &res->recordCount_which); break;
+#endif
case 212: res->defaultOrder = f_humstring(eh, c); break;
case 213: res->avRecordSize = f_integer(eh, c); break;
case 214: res->maxRecordSize = f_integer(eh, c); break;
int select, ODR o)
{
ExpHandle eh;
- Z_ExplainRecord *res = odr_malloc(o, sizeof(*res));
+ Z_ExplainRecord *res = (Z_ExplainRecord *)odr_malloc(o, sizeof(*res));
eh.dh = dh;
eh.select = select;
eh.o = o;
- eh.false_value = odr_malloc(eh.o, sizeof(eh.false_value));
+ eh.false_value = (int *)odr_malloc(eh.o, sizeof(eh.false_value));
*eh.false_value = 0;
- eh.true_value = odr_malloc(eh.o, sizeof(eh.true_value));
+ eh.true_value = (int *)odr_malloc(eh.o, sizeof(eh.true_value));
*eh.true_value = 1;
assert(n->which == DATA1N_root);
logf(LOG_WARN, "Attempt to convert a non-Explain record");
return 0;
}
- n = n->child;
- if (!n || n->next)
+ for (n = n->child; n; n = n->next)
{
- logf(LOG_WARN, "Explain record should have one exactly one child");
- return 0;
- }
- switch (is_numeric_tag (&eh, n))
- {
- case 1:
- res->which = Z_Explain_targetInfo;
- if (!(res->u.targetInfo = f_targetInfo(&eh, n)))
- return 0;
- break;
- case 2:
- res->which = Z_Explain_databaseInfo;
- if (!(res->u.databaseInfo = f_databaseInfo(&eh, n)))
- return 0;
- break;
- default:
- logf(LOG_WARN, "Unknown explain category");
- return 0;
+ switch (is_numeric_tag (&eh, n))
+ {
+ case 1:
+ res->which = Z_Explain_targetInfo;
+ if (!(res->u.targetInfo = f_targetInfo(&eh, n)))
+ return 0;
+ return res;
+ case 2:
+ res->which = Z_Explain_databaseInfo;
+ if (!(res->u.databaseInfo = f_databaseInfo(&eh, n)))
+ return 0;
+ return res;
+ }
}
- return res;
+ logf(LOG_WARN, "No category in Explain record");
+ return 0;
}