Esempio n. 1
0
//-------------------------------------------------------------------------------------------------
inline void_t
Console::prompt(
    std::ctstring_t &a_prompt,
    cbool_t         &a_isVisible,
    std::tstring_t  *a_answer
) const
{
#if xENV_WIN
    xTEST_DIFF(_wnd, xWND_NATIVE_HANDLE_NULL);
    xTEST_EQ(_stdIn.isValid(), true);
    xTEST_EQ(_stdOut.isValid(), true);
#endif

    xTEST_EQ(a_prompt.empty(), false);
    xTEST_PTR(a_answer);

    for ( ; ; ) {
        write(a_prompt + xT(": "));

        for ( ; ; ) {
            ctchar_t letter = static_cast<tchar_t>( std::tcin.get() );

            // asterisks
            xCHECK_DO(a_isVisible, write(xT("*")));

            // ENTER
            xCHECK_DO(letter == 10, break);

            // BACKSPACE
            xCHECK_DO(letter == 0x8, a_answer->clear(); continue);

            a_answer->push_back(letter);
        }

        writeLine(Const::strEmpty());

        xCHECK_DO(a_answer->empty(), continue);

        break;
    }
}
Esempio n. 2
0
//-------------------------------------------------------------------------------------------------
inline void_t
SmtpClient::disconnect()
{
    xCHECK_DO(!_isConnected, disconnect());

    //-------------------------------------
    //RFC
    /*
    [QUIT\r\n]
    +�� dewey POP3 server signing off
    */

    std::tstring_t sRv;

    //-------------------------------------
    //[QUIT]
    std::ctstring_t quitCmd = xT("QUIT\r\n");

    _command(quitCmd, xT("\r\n"), /*ref*/sRv);

    _socket.close();

    _isConnected = false;
}