Merge bk-internal.mysql.com:/home/bk/mysql-4.0

into build.mysql.com:/users/rburnett/mysql-4.0


BitKeeper/etc/logging_ok:
  auto-union
client/mysql.cc:
  Auto merged
sql/log.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
This commit is contained in:
unknown 2004-08-25 06:39:19 +02:00
commit b15ee67874
32 changed files with 347 additions and 81 deletions

View file

@ -17,10 +17,10 @@
#include <my_global.h>
#include <m_string.h>
#include <stdlib.h>
#include <my_getopt.h>
#include <assert.h>
#include <my_sys.h>
#include <mysys_err.h>
#include <my_getopt.h>
static int findopt(char *optpat, uint length,
const struct my_option **opt_res,
@ -56,6 +56,13 @@ char *disabled_my_option= (char*) "0";
my_bool my_getopt_print_errors= 1;
void default_reporter( enum loglevel level, const char *format, ... )
{
va_list args;
va_start( args, format );
vfprintf( stderr, format, args );
va_end( args );
}
/*
function: handle_options
@ -68,10 +75,8 @@ my_bool my_getopt_print_errors= 1;
*/
int handle_options(int *argc, char ***argv,
const struct my_option *longopts,
my_bool (*get_one_option)(int,
const struct my_option *,
char *))
const struct my_option *longopts, my_get_one_option get_one_option,
my_error_reporter reporter )
{
uint opt_found, argvpos= 0, length, i;
my_bool end_of_options= 0, must_be_var, set_maximum_value, special_used,
@ -85,6 +90,8 @@ int handle_options(int *argc, char ***argv,
(*argv)++; /* --- || ---- */
init_variables(longopts);
if (! reporter) reporter = &default_reporter;
for (pos= *argv, pos_end=pos+ *argc; pos != pos_end ; pos++)
{
char *cur_arg= *pos;
@ -109,8 +116,7 @@ int handle_options(int *argc, char ***argv,
if (!*++pos)
{
if (my_getopt_print_errors)
fprintf(stderr, "%s: Option '-O' requires an argument\n",
progname);
reporter( ERROR_LEVEL, "%s: Option '-O' requires an argument\n", progname );
return EXIT_ARGUMENT_REQUIRED;
}
cur_arg= *pos;
@ -126,9 +132,7 @@ int handle_options(int *argc, char ***argv,
if (!*cur_arg)
{
if (my_getopt_print_errors)
fprintf(stderr,
"%s: Option '--set-variable' requires an argument\n",
progname);
reporter( ERROR_LEVEL, "%s: Option '--set-variable' requires an argument\n", progname );
return EXIT_ARGUMENT_REQUIRED;
}
}
@ -140,9 +144,7 @@ int handle_options(int *argc, char ***argv,
if (!*++pos)
{
if (my_getopt_print_errors)
fprintf(stderr,
"%s: Option '--set-variable' requires an argument\n",
progname);
reporter( ERROR_LEVEL, "%s: Option '--set-variable' requires an argument\n", progname );
return EXIT_ARGUMENT_REQUIRED;
}
cur_arg= *pos;
@ -201,7 +203,7 @@ int handle_options(int *argc, char ***argv,
if (opt_found > 1)
{
if (my_getopt_print_errors)
fprintf(stderr,
reporter( ERROR_LEVEL,
"%s: ambiguous option '--%s-%s' (--%s-%s)\n",
progname, special_opt_prefix[i], cur_arg,
special_opt_prefix[i], prev_found);
@ -236,18 +238,16 @@ int handle_options(int *argc, char ***argv,
if (must_be_var)
{
if (my_getopt_print_errors)
fprintf(stderr,
"%s: %s: unknown variable '%s'\n", progname,
option_is_loose ? "WARNING" : "ERROR", cur_arg);
reporter( option_is_loose ? WARNING_LEVEL : ERROR_LEVEL,
"%s: unknown variable '%s'\n", progname, cur_arg );
if (!option_is_loose)
return EXIT_UNKNOWN_VARIABLE;
}
else
{
if (my_getopt_print_errors)
fprintf(stderr,
"%s: %s: unknown option '--%s'\n", progname,
option_is_loose ? "WARNING" : "ERROR", cur_arg);
reporter( option_is_loose ? WARNING_LEVEL : ERROR_LEVEL,
"%s: unknown option '--%s'\n", progname, cur_arg );
if (!option_is_loose)
return EXIT_UNKNOWN_OPTION;
}
@ -263,14 +263,14 @@ int handle_options(int *argc, char ***argv,
if (must_be_var)
{
if (my_getopt_print_errors)
fprintf(stderr, "%s: variable prefix '%s' is not unique\n",
reporter( ERROR_LEVEL, "%s: variable prefix '%s' is not unique\n",
progname, cur_arg);
return EXIT_VAR_PREFIX_NOT_UNIQUE;
}
else
{
if (my_getopt_print_errors)
fprintf(stderr, "%s: ambiguous option '--%s' (%s, %s)\n",
reporter( ERROR_LEVEL, "%s: ambiguous option '--%s' (%s, %s)\n",
progname, cur_arg, prev_found, optp->name);
return EXIT_AMBIGUOUS_OPTION;
}
@ -278,7 +278,7 @@ int handle_options(int *argc, char ***argv,
if (must_be_var && optp->var_type == GET_NO_ARG)
{
if (my_getopt_print_errors)
fprintf(stderr, "%s: option '%s' cannot take an argument\n",
reporter( ERROR_LEVEL, "%s: option '%s' cannot take an argument\n",
progname, optp->name);
return EXIT_NO_ARGUMENT_ALLOWED;
}
@ -287,7 +287,7 @@ int handle_options(int *argc, char ***argv,
if (optend && optp->var_type != GET_BOOL)
{
if (my_getopt_print_errors)
fprintf(stderr, "%s: option '--%s' cannot take an argument\n",
reporter( ERROR_LEVEL, "%s: option '--%s' cannot take an argument\n",
progname, optp->name);
return EXIT_NO_ARGUMENT_ALLOWED;
}
@ -325,7 +325,7 @@ int handle_options(int *argc, char ***argv,
if (!*++pos)
{
if (my_getopt_print_errors)
fprintf(stderr, "%s: option '--%s' requires an argument\n",
reporter( ERROR_LEVEL, "%s: option '--%s' requires an argument\n",
progname, optp->name);
return EXIT_ARGUMENT_REQUIRED;
}
@ -375,7 +375,7 @@ int handle_options(int *argc, char ***argv,
if (!pos[1])
{
if (my_getopt_print_errors)
fprintf(stderr,
reporter( ERROR_LEVEL,
"%s: option '-%c' requires an argument\n",
progname, optp->id);
return EXIT_ARGUMENT_REQUIRED;
@ -387,7 +387,7 @@ int handle_options(int *argc, char ***argv,
}
if ((error= setval(optp, argument, set_maximum_value)))
{
fprintf(stderr,
reporter( ERROR_LEVEL,
"%s: Error while setting value '%s' to '%s'\n",
progname, argument, optp->name);
return error;
@ -399,7 +399,7 @@ int handle_options(int *argc, char ***argv,
if (!opt_found)
{
if (my_getopt_print_errors)
fprintf(stderr,
reporter( ERROR_LEVEL,
"%s: unknown option '-%c'\n", progname, *optend);
return EXIT_UNKNOWN_OPTION;
}
@ -409,7 +409,7 @@ int handle_options(int *argc, char ***argv,
}
if ((error= setval(optp, argument, set_maximum_value)))
{
fprintf(stderr,
reporter( ERROR_LEVEL,
"%s: Error while setting value '%s' to '%s'\n",
progname, argument, optp->name);
return error;