未验证 提交 47625967 编写于 作者: sangshuduo's avatar sangshuduo 提交者: GitHub

Feature/sangshuduo/td 5844 cmdline parameters align (#7442)

* [TD-5844]<feature>: make cmd line parameter similar.

* fix test case align with taosdemo change.

* fix windows stack overflow issue.

* fix mac compile error.

* fix taosdemo cmdline parameter in tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoInsert.py

* fix windows compiler options.

* make taos.exe use mysql style password input.

* make taos shell and taosdump use mysql style password input.

* determine scanf return value.

* make console echo off during password input.
上级 d4105ff2
...@@ -866,10 +866,12 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -866,10 +866,12 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
arguments->user = argv[++i]; arguments->user = argv[++i];
} else if (strncmp(argv[i], "-p", 2) == 0) { } else if (strncmp(argv[i], "-p", 2) == 0) {
if (strlen(argv[i]) == 2) { if (strlen(argv[i]) == 2) {
printf("Enter password:"); printf("Enter password: ");
taosSetConsoleEcho(false);
if (scanf("%s", arguments->password) > 1) { if (scanf("%s", arguments->password) > 1) {
fprintf(stderr, "password read error!\n"); fprintf(stderr, "password read error!\n");
} }
taosSetConsoleEcho(true);
} else { } else {
tstrncpy(arguments->password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE); tstrncpy(arguments->password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE);
} }
......
...@@ -561,9 +561,11 @@ static void parse_password( ...@@ -561,9 +561,11 @@ static void parse_password(
if (strncmp(argv[i], "-p", 2) == 0) { if (strncmp(argv[i], "-p", 2) == 0) {
if (strlen(argv[i]) == 2) { if (strlen(argv[i]) == 2) {
printf("Enter password: "); printf("Enter password: ");
taosSetConsoleEcho(false);
if(scanf("%20s", arguments->password) > 1) { if(scanf("%20s", arguments->password) > 1) {
errorPrint("%s() LN%d, password read error!\n", __func__, __LINE__); errorPrint("%s() LN%d, password read error!\n", __func__, __LINE__);
} }
taosSetConsoleEcho(true);
} else { } else {
tstrncpy(arguments->password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE); tstrncpy(arguments->password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE);
} }
......
...@@ -24,6 +24,8 @@ void* taosLoadDll(const char *filename); ...@@ -24,6 +24,8 @@ void* taosLoadDll(const char *filename);
void* taosLoadSym(void* handle, char* name); void* taosLoadSym(void* handle, char* name);
void taosCloseDll(void *handle); void taosCloseDll(void *handle);
int taosSetConsoleEcho(bool on);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -29,4 +29,30 @@ void* taosLoadSym(void* handle, char* name) { ...@@ -29,4 +29,30 @@ void* taosLoadSym(void* handle, char* name) {
void taosCloseDll(void *handle) { void taosCloseDll(void *handle) {
} }
int taosSetConsoleEcho(bool on)
{
#if 0
#define ECHOFLAGS (ECHO | ECHOE | ECHOK | ECHONL)
int err;
struct termios term;
if (tcgetattr(STDIN_FILENO, &term) == -1) {
perror("Cannot get the attribution of the terminal");
return -1;
}
if (on)
term.c_lflag|=ECHOFLAGS;
else
term.c_lflag &=~ECHOFLAGS;
err = tcsetattr(STDIN_FILENO,TCSAFLUSH,&term);
if (err == -1 && err == EINTR) {
perror("Cannot set the attribution of the terminal");
return -1;
}
#endif
return 0;
}
...@@ -51,4 +51,28 @@ void taosCloseDll(void *handle) { ...@@ -51,4 +51,28 @@ void taosCloseDll(void *handle) {
} }
} }
int taosSetConsoleEcho(bool on)
{
#define ECHOFLAGS (ECHO | ECHOE | ECHOK | ECHONL)
int err;
struct termios term;
if (tcgetattr(STDIN_FILENO, &term) == -1) {
perror("Cannot get the attribution of the terminal");
return -1;
}
if (on)
term.c_lflag|=ECHOFLAGS;
else
term.c_lflag &=~ECHOFLAGS;
err = tcsetattr(STDIN_FILENO,TCSAFLUSH,&term);
if (err == -1 && err == EINTR) {
perror("Cannot set the attribution of the terminal");
return -1;
}
return 0;
}
...@@ -30,3 +30,17 @@ void taosCloseDll(void *handle) { ...@@ -30,3 +30,17 @@ void taosCloseDll(void *handle) {
} }
int taosSetConsoleEcho(bool on)
{
HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
DWORD mode = 0;
GetConsoleMode(hStdin, &mode );
if (on) {
mode |= ENABLE_ECHO_INPUT;
} else {
mode &= ~ENABLE_ECHO_INPUT;
}
SetConsoleMode(hStdin, mode);
return 0;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册