X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=retrieval%2Fd1_grs.c;h=a222aee0d4be6511bfa70a81728ef55e6e993ff7;hp=d17ca3c5973abb7ff9bdef4ed68fde3c17559e31;hb=b440dce0831a72bebe4f4821ab7771cc05e8facb;hpb=044d170f0a963555486df54653cd2fdc5815928b diff --git a/retrieval/d1_grs.c b/retrieval/d1_grs.c index d17ca3c..a222aee 100644 --- a/retrieval/d1_grs.c +++ b/retrieval/d1_grs.c @@ -1,10 +1,20 @@ /* - * Copyright (c) 1995-1997, Index Data. + * Copyright (c) 1995-1999, Index Data. * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * * $Log: d1_grs.c,v $ - * Revision 1.13 1998-02-11 11:53:35 adam + * 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 + * Implemented odr_strdup. Added Reference ID to backend server API. + * + * Revision 1.14 1998/03/16 12:21:15 adam + * Fixed problem with tag names that weren't set to the right value + * when wildcards were used. + * + * Revision 1.13 1998/02/11 11:53:35 adam * Changed code so that it compiles as C++. * * Revision 1.12 1997/11/24 11:33:56 adam @@ -113,13 +123,12 @@ static Z_Variant *make_variant(data1_node *n, int num, ODR o) { case DATA1K_string: t->which = Z_Triple_internationalString; - t->value.internationalString = (char *)odr_malloc(o, - strlen(p->u.variant.value)+1); - strcpy(t->value.internationalString, p->u.variant.value); + t->value.internationalString = + odr_strdup(o, p->u.variant.value); break; default: - logf(LOG_WARN, "Unable to handle value for variant %s", - p->u.variant.type->name); + yaz_log(LOG_WARN, "Unable to handle value for variant %s", + p->u.variant.type->name); return 0; } } @@ -142,8 +151,8 @@ static int traverse_triples(data1_node *n, int level, Z_ElementMetaData *m, D1_VARIANTARRAY); else if (m->num_supportedVariants >= D1_VARIANTARRAY) { - logf(LOG_WARN, "Too many variants (D1_VARIANTARRAY==%d)", - D1_VARIANTARRAY); + yaz_log(LOG_WARN, "Too many variants (D1_VARIANTARRAY==%d)", + D1_VARIANTARRAY); return -1; } @@ -203,7 +212,7 @@ static Z_ElementData *nodetoelementdata(data1_handle dh, data1_node *n, *len += n->u.data.len; break; default: - logf(LOG_WARN, "Can't handle datatype."); + yaz_log(LOG_WARN, "Can't handle datatype."); return 0; } } @@ -241,7 +250,7 @@ static Z_TaggedElement *nodetotaggedelement(data1_handle dh, data1_node *n, if (!(tag = data1_gettagbyname (dh, n->root->u.root.absyn->tagset, "wellKnown"))) { - logf(LOG_WARN, "Unable to locate tag for 'wellKnown'"); + yaz_log(LOG_WARN, "Unable to locate tag for 'wellKnown'"); return 0; } data = n; @@ -249,7 +258,7 @@ static Z_TaggedElement *nodetotaggedelement(data1_handle dh, data1_node *n, } else { - logf(LOG_WARN, "Bad data."); + yaz_log(LOG_WARN, "Bad data."); return 0; } @@ -266,14 +275,14 @@ static Z_TaggedElement *nodetotaggedelement(data1_handle dh, data1_node *n, { char *tagstr; - if (tag) /* well-known tag */ - tagstr = tag->value.string; - else /* tag local to this file */ - tagstr = n->u.tag.tag; - + if (n->which == DATA1N_tag) + tagstr = n->u.tag.tag; /* tag at node */ + else if (tag) + tagstr = tag->value.string; /* no take from well-known */ + else + tagstr = "?"; /* no tag at all! */ res->tagValue->which = Z_StringOrNumeric_string; - res->tagValue->u.string = (char *)odr_malloc(o, strlen(tagstr)+1); - strcpy(res->tagValue->u.string, tagstr); + res->tagValue->u.string = odr_strdup(o, tagstr); } res->tagOccurrence = 0; res->appliedVariant = 0;