X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=retrieval%2Fd1_expout.c;h=ebeed629021172a01645f93cfe2c1a9b2d2566a2;hp=4a45d0f9af243c9a53b7bb18ca96255f43b6e3d0;hb=081bf3419fb97408aea83964cac9f130c6d1bbdc;hpb=4090fc5c7b77769020633d09cf63b325aceaf49a diff --git a/retrieval/d1_expout.c b/retrieval/d1_expout.c index 4a45d0f..ebeed62 100644 --- a/retrieval/d1_expout.c +++ b/retrieval/d1_expout.c @@ -1,10 +1,23 @@ /* - * 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.11 1998-04-02 08:27:37 adam + * Minor change in definition of Z_TargetInfo. Furhter work on Explain + * schema - added AttributeDetails. + * + * 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. * @@ -84,7 +97,7 @@ static int *f_integer(ExpHandle *eh, data1_node *c) 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; @@ -97,7 +110,7 @@ static char *f_string(ExpHandle *eh, data1_node *c) 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; @@ -111,7 +124,7 @@ static bool_t *f_bool(ExpHandle *eh, data1_node *c) 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; @@ -157,12 +170,12 @@ static Z_HumanString *f_humstring(ExpHandle *eh, data1_node *c) 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; @@ -170,7 +183,7 @@ static Z_HumanString *f_humstring(ExpHandle *eh, data1_node *c) 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; @@ -213,7 +226,7 @@ Odr_oid **f_oid_seq (ExpHandle *eh, data1_node *n, int *num, oid_class oclass) } 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) @@ -238,7 +251,7 @@ char **f_string_seq (ExpHandle *eh, data1_node *n, int *num) } 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) @@ -257,7 +270,7 @@ char **f_humstring_seq (ExpHandle *eh, data1_node *n, int *num) 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; @@ -285,13 +298,13 @@ Z_QueryTypeDetails **f_queryTypesSupported (ExpHandle *eh, data1_node *c, } 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++; @@ -305,7 +318,7 @@ Z_QueryTypeDetails **f_queryTypesSupported (ExpHandle *eh, data1_node *c, 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; @@ -377,19 +390,28 @@ static Z_AccessInfo *f_accessInfo(ExpHandle *eh, data1_node *n) 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); @@ -418,10 +440,10 @@ static Z_DatabaseList *f_databaseList(ExpHandle *eh, data1_node *n) 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) { @@ -434,7 +456,7 @@ static Z_DatabaseList *f_databaseList(ExpHandle *eh, data1_node *n) 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; @@ -442,7 +464,7 @@ static Z_TargetInfo *f_targetInfo(ExpHandle *eh, data1_node *n) res->recentNews = 0; res->icon = 0; res->namedResultSets = 0; - res->multipleDbSearch = 0; + res->multipleDBsearch = 0; res->maxResultSets = 0; res->maxResultSize = 0; res->maxTerms = 0; @@ -474,7 +496,7 @@ static Z_TargetInfo *f_targetInfo(ExpHandle *eh, data1_node *n) case 103: res->recentNews = f_humstring(eh, c); break; case 104: res->icon = NULL; break; /* fix */ case 105: res->namedResultSets = f_bool(eh, c); break; - case 106: res->multipleDbSearch = f_bool(eh, c); break; + case 106: res->multipleDBsearch = f_bool(eh, c); break; case 107: res->maxResultSets = f_integer(eh, c); break; case 108: res->maxResultSize = f_integer(eh, c); break; case 109: res->maxTerms = f_integer(eh, c); break; @@ -492,7 +514,7 @@ static Z_TargetInfo *f_targetInfo(ExpHandle *eh, data1_node *n) } 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) { @@ -514,7 +536,7 @@ static Z_TargetInfo *f_targetInfo(ExpHandle *eh, data1_node *n) } 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) { @@ -529,14 +551,14 @@ static Z_TargetInfo *f_targetInfo(ExpHandle *eh, data1_node *n) } if (!res->namedResultSets) res->namedResultSets = eh->false_value; - if (!res->multipleDbSearch) - res->multipleDbSearch = eh->false_value; + if (!res->multipleDBsearch) + res->multipleDBsearch = eh->false_value; return res; } 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; @@ -555,7 +577,11 @@ static Z_DatabaseInfo *f_databaseInfo(ExpHandle *eh, data1_node *n) 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; @@ -592,7 +618,7 @@ static Z_DatabaseInfo *f_databaseInfo(ExpHandle *eh, data1_node *n) } 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) { @@ -616,7 +642,7 @@ static Z_DatabaseInfo *f_databaseInfo(ExpHandle *eh, data1_node *n) } 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) { @@ -634,8 +660,13 @@ static Z_DatabaseInfo *f_databaseInfo(ExpHandle *eh, data1_node *n) 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; @@ -664,14 +695,14 @@ Z_ExplainRecord *data1_nodetoexplain (data1_handle dh, data1_node *n, 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); @@ -680,27 +711,22 @@ Z_ExplainRecord *data1_nodetoexplain (data1_handle dh, data1_node *n, 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; }