~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to extra/my_print_defaults.c

code clean move Item_func_abs, Item_func_int_exp, Item_func_ln, Item_func_log to functions directory

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"
27
 
 
28
 
#include <stdio.h>
29
 
 
30
 
using namespace drizzled;
31
 
 
32
 
const char *config_file="drizzle";              /* Default config file */
33
 
uint32_t verbose= 0, opt_defaults_file_used= 0;
34
 
 
35
 
static struct option my_long_options[] =
 
23
#include <drizzled/global.h>
 
24
#include <mysys/my_sys.h>
 
25
#include <mystrings/m_string.h>
 
26
#include <mysys/my_getopt.h>
 
27
 
 
28
 
 
29
const char *config_file="my";                   /* Default config file */
 
30
uint verbose= 0, opt_defaults_file_used= 0;
 
31
 
 
32
static struct my_option my_long_options[] =
36
33
{
37
34
  /*
38
35
    NB: --config-file is troublesome, because get_defaults_options() doesn't
55
52
   0, 0, 0, 0, 0, 0},
56
53
  {"defaults-extra-file", 'e',
57
54
   "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,
 
55
   (char**) &my_defaults_extra_file, (char**) &my_defaults_extra_file, 0,
59
56
   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
60
57
  {"defaults-group-suffix", 'g',
61
58
   "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,
 
59
   (char**) &my_defaults_group_suffix, (char**) &my_defaults_group_suffix,
63
60
   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
64
61
  {"extra-file", 'e',
65
62
   "Deprecated. Synonym for --defaults-extra-file.",
66
 
   (char**) &internal::my_defaults_extra_file,
67
 
   (char**) &internal::my_defaults_extra_file, 0, GET_STR,
 
63
   (char**) &my_defaults_extra_file,
 
64
   (char**) &my_defaults_extra_file, 0, GET_STR,
68
65
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
69
66
  {"no-defaults", 'n', "Return an empty string (useful for scripts).",
70
67
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
79
76
 
80
77
static void usage(bool version)
81
78
{
82
 
  printf("%s  Ver 1.6 for %s-%s at %s\n",internal::my_progname,HOST_VENDOR,HOST_OS,
83
 
         HOST_CPU);
 
79
  printf("%s  Ver 1.6 for %s at %s\n",my_progname,SYSTEM_TYPE,
 
80
         MACHINE_TYPE);
84
81
  if (version)
85
82
    return;
86
83
  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
84
  puts("Prints all arguments that is give to some program using the default files");
88
 
  printf("Usage: %s [OPTIONS] groups\n", internal::my_progname);
 
85
  printf("Usage: %s [OPTIONS] groups\n", my_progname);
89
86
  my_print_help(my_long_options);
90
 
  internal::my_print_default_files(config_file);
 
87
  my_print_default_files(config_file);
91
88
  my_print_variables(my_long_options);
92
 
  printf("\nExample usage:\n%s --defaults-file=example.cnf client mysql\n", internal::my_progname);
 
89
  printf("\nExample usage:\n%s --defaults-file=example.cnf client mysql\n", my_progname);
93
90
}
94
91
 
95
 
static int get_one_option(int optid, const struct option *, char *)
 
92
static bool
 
93
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
 
94
               char *argument __attribute__((unused)))
96
95
{
97
96
  switch (optid) {
98
97
    case 'c':
140
139
  MY_INIT(argv[0]);
141
140
 
142
141
  org_argv= argv;
143
 
  args_used= internal::get_defaults_options(argc, argv, &defaults, &extra_defaults,
144
 
                                            &group_suffix);
 
142
  args_used= get_defaults_options(argc, argv, &defaults, &extra_defaults,
 
143
                                  &group_suffix);
145
144
 
146
145
  /* Copy defaults-xxx arguments & program name */
147
146
  count=args_used+1;
150
149
  arguments[count]= 0;
151
150
 
152
151
  /* Check out the args */
153
 
  if (!(load_default_groups=(char**) malloc((argc+1)*sizeof(char*))))
 
152
  if (!(load_default_groups=(char**) my_malloc((argc+1)*sizeof(char*),
 
153
                                               MYF(MY_WME))))
154
154
    exit(1);
155
155
  if (get_options(&argc,&argv))
156
156
    exit(1);
157
157
  memcpy(load_default_groups, argv, (argc + 1) * sizeof(*argv));
158
158
 
159
 
  if ((error= internal::load_defaults(config_file, (const char **) load_default_groups,
 
159
  if ((error= 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
 
  internal::free_defaults(arguments);
 
178
  free_defaults(arguments);
179
179
 
180
 
  return error;
 
180
  exit(error);
181
181
}