summaryrefslogtreecommitdiff
path: root/client/mysqlmanager-pwgen.c
diff options
context:
space:
mode:
authorunknown <jani@hynda.(none)>2002-05-22 00:05:05 +0300
committerunknown <jani@hynda.(none)>2002-05-22 00:05:05 +0300
commitbb07d5c0432ceb64b27ff682faa9863051695615 (patch)
tree9eb125f10c2d91711ede0b6149a87d36b5b93b84 /client/mysqlmanager-pwgen.c
parent3181a6af1b782ccbd23cd12b8e39e8e282b482e7 (diff)
downloadmariadb-git-bb07d5c0432ceb64b27ff682faa9863051695615.tar.gz
Changed mysqlbinlog, mysqlmanager-pwgen, mysqlmanagerc, mysqltest,
thread_test and isamchk to use my_getopt. Fixed a bug in my_getopt. client/mysqlbinlog.cc: Changed mysqlbinlog.cc to use my_getopt. client/mysqlmanager-pwgen.c: Changed mysqlmanager-pwgen to use my_getopt. client/mysqlmanagerc.c: Changed mysqlmanagerc to use my_getopt. client/mysqltest.c: Changed mysqltest to use my_getopt. client/thread_test.c: Changed thread_test to use my_getopt. isam/isamchk.c: Changed isamchk to use my_getopt. mysys/my_getopt.c: Fixed a bug in printing options when option didn't have a comment. Added startup initializing and printing for 'GET_BOOL' type variables. sql/mysql_priv.h: Changed type. sql/mysqld.cc: Fixed a bug in --local-infile option. BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
Diffstat (limited to 'client/mysqlmanager-pwgen.c')
-rw-r--r--client/mysqlmanager-pwgen.c74
1 files changed, 41 insertions, 33 deletions
diff --git a/client/mysqlmanager-pwgen.c b/client/mysqlmanager-pwgen.c
index 97eb31eb9c8..db8436c876c 100644
--- a/client/mysqlmanager-pwgen.c
+++ b/client/mysqlmanager-pwgen.c
@@ -14,7 +14,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#define MANAGER_PWGEN_VERSION "1.0"
+#define MANAGER_PWGEN_VERSION "1.1"
#include <my_global.h>
#include <m_ctype.h>
@@ -22,18 +22,23 @@
#include <m_string.h>
#include <mysql_version.h>
#include <errno.h>
-#include <getopt.h>
+#include <my_getopt.h>
#include <md5.h>
const char* outfile=0,*user="root";
-struct option long_options[] =
+static struct my_option my_long_options[] =
{
- {"output-file",required_argument,0,'o'},
- {"user",required_argument,0,'u'},
- {"help",no_argument,0,'?'},
- {"version",no_argument,0,'V'},
- {0,0,0,0}
+ {"output-file", 'o', "Write the output to the file with the given name",
+ (gptr*) &outfile, (gptr*) &outfile, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0,
+ 0, 0},
+ {"user", 'u', "Put given user in the password file", (gptr*) &user,
+ (gptr*) &user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"help", '?', "Display this message and exit", 0, 0, 0, GET_NO_ARG, NO_ARG,
+ 0, 0, 0, 0, 0, 0},
+ {"version", 'V', "Display version info", 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 die(const char* fmt, ...)
@@ -66,36 +71,39 @@ void usage()
printf("This software comes with ABSOLUTELY NO WARRANTY\n\n");
printf("Generates a password file to be used by mysqltest.\n\n");
printf("Usage: %s [OPTIONS]\n", my_progname);
- printf("-?,--help Display this message and exit\n\
--V,--version Display version info\n\
--u,--user= Put given user in the password file\n\
--o,--output-file= Write the output to the file with the given name\n");
+ my_print_help(my_long_options);
+ putchar('\n');
+ 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 '?':
+ usage();
+ exit(0);
+ case 'V':
+ print_version();
+ exit(0);
+ default:
+ usage();
+ exit(1);
+ }
+ return 0;
+}
+
+
int parse_args(int argc, char** argv)
{
- int c,option_index=0;
- while ((c=getopt_long(argc,argv,"?Vu:o:",long_options,&option_index))
- != EOF)
+ int ho_error;
+
+ if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
{
- switch (c)
- {
- case 'o':
- outfile=optarg;
- break;
- case 'u':
- user=optarg;
- break;
- case '?':
- usage();
- exit(0);
- case 'V':
- print_version();
- exit(0);
- default:
- usage();
- exit(1);
- }
+ printf("%s: handle_options() failed with error %d\n", my_progname,
+ ho_error);
+ exit(1);
}
return 0;
}