示例#1
0
//-------------------------------------------------------------------------------------------------
inline void_t
File::reopen(
    std::ctstring_t  &a_filePath,
    const ExOpenMode &a_mode,
    cbool_t          &a_isUseBuffering
)
{
    xTEST_EQ(a_filePath.empty(), false);
    xTEST_NA(a_mode);
    xTEST_NA(a_isUseBuffering);

    // create dir
    Dir( Path(a_filePath).dir() ).pathCreate();

    // create, reopen file
    {
        std::FILE *file = xTFREOPEN(a_filePath.c_str(), _openMode(a_mode).c_str(), get());
        xTEST_PTR(file);

        _handle   = file;
        _filePath = a_filePath;
    }

    // buffering
    if (!a_isUseBuffering) {
        setVBuff(xPTR_NULL, bmNo,   0);
    } else {
        setVBuff(xPTR_NULL, bmFull, BUFSIZ);
    }
}
示例#2
0
//-------------------------------------------------------------------------------------------------
inline bool_t
SmtpClient::_isError(
    std::ctstring_t &a_text
)
{
    xTEST_EQ(a_text.empty(), false);

    bool_t bRv = !(
        !std::memcmp(a_text.c_str(), xT("334"), 3) || // 334 VXNlcm5hbWU6
        !std::memcmp(a_text.c_str(), xT("235"), 3) || // 235 2.0.0 Authentication successful
        !std::memcmp(a_text.c_str(), xT("220"), 3) || // 220 Kerio MailServer ESMTP ready
        !std::memcmp(a_text.c_str(), xT("250"), 3) || // 250 2.0.0 OK
        !std::memcmp(a_text.c_str(), xT("354"), 3) || // 354 Enter mail, end with CRLF.CRLF
        !std::memcmp(a_text.c_str(), xT("221"), 3)    // 221 221 2.0.0 SMTP closing connection
    );

    return bRv;
}
示例#3
0
//-------------------------------------------------------------------------------------------------
inline void_t
Locale::setCurrent(
    std::ctstring_t &a_locale
) const
{
    xTEST_NA(a_locale);

    ctchar_t *locale = a_locale.empty() ? xPTR_NULL : a_locale.c_str();

    ctchar_t *pcszRv = xTSETLOCALE(LC_ALL, locale);
    xTEST_PTR(pcszRv);
}
示例#4
0
Test_Process::unit()
{
    xTEST_CASE("create, wait")
    {
        #if 1
            #if   xENV_WIN
                std::ctstring_t filePath = xT("C:\\Windows\\System32\\attrib.exe");
                std::ctstring_t cmdLine  = xT("");
            #elif xENV_UNIX
                std::ctstring_t filePath = xT("/bin/ls");
                std::ctstring_t cmdLine  = xT("-la");
            #endif

            Process proc;

            proc.create(filePath, xT("%s"), cmdLine.c_str());

            Process::WaitResult wrRes = proc.wait(xTIMEOUT_INFINITE);
            xTEST_EQ(Process::wrAbandoned, wrRes);
        #endif
    }

    xTEST_CASE("kill")
    {
        #if   xENV_WIN
            std::ctstring_t filePath = xT("C:\\Windows\\System32\\attrib.exe");
            std::ctstring_t cmdLine  = xT("/?");
        #elif xENV_UNIX
            std::ctstring_t filePath = xT("/usr/bin/xmessage");
            std::ctstring_t cmdLine  = xT("-print \"Test Message\"");
        #endif