From 3b6397b1d21fa2965693d13933192c5b8d708f84 Mon Sep 17 00:00:00 2001 From: "anozdrin@mysql.com" <> Date: Mon, 19 Jun 2006 14:41:29 +0400 Subject: [PATCH 1/2] WL#3298: IM: make command-line option names consistent 1. Removed '-P' command line option; 2. Renamed '--passwd' command line option to '--print-password-line'. --- mysql-test/t/im_cmd_line.imtest | 4 ++-- server-tools/instance-manager/options.cc | 12 ++++++------ .../instance-manager/user_management_commands.cc | 4 ++-- .../instance-manager/user_management_commands.h | 7 ++++--- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/mysql-test/t/im_cmd_line.imtest b/mysql-test/t/im_cmd_line.imtest index 00e8351535e..29ed420439d 100644 --- a/mysql-test/t/im_cmd_line.imtest +++ b/mysql-test/t/im_cmd_line.imtest @@ -26,7 +26,7 @@ --echo --echo --> Printing out line for 'testuser'... ---exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --passwd --username=testuser --password=abc | tail -1 +--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --print-password-line --username=testuser --password=abc | tail -1 --echo --echo --> Listing users... @@ -45,7 +45,7 @@ --echo --echo --> Printing out line for 'testuser'... ---exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --passwd --username=testuser --password=xyz | tail -1 +--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --print-password-line --username=testuser --password=xyz | tail -1 --echo --echo --> Listing users... diff --git a/server-tools/instance-manager/options.cc b/server-tools/instance-manager/options.cc index 31ce5b00190..07a1fd3e932 100644 --- a/server-tools/instance-manager/options.cc +++ b/server-tools/instance-manager/options.cc @@ -114,7 +114,6 @@ static const int ANGEL_PID_FILE_SUFFIX_LEN= strlen(ANGEL_PID_FILE_SUFFIX); */ enum options { - OPT_PASSWD= 'P', OPT_USERNAME= 'u', OPT_PASSWORD= 'p', OPT_LOG= 256, @@ -135,6 +134,7 @@ enum options { OPT_PORT, OPT_WAIT_TIMEOUT, OPT_BIND_ADDRESS, + OPT_PRINT_PASSWORD_LINE, OPT_ADD_USER, OPT_DROP_USER, OPT_EDIT_USER, @@ -225,8 +225,8 @@ static struct my_option my_long_options[] = (gptr *) &Options::Main::mysqld_safe_compatible, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 0, 0 }, - { "passwd", OPT_PASSWD, - "Prepare an entry for the password file and exit.", + { "print-password-line", OPT_PRINT_PASSWORD_LINE, + "Print out a user entry as a line for the password file and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "password", OPT_PASSWORD, "Password to update the password file", @@ -339,7 +339,7 @@ get_one_option(int optid, case 'V': version(); exit(0); - case OPT_PASSWD: + case OPT_PRINT_PASSWORD_LINE: case OPT_ADD_USER: case OPT_DROP_USER: case OPT_EDIT_USER: @@ -354,8 +354,8 @@ get_one_option(int optid, } switch (optid) { - case OPT_PASSWD: - Options::User_management::cmd= new Passwd_cmd(); + case OPT_PRINT_PASSWORD_LINE: + Options::User_management::cmd= new Print_password_line_cmd(); break; case OPT_ADD_USER: Options::User_management::cmd= new Add_user_cmd(); diff --git a/server-tools/instance-manager/user_management_commands.cc b/server-tools/instance-manager/user_management_commands.cc index 03a3f9814e3..20ebeb0d6bf 100644 --- a/server-tools/instance-manager/user_management_commands.cc +++ b/server-tools/instance-manager/user_management_commands.cc @@ -180,10 +180,10 @@ static int save_password_file(User_map *user_map) } /************************************************************************* - Passwd_cmd + Print_password_line_cmd *************************************************************************/ -int Passwd_cmd::execute() +int Print_password_line_cmd::execute() { LEX_STRING user_name; const char *password; diff --git a/server-tools/instance-manager/user_management_commands.h b/server-tools/instance-manager/user_management_commands.h index 4bf3546f0a6..8d820be5ec7 100644 --- a/server-tools/instance-manager/user_management_commands.h +++ b/server-tools/instance-manager/user_management_commands.h @@ -61,13 +61,14 @@ public: /************************************************************************* - Passwd_cmd: support for --passwd command-line option. + Print_password_line_cmd: support for --print-password-line command-line + option. *************************************************************************/ -class Passwd_cmd : public User_management_cmd +class Print_password_line_cmd : public User_management_cmd { public: - Passwd_cmd() + Print_password_line_cmd() { } public: From 7ecfadbcf29ce934e54dd987feb5dfd6a9797aa7 Mon Sep 17 00:00:00 2001 From: "anozdrin@mysql.com" <> Date: Mon, 19 Jun 2006 15:17:15 +0400 Subject: [PATCH 2/2] Polishing: C_STRING_WITH_SIZE() was renamed to C_STRING_WITH_LEN(). --- include/m_string.h | 2 +- server-tools/instance-manager/commands.cc | 6 +++--- server-tools/instance-manager/instance.cc | 2 +- server-tools/instance-manager/instance_options.cc | 6 +++--- server-tools/instance-manager/priv.cc | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/m_string.h b/include/m_string.h index 9f7ec220f2c..e009447c192 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -256,6 +256,6 @@ typedef struct } LEX_STRING; #define STRING_WITH_LEN(X) (X), ((uint) (sizeof(X) - 1)) -#define C_STRING_WITH_SIZE(X) ((char *) (X)), ((uint) (sizeof(X) - 1)) +#define C_STRING_WITH_LEN(X) ((char *) (X)), ((uint) (sizeof(X) - 1)) #endif diff --git a/server-tools/instance-manager/commands.cc b/server-tools/instance-manager/commands.cc index 07e1e9a18f3..f45b230171e 100644 --- a/server-tools/instance-manager/commands.cc +++ b/server-tools/instance-manager/commands.cc @@ -695,7 +695,7 @@ bool Create_instance::parse_args(const char **text) if (!option_value_str) { - LEX_STRING empty_str= { C_STRING_WITH_SIZE("") }; + LEX_STRING empty_str= { C_STRING_WITH_LEN("") }; if (!(option_value_str= Named_value::alloc_str(&empty_str))) return TRUE; /* out of memory during parsing. */ @@ -1511,7 +1511,7 @@ bool Set_option::parse_args(const char **text) if (!option_value_str) { - LEX_STRING empty_str= { C_STRING_WITH_SIZE("") }; + LEX_STRING empty_str= { C_STRING_WITH_LEN("") }; if (!(option_value_str= Named_value::alloc_str(&empty_str))) return TRUE; /* out of memory during parsing. */ @@ -1650,7 +1650,7 @@ bool Unset_option::parse_args(const char **text) return TRUE; /* out of memory during parsing. */ { - LEX_STRING empty_str= { C_STRING_WITH_SIZE("") }; + LEX_STRING empty_str= { C_STRING_WITH_LEN("") }; if (!(option_value_str= Named_value::alloc_str(&empty_str))) { diff --git a/server-tools/instance-manager/instance.cc b/server-tools/instance-manager/instance.cc index 456052bf7e5..340a2d67353 100644 --- a/server-tools/instance-manager/instance.cc +++ b/server-tools/instance-manager/instance.cc @@ -37,7 +37,7 @@ const LEX_STRING -Instance::DFLT_INSTANCE_NAME= { C_STRING_WITH_SIZE("mysqld") }; +Instance::DFLT_INSTANCE_NAME= { C_STRING_WITH_LEN("mysqld") }; static const char * const INSTANCE_NAME_PREFIX= Instance::DFLT_INSTANCE_NAME.str; static const int INSTANCE_NAME_PREFIX_LEN= Instance::DFLT_INSTANCE_NAME.length; diff --git a/server-tools/instance-manager/instance_options.cc b/server-tools/instance-manager/instance_options.cc index b05e40734b7..7b3f435eae5 100644 --- a/server-tools/instance-manager/instance_options.cc +++ b/server-tools/instance-manager/instance_options.cc @@ -120,7 +120,7 @@ int Instance_options::get_default_option(char *result, size_t result_len, { int rc= 1; LEX_STRING verbose_option= - { C_STRING_WITH_SIZE(" --no-defaults --verbose --help") }; + { C_STRING_WITH_LEN(" --no-defaults --verbose --help") }; /* reserve space for the path + option + final '\0' */ Buffer cmd(mysqld_path.length + verbose_option.length + 1); @@ -155,7 +155,7 @@ int Instance_options::fill_instance_version() { char result[MAX_VERSION_LENGTH]; LEX_STRING version_option= - { C_STRING_WITH_SIZE(" --no-defaults --version") }; + { C_STRING_WITH_LEN(" --no-defaults --version") }; int rc= 1; Buffer cmd(mysqld_path.length + version_option.length + 1); @@ -210,7 +210,7 @@ int Instance_options::fill_mysqld_real_path() { char result[FN_REFLEN]; LEX_STRING help_option= - { C_STRING_WITH_SIZE(" --no-defaults --help") }; + { C_STRING_WITH_LEN(" --no-defaults --help") }; int rc= 1; Buffer cmd(mysqld_path.length + help_option.length); diff --git a/server-tools/instance-manager/priv.cc b/server-tools/instance-manager/priv.cc index d3cc52ec638..3dae900d84b 100644 --- a/server-tools/instance-manager/priv.cc +++ b/server-tools/instance-manager/priv.cc @@ -43,7 +43,7 @@ bool linuxthreads; The following string must be less then 80 characters, as mysql_connection.cc relies on it */ -const LEX_STRING mysqlmanager_version= { C_STRING_WITH_SIZE("1.0-beta") }; +const LEX_STRING mysqlmanager_version= { C_STRING_WITH_LEN("1.0-beta") }; const unsigned char protocol_version= PROTOCOL_VERSION;