X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=ztest%2Fread-grs.c;h=27510464aba3a8394f2d4b7993cc5558184a847c;hp=c847187141eabc4893dc0890eb12000c24260a97;hb=356e1d9e8eeb92d9ca9e883c1048ad79e5a5c49f;hpb=2203bb027f811b89e75ef2c743232f97eaf1464f diff --git a/ztest/read-grs.c b/ztest/read-grs.c index c847187..2751046 100644 --- a/ztest/read-grs.c +++ b/ztest/read-grs.c @@ -1,10 +1,22 @@ /* - * Copyright (c) 1995, Index Data. + * Copyright (c) 1995-1999, Index Data. * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * * $Log: read-grs.c,v $ - * Revision 1.1 1997-09-01 08:55:53 adam + * 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 * New windows NT/95 port using MSV5.0. Test server ztest now in * separate directory. When using NT, this test server may operate * as an NT service. Note that the service.[ch] should be part of @@ -24,8 +36,8 @@ #include #include -#include -#include +#include +#include #define GRS_MAX_FIELDS 50 @@ -53,7 +65,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') @@ -67,32 +79,33 @@ Z_GenericRecord *read_grs1(FILE *f, ODR o) return 0; if (!r) { - r = odr_malloc(o, sizeof(*r)); - r->elements = odr_malloc(o, sizeof(Z_TaggedElement*) * - GRS_MAX_FIELDS); + r = (Z_GenericRecord *)odr_malloc(o, sizeof(*r)); + r->elements = (Z_TaggedElement **) + odr_malloc(o, sizeof(Z_TaggedElement*) * GRS_MAX_FIELDS); r->num_elements = 0; } - r->elements[r->num_elements] = t = odr_malloc(o, - sizeof(Z_TaggedElement)); - t->tagType = odr_malloc(o, sizeof(int)); + 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 = odr_malloc(o, sizeof(Z_StringOrNumeric)); + t->tagValue = (Z_StringOrNumeric *) + odr_malloc(o, sizeof(Z_StringOrNumeric)); if ((ivalue = atoi(value))) { t->tagValue->which = Z_StringOrNumeric_numeric; - t->tagValue->u.numeric = odr_malloc(o, sizeof(int)); + t->tagValue->u.numeric = (int *)odr_malloc(o, sizeof(int)); *t->tagValue->u.numeric = ivalue; } else { t->tagValue->which = Z_StringOrNumeric_string; - t->tagValue->u.string = odr_malloc(o, strlen(value)+1); + t->tagValue->u.string = (char *)odr_malloc(o, strlen(value)+1); strcpy(t->tagValue->u.string, value); } t->tagOccurrence = 0; t->metaData = 0; t->appliedVariant = 0; - t->content = c = odr_malloc(o, sizeof(Z_ElementData)); + t->content = c = (Z_ElementData *)odr_malloc(o, sizeof(Z_ElementData)); if (*buf == '{') { c->which = Z_ElementData_subtree; @@ -102,8 +115,7 @@ Z_GenericRecord *read_grs1(FILE *f, ODR o) { c->which = Z_ElementData_string; buf[strlen(buf)-1] = '\0'; - c->u.string = odr_malloc(o, strlen(buf)+1); - strcpy(c->u.string, buf); + c->u.string = odr_strdup(o, buf); } r->num_elements++; }