summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2002-06-03 12:59:31 +0300
committerunknown <monty@hundin.mysql.fi>2002-06-03 12:59:31 +0300
commitf0409fa920c7908f2f9ef03919583a32bf84eaad (patch)
treebe04186411dc657ef6bbcbe01267d30f2675c914 /tools
parentebbcb0f391d7df364e0ccc6bca706456e9aadbf7 (diff)
parent7cb2e2d1dce2c7466388f4a6ade0614564be82fc (diff)
downloadmariadb-git-f0409fa920c7908f2f9ef03919583a32bf84eaad.tar.gz
merge with 4.0
BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union BUILD/SETUP.sh: Auto merged BUILD/compile-pentium-debug: Auto merged BitKeeper/triggers/post-commit: Auto merged configure.in: Auto merged Docs/manual.texi: Auto merged client/mysql.cc: Auto merged client/mysqldump.c: Auto merged client/mysqltest.c: Auto merged extra/mysql_install.c: Auto merged extra/resolve_stack_dump.c: Auto merged extra/resolveip.c: Auto merged include/my_sys.h: Auto merged include/mysqld_error.h: Auto merged isam/pack_isam.c: Auto merged libmysql/Makefile.shared: Auto merged libmysql/libmysql.c: Auto merged myisam/ft_dump.c: Auto merged myisam/ft_test1.c: Auto merged myisam/ftdefs.h: Auto merged myisam/mi_check.c: Auto merged myisam/mi_test1.c: Auto merged myisam/mi_write.c: Auto merged myisam/myisamchk.c: Auto merged myisam/myisampack.c: Auto merged mysql-test/mysql-test-run.sh: Auto merged mysql-test/r/select_found.result: Auto merged mysql-test/t/select_found.test: Auto merged mysys/charset.c: Auto merged mysys/default.c: Auto merged mysys/hash.c: Auto merged sql/field.cc: Auto merged sql/gen_lex_hash.cc: Auto merged sql/ha_innodb.cc: Auto merged sql/hostname.cc: Auto merged sql/item_cmpfunc.h: Auto merged sql/item_strfunc.cc: Auto merged sql/item_timefunc.h: Auto merged sql/lex.h: Auto merged sql/log.cc: Auto merged sql/mysql_priv.h: Auto merged sql/repl_failsafe.cc: Auto merged sql/slave.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_cache.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_db.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_string.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_union.cc: Auto merged sql/share/czech/errmsg.txt: Auto merged sql/share/danish/errmsg.txt: Auto merged sql/share/dutch/errmsg.txt: Auto merged sql/share/english/errmsg.txt: Auto merged sql/share/estonian/errmsg.txt: Auto merged sql/share/german/errmsg.txt: Auto merged sql/share/greek/errmsg.txt: Auto merged sql/share/hungarian/errmsg.txt: Auto merged sql/share/italian/errmsg.txt: Auto merged sql/share/japanese/errmsg.txt: Auto merged sql/share/korean/errmsg.txt: Auto merged sql/share/norwegian-ny/errmsg.txt: Auto merged sql/share/norwegian/errmsg.txt: Auto merged sql/sql_update.cc: Auto merged sql/structs.h: Auto merged sql/share/polish/errmsg.txt: Auto merged sql/share/portuguese/errmsg.txt: Auto merged sql/share/romanian/errmsg.txt: Auto merged sql/share/russian/errmsg.txt: Auto merged sql/share/slovak/errmsg.txt: Auto merged sql/share/spanish/errmsg.txt: Auto merged sql/share/swedish/errmsg.txt: Auto merged sql/share/ukrainian/errmsg.txt: Auto merged strings/Makefile.am: Auto merged strings/ctype-ujis.c: Auto merged tools/mysqlmanager.c: Auto merged
Diffstat (limited to 'tools')
-rw-r--r--tools/mysqlmanager.c173
1 files changed, 78 insertions, 95 deletions
diff --git a/tools/mysqlmanager.c b/tools/mysqlmanager.c
index 536b76a1351..a68038a8c37 100644
--- a/tools/mysqlmanager.c
+++ b/tools/mysqlmanager.c
@@ -30,7 +30,7 @@
#include <m_string.h>
#include <m_ctype.h>
#include <hash.h>
-#include <getopt.h>
+#include <my_getopt.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <errno.h>
@@ -41,8 +41,8 @@
#include <sys/wait.h>
#endif
-#define MANAGER_VERSION "1.0"
-#define MANAGER_GREETING "MySQL Server Management Daemon v. 1.0"
+#define MANAGER_VERSION "1.2"
+#define MANAGER_GREETING "MySQL Server Management Daemon v. 1.2"
#define LOG_ERR 1
#define LOG_WARN 2
@@ -99,7 +99,7 @@
#define DO_STACKTRACE 1
#endif
-uint manager_port = MANAGER_PORT;
+uint manager_port;
FILE* errfp;
const char* manager_log_file = MANAGER_LOG_FILE;
pthread_mutex_t lock_log,lock_shutdown,lock_exec_hash,lock_launch_thd;
@@ -108,14 +108,14 @@ pthread_t loop_th,launch_msg_th;
int manager_sock = -1;
uchar* stack_bottom=0;
struct sockaddr_in manager_addr;
-ulong manager_bind_addr = INADDR_ANY;
-int manager_back_log = MANAGER_BACK_LOG;
+ulong manager_bind_addr;
+int manager_back_log;
int in_shutdown = 0, shutdown_requested=0;
-int manager_connect_retries=MANAGER_CONNECT_RETRIES;
+int manager_connect_retries;
const char* manager_greeting = MANAGER_GREETING;
-uint manager_max_cmd_len = MANAGER_MAX_CMD_LEN;
+uint manager_max_cmd_len;
const char* manager_pw_file=MANAGER_PW_FILE;
-int one_thread = 0; /* for debugging */
+my_bool one_thread; /* for debugging */
typedef enum {PARAM_STDOUT,PARAM_STDERR} PARAM_TYPE;
@@ -232,8 +232,8 @@ static int set_exec_param(struct manager_thd* thd, char* args_start,
#define HANDLE_DECL(com) static int com (struct manager_thd* thd, char* args_start,char* args_end)
#define HANDLE_NOARG_DECL(com) static int com \
- (struct manager_thd* thd, char* __attribute__((unused)) args_start,\
- char* __attribute__((unused)) args_end)
+ (struct manager_thd* thd, char *args_start __attribute__((unused)),\
+ char* args_end __attribute__((unused)))
HANDLE_NOARG_DECL(handle_ping);
@@ -272,22 +272,44 @@ struct manager_cmd commands[] =
{0,0,0,0}
};
-struct option long_options[] =
-{
- {"debug", optional_argument, 0, '#'},
- {"help", no_argument, 0, 'h'},
- {"port", required_argument, 0, 'P'},
- {"log", required_argument, 0, 'l'},
- {"bind-address", required_argument, 0, 'b'},
- {"tcp-backlog", required_argument, 0, 'B'},
- {"greeting", required_argument, 0, 'g'},
- {"max-command-len",required_argument,0,'m'},
- {"one-thread",no_argument,0,'d'},
- {"connect-retries",required_argument,0,'C'},
- {"password-file",required_argument,0,'p'},
- {"pid-file",required_argument,0,'f'},
- {"version", no_argument, 0, 'V'},
- {0, 0, 0, 0}
+
+static struct my_option my_long_options[] =
+{
+#ifndef DBUG_OFF
+ {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'",
+ 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
+#endif
+ {"help", '?', "Display this help and exit.",
+ 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"port", 'P', "Port number to listen on.", (gptr*) &manager_port,
+ (gptr*) &manager_port, 0, GET_UINT, REQUIRED_ARG, MANAGER_PORT, 0, 0, 0,
+ 0, 0},
+ {"log", 'l', "Path to log file.", (gptr*) &manager_log_file,
+ (gptr*) &manager_log_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"bind-address", 'b', "Address to listen on.", (gptr*) &manager_bind_addr,
+ (gptr*) &manager_bind_addr, 0, GET_ULONG, REQUIRED_ARG, INADDR_ANY, 0,
+ 0, 0, 0, 0},
+ {"tcp-backlog", 'B', "Size of TCP/IP listen queue.",
+ (gptr*) &manager_back_log, (gptr*) &manager_back_log, 0, GET_INT,
+ REQUIRED_ARG, MANAGER_BACK_LOG, 0, 0, 0, 0, 0},
+ {"greeting", 'g', "Set greeting on connect", (gptr*) &manager_greeting,
+ (gptr*) &manager_greeting, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"max-command-len", 'm', "Maximum command length",
+ (gptr*) &manager_max_cmd_len, (gptr*) &manager_max_cmd_len, 0, GET_UINT,
+ REQUIRED_ARG, MANAGER_MAX_CMD_LEN, 0, 0, 0, 0, 0},
+ {"one-thread", 'd', "Use one thread ( for debugging)", (gptr*) &one_thread,
+ (gptr*) &one_thread, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"connect-retries", 'C', "Number of attempts to establish MySQL connection",
+ (gptr*) &manager_connect_retries, (gptr*) &manager_connect_retries, 0,
+ GET_INT, REQUIRED_ARG, MANAGER_CONNECT_RETRIES, 0, 0, 0, 0, 0},
+ {"password-file", 'p', "Password file for manager",
+ (gptr*) &manager_pw_file, (gptr*) &manager_pw_file, 0, GET_STR,
+ REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"pid-file", 'f', "Pid file to use", (gptr*) &pid_file, (gptr*) &pid_file,
+ 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"version", 'V', "Output version information and exit.", 0, 0, 0,
+ GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
static void die(const char* fmt,...);
@@ -1063,7 +1085,7 @@ static void log_msg(const char* fmt, int msg_type, va_list args)
}
static pthread_handler_decl(process_launcher_messages,
- __attribute__((unused)) arg)
+ args __attribute__((unused)))
{
my_thread_init();
for (;!in_shutdown;)
@@ -1280,80 +1302,41 @@ static void usage()
printf("MySQL AB, by Sasha\n");
printf("This software comes with ABSOLUTELY NO WARRANTY\n\n");
printf("Manages instances of MySQL server.\n\n");
- printf("Usage: %s [OPTIONS]", my_progname);
- printf("\n\
- -?, --help Display this help and exit.\n");
-#ifndef DBUG_OFF
- puts("\
- -#, --debug=[...] Output debug log. Often this is 'd:t:o,filename`");
-#endif
- printf("\
- -P, --port=... Port number to listen on.\n\
- -l, --log=... Path to log file.\n\
- -b, --bind-address=... Address to listen on.\n\
- -B, --tcp-backlog==... Size of TCP/IP listen queue.\n\
- -g, --greeting= Set greeting on connect \n\
- -m, --max-command-len Maximum command length \n\
- -d, --one-thread Use one thread ( for debugging) \n\
- -C, --connect-retries Number of attempts to establish MySQL connection \n\
- -m, --max-command-len Maximum command length \n\
- -V, --version Output version information and exit.\n\n");
+ printf("Usage: %s [OPTIONS]\n\n", my_progname);
+ my_print_help(my_long_options);
+ my_print_variables(my_long_options);
}
-static int parse_args(int argc, char **argv)
+
+static my_bool
+get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
+ char *argument)
{
- int c, option_index = 0;
- while ((c=getopt_long(argc,argv,"P:?#:Vl:b:B:g:m:dC:p:f:",
- long_options,&option_index)) != EOF)
- {
- switch (c)
- {
- case '#':
- DBUG_PUSH(optarg ? optarg : "d:t:O,/tmp/mysqlmgrd.trace");
- break;
- case 'd':
- one_thread=1;
- break;
- case 'p':
- manager_pw_file=optarg;
- break;
- case 'f':
- pid_file=optarg;
- break;
- case 'C':
- manager_connect_retries=atoi(optarg);
- break;
- case 'P':
- manager_port=atoi(optarg);
- break;
- case 'm':
- manager_max_cmd_len=atoi(optarg);
- break;
- case 'g':
- manager_greeting=optarg;
- case 'b':
- manager_bind_addr = inet_addr(optarg);
- break;
- case 'B':
- manager_back_log = atoi(optarg);
- break;
- case 'l':
- manager_log_file=optarg;
- break;
- case 'V':
- print_version();
- exit(0);
- case '?':
- usage();
- exit(0);
- default:
- usage();
- exit(1);
- }
+ switch (optid) {
+ case '#':
+ DBUG_PUSH(argument ? argument : "d:t:O,/tmp/mysqlmgrd.trace");
+ break;
+ case 'V':
+ print_version();
+ exit(0);
+ case '?':
+ usage();
+ exit(0);
}
return 0;
}
+
+static int parse_args(int argc, char **argv)
+{
+ int ho_error;
+
+ if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
+ exit(ho_error);
+
+ return 0;
+}
+
static int init_server()
{
int arg=1;