summaryrefslogtreecommitdiff
path: root/extra/mysql_install.c
diff options
context:
space:
mode:
Diffstat (limited to 'extra/mysql_install.c')
-rw-r--r--extra/mysql_install.c60
1 files changed, 32 insertions, 28 deletions
diff --git a/extra/mysql_install.c b/extra/mysql_install.c
index 3f716dccef5..3f3da8cfb51 100644
--- a/extra/mysql_install.c
+++ b/extra/mysql_install.c
@@ -18,7 +18,7 @@
/* Install or upgrade MySQL server. By Sasha Pachev <sasha@mysql.com>
*/
-#define INSTALL_VERSION "1.0"
+#define INSTALL_VERSION "1.2"
#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
@@ -135,7 +137,7 @@ static int init_question_widget(QUESTION_WIDGET* w, const char* question,
}
w->question = question;
w->default_ind = default_ind;
- if (init_dynamic_array(&w->answers,sizeof(char*),
+ if (my_init_dynamic_array(&w->answers,sizeof(char*),
ANSWERS_CHUNCK,ANSWERS_CHUNCK))
die("Out of memory");
return 0;
@@ -195,26 +197,30 @@ 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;
+
+ if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
+ exit(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);
- }
- }
return 0;
}
@@ -231,10 +237,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)