~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to extra/my_print_defaults.cc

  • Committer: Brian Aker
  • Date: 2010-04-05 23:46:43 UTC
  • Revision ID: brian@gaz-20100405234643-0he3xnj902rc70r8
Fixing tests to work with PBXT.

Show diffs side-by-side

added added

removed removed

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