1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2013 Index Data
3 * See the file LICENSE for details.
11 #include <yaz/options.h>
12 #include <yaz/record_conv.h>
14 const char *prog = "yaz-record-conv";
16 static void usage(void)
18 fprintf(stderr, "%s: usage\nyaz-record-conf config file ..\n", prog);
21 int main (int argc, char **argv)
25 yaz_record_conv_t p = 0;
27 while ((r = options("V", argv, argc, &arg)) != -2)
37 xmlDocPtr doc = xmlParseFile(arg);
40 p = yaz_record_conv_create();
43 xmlNodePtr ptr = xmlDocGetRootElement(doc);
46 r = yaz_record_conv_configure(p, ptr);
49 fprintf(stderr, "record conf error: %s\n",
50 yaz_record_conv_get_error(p));
57 yaz_record_conv_destroy(p);
63 WRBUF input_record = wrbuf_alloc();
64 WRBUF output_record = wrbuf_alloc();
65 FILE *f = fopen(arg, "rb");
69 fprintf(stderr, "%s: open failed: %s\n",
73 while ((c = getc(f)) != EOF)
74 wrbuf_putc(input_record, c);
76 r = yaz_record_conv_record(p,
77 wrbuf_buf(input_record),
78 wrbuf_len(input_record),
82 fprintf(stderr, "%s: %s: Error %s\n",
84 yaz_record_conv_get_error(p));
89 fwrite(wrbuf_buf(output_record), 1,
90 wrbuf_len(output_record), stdout);
92 wrbuf_destroy(input_record);
93 wrbuf_destroy(output_record);
98 fprintf(stderr, "%s: YAZ not compiled with Libxml2 support\n",
108 yaz_record_conv_destroy(p);
117 * c-file-style: "Stroustrup"
118 * indent-tabs-mode: nil
120 * vim: shiftwidth=4 tabstop=8 expandtab