20
20
** Written by Monty
24
#include "drizzled/internal/my_sys.h"
25
#include "drizzled/internal/m_string.h"
26
#include "drizzled/option.h"
23
#include <drizzled/global.h>
24
#include <mysys/my_sys.h>
25
#include <mystrings/m_string.h>
26
#include <mysys/my_getopt.h>
30
using namespace drizzled;
31
bool get_one_option(int optid, const struct my_option *, char *);
32
33
const char *config_file="drizzle"; /* Default config file */
33
34
uint32_t verbose= 0, opt_defaults_file_used= 0;
35
static struct option my_long_options[] =
36
static struct my_option my_long_options[] =
38
39
NB: --config-file is troublesome, because get_defaults_options() doesn't
56
57
{"defaults-extra-file", 'e',
57
58
"Read this file after the global config file and before the config file in the users home directory; should be the first option",
58
(char**) &internal::my_defaults_extra_file, (char**) &internal::my_defaults_extra_file, 0,
59
(char**) &my_defaults_extra_file, (char**) &my_defaults_extra_file, 0,
59
60
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
60
61
{"defaults-group-suffix", 'g',
61
62
"In addition to the given groups, read also groups with this suffix",
62
(char**) &internal::my_defaults_group_suffix, (char**) &internal::my_defaults_group_suffix,
63
(char**) &my_defaults_group_suffix, (char**) &my_defaults_group_suffix,
63
64
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
64
65
{"extra-file", 'e',
65
66
"Deprecated. Synonym for --defaults-extra-file.",
66
(char**) &internal::my_defaults_extra_file,
67
(char**) &internal::my_defaults_extra_file, 0, GET_STR,
67
(char**) &my_defaults_extra_file,
68
(char**) &my_defaults_extra_file, 0, GET_STR,
68
69
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
69
70
{"no-defaults", 'n', "Return an empty string (useful for scripts).",
70
71
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
80
81
static void usage(bool version)
82
printf("%s Ver 1.6 for %s-%s at %s\n",internal::my_progname,HOST_VENDOR,HOST_OS,
83
printf("%s Ver 1.6 for %s-%s at %s\n",my_progname,HOST_VENDOR,HOST_OS,
86
87
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");
87
88
puts("Prints all arguments that is give to some program using the default files");
88
printf("Usage: %s [OPTIONS] groups\n", internal::my_progname);
89
printf("Usage: %s [OPTIONS] groups\n", my_progname);
89
90
my_print_help(my_long_options);
90
internal::my_print_default_files(config_file);
91
my_print_default_files(config_file);
91
92
my_print_variables(my_long_options);
92
printf("\nExample usage:\n%s --defaults-file=example.cnf client mysql\n", internal::my_progname);
93
printf("\nExample usage:\n%s --defaults-file=example.cnf client mysql\n", my_progname);
95
static int get_one_option(int optid, const struct option *, char *)
96
bool get_one_option(int optid, const struct my_option *, char *)
140
141
MY_INIT(argv[0]);
143
args_used= internal::get_defaults_options(argc, argv, &defaults, &extra_defaults,
144
args_used= get_defaults_options(argc, argv, &defaults, &extra_defaults,
146
147
/* Copy defaults-xxx arguments & program name */
147
148
count=args_used+1;
157
158
memcpy(load_default_groups, argv, (argc + 1) * sizeof(*argv));
159
if ((error= internal::load_defaults(config_file, (const char **) load_default_groups,
160
if ((error= load_defaults(config_file, (const char **) load_default_groups,
160
161
&count, &arguments)))
162
163
if (verbose && opt_defaults_file_used)