From 2276e8aeb845f5186f48925ae4e6c1e80ff529a8 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 22 May 2002 23:54:24 +0300 Subject: moved my_getopt.h under client_priv.h Changed my_print_defaults, mysql_install, perror, resolve_stack_dump, resolveip and pack_isam to use my_getopt. client/client_priv.h: getopt -> my_getopt client/mysql.cc: moved my_getopt.h under client_priv.h client/mysqladmin.c: moved my_getopt.h under client_priv.h client/mysqlbinlog.cc: moved my_getopt.h under client_priv.h client/mysqlcheck.c: moved my_getopt.h under client_priv.h client/mysqldump.c: moved my_getopt.h under client_priv.h client/mysqlimport.c: moved my_getopt.h under client_priv.h client/mysqlshow.c: moved my_getopt.h under client_priv.h extra/my_print_defaults.c: Changed from getopt to use my_getopt extra/mysql_install.c: Changed from getopt to use my_getopt extra/perror.c: Changed from getopt to use my_getopt extra/resolve_stack_dump.c: Changed from getopt to use my_getopt extra/resolveip.c: Changed from getopt to use my_getopt fs/mysqlcorbafs.c: Left reminder about my_getopt when this program is ready. Currently it's not being compiled. isam/pack_isam.c: Changed from getopt to use my_getopt --- extra/mysql_install.c | 61 ++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 27 deletions(-) (limited to 'extra/mysql_install.c') diff --git a/extra/mysql_install.c b/extra/mysql_install.c index d02c054d4eb..0153ad3bf70 100644 --- a/extra/mysql_install.c +++ b/extra/mysql_install.c @@ -18,7 +18,7 @@ /* Install or upgrade MySQL server. By Sasha Pachev */ -#define INSTALL_VERSION "1.0" +#define INSTALL_VERSION "1.1" #define DONT_USE_RAID #include @@ -27,17 +27,19 @@ #include #include #include -#include +#include #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) -- cgit v1.2.1