X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=retrieval%2Fd1_grs.c;h=ece37817f98f07748f1f4226c693c94a7dea0401;hb=a774858896a9b56c966edbfb70d8eae1c91c4ad1;hp=a222aee0d4be6511bfa70a81728ef55e6e993ff7;hpb=b440dce0831a72bebe4f4821ab7771cc05e8facb;p=yaz-moved-to-github.git diff --git a/retrieval/d1_grs.c b/retrieval/d1_grs.c index a222aee..ece3781 100644 --- a/retrieval/d1_grs.c +++ b/retrieval/d1_grs.c @@ -4,7 +4,22 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: d1_grs.c,v $ - * Revision 1.16 1999-08-27 09:40:32 adam + * Revision 1.21 2002-05-28 21:09:44 adam + * schema mapping supports duplicate maps (copy instead of pointer swap) + * + * Revision 1.20 2002/05/13 14:13:37 adam + * XML reader for data1 (EXPAT) + * + * Revision 1.19 2002/04/15 09:06:30 adam + * Fix explain tags for XML writer + * + * Revision 1.18 2002/04/12 14:40:07 adam + * GRS-1 writer accepts non-abs + * + * Revision 1.17 1999/11/30 13:47:12 adam + * Improved installation. Moved header files to include/yaz. + * + * Revision 1.16 1999/08/27 09:40:32 adam * Renamed logf function to yaz_log. Removed VC++ project files. * * Revision 1.15 1999/03/31 11:18:25 adam @@ -61,10 +76,9 @@ #include #include -#include -#include - -#include +#include +#include +#include #define D1_VARIANTARRAY 20 /* fixed max length on sup'd variant-list. Lazy me */ @@ -188,32 +202,32 @@ static Z_ElementData *nodetoelementdata(data1_handle dh, data1_node *n, switch (n->u.data.what) { - case DATA1I_num: - res->which = Z_ElementData_numeric; - res->u.numeric = (int *)odr_malloc(o, sizeof(int)); - *res->u.numeric = atoi(n->u.data.data); - *len += 4; - break; - case DATA1I_text: - toget = n->u.data.len; - if (p->u.tag.get_bytes > 0 && p->u.tag.get_bytes < toget) - toget = p->u.tag.get_bytes; - res->which = Z_ElementData_string; - res->u.string = (char *)odr_malloc(o, toget+1); - memcpy(res->u.string, n->u.data.data, toget); - res->u.string[toget] = '\0'; - *len += toget; - break; - case DATA1I_oid: - res->which = Z_ElementData_oid; - strncpy(str, n->u.data.data, n->u.data.len); - str[n->u.data.len] = '\0'; - res->u.oid = odr_getoidbystr(o, str); - *len += n->u.data.len; - break; - default: - yaz_log(LOG_WARN, "Can't handle datatype."); - return 0; + case DATA1I_num: + res->which = Z_ElementData_numeric; + res->u.numeric = (int *)odr_malloc(o, sizeof(int)); + *res->u.numeric = atoi(n->u.data.data); + *len += 4; + break; + case DATA1I_text: + toget = n->u.data.len; + if (p && p->u.tag.get_bytes > 0 && p->u.tag.get_bytes < toget) + toget = p->u.tag.get_bytes; + res->which = Z_ElementData_string; + res->u.string = (char *)odr_malloc(o, toget+1); + memcpy(res->u.string, n->u.data.data, toget); + res->u.string[toget] = '\0'; + *len += toget; + break; + case DATA1I_oid: + res->which = Z_ElementData_oid; + strncpy(str, n->u.data.data, n->u.data.len); + str[n->u.data.len] = '\0'; + res->u.oid = odr_getoidbystr(o, str); + *len += n->u.data.len; + break; + default: + yaz_log(LOG_WARN, "Can't handle datatype."); + return 0; } } else @@ -232,7 +246,7 @@ static Z_TaggedElement *nodetotaggedelement(data1_handle dh, data1_node *n, Z_TaggedElement *res = (Z_TaggedElement *)odr_malloc(o, sizeof(*res)); data1_tag *tag = 0; data1_node *data; - int leaf; + int leaf = 0; if (n->which == DATA1N_tag) { @@ -247,7 +261,8 @@ static Z_TaggedElement *nodetotaggedelement(data1_handle dh, data1_node *n, */ else if (n->which == DATA1N_data || n->which == DATA1N_variant) { - if (!(tag = data1_gettagbyname (dh, n->root->u.root.absyn->tagset, + if (n->root->u.root.absyn && + !(tag = data1_gettagbyname (dh, n->root->u.root.absyn->tagset, "wellKnown"))) { yaz_log(LOG_WARN, "Unable to locate tag for 'wellKnown'"); @@ -280,7 +295,7 @@ static Z_TaggedElement *nodetotaggedelement(data1_handle dh, data1_node *n, else if (tag) tagstr = tag->value.string; /* no take from well-known */ else - tagstr = "?"; /* no tag at all! */ + tagstr = "???"; /* no tag at all! */ res->tagValue->which = Z_StringOrNumeric_string; res->tagValue->u.string = odr_strdup(o, tagstr); } @@ -327,7 +342,8 @@ Z_GenericRecord *data1_nodetogr(data1_handle dh, data1_node *n, for (c = n->child; c; c = c->next) num_children++; - res->elements = (Z_TaggedElement **)odr_malloc(o, sizeof(Z_TaggedElement *) * num_children); + res->elements = (Z_TaggedElement **) + odr_malloc(o, sizeof(Z_TaggedElement *) * num_children); res->num_elements = 0; for (c = n->child; c; c = c->next) {