-/* $Id: zebrash.c,v 1.30 2004-11-19 10:27:04 heikki Exp $
- Copyright (C) 2002,2003,2004
- Index Data Aps
+/* $Id: zebrash.c,v 1.42 2007-01-15 15:10:17 adam Exp $
+ Copyright (C) 1995-2007
+ Index Data ApS
This file is part of the Zebra server.
for more details.
You should have received a copy of the GNU General Public License
-along with Zebra; see the file LICENSE.zebra. If not, write to the
-Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
*/
/*
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
-#include <unistd.h> /* for isatty */
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#if HAVE_READLINE_READLINE_H
#include <readline/readline.h>
#endif
#include <idzebra/api.h>
-#include <yaz/ylog.h>
+#include <yaz/log.h>
#include <yaz/proto.h>
#include <yaz/sortspec.h>
#include <yaz/options.h>
if (!zs)
wrbuf_puts(outbuff,"zebra seems not to have been started, "
"trying anyway\n");
- zh=zebra_open(zs);
+ zh = zebra_open(zs, 0);
return 0; /* ok */
}
static int cmd_record_insert( char *args[], WRBUF outbuff)
{
- SYSNO sysno=0;
+ zint sysno = 0;
int rc;
char *rec=restargs(args,1);
0);
if (0==rc)
{
- wrbuf_printf(outbuff,"ok sysno=%d\n",sysno);
+ wrbuf_printf(outbuff,"ok sysno=" ZINT_FORMAT "\n",sysno);
}
return rc;
}
* Searching and retrieving
*/
-static int cmd_search_pqf( char *args[], WRBUF outbuff)
+static int cmd_search_pqf(char *args[], WRBUF outbuff)
{
- int hits=0;
- char *set=args[1];
- char *qry=restargs(args,2);
+ zint hits = 0;
+ char *set = args[1];
+ char *qry = restargs(args,2);
int rc;
- rc=zebra_search_PQF(zh, qry, set, &hits);
+ rc = zebra_search_PQF(zh, qry, set, &hits);
if (0==rc)
- wrbuf_printf(outbuff,"%d hits found\n",hits);
+ wrbuf_printf(outbuff, ZINT_FORMAT " hits found\n", hits);
return rc;
}
{
char *setname=DEFAULTRESULTSET;
int rc;
- int hits=0;
- WRBUF qry=wrbuf_alloc();
+ zint hits = 0;
+ WRBUF qry = wrbuf_alloc();
if (0==strstr(args[0],"@attr"))
wrbuf_puts(qry, "@attr 1=/ ");
wrbuf_puts(qry,restargs(args,1));
if (!zh)
onecommand("quickstart", outbuff, "");
wrbuf_printf(outbuff, "find %s\n",wrbuf_buf(qry));
- rc=zebra_search_PQF(zh, wrbuf_buf(qry), setname, &hits);
+ rc = zebra_search_PQF(zh, wrbuf_buf(qry), setname, &hits);
if (0==rc)
{
- wrbuf_printf(outbuff,"%d hits found\n",hits);
- nextrecno=1;
+ wrbuf_printf(outbuff, ZINT_FORMAT " hits found\n", hits);
+ nextrecno = 1;
}
- wrbuf_free(qry,1);
+ wrbuf_free(qry, 1);
return rc;
}
/* If Zebra reports an error after an operation,
* append it to the outbuff and log it */
-static void Zerrors ( WRBUF outbuff)
+static void Zerrors (WRBUF outbuff)
{
int ec;
if (!zh)
wrbuf_printf(outbuff, " Zebra error %d: %s, (%s)\n",
ec, zebra_errString (zh),
zebra_errAdd (zh) );
- zebra_clearError(zh);
}
}
* The shell
*/
-void shell()
+void shell(void)
{
int rc=0;
WRBUF outbuff=wrbuf_alloc();
} /* shell() */
-static void usage()
+static void usage(void)
{
printf ("usage:\n");
printf ("zebrash [-c config]\n");
shell();
return 0;
} /* main */
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+