1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2010 Index Data
3 * See the file LICENSE for details.
10 #include <yaz/options.h>
11 #include <yaz/record_conv.h>
13 const char *prog = "yaz-record-conv";
15 static void usage(void)
17 fprintf(stderr, "%s: usage\nyaz-record-conf config file ..\n", prog);
20 int main (int argc, char **argv)
24 yaz_record_conv_t p = 0;
26 while ((r = options("V", argv, argc, &arg)) != -2)
35 xmlDocPtr doc = xmlParseFile(arg);
38 p = yaz_record_conv_create();
41 xmlNodePtr ptr = xmlDocGetRootElement(doc);
44 r = yaz_record_conv_configure(p, ptr);
47 fprintf(stderr, "record conf error: %s\n",
48 yaz_record_conv_get_error(p));
55 yaz_record_conv_destroy(p);
61 WRBUF input_record = wrbuf_alloc();
62 WRBUF output_record = wrbuf_alloc();
63 FILE *f = fopen(arg, "rb");
67 fprintf(stderr, "%s: open failed: %s\n",
71 while ((c = getc(f)) != EOF)
72 wrbuf_putc(input_record, c);
74 r = yaz_record_conv_record(p,
75 wrbuf_buf(input_record),
76 wrbuf_len(input_record),
80 fprintf(stderr, "%s: %s: Error %s\n",
82 yaz_record_conv_get_error(p));
87 fwrite(wrbuf_buf(output_record), 1,
88 wrbuf_len(output_record), stdout);
90 wrbuf_destroy(input_record);
91 wrbuf_destroy(output_record);
99 yaz_record_conv_destroy(p);
107 * c-file-style: "Stroustrup"
108 * indent-tabs-mode: nil
110 * vim: shiftwidth=4 tabstop=8 expandtab