Commit d9fa2bc2 authored by unknown's avatar unknown

Merge work:/home/bk/mysql-4.0/ into hynda.(none):/home/my/bk/mysql-4.0

parents ffe72b2a 2276e8ae
......@@ -22,7 +22,7 @@
#include <mysql_embed.h>
#include <mysql.h>
#include <errmsg.h>
#include <getopt.h>
#include <my_getopt.h>
/* We have to define 'enum options' identical in all files to keep OS2 happy */
......
......@@ -32,7 +32,6 @@
#include "client_priv.h"
#include <m_ctype.h>
#include <stdarg.h>
#include <my_getopt.h>
#include <my_dir.h>
#ifndef __GNU_LIBRARY__
#define __GNU_LIBRARY__ // Skip warnings in getopt.h
......@@ -41,7 +40,7 @@
#include <signal.h>
#include <violite.h>
const char *VER= "12.5";
const char *VER= "12.6";
/* Don't try to make a nice table if the data is too big */
#define MAX_COLUMN_LENGTH 1024
......
......@@ -19,12 +19,11 @@
#include "client_priv.h"
#include <signal.h>
#include <my_getopt.h>
#ifdef THREAD
#include <my_pthread.h> /* because of signal() */
#endif
#define ADMIN_VERSION "8.32"
#define ADMIN_VERSION "8.34"
#define MAX_MYSQL_VAR 64
#define SHUTDOWN_DEF_TIMEOUT 3600 /* Wait for shutdown */
#define MAX_TRUNC_LENGTH 3
......
......@@ -19,7 +19,6 @@
#include "client_priv.h"
#include <time.h>
#include "log_event.h"
#include <my_getopt.h>
#define PROBE_HEADER_LEN (4+EVENT_LEN_OFFSET+4)
......@@ -125,7 +124,7 @@ static void die(const char* fmt, ...)
static void print_version()
{
printf("%s Ver 2.1 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE);
printf("%s Ver 2.2 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE);
}
......
......@@ -16,10 +16,9 @@
/* By Jani Tolonen, 2001-04-20, MySQL Development Team */
#define CHECK_VERSION "2.2"
#define CHECK_VERSION "2.3"
#include "client_priv.h"
#include <my_getopt.h>
#include <m_ctype.h>
#include "mysql_version.h"
#include "mysqld_error.h"
......
......@@ -35,7 +35,7 @@
** and adapted to mysqldump 05/11/01 by Jani Tolonen
*/
#define DUMP_VERSION "9.04"
#define DUMP_VERSION "9.05"
#include <my_global.h>
#include <my_sys.h>
......@@ -46,7 +46,6 @@
#include "mysql.h"
#include "mysql_version.h"
#include "mysqld_error.h"
#include <my_getopt.h>
/* Exit codes */
......
......@@ -25,11 +25,10 @@
** * *
** *************************
*/
#define IMPORT_VERSION "3.2"
#define IMPORT_VERSION "3.3"
#include "client_priv.h"
#include "mysql_version.h"
#include <my_getopt.h>
static void db_error_with_table(MYSQL *mysql, char *table);
static void db_error(MYSQL *mysql);
......
......@@ -16,7 +16,7 @@
/* Show databases, tables or columns */
#define SHOW_VERSION "9.2"
#define SHOW_VERSION "9.3"
#include <my_global.h>
#include "client_priv.h"
......@@ -27,7 +27,6 @@
#include "mysqld_error.h"
#include <signal.h>
#include <stdarg.h>
#include <my_getopt.h>
#include "sslopt-vars.h"
static my_string host=0,opt_password=0,user=0;
......
......@@ -23,71 +23,80 @@
#include <my_global.h>
#include <my_sys.h>
#include <getopt.h>
#include <my_getopt.h>
const char *config_file="my"; /* Default config file */
static struct option long_options[] =
static struct my_option my_long_options[] =
{
{"config-file", required_argument, 0, 'c'},
{"defaults-file", required_argument, 0, 'c'},
{"defaults-extra-file", required_argument, 0, 'e'},
{"extra-file", required_argument, 0, 'e'},
{"no-defaults", no_argument, 0, 'n'},
{"help", no_argument, 0, '?'},
{"version", no_argument, 0, 'V'},
{0, 0, 0, 0}
{"config-file", 'c', "The config file to be used",
(gptr*) &config_file, (gptr*) &config_file, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
{"defaults-file", 'c', "Synonym for --config-file",
(gptr*) &config_file, (gptr*) &config_file, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
{"defaults-extra-file", 'e',
"Read this file after the global /etc config file and before the config file in the users home directory.",
(gptr*) &defaults_extra_file, (gptr*) &defaults_extra_file, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"extra-file", 'e',
"Synonym for --defaults-extra-file",
(gptr*) &defaults_extra_file, (gptr*) &defaults_extra_file, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"no-defaults", 'n', "Return an empty string (useful for scripts)",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"help", '?', "Display this help message and exit.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit.",
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}
};
static void usage(my_bool version)
{
printf("%s Ver 1.3 for %s at %s\n",my_progname,SYSTEM_TYPE,
printf("%s Ver 1.4 for %s at %s\n",my_progname,SYSTEM_TYPE,
MACHINE_TYPE);
if (version)
return;
puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n");
puts("Prints all arguments that is give to some program using the default files");
printf("Usage: %s [OPTIONS] groups\n",my_progname);
printf("\n\
-c, --config-file=#, --defaults-file=#\n\
The config file to use (default '%s')\n\
-e, --extra-file=#, --defaults-extra-file=#\n\
Read this file after the global /etc config file and\n\
before the config file in the users home directory.\n\
-n, --no-defaults Return an empty string (useful for scripts)\n\
-?, --help Display this help message and exit.\n\
-V, --version Output version information and exit.\n",
config_file);
printf("\nExample usage:\n%s --config-file=my client mysql\n",my_progname);
printf("Usage: %s [OPTIONS] groups\n", my_progname);
my_print_help(my_long_options);
my_print_variables(my_long_options);
printf("\nExample usage:\n%s --config-file=my client mysql\n", my_progname);
}
static int get_options(int *argc,char ***argv)
{
int c,option_index;
while ((c=getopt_long(*argc,*argv,"nc:e:V?I",
long_options, &option_index)) != EOF)
{
switch (c) {
case 'c':
config_file=optarg;
break;
case 'e':
defaults_extra_file=optarg; /* Used by the load_defaults */
break;
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument __attribute__((unused)))
{
switch (optid) {
case 'n':
exit(0);
exit(0);
case 'I':
case '?':
usage(0);
exit(0);
usage(0);
exit(0);
case 'V':
usage(1);
exit(0);
}
usage(1);
exit(0);
}
return 0;
}
static int get_options(int *argc,char ***argv)
{
int ho_error;
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
{
printf("%s: handle_options() failed with error %d\n", my_progname,
ho_error);
exit(1);
}
(*argc)-=optind;
(*argv)+=optind;
if (*argc < 1)
{
usage(0);
......
......@@ -18,7 +18,7 @@
/* Install or upgrade MySQL server. By Sasha Pachev <sasha@mysql.com>
*/
#define INSTALL_VERSION "1.0"
#define INSTALL_VERSION "1.1"
#define DONT_USE_RAID
#include <my_global.h>
......@@ -27,17 +27,19 @@
#include <m_string.h>
#include <mysql_version.h>
#include <errno.h>
#include <getopt.h>
#include <my_getopt.h>
#define ANSWERS_CHUNCK 32
int have_gui=0;
struct option long_options[] =
static struct my_option my_long_options[] =
{
{"help", no_argument, 0, '?'},
{"version", no_argument, 0, 'V'},
{0, 0,0,0}
{"help", '?', "Display this help and exit.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit.",
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}
};
/* For now, not much exciting here, but we'll add more once
......@@ -195,26 +197,33 @@ static int ask_user(const char* question,int default_ind, ...)
return ans;
}
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument __attribute__((unused)))
{
switch(optid) {
case 'V':
print_version();
exit(0);
case '?':
usage();
exit(0);
}
return 0;
}
static int parse_args(int argc, char **argv)
{
int c, option_index = 0;
int ho_error;
while((c = getopt_long(argc, argv, "?V",
long_options, &option_index)) != EOF)
{
switch(c)
{
case 'V':
print_version();
exit(0);
case '?':
usage();
exit(0);
default:
usage();
exit(1);
}
}
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
{
printf("%s: handle_options() failed with error %d\n", my_progname,
ho_error);
exit(1);
}
return 0;
}
......@@ -231,10 +240,8 @@ static void usage()
printf("This software comes with ABSOLUTELY NO WARRANTY\n\n");
printf("Install or upgrade MySQL server.\n\n");
printf("Usage: %s [OPTIONS] \n", my_progname);
printf("\n\
-?, --help Display this help and exit.\n\
-h, --host=... Connect to host.\n\
-V, --version Output version information and exit.\n");
my_print_help(my_long_options);
my_print_variables(my_long_options);
}
int main(int argc, char** argv)
......
......@@ -16,32 +16,42 @@
/* Return error-text for system error messages and nisam messages */
#define PERROR_VERSION "2.7"
#define PERROR_VERSION "2.8"
#include <my_global.h>
#include <my_sys.h>
#include <m_string.h>
#include <errno.h>
#include <getopt.h>
#include <my_getopt.h>
static my_bool verbose, print_all_codes;
static struct option long_options[] =
static struct my_option my_long_options[] =
{
{"help", no_argument, 0, '?'},
{"info", no_argument, 0, 'I'},
{"all", no_argument, 0, 'a'},
{"silent", no_argument, 0, 's'},
{"verbose", no_argument, 0, 'v'},
{"version", no_argument, 0, 'V'},
{0, 0, 0, 0}
{"help", '?', "Displays this help and exits.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
{"info", 'I', "Synonym for --help", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#ifdef HAVE_SYS_ERRLIST
{"all", 'a', "Print all the error messages and the number.",
(gptr*) &print_all_codes, (gptr*) &print_all_codes, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0},
#endif
{"silent", 's', "Only print the error message", 0, 0, 0, GET_NO_ARG, NO_ARG,
0, 0, 0, 0, 0, 0},
{"verbose", 'v', "Print error code and message (default).", (gptr*) &verbose,
(gptr*) &verbose, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{"version", 'V', "Displays version information and exits.",
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}
};
typedef struct ha_errors {
int errcode;
const char *msg;
} HA_ERRORS;
static int verbose=1,print_all_codes=0;
static HA_ERRORS ha_errlist[]=
{
......@@ -99,57 +109,43 @@ static void usage(void)
printf("Print a description for a system error code or a error code from\na MyISAM/ISAM/BDB table handler.\n");
printf("If you want to get the error for a negative error code, you should use\n-- before the first error code to tell perror that there was no more options.\n\n");
printf("Usage: %s [OPTIONS] [ERRORCODE [ERRORCODE...]]\n",my_progname);
printf("\n\
-?, --help Displays this help and exits.\n\
-I, --info Synonym for the above.");
#ifdef HAVE_SYS_ERRLIST
printf("\n\
-a, --all Print all the error messages and the number.");
#endif
printf("\n\
-s, --silent Only print the error message\n\
-v, --verbose Print error code and message (default).\n\
-V, --version Displays version information and exits.\n");
my_print_help(my_long_options);
my_print_variables(my_long_options);
}
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument __attribute__((unused)))
{
switch (optid) {
case 's':
verbose=0;
break;
case 'V':
print_version();
exit(0);
break;
case 'I':
case '?':
usage();
exit(0);
break;
}
return 0;
}
static int get_options(int *argc,char ***argv)
{
int c,option_index;
int ho_error;
while ((c=getopt_long(*argc,*argv,"asvVI?",long_options,
&option_index)) != EOF)
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
{
switch (c) {
#ifdef HAVE_SYS_ERRLIST
case 'a':
print_all_codes=1;
break;
#endif
case 'v':
verbose=1;
break;
case 's':
verbose=0;
break;
case 'V':
print_version();
exit(0);
break;
case 'I':
case '?':
usage();
exit(0);
break;
default:
fprintf(stderr,"%s: Illegal option character '%c'\n",
my_progname,opterr);
return(1);
break;
}
printf("%s: handle_options() failed with error %d\n", my_progname,
ho_error);
exit(1);
}
(*argc)-=optind;
(*argv)+=optind;
if (!*argc && !print_all_codes)
{
usage();
......
......@@ -25,12 +25,12 @@
#include <m_string.h>
#include <mysql_version.h>
#include <errno.h>
#include <getopt.h>
#include <my_getopt.h>
#define INIT_SYM_TABLE 4096
#define INC_SYM_TABLE 4096
#define MAX_SYM_SIZE 128
#define DUMP_VERSION "1.2"
#define DUMP_VERSION "1.3"
#define HEX_INVALID (uchar)255
typedef ulong my_long_addr_t ; /* at some point, we need to fix configure
......@@ -48,15 +48,21 @@ static char* dump_fname = 0, *sym_fname = 0;
static DYNAMIC_ARRAY sym_table; /* how do you like this , static DYNAMIC ? */
static FILE* fp_dump, *fp_sym = 0, *fp_out;
struct option long_options[] =
static struct my_option my_long_options[] =
{
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
{"symbols-file", required_argument, 0, 's'},
{"numeric-dump-file", required_argument, 0, 'n'},
{0, 0,0,0}
{"help", 'h', "Display this help and exit.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"symbols-file", 's', "Use specified symbols file.", (gptr*) &sym_fname,
(gptr*) &sym_fname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"numeric-dump-file", 'n', "Read the dump from specified file.",
(gptr*) &dump_fname, (gptr*) &dump_fname, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
static void verify_sort();
static void print_version(void)
......@@ -72,11 +78,8 @@ static void usage()
printf("This software comes with ABSOLUTELY NO WARRANTY\n\n");
printf("Resolve numeric stack strace dump into symbols.\n\n");
printf("Usage: %s [OPTIONS] symbols-file [numeric-dump-file]\n", my_progname);
printf("\n\
-?, --help Display this help and exit.\n\
-s, --symbols-file=... Use specified symbols file.\n\
-n, --numeric-dump-file=... Read the dump from specified file.\n\
-V, --version Output version information and exit.\n");
my_print_help(my_long_options);
my_print_variables(my_long_options);
printf("\n\
The symbols-file should include the output from: 'nm --numeric-sort mysqld'.\n\
The numeric-dump-file should contain a numeric stack trace from mysqld.\n\
......@@ -97,40 +100,36 @@ static void die(const char* fmt, ...)
}
static int parse_args(int argc, char **argv)
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument __attribute__((unused)))
{
int c, option_index = 0;
switch(optid) {
case 'V':
print_version();
exit(0);
case '?':
usage();
exit(0);
}
return 0;
}
while((c = getopt_long(argc, argv, "?Vn:s:",
long_options, &option_index)) != EOF)
{
switch(c)
{
case 'n':
dump_fname = optarg;
break;
case 's':
sym_fname = optarg;
break;
case 'V':
print_version();
exit(0);
case '?':
usage();
exit(0);
default:
usage();
exit(1);
}
}
argc-=optind;
argv+=optind;
static int parse_args(int argc, char **argv)
{
int ho_error;
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
{
printf("%s: handle_options() failed with error %d\n", my_progname,
ho_error);
exit(1);
}
/*
The following code is to make the command compatible with the old
version that required one to use the -n and -s options
*/
*/
if (argc == 2)
{
......
......@@ -16,7 +16,7 @@
/* Resolves IP's to hostname and hostnames to IP's */
#define RESOLVE_VERSION "2.0"
#define RESOLVE_VERSION "2.1"
#include <my_global.h>
#include <m_ctype.h>
......@@ -30,7 +30,7 @@
#endif
#include <arpa/inet.h>
#include <netdb.h>
#include <getopt.h>
#include <my_getopt.h>
#ifdef SCO
#undef h_errno
......@@ -42,15 +42,19 @@ extern int h_errno;
#endif
static int silent=0;
static my_bool silent;
static struct option long_options[] =
static struct my_option my_long_options[] =
{
{"help", no_argument, 0, '?'},
{"info", no_argument, 0, 'I'},
{"silent", no_argument, 0, 's'},
{"version", no_argument, 0, 'V'},
{0, 0, 0, 0}
{"help", '?', "Displays this help and exits.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"info", 'I', "Synonym for --help",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"silent", 's', "Be more silent.", (gptr*) &silent, (gptr*) &silent,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Displays version information and exits.",
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}
};
......@@ -67,41 +71,39 @@ static void usage(void)
puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n");
puts("Get hostname based on IP-address or IP-address based on hostname.\n");
printf("Usage: %s [OPTIONS] hostname or IP-address\n",my_progname);
printf("\n\
-?, --help Displays this help and exits.\n\
-I, --info Synonym for the above.\n\
-s, --silent Be more silent.\n\
-V, --version Displays version information and exits.\n");
my_print_help(my_long_options);
my_print_variables(my_long_options);
}
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument __attribute__((unused)))
{
switch (optid) {
case 'V': print_version(); exit(0);
case 'I':
case '?':
usage();
exit(0);
}
return 0;
}
/*static my_string load_default_groups[]= { "resolveip","client",0 }; */
static int get_options(int *argc,char ***argv)
{
int c,option_index;
int ho_error;
/* load_defaults("my",load_default_groups,argc,argv); */
while ((c=getopt_long(*argc,*argv,"?IsV",
long_options, &option_index)) != EOF)
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
{
switch (c) {
case 's':
silent=1;
break;
case 'V': print_version(); exit(0);
case 'I':
case '?':
usage();
exit(0);
default:
fprintf(stderr,"%s: Illegal option character '%c'\n",
my_progname,opterr);
return(1);
break;
}
printf("%s: handle_options() failed with error %d\n", my_progname,
ho_error);
exit(1);
}
(*argc)-=optind;
(*argv)+=optind;
if (*argc == 0)
{
usage();
......
......@@ -23,7 +23,7 @@
#include "libmysqlfs.h"
#include "mysqlcorbafs.h"
#include <getopt.h>
#include <my_getopt.h>
#define MAXPATHLEN 256
#include <sys/types.h>
......@@ -62,6 +62,10 @@ static char *default_charset, *current_host, *current_user, *opt_password,
*path,*fields_terminated=0, *lines_terminated=0, *enclosed=0,
*opt_enclosed=0, *escaped=0;
/* This should be fixed to use my_getopt when the program is ready
static struct option long_options[] =
{
{"add-locks", no_argument, 0,OPT_LOCKS},
......@@ -99,6 +103,7 @@ static struct option long_options[] =
{0, 0, 0, 0}
};
*/
/*
void
......@@ -428,6 +433,8 @@ static int get_options(int *argc,char ***argv)
my_bool tty_password=0;
DBUG_ENTER("get_options");
load_defaults("my",load_default_groups,argc,argv);
/* change this to use my_getopt when program is ready */
set_all_changeable_vars(changeable_vars);
while ((c=getopt_long(*argc,*argv,"#::p::h:u:O:P:S:T:EBaAcCdefFlnqtvVw:?Ix",
long_options, &option_index)) != EOF)
......
......@@ -30,7 +30,7 @@
#ifndef __GNU_LIBRARY__
#define __GNU_LIBRARY__ /* Skipp warnings in getopt.h */
#endif
#include <getopt.h>
#include <my_getopt.h>
#if INT_MAX > 32767
#define BITS_SAVED 32
......@@ -182,8 +182,9 @@ static int mrg_rrnd(MRG_INFO *info,byte *buf);
static void mrg_reset(MRG_INFO *mrg);
static int backup=0,error_on_write=0,test_only=0,verbose=0,silent=0,
write_loop=0,force_pack=0,opt_wait=0,isamchk_neaded=0;
static int error_on_write=0,test_only=0,verbose=0,silent=0,
write_loop=0,force_pack=0,isamchk_neaded=0;
static my_bool backup, opt_wait;
static int tmpfile_createflag=O_RDWR | O_TRUNC | O_EXCL;
static uint tree_buff_length=8196-MALLOC_OVERHEAD,force_pack_ref_length;
static char tmp_dir[FN_REFLEN]={0},*join_table;
......@@ -240,26 +241,44 @@ int main(int argc, char **argv)
}
static struct option long_options[] =
static struct my_option my_long_options[] =
{
{"backup", no_argument, 0, 'b'},
{"debug", optional_argument, 0, '#'},
{"force", no_argument, 0, 'f'},
{"join", required_argument, 0, 'j'},
{"help", no_argument, 0, '?'},
{"packlength",required_argument, 0, 'p'},
{"silent", no_argument, 0, 's'},
{"tmpdir", required_argument, 0, 'T'},
{"test", no_argument, 0, 't'},
{"verbose", no_argument, 0, 'v'},
{"version", no_argument, 0, 'V'},
{"wait", no_argument, 0, 'w'},
{0, 0, 0, 0}
{"backup", 'b', "Make a backup of the table as table_name.OLD",
(gptr*) &backup, (gptr*) &backup, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"debug", '#', "Output debug log. Often this is 'd:t:o,filename'",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"force", 'f',
"Force packing of table even if it's gets bigger or tempfile exists.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"join", 'j',
"Join all given tables into 'new_table_name'. All tables MUST have the identical layout.",
(gptr*) &join_table, (gptr*) &join_table, 0, GET_STR, REQUIRED_ARG, 0, 0,
0, 0, 0, 0},
{"help", '?', "Display this help and exit.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"packlength", 'p', "Force storage size of recordlength (1, 2 or 3)",
(gptr*) &force_pack_ref_length, (gptr*) &force_pack_ref_length, 0,
GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"silent", 's', "Be more silent.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0 ,0},
{"tmpdir", 'T', "Use temporary directory to store temporary table",
(gptr*) &tmp_dir, (gptr*) &tmp_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0,
0, 0},
{"test", 't', "Don't pack table, only test packing it",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0 ,0},
{"verbose", 'v', "Write info about progress and packing result",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0 ,0},
{"version", 'V', "output version information and exit",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0 ,0},
{"wait", 'w', "Wait and retry if table is in use", (gptr*) &opt_wait,
(gptr*) &opt_wait, 0, GET_BOOL, 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}
};
static void print_version(void)
{
printf("%s Ver 5.8 for %s on %s\n",my_progname,SYSTEM_TYPE,MACHINE_TYPE);
printf("%s Ver 5.9 for %s on %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE);
}
static void usage(void)
......@@ -274,92 +293,75 @@ static void usage(void)
puts("You should give the .ISM file as the filename argument");
printf("\nUsage: %s [OPTIONS] filename...\n", my_progname);
puts("\n\
-b, --backup Make a backup of the table as table_name.OLD\n\
-f, --force Force packing of table even if it's gets bigger or\n\
tempfile exists.\n\
-j, --join='new_table_name'\n\
Join all given tables into 'new_table_name'.\n\
All tables MUST have the identical layout.\n\
-p, --packlength=# Force storage size of recordlength (1,2 or 3)\n\
-s, --silent Be more silent.\n\
-t, --test Don't pack table, only test packing it\n\
-v, --verbose Write info about progress and packing result\n\
-w, --wait Wait and retry if table is in use\n\
-T, --tmpdir=# Use temporary directory to store temporary table\n\
-#, --debug=... output debug log. Often this is 'd:t:o,filename`\n\
-?, --help display this help and exit\n\
-V, --version output version information and exit\n");
print_defaults("my",load_default_groups);
my_print_help(my_long_options);
print_defaults("my", load_default_groups);
my_print_variables(my_long_options);
}
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
uint length;
switch(optid) {
case 'f':
force_pack= 1;
tmpfile_createflag= O_RDWR | O_TRUNC;
break;
case 'p':
if (force_pack_ref_length > 3)
force_pack_ref_length= 0;
break;
case 's':
write_loop= verbose= 0;
silent= 1;
break;
case 't':
test_only= verbose= 1;
break;
case 'T':
length=(uint) (strmov(tmp_dir, argument) - tmp_dir);
if (length != dirname_length(tmp_dir))
{
tmp_dir[length]= FN_LIBCHAR;
tmp_dir[length + 1]= 0;
}
break;
case 'v':
verbose= 1;
silent= 0;
break;
case '#':
DBUG_PUSH(argument ? argument : "d:t:o");
break;
case 'V': print_version(); exit(0);
case 'I':
case '?':
usage();
exit(0);
}
return 0;
}
/* reads options */
/* Initiates DEBUG - but no debugging here ! */
static void get_options(int *argc,char ***argv)
static void get_options(int *argc, char ***argv)
{
int c,option_index=0;
uint length;
int ho_error;
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
{
printf("%s: handle_options() failed with error %d\n", my_progname,
ho_error);
exit(1);
}
my_progname= argv[0][0];
if (isatty(fileno(stdout)))
write_loop=1;
while ((c=getopt_long(*argc,*argv,"bfj:p:stvwT:#::?V",long_options,
&option_index)) != EOF)
{
switch(c) {
case 'b':
backup=1;
break;
case 'f':
force_pack=1;
tmpfile_createflag=O_RDWR | O_TRUNC;
break;
case 'j':
join_table=optarg;
break;
case 'p':
force_pack_ref_length=(uint) atoi(optarg);
if (force_pack_ref_length > 3)
force_pack_ref_length=0;
break;
case 's':
write_loop=verbose=0; silent=1;
break;
case 't':
test_only=verbose=1;
break;
case 'T':
length=(uint) (strmov(tmp_dir,optarg)-tmp_dir);
if (length != dirname_length(tmp_dir))
{
tmp_dir[length]=FN_LIBCHAR;
tmp_dir[length+1]=0;
}
break;
case 'v':
verbose=1; silent=0;
break;
case 'w':
opt_wait=1;
break;
case '#':
DBUG_PUSH(optarg ? optarg : "d:t:o");
break;
case 'V': print_version(); exit(0);
case 'I':
case '?':
usage();
exit(0);
default:
fprintf(stderr,"%s: Illegal option: -%c\n",my_progname,opterr);
usage();
exit(1);
}
}
(*argc)-=optind;
(*argv)+=optind;
if (!*argc)
{
usage();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment