~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to extra/my_print_defaults.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-09-13 00:53:34 UTC
  • mto: (1126.9.2 captain-20090915-01)
  • mto: This revision was merged to the branch mainline in revision 1133.
  • Revision ID: osullivan.padraig@gmail.com-20090913005334-6wio2sbjugskfbm3
Added calls to the connection start/end dtrace probes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
**  Written by Monty
21
21
*/
22
22
 
23
 
#include "config.h"
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>
27
27
 
28
28
#include <stdio.h>
29
29
 
30
 
using namespace drizzled;
 
30
extern "C"
 
31
bool get_one_option(int optid, const struct my_option *, char *);
31
32
 
32
33
const char *config_file="drizzle";              /* Default config file */
33
34
uint32_t verbose= 0, opt_defaults_file_used= 0;
34
35
 
35
 
static struct option my_long_options[] =
 
36
static struct my_option my_long_options[] =
36
37
{
37
38
  /*
38
39
    NB: --config-file is troublesome, because get_defaults_options() doesn't
55
56
   0, 0, 0, 0, 0, 0},
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},
79
80
 
80
81
static void usage(bool version)
81
82
{
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,
83
84
         HOST_CPU);
84
85
  if (version)
85
86
    return;
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);
93
94
}
94
95
 
95
 
static int get_one_option(int optid, const struct option *, char *)
 
96
bool get_one_option(int optid, const struct my_option *, char *)
96
97
{
97
98
  switch (optid) {
98
99
    case 'c':
140
141
  MY_INIT(argv[0]);
141
142
 
142
143
  org_argv= argv;
143
 
  args_used= internal::get_defaults_options(argc, argv, &defaults, &extra_defaults,
144
 
                                            &group_suffix);
 
144
  args_used= get_defaults_options(argc, argv, &defaults, &extra_defaults,
 
145
                                  &group_suffix);
145
146
 
146
147
  /* Copy defaults-xxx arguments & program name */
147
148
  count=args_used+1;
156
157
    exit(1);
157
158
  memcpy(load_default_groups, argv, (argc + 1) * sizeof(*argv));
158
159
 
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)))
161
162
  {
162
163
    if (verbose && opt_defaults_file_used)
175
176
  for (argument= arguments+1 ; *argument ; argument++)
176
177
    puts(*argument);
177
178
  free((char*) load_default_groups);
178
 
  internal::free_defaults(arguments);
 
179
  free_defaults(arguments);
179
180
 
180
181
  return error;
181
182
}