X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=index%2Fzebrash.c;h=73cc7d49a02c972508aad6b0e921ff5a8e5f05b2;hp=577f9424255438031069243a126e51bd92c7edd3;hb=89d3a004b7c651fd5673abfc192e1472dc4d4197;hpb=6c9fcd3b5d3108702fa1ffc92dab4ab6060f9a19 diff --git a/index/zebrash.c b/index/zebrash.c index 577f942..73cc7d4 100644 --- a/index/zebrash.c +++ b/index/zebrash.c @@ -1,5 +1,5 @@ -/* $Id: zebrash.c,v 1.32 2005-01-15 19:38:29 adam Exp $ - Copyright (C) 1995-2005 +/* $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. @@ -15,9 +15,9 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 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 + */ /* @@ -28,7 +28,9 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include #include -#include /* for isatty */ +#if HAVE_UNISTD_H +#include +#endif #if HAVE_READLINE_READLINE_H #include @@ -191,7 +193,7 @@ static int cmd_zebra_open( char *args[], WRBUF outbuff) 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 */ } @@ -349,7 +351,7 @@ static int cmd_end_trans( char *args[], WRBUF outbuff) static int cmd_record_insert( char *args[], WRBUF outbuff) { - SYSNO sysno=0; + zint sysno = 0; int rc; char *rec=restargs(args,1); @@ -363,7 +365,7 @@ static int cmd_record_insert( char *args[], WRBUF outbuff) 0); if (0==rc) { - wrbuf_printf(outbuff,"ok sysno=%d\n",sysno); + wrbuf_printf(outbuff,"ok sysno=" ZINT_FORMAT "\n",sysno); } return rc; } @@ -390,15 +392,15 @@ static int cmd_exchange_record( char *args[], WRBUF outbuff) * 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; } @@ -406,21 +408,21 @@ static int cmd_find( char *args[], WRBUF outbuff) { 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; } @@ -741,7 +743,7 @@ static int cmd_help( char *args[], WRBUF outbuff) /* 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) @@ -755,7 +757,6 @@ static void Zerrors ( WRBUF outbuff) wrbuf_printf(outbuff, " Zebra error %d: %s, (%s)\n", ec, zebra_errString (zh), zebra_errAdd (zh) ); - zebra_clearError(zh); } } @@ -763,7 +764,7 @@ static void Zerrors ( WRBUF outbuff) * The shell */ -void shell() +void shell(void) { int rc=0; WRBUF outbuff=wrbuf_alloc(); @@ -826,7 +827,7 @@ void shell() } /* shell() */ -static void usage() +static void usage(void) { printf ("usage:\n"); printf ("zebrash [-c config]\n"); @@ -860,3 +861,11 @@ int main (int argc, char ** argv) shell(); return 0; } /* main */ +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +