X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=ztest%2Fztest.c;h=ee4ce6dad1cee57ce321abefffb2215ae235aac6;hb=b23f8886419f5fa9f4a46ba15812ad02d1ca8e55;hp=07bc6949c2bc1b0ba3656bc905942af30dd5cfd4;hpb=8448f144099c16b7ab17b2547cc3a04816dcce07;p=yaz-moved-to-github.git diff --git a/ztest/ztest.c b/ztest/ztest.c index 07bc694..ee4ce6d 100644 --- a/ztest/ztest.c +++ b/ztest/ztest.c @@ -7,7 +7,16 @@ * Chas Woodfield, Fretwell Downing Datasystems. * * $Log: ztest.c,v $ - * Revision 1.19 1998-10-20 15:16:22 adam + * Revision 1.22 1999-05-26 13:49:12 adam + * DB Update implemented in client (very basic). + * + * Revision 1.21 1998/12/15 12:45:42 adam + * Minor change. + * + * Revision 1.20 1998/12/14 14:48:05 adam + * Fixed memory leak - happened when fetching MARC records. + * + * Revision 1.19 1998/10/20 15:16:22 adam * Minor change to prevent warning. * * Revision 1.18 1998/10/20 15:13:45 adam @@ -77,7 +86,6 @@ #include #include -#include #include #include @@ -127,11 +135,7 @@ int ztest_esrequest (void *handle, bend_esrequest_rr *rr) { logf (LOG_WARN, "No task specific parameters"); } - else if (rr->esr->taskSpecificParameters->which != Z_External_itemOrder) - { - logf (LOG_WARN, "Not Item Order %d", rr->esr->taskSpecificParameters->which); - } - else + else if (rr->esr->taskSpecificParameters->which == Z_External_itemOrder) { Z_ItemOrder *it = rr->esr->taskSpecificParameters->u.itemOrder; switch (it->which) @@ -170,6 +174,11 @@ int ztest_esrequest (void *handle, bend_esrequest_rr *rr) break; } } + else + { + logf (LOG_WARN, "Unknown Extended Service(%d)", + rr->esr->taskSpecificParameters->which); + } rr->errcode = 0; return 0; } @@ -209,7 +218,7 @@ static int atoin (const char *buf, int n) return val; } -char *marc_read(FILE *inf) +char *marc_read(FILE *inf, ODR odr) { char length_str[5]; size_t size; @@ -220,7 +229,7 @@ char *marc_read(FILE *inf) size = atoin (length_str, 5); if (size <= 6) return NULL; - if (!(buf = (char*) xmalloc (size+1))) + if (!(buf = (char*) odr_malloc (odr, size+1))) return NULL; if (fread (buf+5, 1, size-5, inf) != (size-5)) { @@ -232,27 +241,25 @@ char *marc_read(FILE *inf) return buf; } -static char *dummy_database_record (int num) +static char *dummy_database_record (int num, ODR odr) { FILE *inf = fopen ("dummy-records", "r"); - char *buf = 0; + char *buf; if (!inf) return NULL; while (--num >= 0) { - if (buf) - xfree(buf); if (num == 98) { - buf = (char*) xmalloc(2101); + buf = (char*) odr_malloc(odr, 2101); assert(buf); memset(buf, 'A', 2100); buf[2100] = '\0'; break; } else - buf = marc_read (inf); + buf = marc_read (inf, odr); if (!num || !buf) break; } @@ -309,11 +316,10 @@ bend_fetchresult *bend_fetch(void *handle, bend_fetchrequest *q, int *fd) return r; } } - else if ((cp = dummy_database_record(q->number))) + else if ((cp = dummy_database_record(q->number, q->stream))) { r->len = strlen(cp); - r->record = (char *) odr_malloc (q->stream, 1+r->len); - strcpy (r->record, cp); + r->record = cp; r->format = VAL_USMARC; } else