-/* $Id: zoomtst9.c,v 1.2 2006-04-21 10:28:08 adam Exp $ */
-
-/** \file zoomtst9.c
- \brief Extended Service Update
-*/
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2013 Index Data
+ * See the file LICENSE for details.
+ */
#include <stdio.h>
#include <string.h>
+#include <yaz/wrbuf.h>
#include <yaz/nmem.h>
#include <yaz/xmalloc.h>
#include <yaz/zoom.h>
-static void usage()
+static void usage(void)
{
fprintf(stderr, "usage:\n"
"zoomtst9 target [insert|delete|replace|update] id1 rec1 "
ZOOM_options o = ZOOM_options_create ();
int error;
const char *errmsg, *addinfo;
-
+
if (argc < 3)
usage();
z = ZOOM_connection_create (o);
-
+
/* connect and init */
ZOOM_connection_connect (z, argv[1], 0);
-
+
if ((error = ZOOM_connection_error(z, &errmsg, &addinfo)))
{
fprintf(stderr, "%s error: %s (%d) %s\n",
ZOOM_package_option_set(pkg, "recordIdOpaque",
argv[i][0] ? argv[i] : 0);
i++;
- ZOOM_package_option_set(pkg, "record",
- argv[i][0] ? argv[i] : 0);
+ if (!strcmp(argv[i], "-"))
+ {
+ /* For -, read record buffer from stdin */
+ WRBUF w = wrbuf_alloc();
+ int ch;
+ while ((ch = getchar()) != EOF)
+ wrbuf_putc(w, ch);
+ wrbuf_putc(w, '\0');
+ ZOOM_package_option_set(pkg, "record", wrbuf_buf(w));
+ }
+ else
+ {
+ ZOOM_package_option_set(pkg, "record",
+ argv[i][0] ? argv[i] : 0);
+ }
i++;
ZOOM_package_send(pkg, "update"); /* Update EXT service */
/*
* Local variables:
* c-basic-offset: 4
+ * c-file-style: "Stroustrup"
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab