1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2011 Index Data
3 * See the file LICENSE for details.
12 #include <yaz/xmalloc.h>
18 int main(int argc, char **argv)
22 const char *errmsg, *addinfo;
25 fprintf(stderr, "Usage:\n%s <target> <file> [<file> ...]\n", argv[0]);
26 fprintf(stderr, " eg. bagel.indexdata.dk/gils foo.xml bar.xml\n");
30 z = ZOOM_connection_create(0);
32 for (i = 2; i < argc; i++) {
33 char *buf, *fn = argv[i];
35 size_t size, offset = 0;
38 ZOOM_connection_connect(z, argv[1], 0);
39 if ((error = ZOOM_connection_error(z, &errmsg, &addinfo))) {
40 fprintf(stderr, "Error: %s (%d) %s\n", errmsg, error, addinfo);
44 if (stat(fn, &statbuf) < 0 ||
45 (fd = open(fn, O_RDONLY)) < 0) {
49 size = statbuf.st_size;
50 printf("size=%lu\n", (unsigned long) size);
51 buf = (char *) xmalloc(size+1);
52 while ((n = read(fd, &buf[offset], size)) < size) {
64 ZOOM_package pkg = ZOOM_connection_package(z, 0);
65 ZOOM_package_option_set(pkg, "action", "specialUpdate");
66 ZOOM_package_option_set(pkg, "record", buf);
67 ZOOM_package_send(pkg, "update");
68 if ((error = ZOOM_connection_error(z, &errmsg, &addinfo))) {
69 printf("file '%s': error %d (%s) %s\n",
70 fn, error, errmsg, addinfo);
72 printf("file '%s': ok\n", fn);
77 if (i < argc-1) sleep(2);
80 ZOOM_connection_destroy(z);
86 * c-file-style: "Stroustrup"
87 * indent-tabs-mode: nil
89 * vim: shiftwidth=4 tabstop=8 expandtab