From 935bef34ad811941165051ce9cb9f1a61027baa9 Mon Sep 17 00:00:00 2001 From: teodor Date: Wed, 9 Feb 2005 10:49:59 +0000 Subject: [PATCH] Usage() extends --- tbtreetest.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tbtreetest.c b/tbtreetest.c index a3779ca..cb5456e 100644 --- a/tbtreetest.c +++ b/tbtreetest.c @@ -42,6 +42,22 @@ usage() { puts( "Usage:\n" "tbtreetest [ -c CACHESIZE ] [-r] [-k] [-f FILE] [-D | -L | -b | -i KEY -v VALUE [ -S strategynumber ] | -d KEY | -s KEY ] [-V] [-q]\n" + "\t-c CACHESIZE - cache size in pages (default 0)\n" + "\t-r - readonly mode\n" + "\t-k - fixed size key (integer)\n" + "\t-f FILE - db-file (default ./BTREE)"); + puts( + "\t-D - dump data base\n" + "\t-L - list all pairs (in bulk format)\n" + "\t-b - bulk operations from stdin in format (insert/delete/search):\n" + "\t I KEY VALUE\n" + "\t D KEY\n" + "\t S KEY\n" + "\t-i KEY -v VALUE - insert KEY/VALUE\n" + "\t-d KEY - delete key\n" + "\t-s KEY - search key\n" + "\t-V - print page read/writes at the end\n" + "\t-q - do not print results of searches\n" ); exit(1); } @@ -49,6 +65,7 @@ usage() { extern char *optarg; extern int opterr; +#define MODE_NO 0 #define MODE_SEARCH 1 #define MODE_INSERT 2 #define MODE_DELETE 3 @@ -104,7 +121,7 @@ main(int argn, char *argv[]) { int rc=0; char *file="BTREE"; char *key=NULL, *val=NULL; - int mode=0, verbose=0, quietout=0; + int mode=MODE_NO, verbose=0, quietout=0; opentlog(TL_OPEN_STDERR,TL_DEBUG, NULL); @@ -167,8 +184,11 @@ main(int argn, char *argv[]) { } } - db.cmpkey = (db.keylen) ? cmpINT : cmpSTR; + if ( mode==MODE_NO ) + usage(); + db.cmpkey = (db.keylen) ? cmpINT : cmpSTR; + if ( (rc=TBTOpen(&db, file))!= TBT_OK ) exit(1); -- 2.46.1