diff options
author | unknown <jani@rhols221.arenanet.fi> | 2002-05-24 14:06:58 +0300 |
---|---|---|
committer | unknown <jani@rhols221.arenanet.fi> | 2002-05-24 14:06:58 +0300 |
commit | 072e605cdc5f8803d90f88877c7abe1b4efaa551 (patch) | |
tree | dde3a16d80cc4857063e077d484ded67a7697cb5 /myisam/ft_dump.c | |
parent | 701d369d1844f19853223860c8610e40b802f428 (diff) | |
download | mariadb-git-072e605cdc5f8803d90f88877c7abe1b4efaa551.tar.gz |
Changed ft_dump, ft_eval, ft_test1, mi_test1, myisampack, gen_lex_hash,
mysqlmanager from using GNU getopt to use my_getopt.
Changed some files that just included old getopt.h to include
my_getopt.h now.
Fixed a bug in my_print_help() in my_getopt.c.
Made better documentation for option -G in mysql client.
client/mysql.cc:
Documented --named-commands better.
myisam/ft_dump.c:
Changed getopt to my_getopt.
myisam/ft_eval.c:
Changed getopt to my_getopt.
myisam/ft_test1.c:
Changed getopt to my_getopt.
myisam/mi_check.c:
getopt.h -> my_getopt.h
myisam/mi_test1.c:
Changed getopt to my_getopt.
myisam/myisampack.c:
Changed getopt to my_getopt.
mysys/my_getopt.c:
Fixed a bug when printing help for option that didn't have a
description.
sql/gen_lex_hash.cc:
Changed getopt to my_getopt.
tools/mysqlmanager.c:
Changed getopt to my_getopt.
vio/test-ssl.c:
getopt.h -> my_getopt.h
vio/test-sslclient.c:
getopt.h -> my_getopt.h
vio/test-sslserver.c:
getopt.h -> my_getopt.h
vio/viotest-ssl.c:
getopt.h -> my_getopt.h
BitKeeper/etc/logging_ok:
Logging to logging@openlogging.org accepted
Diffstat (limited to 'myisam/ft_dump.c')
-rw-r--r-- | myisam/ft_dump.c | 103 |
1 files changed, 71 insertions, 32 deletions
diff --git a/myisam/ft_dump.c b/myisam/ft_dump.c index 6308694b58e..619e59efc3e 100644 --- a/myisam/ft_dump.c +++ b/myisam/ft_dump.c @@ -14,22 +14,46 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Written by Sergei A. Golubchik, who has a shared copyright to this code */ +/* Written by Sergei A. Golubchik, who has a shared copyright to this code + added support for long options (my_getopt) 22.5.2002 by Jani Tolonen */ #include "ftdefs.h" -#include <getopt.h> +#include <my_getopt.h> static void get_options(int argc,char *argv[]); -static void usage(char *argv[]); +static void usage(); static void complain(int val); -static int count=0, stats=0, dump=0, verbose=0, lstats=0; +static int count=0, stats=0, dump=0, lstats=0; +static my_bool verbose; static char *query=NULL; static uint lengths[256]; #define MAX_LEN (HA_FT_MAXLEN+10) #define HOW_OFTEN_TO_WRITE 10000 +static struct my_option my_long_options[] = +{ + {"dump", 'd', "Dump index (incl. data offsets and word weights)", + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"stats", 's', "Report global stats", + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"verbose", 'v', "Be verbose", + (gptr*) &verbose, (gptr*) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"count", 'c', "Calculate per-word stats (counts and global weights)", + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"length", 'l', "Report length distribution", + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"execute", 'e', "Execute given query", (gptr*) &query, (gptr*) &query, 0, + GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"help", 'h', "Display help and exit", + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"help", '?', "Synonym for -h", + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} +}; + + int main(int argc,char *argv[]) { int error=0; @@ -52,7 +76,7 @@ int main(int argc,char *argv[]) setbuf(stdout,NULL); if (argc-optind < 2) - usage(argv); + usage(); if (!(info=mi_open(argv[optind],2,HA_OPEN_ABORT_IF_LOCKED))) goto err; @@ -184,45 +208,60 @@ err: return 0; } -const char *options="dslcvh"; + +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument __attribute__((unused))) +{ + switch(optid) { + case 'd': + dump=1; + complain(count || query); + break; + case 's': + stats=1; + complain(query!=0); + break; + case 'c': + count= 1; + complain(dump || query); + break; + case 'l': + lstats=1; + complain(query!=0); + break; + case 'e': + complain(dump || count || stats); + break; + case '?': + case 'h': + usage(); + } + return 0; +} static void get_options(int argc, char *argv[]) { - int c; + int ho_error; - while ((c=getopt(argc,argv,options)) != -1) + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) { - switch(c) { - case 'd': dump=1; complain(count || query); break; - case 's': stats=1; complain(query!=0); break; - case 'v': verbose=1; break; - case 'c': count=1; complain(dump || query); break; - case 'l': lstats=1; complain(query!=0); break; - case 'e': query=my_strdup(optarg,MYF(MY_FAE)); complain(dump || count || stats); break; - case '?': - case 'h': - default: - usage(argv); - } + printf("%s: handle_options() failed with error %d\n", my_progname, + ho_error); + exit(1); } - return; } /* get options */ -static void usage(char *argv[]) + +static void usage() { - printf("\n\ -Use: %s [-%s] <table_name> <index_no>\n\ -\n\ --d Dump index (incl. data offsets and word weights)\n\ --s Report global stats\n\ --c Calculate per-word stats (counts and global weights)\n\ --l Report length distribution\n\ --v Be verbose\n\ --h This text\n\ -", *argv, options); + printf("Use: ft_dump <table_name> <index_no>\n"); + my_print_help(my_long_options); + my_print_variables(my_long_options); exit(1); } + static void complain(int val) /* Kinda assert :-) */ { if (val) |