X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=data1%2Fd1_expout.c;h=659fa9e30885320851230675714bc9b089d82eee;hp=ce0a5e3ba889be1d621fe192994b376343ac35ae;hb=e4c6861efeeea654bfb00c5f0239ee258629d77f;hpb=5a54cb4d2b46949fceead27d0edb1a44df2d7da2 diff --git a/data1/d1_expout.c b/data1/d1_expout.c index ce0a5e3..659fa9e 100644 --- a/data1/d1_expout.c +++ b/data1/d1_expout.c @@ -1,5 +1,5 @@ /* This file is part of the Zebra server. - Copyright (C) 1994-2010 Index Data + Copyright (C) 2004-2013 Index Data Zebra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -18,9 +18,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* - * This module converts data1 tree to Z39.50 Explain records + * This module converts data1 tree to Z39.50 Explain records */ +#if HAVE_CONFIG_H +#include +#endif #include #include #include @@ -113,7 +116,7 @@ static Odr_oid *f_oid(ExpHandle *eh, data1_node *c, oid_class oclass) c = c->child; if (!is_data_tag (eh, c) || c->u.data.len > 63) return 0; - yaz_snprintf(oidstr, sizeof(oidstr)-1, + yaz_snprintf(oidstr, sizeof(oidstr)-1, "%.*s", c->u.data.len, c->u.data.data); return yaz_string_to_oid_odr(yaz_oid_std(), @@ -187,7 +190,7 @@ Odr_oid **f_oid_seq (ExpHandle *eh, data1_node *n, int *num, oid_class oclass) res[i++] = f_oid (eh, c, oclass); return res; } - + char **f_string_seq (ExpHandle *eh, data1_node *n, int *num) { char **res; @@ -399,7 +402,7 @@ static Odr_int *f_recordCount(ExpHandle *eh, data1_node *c, int *which) *wp = Z_DatabaseInfo_approxNumber; else return 0; - if (!c->child || c->child->which != DATA1N_data || + if (!c->child || c->child->which != DATA1N_data || c->child->u.data.len >= sizeof(intbuf)) return 0; sprintf(intbuf, "%.*s", c->child->u.data.len, c->child->u.data.data); @@ -411,13 +414,13 @@ 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)) @@ -437,10 +440,10 @@ 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) + if (!is_numeric_tag (eh, c) != 102) continue; ++i; } @@ -448,7 +451,7 @@ static Z_DatabaseList *f_databaseList(ExpHandle *eh, data1_node *n) 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; @@ -466,7 +469,7 @@ 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; @@ -502,13 +505,13 @@ static Z_NetworkAddressOther *f_networkAddressOther(ExpHandle *eh, return res; } -static Z_NetworkAddress **f_networkAddresses(ExpHandle *eh, data1_node *n, +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) { @@ -523,7 +526,7 @@ static Z_NetworkAddress **f_networkAddresses(ExpHandle *eh, data1_node *n, 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)) @@ -592,7 +595,7 @@ static Z_CategoryList *f_categoryList(ExpHandle *eh, data1_node *n) } if (res->num_categories) res->categories = - (Z_CategoryInfo **)odr_malloc (eh->o, res->num_categories + (Z_CategoryInfo **)odr_malloc (eh->o, res->num_categories * sizeof(*res->categories)); for (n = c->child; n; n = n->next) { @@ -637,7 +640,7 @@ static Z_TargetInfo *f_targetInfo(ExpHandle *eh, data1_node *n) res->num_languages = 0; res->languages = NULL; res->commonAccessInfo = 0; - + for (c = n->child; c; c = c->next) { int i = 0; @@ -657,7 +660,7 @@ static Z_TargetInfo *f_targetInfo(ExpHandle *eh, data1_node *n) case 111: res->welcomeMessage = f_humstring(eh, c); break; case 112: res->contactInfo = f_contactInfo(eh, c); break; case 113: res->description = f_humstring(eh, c); break; - case 114: + case 114: res->num_nicknames = 0; for (n = c->child; n; n = n->next) { @@ -667,7 +670,7 @@ static Z_TargetInfo *f_targetInfo(ExpHandle *eh, data1_node *n) } if (res->num_nicknames) res->nicknames = - (char **)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) { @@ -698,7 +701,7 @@ static Z_TargetInfo *f_targetInfo(ExpHandle *eh, data1_node *n) res->dbCombinations[i++] = f_databaseList (eh, n); } break; - case 119: + case 119: res->addresses = f_networkAddresses (eh, c, &res->num_addresses); break; @@ -768,7 +771,7 @@ static Z_DatabaseInfo *f_databaseInfo(ExpHandle *eh, data1_node *n) res->supplierContactInfo = 0; res->submissionContactInfo = 0; res->accessInfo = 0; - + for (c = n->child; c; c = c->next) { int i = 0; @@ -789,7 +792,7 @@ static Z_DatabaseInfo *f_databaseInfo(ExpHandle *eh, data1_node *n) } if (res->num_nicknames) res->nicknames = - (char **)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) { @@ -813,7 +816,7 @@ static Z_DatabaseInfo *f_databaseInfo(ExpHandle *eh, data1_node *n) } if (res->num_keywords) res->keywords = - (Z_HumanString **)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) { @@ -886,7 +889,7 @@ Z_AttributeDescription *f_attributeDescription ( odr_malloc(eh->o, sizeof(*res)); data1_node *c; int i = 0; - + res->name = 0; res->description = 0; res->attributeValue = 0; @@ -1139,7 +1142,7 @@ Z_AttributeSetDetails *f_attributeSetDetails (ExpHandle *eh, data1_node *n) Z_AttributeSetDetails *res = (Z_AttributeSetDetails *) odr_malloc(eh->o, sizeof(*res)); data1_node *c; - + res->attributeSet = 0; res->num_attributesByType = 0; res->attributesByType = 0; @@ -1371,7 +1374,7 @@ Z_ExplainRecord *data1_nodetoexplain (data1_handle dh, data1_node *n, res->which = Z_Explain_categoryList; if (!(res->u.categoryList = f_categoryList(&eh, n))) return 0; - return res; + return res; case 2: res->which = Z_Explain_targetInfo; if (!(res->u.targetInfo = f_targetInfo(&eh, n))) @@ -1386,7 +1389,7 @@ Z_ExplainRecord *data1_nodetoexplain (data1_handle dh, data1_node *n, res->which = Z_Explain_attributeSetInfo; if (!(res->u.attributeSetInfo = f_attributeSetInfo(&eh, n))) return 0; - return res; + return res; case 10: res->which = Z_Explain_attributeDetails; if (!(res->u.attributeDetails = f_attributeDetails(&eh, n)))