~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzleadmin.cc

  • Committer: Brian Aker
  • Date: 2008-08-08 15:49:29 UTC
  • mfrom: (266.1.2 codestyle)
  • Revision ID: brian@tangent.org-20080808154929-h4fdk8jiebn2s03q
Merge from PatrickG

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include <mysys/my_pthread.h>                           /* because of signal()  */
21
21
#include <sys/stat.h>
22
22
 
 
23
/* Added this for string translation. */
 
24
#include <libdrizzle/gettext.h>
 
25
 
23
26
#define ADMIN_VERSION "8.42"
24
27
#define SHUTDOWN_DEF_TIMEOUT 3600               /* Wait for shutdown */
25
28
 
63
66
 
64
67
static struct my_option my_long_options[] =
65
68
{
66
 
  {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG,
 
69
  {"help", '?', N_("Display this help and exit."), 0, 0, 0, GET_NO_ARG,
67
70
   NO_ARG, 0, 0, 0, 0, 0, 0},
68
 
  {"host", 'h', "Connect to host.", (char**) &host, (char**) &host, 0, GET_STR,
 
71
  {"host", 'h', N_("Connect to host."), (char**) &host, (char**) &host, 0, GET_STR,
69
72
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
70
73
  {"password", 'p',
71
 
   "Password to use when connecting to server. If password is not given it's asked from the tty.",
 
74
   N_("Password to use when connecting to server. If password is not given it's asked from the tty."),
72
75
   0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
73
 
  {"port", 'P', "Port number to use for connection or 0 for default to, in "
 
76
  {"port", 'P', N_("Port number to use for connection or 0 for default to, in "
74
77
   "order of preference, my.cnf, $MYSQL_TCP_PORT, "
75
 
   "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").",
 
78
   "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ")."),
76
79
   (char**) &tcp_port,
77
80
   (char**) &tcp_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
78
 
  {"silent", 's', "Silently exit if one can't connect to server.",
 
81
  {"silent", 's', N_("Silently exit if one can't connect to server."),
79
82
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
80
83
#ifndef DONT_ALLOW_USER_CHANGE
81
 
  {"user", 'u', "User for login if not current user.", (char**) &user,
 
84
  {"user", 'u', N_("User for login if not current user."), (char**) &user,
82
85
   (char**) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
83
86
#endif
84
 
  {"verbose", 'v', "Write more information.", (char**) &opt_verbose,
 
87
  {"verbose", 'v', N_("Write more information."), (char**) &opt_verbose,
85
88
   (char**) &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
86
 
  {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG,
 
89
  {"version", 'V', N_("Output version information and exit."), 0, 0, 0, GET_NO_ARG,
87
90
   NO_ARG, 0, 0, 0, 0, 0, 0},
88
 
  {"wait", 'w', "Wait and retry if connection is down.", 0, 0, 0, GET_UINT,
 
91
  {"wait", 'w', N_("Wait and retry if connection is down."), 0, 0, 0, GET_UINT,
89
92
   OPT_ARG, 0, 0, 0, 0, 0, 0},
90
93
  {"connect_timeout", OPT_CONNECT_TIMEOUT, "", (char**) &opt_connect_timeout,
91
94
   (char**) &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, 3600*12, 0,
248
251
        if (!host)
249
252
          host= (char*) LOCAL_HOST;
250
253
 
251
 
        my_printf_error(0,"connect to server at '%s' failed\nerror: '%s'",
 
254
        my_printf_error(0,_("connect to server at '%s' failed\nerror: '%s'"),
252
255
        error_flags, host, drizzle_error(drizzle));
253
256
 
254
257
        if (drizzle_errno(drizzle) == CR_CONN_HOST_ERROR ||
255
258
          drizzle_errno(drizzle) == CR_UNKNOWN_HOST)
256
259
        {
257
 
          fprintf(stderr,"Check that drizzled is running on %s",host);
258
 
          fprintf(stderr," and that the port is %d.\n",
 
260
          fprintf(stderr,_("Check that drizzled is running on %s"),host);
 
261
          fprintf(stderr,_(" and that the port is %d.\n"),
259
262
          tcp_port ? tcp_port: drizzle_port);
260
 
          fprintf(stderr,"You can check this by doing 'telnet %s %d'\n",
 
263
          fprintf(stderr,_("You can check this by doing 'telnet %s %d'\n"),
261
264
                  host, tcp_port ? tcp_port: drizzle_port);
262
265
        }
263
266
      }
268
271
    if ((drizzle_errno(drizzle) != CR_CONN_HOST_ERROR) &&
269
272
        (drizzle_errno(drizzle) != CR_CONNECTION_ERROR))
270
273
    {
271
 
      fprintf(stderr,"Got error: %s\n", drizzle_error(drizzle));
 
274
      fprintf(stderr,_("Got error: %s\n"), drizzle_error(drizzle));
272
275
    }
273
276
    else if (!option_silent)
274
277
    {
275
278
      if (!info)
276
279
      {
277
280
        info=1;
278
 
        fputs("Waiting for Drizzle server to answer",stderr);
 
281
        fputs(_("Waiting for Drizzle server to answer"),stderr);
279
282
        (void) fflush(stderr);
280
283
      }
281
284
      else
308
311
    case ADMIN_SHUTDOWN:
309
312
    {
310
313
      if (opt_verbose)
311
 
        printf("shutting down drizzled...\n");
 
314
        printf(_("shutting down drizzled...\n"));
312
315
 
313
316
      if (drizzle_shutdown(drizzle, SHUTDOWN_DEFAULT))
314
317
      {
315
 
        my_printf_error(0, "shutdown failed; error: '%s'", error_flags,
 
318
        my_printf_error(0, _("shutdown failed; error: '%s'"), error_flags,
316
319
                        drizzle_error(drizzle));
317
320
        return -1;
318
321
      }
319
322
      drizzle_close(drizzle);   /* Close connection to avoid error messages */
320
323
 
321
324
      if (opt_verbose)
322
 
        printf("done\n");
 
325
        printf(_("done\n"));
323
326
 
324
327
      argc=1;             /* Force SHUTDOWN to be the last command */
325
328
      break;
329
332
      if (!drizzle_ping(drizzle))
330
333
      {
331
334
        if (option_silent < 2)
332
 
          puts("drizzled is alive");
 
335
          puts(_("drizzled is alive"));
333
336
      }
334
337
      else
335
338
      {
337
340
        {
338
341
          drizzle->reconnect=1;
339
342
          if (!drizzle_ping(drizzle))
340
 
            puts("connection was down, but drizzled is now alive");
 
343
            puts(_("connection was down, but drizzled is now alive"));
341
344
        }
342
345
        else
343
346
              {
344
 
          my_printf_error(0,"drizzled doesn't answer to ping, error: '%s'",
 
347
          my_printf_error(0,_("drizzled doesn't answer to ping, error: '%s'"),
345
348
          error_flags, drizzle_error(drizzle));
346
349
          return -1;
347
350
        }
350
353
      break;
351
354
 
352
355
    default:
353
 
      my_printf_error(0, "Unknown command: '%-.60s'", error_flags, argv[0]);
 
356
      my_printf_error(0, _("Unknown command: '%-.60s'"), error_flags, argv[0]);
354
357
      return 1;
355
358
    }
356
359
  }
359
362
 
360
363
static void print_version(void)
361
364
{
362
 
  printf("%s  Ver %s Distrib %s, for %s on %s\n",my_progname,ADMIN_VERSION,
 
365
  printf(_("%s  Ver %s Distrib %s, for %s on %s\n"),my_progname,ADMIN_VERSION,
363
366
         drizzle_get_client_info(),SYSTEM_TYPE,MACHINE_TYPE);
364
367
}
365
368
 
366
369
static void usage(void)
367
370
{
368
371
  print_version();
369
 
  puts("Copyright (C) 2000-2006 DRIZZLE AB");
370
 
  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");
371
 
  puts("Administration program for the drizzled daemon.");
372
 
  printf("Usage: %s [OPTIONS] command command....\n", my_progname);
 
372
  puts(_("Copyright (C) 2000-2008 MySQL AB"));
 
373
  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"));
 
374
  puts(_("Administration program for the drizzled daemon."));
 
375
  printf(_("Usage: %s [OPTIONS] command command....\n"), my_progname);
373
376
  my_print_help(my_long_options);
374
 
  puts("\
 
377
  puts(_("\
375
378
  ping         Check if server is down\n\
376
 
  shutdown     Take server down\n");
 
379
  shutdown     Take server down\n"));
377
380
}