Fixed bad function name

This commit is contained in:
Alexey Milovidov 2019-02-02 03:25:12 +03:00
parent 0f577da5c2
commit 7f8ac2d26b
4 changed files with 12 additions and 12 deletions

View File

@ -8,7 +8,7 @@
#include <Common/Exception.h>
#include <IO/ConnectionTimeouts.h>
#include <common/SetTerminalEcho.h>
#include <common/setTerminalEcho.h>
#include <ext/scope_guard.h>
#include <Poco/Util/AbstractConfiguration.h>
@ -56,10 +56,10 @@ struct ConnectionParameters
throw Exception("Specified both --password and --ask-password. Remove one of them", ErrorCodes::BAD_ARGUMENTS);
std::cout << "Password for user " << user << ": ";
SetTerminalEcho(false);
setTerminalEcho(false);
SCOPE_EXIT({
SetTerminalEcho(true);
setTerminalEcho(true);
});
std::getline(std::cin, password);
std::cout << std::endl;

View File

@ -19,7 +19,7 @@ add_library (common ${LINK_MODE}
src/JSON.cpp
src/getMemoryAmount.cpp
src/demangle.cpp
src/SetTerminalEcho.cpp
src/setTerminalEcho.cpp
include/common/Types.h
include/common/DayNum.h
@ -37,7 +37,7 @@ add_library (common ${LINK_MODE}
include/common/JSON.h
include/common/getMemoryAmount.h
include/common/demangle.h
include/common/SetTerminalEcho.h
include/common/setTerminalEcho.h
include/common/find_symbols.h
include/common/constexpr_helpers.h

View File

@ -1,4 +1,4 @@
#pragma once
/// Enable or disable echoing of typed characters. Throws std::runtime_error on error.
void SetTerminalEcho(bool enable);
void setTerminalEcho(bool enable);

View File

@ -1,6 +1,6 @@
// https://stackoverflow.com/questions/1413445/reading-a-password-from-stdcin
#include <common/SetTerminalEcho.h>
#include <common/setTerminalEcho.h>
#include <stdexcept>
#include <cstring>
#include <string>
@ -13,13 +13,13 @@
#include <errno.h>
#endif
void SetTerminalEcho(bool enable)
void setTerminalEcho(bool enable)
{
#ifdef WIN32
auto handle = GetStdHandle(STD_INPUT_HANDLE);
DWORD mode;
if (!GetConsoleMode(handle, &mode))
throw std::runtime_error(std::string("SetTerminalEcho failed get: ") + std::to_string(GetLastError()));
throw std::runtime_error(std::string("setTerminalEcho failed get: ") + std::to_string(GetLastError()));
if (!enable)
mode &= ~ENABLE_ECHO_INPUT;
@ -27,11 +27,11 @@ void SetTerminalEcho(bool enable)
mode |= ENABLE_ECHO_INPUT;
if (!SetConsoleMode(handle, mode))
throw std::runtime_error(std::string("SetTerminalEcho failed set: ") + std::to_string(GetLastError()));
throw std::runtime_error(std::string("setTerminalEcho failed set: ") + std::to_string(GetLastError()));
#else
struct termios tty;
if (tcgetattr(STDIN_FILENO, &tty))
throw std::runtime_error(std::string("SetTerminalEcho failed get: ") + strerror(errno));
throw std::runtime_error(std::string("setTerminalEcho failed get: ") + strerror(errno));
if (!enable)
tty.c_lflag &= ~ECHO;
else
@ -39,6 +39,6 @@ void SetTerminalEcho(bool enable)
auto ret = tcsetattr(STDIN_FILENO, TCSANOW, &tty);
if (ret)
throw std::runtime_error(std::string("SetTerminalEcho failed set: ") + strerror(errno));
throw std::runtime_error(std::string("setTerminalEcho failed set: ") + strerror(errno));
#endif
}