projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Generate yaz-version.h from configure.ac (except YAZ_VERSIONL)
[yaz-moved-to-github.git]
/
ztest
/
read-marc.c
diff --git
a/ztest/read-marc.c
b/ztest/read-marc.c
index
6333a40
..
e1ecb3b
100644
(file)
--- a/
ztest/read-marc.c
+++ b/
ztest/read-marc.c
@@
-1,16
+1,18
@@
-/*
- * Copyright (c) 2002, Index Data.
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2008 Index Data
* See the file LICENSE for details.
* See the file LICENSE for details.
- *
- * $Id: read-marc.c,v 1.3 2002-09-24 08:05:41 adam Exp $
*/
*/
-/*
- * Little toy-thing to read a MARC records from a fixed array.
+/** \file
+ * \brief Little toy-thing to read MARC records from a file or fixed array.
*/
*/
+
#include <ctype.h>
#include <ctype.h>
-#include <yaz/odr.h>
#include <yaz/wrbuf.h>
#include <yaz/wrbuf.h>
+#include <yaz/marcdisp.h>
+#include <yaz/odr.h>
+
+#include "ztest.h"
char *marc_records[] = {
char *marc_records[] = {
@@
-1536,7
+1538,7
@@
static int atoin (const char *buf, int n)
int val = 0;
while (--n >= 0)
{
int val = 0;
while (--n >= 0)
{
- if (isdigit(*buf))
+ if (isdigit(*(const unsigned char *) buf))
val = val*10 + (*buf - '0');
buf++;
}
val = val*10 + (*buf - '0');
buf++;
}
@@
-1573,12
+1575,6
@@
char *dummy_marc_record (int num, ODR odr)
FILE *inf;
char *buf = 0;
FILE *inf;
char *buf = 0;
- if (num == 98)
- { /* this will generate a very bad MARC record (testing only) */
- buf = (char*) odr_malloc(odr, 2101);
- memset(buf, '7', 2100);
- buf[2100] = '\0';
- }
inf = fopen ("dummy-records", "r");
if (!inf)
{ /* file not there. Get them from fixed array */
inf = fopen ("dummy-records", "r");
if (!inf)
{ /* file not there. Get them from fixed array */
@@
-1600,20
+1596,31
@@
char *dummy_marc_record (int num, ODR odr)
/* read MARC record and convert to XML */
char *dummy_xml_record (int num, ODR odr)
{
/* read MARC record and convert to XML */
char *dummy_xml_record (int num, ODR odr)
{
- WRBUF wr = wrbuf_alloc ();
+ yaz_marc_t mt = yaz_marc_create();
+ const char *result;
+ size_t rlen;
char *rec = dummy_marc_record (num, odr);
int len;
char *rec = dummy_marc_record (num, odr);
int len;
+
if (!rec)
return 0;
if (!rec)
return 0;
- len = yaz_marc_decode (rec, wr, 0, -1, 1);
+ yaz_marc_xml(mt, YAZ_MARC_MARCXML);
+ len = yaz_marc_decode_buf (mt, rec, -1, &result, &rlen);
if (len > 1)
{
if (len > 1)
{
- len = wrbuf_len(wr);
- rec = (char *) odr_malloc (odr, len+1);
- memcpy (rec, wrbuf_buf(wr), len+1);
- rec[len] = 0;
+ rec = (char *) odr_malloc(odr, rlen+1);
+ memcpy(rec, result, rlen);
+ rec[rlen] = '\0';
}
}
- wrbuf_free (wr, 1);
+ yaz_marc_destroy(mt);
return rec;
}
return rec;
}
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+