|
|
Index Data > YAZ > YAZ User's Guide and Reference > MARC YAZ provides a fast utility that decodes MARC records and encodes to a varity of output formats. The MARC records must be encoded in ISO2709.
#include <yaz/marcdisp.h>
/* create handler */
yaz_marc_t yaz_marc_create(void);
/* destroy */
void yaz_marc_destroy(yaz_marc_t mt);
/* set XML mode YAZ_MARC_LINE, YAZ_MARC_SIMPLEXML, ... */
void yaz_marc_xml(yaz_marc_t mt, int xmlmode);
#define YAZ_MARC_LINE 0
#define YAZ_MARC_SIMPLEXML 1
#define YAZ_MARC_OAIMARC 2
#define YAZ_MARC_MARCXML 3
#define YAZ_MARC_ISO2709 4
#define YAZ_MARC_XCHANGE 5
/* supply iconv handle for character set conversion .. */
void yaz_marc_iconv(yaz_marc_t mt, yaz_iconv_t cd);
/* set debug level, 0=none, 1=more, 2=even more, .. */
void yaz_marc_debug(yaz_marc_t mt, int level);
/* decode MARC in buf of size bsize. Returns >0 on success; <=0 on failure.
On success, result in *result with size *rsize. */
int yaz_marc_decode_buf (yaz_marc_t mt, const char *buf, int bsize,
char **result, int *rsize);
/* decode MARC in buf of size bsize. Returns >0 on success; <=0 on failure.
On success, result in WRBUF */
int yaz_marc_decode_wrbuf (yaz_marc_t mt, const char *buf,
int bsize, WRBUF wrbuf);
A MARC conversion handle must be created by using
All other function operate on a
The actual conversion functions are
Example 7.18. Display of MARC record The followint program snippet illustrates how the MARC API may be used to convert a MARC record to the line-by-line format:
void print_marc(const char *marc_buf, int marc_buf_size)
{
char *result; /* for result buf */
int result_len; /* for size of result */
yaz_marc_t mt = yaz_marc_create();
yaz_marc_xml(mt, YAZ_MARC_LINE);
yaz_marc_decode_buf(mt, marc_buf, marc_buf_size,
&result, &result_len);
fwrite(result, result_len, 1, stdout);
yaz_marc_destroy(mt); /* note that result is now freed... */
}
|
|||
|
|
||||
| Copyright Index Data ApS 2008 | ||||