Commit c143f01d authored by jani@hynda.mysql.fi's avatar jani@hynda.mysql.fi

Changed mysql, mysqladmin, mysqlshow, mysqldump, mysqlimport,

mysqlcheck and myisamchk to use new my_getopt struct.
parent 697978b5
...@@ -31,4 +31,9 @@ enum options { OPT_CHARSETS_DIR=256, OPT_DEFAULT_CHARSET, ...@@ -31,4 +31,9 @@ enum options { OPT_CHARSETS_DIR=256, OPT_DEFAULT_CHARSET,
OPT_LOW_PRIORITY, OPT_AUTO_REPAIR, OPT_COMPRESS, OPT_LOW_PRIORITY, OPT_AUTO_REPAIR, OPT_COMPRESS,
OPT_DROP, OPT_LOCKS, OPT_KEYWORDS, OPT_DELAYED, OPT_OPTIMIZE, OPT_DROP, OPT_LOCKS, OPT_KEYWORDS, OPT_DELAYED, OPT_OPTIMIZE,
OPT_FTB, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC, OPT_TABLES, OPT_FTB, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC, OPT_TABLES,
OPT_MASTER_DATA, OPT_AUTOCOMMIT}; OPT_MASTER_DATA, OPT_AUTOCOMMIT, OPT_AUTO_REHASH,
OPT_LINE_NUMBERS, OPT_COLUMN_NAMES, OPT_CONNECT_TIMEOUT,
OPT_MAX_ALLOWED_PACKET, OPT_NET_BUFFER_LENGTH,
OPT_SELECT_LIMIT, OPT_MAX_JOIN_SIZE, OPT_SSL_SSL,
OPT_SSL_KEY, OPT_SSL_CERT, OPT_SSL_CA, OPT_SSL_CAPATH,
OPT_SSL_CIPHER, OPT_SHUTDOWN_TIMEOUT};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -16,9 +16,10 @@ ...@@ -16,9 +16,10 @@
/* Show databases, tables or columns */ /* Show databases, tables or columns */
#define SHOW_VERSION "8.3" #define SHOW_VERSION "9.0"
#include <my_global.h> #include <my_global.h>
#include "client_priv.h"
#include <my_sys.h> #include <my_sys.h>
#include <m_string.h> #include <m_string.h>
#include "mysql.h" #include "mysql.h"
...@@ -26,10 +27,11 @@ ...@@ -26,10 +27,11 @@
#include "mysqld_error.h" #include "mysqld_error.h"
#include <signal.h> #include <signal.h>
#include <stdarg.h> #include <stdarg.h>
#include <getopt.h> #include <my_getopt.h>
#include "sslopt-vars.h"
static my_string host=0,opt_password=0,user=0; static my_string host=0,opt_password=0,user=0;
static my_bool opt_show_keys=0,opt_compress=0,opt_status=0; static my_bool opt_show_keys=0,opt_compress=0,opt_status=0, tty_password=0;
static uint opt_verbose=0; static uint opt_verbose=0;
static void get_options(int *argc,char ***argv); static void get_options(int *argc,char ***argv);
...@@ -48,7 +50,6 @@ static void print_res_row(MYSQL_RES *result,MYSQL_ROW cur); ...@@ -48,7 +50,6 @@ static void print_res_row(MYSQL_RES *result,MYSQL_ROW cur);
static const char *load_default_groups[]= { "mysqlshow","client",0 }; static const char *load_default_groups[]= { "mysqlshow","client",0 };
static my_string opt_mysql_unix_port=0; static my_string opt_mysql_unix_port=0;
#include "sslopt-vars.h"
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
...@@ -121,29 +122,48 @@ int main(int argc, char **argv) ...@@ -121,29 +122,48 @@ int main(int argc, char **argv)
return 0; /* No compiler warnings */ return 0; /* No compiler warnings */
} }
static struct my_option my_long_options[] =
static struct option long_options[] =
{ {
{"character-sets-dir", required_argument, 0, 'c'}, {"character-sets-dir", 'c', "Directory where character sets are",
{"compress", no_argument, 0, 'C'}, (gptr*) &charsets_dir, (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0,
{"debug", optional_argument, 0, '#'}, 0, 0, 0, 0, 0},
{"help", no_argument, 0, '?'}, {"compress", 'C', "Use compression in server/client protocol",
{"host", required_argument, 0, 'h'}, (gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
{"status", no_argument, 0, 'i'}, 0, 0, 0},
{"keys", no_argument, 0, 'k'}, {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'",
{"password", optional_argument, 0, 'p'}, 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"port", required_argument, 0, 'P'}, {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG,
0, 0, 0, 0, 0, 0},
{"host", 'h', "Connect to host.", (gptr*) &host, (gptr*) &host, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"status", 'i', "Shows a lot of extra information about each table.",
(gptr*) &opt_status, (gptr*) &opt_status, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0},
{"keys", 'k', "Show keys for table", (gptr*) &opt_show_keys,
(gptr*) &opt_show_keys, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"password", 'p',
"Password to use when connecting to server. If password is not given it's asked from the tty.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection.", 0, 0, 0, GET_LONG,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#ifdef __WIN__ #ifdef __WIN__
{"pipe", no_argument, 0, 'W'}, {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"socket", required_argument, 0, 'S'}, {"socket", 'S', "Socket file to use for connection.",
(gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#include "sslopt-longopts.h" #include "sslopt-longopts.h"
#ifndef DONT_ALLOW_USER_CHANGE #ifndef DONT_ALLOW_USER_CHANGE
{"user", required_argument, 0, 'u'}, {"user", 'u', "User for login if not current user.", (gptr*) &user,
(gptr*) &user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"verbose", no_argument, 0, 'v'}, {"verbose", 'v',
{"version", no_argument, 0, 'V'}, "More verbose output; You can use this multiple times to get even more verbose output.",
{0, 0, 0, 0} 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}
}; };
...@@ -160,33 +180,6 @@ static void usage(void) ...@@ -160,33 +180,6 @@ 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("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("Shows the structure of a mysql database (databases,tables and columns)\n"); puts("Shows the structure of a mysql database (databases,tables and columns)\n");
printf("Usage: %s [OPTIONS] [database [table [column]]]\n",my_progname); printf("Usage: %s [OPTIONS] [database [table [column]]]\n",my_progname);
printf("\n\
-#, --debug=... output debug log. Often this is 'd:t:o,filename`\n\
-?, --help display this help and exit\n\
-c, --character-sets-dir=...\n\
Directory where character sets are\n\
-C, --compress Use compression in server/client protocol\n\
-h, --host=... connect to host\n\
-i, --status Shows a lot of extra information about each table\n\
-k, --keys show keys for table\n\
-p, --password[=...] password to use when connecting to server\n\
If password is not given it's asked from the tty.\n");
#ifdef __WIN__
puts("-W, --pipe Use named pipes to connect to server");
#endif
printf("\
-P --port=... Port number to use for connection\n\
-S --socket=... Socket file to use for connection\n");
#include "sslopt-usage.h"
#ifndef DONT_ALLOW_USER_CHANGE
printf("\
-u, --user=# user for login if not current user\n");
#endif
printf("\
-v, --verbose more verbose output; You can use this multiple times\n\
to get even more verbose output.\n\
-V, --version output version information and exit\n");
puts("\n\ puts("\n\
If last argument contains a shell or SQL wildcard (*,?,% or _) then only\n\ If last argument contains a shell or SQL wildcard (*,?,% or _) then only\n\
what\'s matched by the wildcard is shown.\n\ what\'s matched by the wildcard is shown.\n\
...@@ -195,44 +188,31 @@ If no table is given then all matching tables in database are shown\n\ ...@@ -195,44 +188,31 @@ If no table is given then all matching tables in database are shown\n\
If no column is given then all matching columns and columntypes in table\n\ If no column is given then all matching columns and columntypes in table\n\
are shown"); are shown");
print_defaults("my",load_default_groups); print_defaults("my",load_default_groups);
my_print_help(my_long_options);
my_print_variables(my_long_options);
} }
static my_bool
static void get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
get_options(int *argc,char ***argv) char *argument)
{ {
int c,option_index; switch(optid) {
my_bool tty_password=0;
while ((c=getopt_long(*argc,*argv,"c:h:p::u:#::P:S:Ck?vVWi",long_options,
&option_index)) != EOF)
{
switch(c) {
case 'C':
opt_compress=1;
break;
case 'c': case 'c':
charsets_dir= optarg; charsets_dir= argument;
break; break;
case 'v': case 'v':
opt_verbose++; opt_verbose++;
break; break;
case 'h': case 'h':
host = optarg; host = argument;
break;
case 'i':
opt_status=1;
break;
case 'k':
opt_show_keys=1;
break; break;
case 'p': case 'p':
if (optarg) if (argument)
{ {
char *start=optarg; char *start=argument;
my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR)); my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
opt_password=my_strdup(optarg,MYF(MY_FAE)); opt_password=my_strdup(argument,MYF(MY_FAE));
while (*optarg) *optarg++= 'x'; /* Destroy argument */ while (*argument) *argument++= 'x'; /* Destroy argument */
if (*start) if (*start)
start[1]=0; /* Cut length of argument */ start[1]=0; /* Cut length of argument */
} }
...@@ -241,14 +221,14 @@ get_options(int *argc,char ***argv) ...@@ -241,14 +221,14 @@ get_options(int *argc,char ***argv)
break; break;
#ifndef DONT_ALLOW_USER_CHANGE #ifndef DONT_ALLOW_USER_CHANGE
case 'u': case 'u':
user=optarg; user=argument;
break; break;
#endif #endif
case 'P': case 'P':
opt_mysql_port= (unsigned int) atoi(optarg); opt_mysql_port= (unsigned int) atoi(argument);
break; break;
case 'S': case 'S':
opt_mysql_unix_port= optarg; opt_mysql_unix_port= argument;
break; break;
case 'W': case 'W':
#ifdef __WIN__ #ifdef __WIN__
...@@ -257,23 +237,33 @@ get_options(int *argc,char ***argv) ...@@ -257,23 +237,33 @@ get_options(int *argc,char ***argv)
break; break;
#include "sslopt-case.h" #include "sslopt-case.h"
case '#': case '#':
DBUG_PUSH(optarg ? optarg : "d:t:o"); DBUG_PUSH(argument ? argument : "d:t:o");
break; break;
case 'V': case 'V':
print_version(); print_version();
exit(0); exit(0);
break; break;
default:
fprintf(stderr,"Illegal option character '%c'\n",opterr);
/* Fall throught */
case '?': case '?':
case 'I': /* Info */ case 'I': /* Info */
usage(); usage();
exit(0); exit(0);
} }
return 0;
}
static void
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 (tty_password) if (tty_password)
opt_password=get_tty_password(NullS); opt_password=get_tty_password(NullS);
return; return;
......
...@@ -14,28 +14,21 @@ ...@@ -14,28 +14,21 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
struct my_optarg C_MODE_START
{
char *arg; /* option argument */
int pos; /* next element in ARGV */
int verbose; /* 0 = inhibit warnings of unrecognized options */
int unrecognized; /* position of the unrecognized option */
};
enum get_opt_var_type { GET_NO_ARG, GET_BOOL, GET_LONG, GET_LL, GET_STR };
enum get_opt_var_type { GET_NO_ARG, GET_LONG, GET_LL, GET_STR };
enum get_opt_arg_type { NO_ARG, OPT_ARG, REQUIRED_ARG }; enum get_opt_arg_type { NO_ARG, OPT_ARG, REQUIRED_ARG };
struct my_option struct my_option
{ {
const char *name; /* Name of the option */ const char *name; /* Name of the option */
int id; /* unique id or short option */
const char *comment; /* option comment, for autom. --help */ const char *comment; /* option comment, for autom. --help */
gptr *value; /* The variable value */ gptr *value; /* The variable value */
gptr *u_max_value; /* The user def. max variable value */ gptr *u_max_value; /* The user def. max variable value */
const char **str_values; /* Pointer to possible values */ const char **str_values; /* Pointer to possible values */
enum get_opt_var_type var_type; enum get_opt_var_type var_type;
enum get_opt_arg_type arg_type; enum get_opt_arg_type arg_type;
int id; /* unique id or short option */
longlong def_value; /* Default value */ longlong def_value; /* Default value */
longlong min_value; /* Min allowed value */ longlong min_value; /* Min allowed value */
longlong max_value; /* Max allowed value */ longlong max_value; /* Max allowed value */
...@@ -44,6 +37,8 @@ struct my_option ...@@ -44,6 +37,8 @@ struct my_option
int app_type; /* To be used by an application */ int app_type; /* To be used by an application */
}; };
extern char *disabled_my_option;
extern int handle_options (int *argc, char ***argv, extern int handle_options (int *argc, char ***argv,
const struct my_option *longopts, const struct my_option *longopts,
my_bool (*get_one_option)(int, my_bool (*get_one_option)(int,
...@@ -51,3 +46,5 @@ extern int handle_options (int *argc, char ***argv, ...@@ -51,3 +46,5 @@ extern int handle_options (int *argc, char ***argv,
char *)); char *));
extern void my_print_help(const struct my_option *options); extern void my_print_help(const struct my_option *options);
extern void my_print_variables(const struct my_option *options); extern void my_print_variables(const struct my_option *options);
C_MODE_END
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
break; break;
case OPT_SSL_KEY: case OPT_SSL_KEY:
opt_use_ssl = 1; /* true */ opt_use_ssl = 1; /* true */
my_free(opt_ssl_key, MYF(MY_ALLOW_ZERO_PTR)); //QQ to be removed??? my_free(opt_ssl_key, MYF(MY_ALLOW_ZERO_PTR));
opt_ssl_key = my_strdup(optarg, MYF(0)); //QQ to be removed??? opt_ssl_key = my_strdup(optarg, MYF(0));
break; break;
case OPT_SSL_CERT: case OPT_SSL_CERT:
opt_use_ssl = 1; /* true */ opt_use_ssl = 1; /* true */
......
...@@ -16,17 +16,26 @@ ...@@ -16,17 +16,26 @@
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
#define OPT_SSL_SSL 200 {"ssl", OPT_SSL_SSL,
#define OPT_SSL_KEY 201 "Use SSL for connection (automatically set with other flags)",
#define OPT_SSL_CERT 202 (gptr*) &opt_use_ssl, (gptr*) &opt_use_ssl, 0, GET_BOOL, NO_ARG, 0, 0, 0,
#define OPT_SSL_CA 203 0, 0, 0},
#define OPT_SSL_CAPATH 204 {"ssl-key", OPT_SSL_KEY, "X509 key in PEM format (implies --ssl)",
#define OPT_SSL_CIPHER 205 (gptr*) &opt_ssl_key, (gptr*) &opt_ssl_key, 0, GET_STR, REQUIRED_ARG,
{"ssl", no_argument, 0, OPT_SSL_SSL}, 0, 0, 0, 0, 0, 0},
{"ssl-key", required_argument, 0, OPT_SSL_KEY}, {"ssl-cert", OPT_SSL_CERT, "X509 cert in PEM format (implies --ssl)",
{"ssl-cert", required_argument, 0, OPT_SSL_CERT}, (gptr*) &opt_ssl_cert, (gptr*) &opt_ssl_cert, 0, GET_STR, REQUIRED_ARG,
{"ssl-ca", required_argument, 0, OPT_SSL_CA}, 0, 0, 0, 0, 0, 0},
{"ssl-capath", required_argument, 0, OPT_SSL_CAPATH}, {"ssl-ca", OPT_SSL_CA,
{"ssl-cipher", required_argument, 0, OPT_SSL_CIPHER}, "CA file in PEM format (check OpenSSL docs, implies --ssl)",
(gptr*) &opt_ssl_ca, (gptr*) &opt_ssl_ca, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
{"ssl-capath", OPT_SSL_CAPATH,
"CA directory (check OpenSSL docs, implies --ssl)",
(gptr*) &opt_ssl_capath, (gptr*) &opt_ssl_capath, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
{"ssl-cipher", OPT_SSL_CAPATH, "SSL cipher to use (implies --ssl)",
(gptr*) &opt_ssl_cipher, (gptr*) &opt_ssl_cipher, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
This diff is collapsed.
...@@ -35,6 +35,7 @@ static void init_variables(const struct my_option *options); ...@@ -35,6 +35,7 @@ static void init_variables(const struct my_option *options);
static const char *special_opt_prefix[]= static const char *special_opt_prefix[]=
{"skip", "disable", "enable", "maximum", 0}; {"skip", "disable", "enable", "maximum", 0};
char *disabled_my_option= (char*) "0";
/* Return error values from handle_options */ /* Return error values from handle_options */
...@@ -66,7 +67,7 @@ int handle_options(int *argc, char ***argv, ...@@ -66,7 +67,7 @@ int handle_options(int *argc, char ***argv,
char *)) char *))
{ {
uint opt_found, argvpos= 0, length, spec_len, i; uint opt_found, argvpos= 0, length, spec_len, i;
int err; int err= 0;
my_bool end_of_options= 0, must_be_var, set_maximum_value, special_used; my_bool end_of_options= 0, must_be_var, set_maximum_value, special_used;
char *progname= *(*argv), **pos, *optend, *prev_found; char *progname= *(*argv), **pos, *optend, *prev_found;
const struct my_option *optp; const struct my_option *optp;
...@@ -177,7 +178,7 @@ int handle_options(int *argc, char ***argv, ...@@ -177,7 +178,7 @@ int handle_options(int *argc, char ***argv,
We were called with a special prefix, we can reuse opt_found We were called with a special prefix, we can reuse opt_found
*/ */
special_used= 1; special_used= 1;
cur_arg += (spec_len + 1); cur_arg+= (spec_len + 1);
if ((opt_found= findopt(cur_arg, length - (spec_len + 1), if ((opt_found= findopt(cur_arg, length - (spec_len + 1),
&optp, &prev_found))) &optp, &prev_found)))
{ {
...@@ -190,7 +191,7 @@ int handle_options(int *argc, char ***argv, ...@@ -190,7 +191,7 @@ int handle_options(int *argc, char ***argv,
return ERR_AMBIGUOUS_OPTION; return ERR_AMBIGUOUS_OPTION;
} }
if (i < DISABLE_OPTION_COUNT) if (i < DISABLE_OPTION_COUNT)
optend= (char*) "0"; optend= disabled_my_option;
else if (!compare_strings(special_opt_prefix[i],"enable",6)) else if (!compare_strings(special_opt_prefix[i],"enable",6))
optend= (char*) "1"; optend= (char*) "1";
else if (!compare_strings(special_opt_prefix[i],"maximum",7)) else if (!compare_strings(special_opt_prefix[i],"maximum",7))
...@@ -236,16 +237,45 @@ int handle_options(int *argc, char ***argv, ...@@ -236,16 +237,45 @@ int handle_options(int *argc, char ***argv,
} }
if (must_be_var && !optp->value) if (must_be_var && !optp->value)
{ {
fprintf(stderr, "%s: the argument '%s' is not an variable\n", fprintf(stderr, "%s: argument '%s' is not a variable\n",
progname, *pos); progname, *pos);
return ERR_MUST_BE_VARIABLE; return ERR_MUST_BE_VARIABLE;
} }
if (optp->arg_type == NO_ARG && optend && !special_used) if (optp->arg_type == NO_ARG)
{
if (optend && !special_used)
{ {
fprintf(stderr, "%s: option '--%s' cannot take an argument\n", fprintf(stderr, "%s: option '--%s' cannot take an argument\n",
progname, optp->name); progname, optp->name);
return ERR_NO_ARGUMENT_ALLOWED; return ERR_NO_ARGUMENT_ALLOWED;
} }
if (optp->var_type == GET_BOOL)
{
/*
Set bool to 1 if no argument or if the user has used
--enable-'option-name'.
*optend was set to '0' if one used --disable-option
*/
*((my_bool*) optp->value)= (my_bool) (!optend || *optend == '1');
(*argc)--;
continue;
}
argument= optend;
}
else if (optp->arg_type == OPT_ARG && optp->var_type == GET_BOOL)
{
if (optend == disabled_my_option)
*((my_bool*) optp->value)= (my_bool) 0;
else
{
if (!optend) /* No argument -> enable option */
*((my_bool*) optp->value)= (my_bool) 1;
else /* If argument differs from 0, enable option, else disable */
*((my_bool*) optp->value)= (my_bool) atoi(optend) != 0;
}
(*argc)--;
continue;
}
else if (optp->arg_type == REQUIRED_ARG && !optend) else if (optp->arg_type == REQUIRED_ARG && !optend)
{ {
/* Check if there are more arguments after this one */ /* Check if there are more arguments after this one */
...@@ -312,6 +342,7 @@ int handle_options(int *argc, char ***argv, ...@@ -312,6 +342,7 @@ int handle_options(int *argc, char ***argv,
{ {
gptr *result_pos= (set_maximum_value) ? gptr *result_pos= (set_maximum_value) ?
optp->u_max_value : optp->value; optp->u_max_value : optp->value;
if (!result_pos) if (!result_pos)
{ {
fprintf(stderr, fprintf(stderr,
...@@ -327,7 +358,6 @@ int handle_options(int *argc, char ***argv, ...@@ -327,7 +358,6 @@ int handle_options(int *argc, char ***argv,
if (err) if (err)
return ERR_UNKNOWN_SUFFIX; return ERR_UNKNOWN_SUFFIX;
} }
else
get_one_option(optp->id, optp, argument); get_one_option(optp->id, optp, argument);
(*argc)--; /* option handled (shortorlong), decrease argument count */ (*argc)--; /* option handled (shortorlong), decrease argument count */
...@@ -489,17 +519,19 @@ void my_print_help(const struct my_option *options) ...@@ -489,17 +519,19 @@ void my_print_help(const struct my_option *options)
col+= 2 + strlen(optp->name); col+= 2 + strlen(optp->name);
if (optp->var_type == GET_STR) if (optp->var_type == GET_STR)
{ {
printf("=name "); printf("%s=name%s ", optp->arg_type == OPT_ARG ? "[" : "",
optp->arg_type == OPT_ARG ? "]" : "");
col+= 6; col+= 6;
} }
else if (optp->var_type == GET_NO_ARG) else if (optp->var_type == GET_NO_ARG || optp->var_type == GET_BOOL)
{ {
putchar(' '); putchar(' ');
col++; col++;
} }
else else
{ {
printf("=# "); printf("%s=#%s ", optp->arg_type == OPT_ARG ? "[" : "",
optp->arg_type == OPT_ARG ? "]" : "");
col+= 3; col+= 3;
} }
if (col > name_space) if (col > name_space)
...@@ -546,7 +578,7 @@ void my_print_variables(const struct my_option *options) ...@@ -546,7 +578,7 @@ void my_print_variables(const struct my_option *options)
printf("--------------------------------- -------------\n"); printf("--------------------------------- -------------\n");
for (optp= options; optp->id; optp++) for (optp= options; optp->id; optp++)
{ {
if (optp->value) if (optp->value && optp->var_type != GET_BOOL)
{ {
printf("%s", optp->name); printf("%s", optp->name);
length= strlen(optp->name); length= strlen(optp->name);
...@@ -554,10 +586,10 @@ void my_print_variables(const struct my_option *options) ...@@ -554,10 +586,10 @@ void my_print_variables(const struct my_option *options)
putchar(' '); putchar(' ');
if (optp->var_type == GET_STR) if (optp->var_type == GET_STR)
{ {
if (!optp->def_value && !*((char**) optp->value)) if (*((char**) optp->value))
printf("(No default value)\n");
else
printf("%s\n", *((char**) optp->value)); printf("%s\n", *((char**) optp->value));
else
printf("(No default value)\n");
} }
else if (optp->var_type == GET_LONG) else if (optp->var_type == GET_LONG)
{ {
......
...@@ -2832,7 +2832,9 @@ static struct option long_options[] = { ...@@ -2832,7 +2832,9 @@ static struct option long_options[] = {
{"socket", required_argument, 0, (int) OPT_SOCKET}, {"socket", required_argument, 0, (int) OPT_SOCKET},
{"sql-bin-update-same", no_argument, 0, (int) OPT_SQL_BIN_UPDATE_SAME}, {"sql-bin-update-same", no_argument, 0, (int) OPT_SQL_BIN_UPDATE_SAME},
{"sql-mode", required_argument, 0, (int) OPT_SQL_MODE}, {"sql-mode", required_argument, 0, (int) OPT_SQL_MODE},
#ifdef TO_BE_DONE
#include "sslopt-longopts.h" #include "sslopt-longopts.h"
#endif
#ifdef __WIN__ #ifdef __WIN__
{"standalone", no_argument, 0, (int) OPT_STANDALONE}, {"standalone", no_argument, 0, (int) OPT_STANDALONE},
#endif #endif
...@@ -3992,8 +3994,10 @@ static void get_options(int argc,char **argv) ...@@ -3992,8 +3994,10 @@ static void get_options(int argc,char **argv)
strmov(mysql_charsets_dir, optarg); strmov(mysql_charsets_dir, optarg);
charsets_dir = mysql_charsets_dir; charsets_dir = mysql_charsets_dir;
break; break;
#ifdef TO_BE_DONE
#include "sslopt-case.h" #include "sslopt-case.h"
case OPT_DES_KEY_FILE: case OPT_DES_KEY_FILE:
#endif
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
des_key_file=optarg; des_key_file=optarg;
#endif #endif
......
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