X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=ztest%2Fread-grs.c;h=97123e30252cdb31d1fc4980b552b4d8b9465607;hb=7f0e24a73392b1288b117ee46482f58f471ea094;hp=2b9c103361b3aa21120a514d0ed5149e8283efc5;hpb=044d170f0a963555486df54653cd2fdc5815928b;p=yaz-moved-to-github.git diff --git a/ztest/read-grs.c b/ztest/read-grs.c index 2b9c103..97123e3 100644 --- a/ztest/read-grs.c +++ b/ztest/read-grs.c @@ -1,10 +1,21 @@ /* - * Copyright (c) 1995, Index Data. + * Copyright (c) 1995-2001, Index Data. * See the file LICENSE for details. - * Sebastian Hammer, Adam Dickmeiss * * $Log: read-grs.c,v $ - * Revision 1.2 1998-02-11 11:53:36 adam + * Revision 1.6 2001-03-25 21:55:13 adam + * Added odr_intdup. Ztest server returns TaskPackage for ItemUpdate. + * + * Revision 1.5 1999/11/30 13:47:12 adam + * Improved installation. Moved header files to include/yaz. + * + * Revision 1.4 1999/08/27 09:40:32 adam + * Renamed logf function to yaz_log. Removed VC++ project files. + * + * Revision 1.3 1999/03/31 11:18:25 adam + * Implemented odr_strdup. Added Reference ID to backend server API. + * + * Revision 1.2 1998/02/11 11:53:36 adam * Changed code so that it compiles as C++. * * Revision 1.1 1997/09/01 08:55:53 adam @@ -27,8 +38,8 @@ #include #include -#include -#include +#include +#include #define GRS_MAX_FIELDS 50 @@ -56,7 +67,7 @@ Z_GenericRecord *read_grs1(FILE *f, ODR o) return r; if (sscanf(buf, "(%d,%[^)])", &type, value) != 2) { - logf(LOG_WARN, "Bad data in '%s'", buf); + yaz_log(LOG_WARN, "Bad data in '%s'", buf); return 0; } if (!type && *value == '0') @@ -71,20 +82,19 @@ Z_GenericRecord *read_grs1(FILE *f, ODR o) if (!r) { r = (Z_GenericRecord *)odr_malloc(o, sizeof(*r)); - r->elements = (Z_TaggedElement **)odr_malloc(o, sizeof(Z_TaggedElement*) * - GRS_MAX_FIELDS); + r->elements = (Z_TaggedElement **) + odr_malloc(o, sizeof(Z_TaggedElement*) * GRS_MAX_FIELDS); r->num_elements = 0; } - r->elements[r->num_elements] = t = (Z_TaggedElement *)odr_malloc(o, - sizeof(Z_TaggedElement)); - t->tagType = (int *)odr_malloc(o, sizeof(int)); - *t->tagType = type; - t->tagValue = (Z_StringOrNumeric *)odr_malloc(o, sizeof(Z_StringOrNumeric)); + r->elements[r->num_elements] = t = (Z_TaggedElement *) + odr_malloc(o, sizeof(Z_TaggedElement)); + t->tagType = odr_intdup(o, type); + t->tagValue = (Z_StringOrNumeric *) + odr_malloc(o, sizeof(Z_StringOrNumeric)); if ((ivalue = atoi(value))) { t->tagValue->which = Z_StringOrNumeric_numeric; - t->tagValue->u.numeric = (int *)odr_malloc(o, sizeof(int)); - *t->tagValue->u.numeric = ivalue; + t->tagValue->u.numeric = odr_intdup(o, ivalue); } else { @@ -105,8 +115,7 @@ Z_GenericRecord *read_grs1(FILE *f, ODR o) { c->which = Z_ElementData_string; buf[strlen(buf)-1] = '\0'; - c->u.string = (char *)odr_malloc(o, strlen(buf)+1); - strcpy(c->u.string, buf); + c->u.string = odr_strdup(o, buf); } r->num_elements++; }