PANTHEIOS_CALL(int) pantheios_be_logEntry(
    void*               feToken
,   void*               beToken
,   int                 severity
,   PAN_CHAR_T const*   entry
,   size_t              cchEntry
)
{
    STLSOFT_SUPPRESS_UNUSED(feToken);
    STLSOFT_SUPPRESS_UNUSED(beToken);
    STLSOFT_SUPPRESS_UNUSED(severity);
    STLSOFT_SUPPRESS_UNUSED(entry);

    if(0 == s_feInitValue)
    {
        XTESTS_FAIL_WITH_QUALIFIER("back-end entry logging", "front-end has not yet been initialised");
    }
    else if(1 != s_feInitValue)
    {
        XTESTS_FAIL_WITH_QUALIFIER("back-end entry logging", "front-end has been uninitialised");
    }
    else if(0 == s_beInitValue)
    {
        XTESTS_FAIL_WITH_QUALIFIER("back-end entry logging", "back-end has not been initialised");
    }
    else if(1 != s_beInitValue)
    {
        XTESTS_FAIL_WITH_QUALIFIER("back-end entry logging", "back-end has been uninitialised");
    }

        return (int)cchEntry;
}
Beispiel #2
0
static int main_(int argc, char **argv)
{
#ifndef PANTHEIOS_USE_WIDE_STRINGS
    pantheios::log_DEBUG("main_(", pantheios::args(argc, argv), ")");
#endif

    {
        unsigned    flags = PANTHEIOS_BE_FILE_F_DISCARD_CACHED_CONTENTS | PANTHEIOS_BE_FILE_F_TRUNCATE;

        int res1 = pantheios_be_file_setFilePath(PSTR("test-%T-%D.log"), flags, flags, PANTHEIOS_BEID_LOCAL);

        pantheios_be_file_flush(PANTHEIOS_BEID_LOCAL);

        pantheios::log_NOTICE(PSTR("stmt 1"));
    }

#ifndef PANTHEIOS_USE_WIDE_STRINGS
    {
        pantheios::log_NOTICE("stmt 1");
        unsigned    flags = PANTHEIOS_BE_FILE_F_DISCARD_CACHED_CONTENTS | PANTHEIOS_BE_FILE_F_TRUNCATE;

        int res1 = pantheios_be_file_setFilePath(FILENAME_LOCAL, flags, flags, PANTHEIOS_BEID_LOCAL);

        pantheios::log_NOTICE("stmt 2");
        pantheios::log_NOTICE("stmt 3");

        int res2 = pantheios_be_file_setFilePath(FILENAME_REMOTE, flags, flags, PANTHEIOS_BEID_REMOTE);

        pantheios::log_NOTICE("stmt 4");
        pantheios::log_NOTICE("stmt 5");

        pantheios_be_file_setFilePath(NULL, PANTHEIOS_BEID_LOCAL);
        pantheios_be_file_setFilePath(NULL, PANTHEIOS_BEID_REMOTE);

        pantheios::log_NOTICE("stmt 6");
        pantheios::log_NOTICE("stmt 7");

        file_lines_t    local_lines(FILENAME_LOCAL);
        file_lines_t    remote_lines(FILENAME_REMOTE);

        const size_t    numLocal    =   local_lines.size();
        const size_t    numRemote   =   remote_lines.size();

        STLSOFT_ASSERT(4 == numLocal);
        STLSOFT_ASSERT(2 == numRemote);

        fs_traits_t::delete_file(FILENAME_LOCAL);
        fs_traits_t::get_last_error();
        fs_traits_t::delete_file(FILENAME_REMOTE);
        fs_traits_t::get_last_error();

        STLSOFT_SUPPRESS_UNUSED(res1);
        STLSOFT_SUPPRESS_UNUSED(res2);
    }
#endif

    pantheios::log_DEBUG(PSTR("exiting main_()"));

    return EXIT_SUCCESS;
}
inline bool truncation_test_helper_runtime_test(FROM from, no_type, TO ) // The use of the dummy variable is to fix a bug with VC++ 5-7.0
{
#ifdef _DEBUG
# if defined(STLSOFT_COMPILER_IS_MSVC)
	int const flags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
	_CrtSetDbgFlag(flags & ~(_CRTDBG_ALLOC_MEM_DF));
# endif /* VC++ */

    char const* TO_     =   typeid(TO).name();
    char const* FROM_   =   typeid(FROM).name();

    STLSOFT_SUPPRESS_UNUSED(TO_);
    STLSOFT_SUPPRESS_UNUSED(FROM_);
# if defined(STLSOFT_COMPILER_IS_MSVC)
	_CrtSetDbgFlag(flags);
# endif /* VC++ */
#endif /* _DEBUG */

    // Types are different

    // Next test for same sign
    enum {  TO_is_signed            =   is_signed_type<TO>::value                   };
    enum {  FROM_is_signed          =   is_signed_type<FROM>::value                 };

    enum {  types_have_same_sign    =   int(TO_is_signed) == int(FROM_is_signed)    };

    const ss_size_t sizeofFROM  =   sizeof(FROM);
    const ss_size_t sizeofTO    =   sizeof(TO);

    STLSOFT_STATIC_ASSERT(sizeofFROM >= sizeofTO || FROM_is_signed);

    typedef ss_typename_param_k value_to_yesno_type<types_have_same_sign>::type  same_sign_yesno_t;

    return truncation_test_helper_runtime_test_same_sign<TO>(from, same_sign_yesno_t(), TO());
}
PANTHEIOS_CALL(int) pantheios_fe_isSeverityLogged(  void*   token
                                                ,   int     severity
                                                ,   int     backEndId)
{
    STLSOFT_SUPPRESS_UNUSED(token);
    STLSOFT_SUPPRESS_UNUSED(severity);
    STLSOFT_SUPPRESS_UNUSED(backEndId);

    if(0 == s_feInitValue)
    {
        XTESTS_FAIL_WITH_QUALIFIER("front-end severity test", "front-end has not yet been initialised");
    }
    else if(1 != s_feInitValue)
    {
        XTESTS_FAIL_WITH_QUALIFIER("front-end severity test", "front-end has been uninitialised");
    }
    else if(0 == s_beInitValue)
    {
        XTESTS_FAIL_WITH_QUALIFIER("front-end severity test", "back-end has not yet been initialised");
    }
    else if(1 != s_beInitValue)
    {
        XTESTS_FAIL_WITH_QUALIFIER("front-end severity test", "back-end has been uninitialised");
    }

    return 0;
}
    bool truncation_test_v2(FROM from, TO dummy)
    {
#ifdef _DEBUG
        char const  *TO_    =   typeid(TO).name();
        char const  *FROM_  =   typeid(FROM).name();

        STLSOFT_SUPPRESS_UNUSED(TO_);
        STLSOFT_SUPPRESS_UNUSED(FROM_);
#endif /* _DEBUG */

        enum { fromIsSigned =   stlsoft::is_signed_type<FROM>::value    };
        enum { toIsSigned   =   stlsoft::is_signed_type<TO>::value      };

        enum
        {
            is_statically_determined =  
                (   int(fromIsSigned) == int(toIsSigned) &&
                    sizeof(FROM) <= sizeof(TO)) ||
                (   !fromIsSigned &&
                    toIsSigned &&
                    sizeof(FROM) < sizeof(TO))
        };

        typedef ss_typename_type_k value_to_yesno_type<is_statically_determined>::type  yesno_t;

        return truncation_test_v2_is_statically_determined(from, dummy, yesno_t());
    }
static int pantheios_be_WindowsMessageBox_init_(
    pan_char_t const*   processIdentity
,   int                 id
,   void const*         unused
,   void*               reserved
,   void**              ptoken
)
{
    STLSOFT_SUPPRESS_UNUSED(unused);
    STLSOFT_SUPPRESS_UNUSED(reserved);

    // (iii) create the context

    WindowsMessageBox_Context* ctxt = new(processIdentity) WindowsMessageBox_Context(id);

#ifndef STLSOFT_CF_THROW_BAD_ALLOC
    if(NULL == ctxt)
    {
        return PANTHEIOS_INIT_RC_OUT_OF_MEMORY;
    }
#endif /* !STLSOFT_CF_THROW_BAD_ALLOC */

    *ptoken = ctxt;

    return 0;
}
int main(int argc, char **argv)
{
  // Use of be.file involves several steps:
  //
  // 1. Linking to the back-end, either explicitly or implicitly
  // 2. Setting the log file path for the given back-end(s)
  // 3. Making log statements
  // 4. Changing the log file path for the given back-end(s)
  // 5. Closing the log file for the given back-end(s)

  // In this case, linking is performed either by the build makefile or the
  // IDE project file, to the be.file back-end.
  //
  // In this case, the log file path via the application-defined callback
  // function pantheios_be_file_getAppInit(), which is called during program
  // initialisation, prior to main() being called. At the same time, the
  // flags PANTHEIOS_BE_FILE_F_TRUNCATE and
  // PANTHEIOS_BE_FILE_F_DELETE_IF_EMPTY are specified
  //
  // In this case, the file is closed automatically during program
  // uninitialisation.

  try
  {
#ifndef PANTHEIOS_USE_WIDE_STRINGS
    pantheios::log_DEBUG("main(", pantheios::args(argc, argv), ")");
#else /* ? !PANTHEIOS_USE_WIDE_STRINGS */
    STLSOFT_SUPPRESS_UNUSED(argc); STLSOFT_SUPPRESS_UNUSED(argv);
#endif /* !PANTHEIOS_USE_WIDE_STRINGS */

    pantheios::log_NOTICE(PSTR("stmt 1"));


    pantheios::log_NOTICE(PSTR("stmt 2"));


    pantheios::log_NOTICE(PSTR("stmt 3"));


    pantheios::log_NOTICE(PSTR("stmt 4"));

    pantheios::log_DEBUG(PSTR("exiting main()"));

    return EXIT_SUCCESS;
  }
  catch(std::bad_alloc&)
  {
    pantheios::log(pantheios::alert, PSTR("out of memory"));
  }
  catch(std::exception& x)
  {
    pantheios::log_CRITICAL(PSTR("Exception: "), x);
  }
  catch(...)
  {
    pantheios::logputs(pantheios::emergency, PSTR("Unexpected unknown error"));
  }

  return EXIT_FAILURE;
}
inline bool truncation_test_helper_runtime_test_same_sign(FROM from, no_type, TO)
{
#ifdef _DEBUG
# if defined(STLSOFT_COMPILER_IS_MSVC)
	int const flags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
	_CrtSetDbgFlag(flags & ~(_CRTDBG_ALLOC_MEM_DF));
# endif /* VC++ */

    char const* TO_     =   typeid(TO).name();
    char const* FROM_   =   typeid(FROM).name();

    STLSOFT_SUPPRESS_UNUSED(TO_);
    STLSOFT_SUPPRESS_UNUSED(FROM_);
# if defined(STLSOFT_COMPILER_IS_MSVC)
	_CrtSetDbgFlag(flags);
# endif /* VC++ */
#endif /* _DEBUG */

    enum {  TO_is_signed            =   is_signed_type<TO>::value                   };
    enum {  FROM_is_signed          =   is_signed_type<FROM>::value                 };

    const ss_size_t sizeofFROM  =   sizeof(FROM);
    const ss_size_t sizeofTO    =   sizeof(TO);

    STLSOFT_SUPPRESS_UNUSED(sizeofFROM);
    STLSOFT_SUPPRESS_UNUSED(sizeofTO);

    STLSOFT_STATIC_ASSERT((0 == int(TO_is_signed)) != (0 == int(FROM_is_signed)));

    typedef ss_typename_param_k value_to_yesno_type<FROM_is_signed>::type  same_sign_yesno_t;

    return truncation_test_helper_runtime_test_different_sign_FROM_is_signed<TO>(from, same_sign_yesno_t(), TO());
}
PANTHEIOS_CALL(int) pantheios_be_init(
    PAN_CHAR_T const*   processIdentity
,   void*               reserved
,   void**              ptoken
)
{
    STLSOFT_SUPPRESS_UNUSED(processIdentity);
    STLSOFT_SUPPRESS_UNUSED(reserved);
    STLSOFT_SUPPRESS_UNUSED(ptoken);

    if(0 == s_feInitValue)
    {
        XTESTS_FAIL_WITH_QUALIFIER("back-end initialisation", "front-end has not yet been initialised");
    }
    else if(1 != s_feInitValue)
    {
        XTESTS_FAIL_WITH_QUALIFIER("back-end initialisation", "front-end has been uninitialised");
    }
    else if(0 != s_beInitValue)
    {
        XTESTS_FAIL_WITH_QUALIFIER("back-end initialisation", "back-end has already been initialised");
    }
    else
    {
        ++s_beInitValue;

        return 0;
    }

    return PANTHEIOS_BE_INIT_RC_INTENDED_FAILURE;
}
static int main_(int argc, char **argv)
{
    STLSOFT_SUPPRESS_UNUSED(argc);
    STLSOFT_SUPPRESS_UNUSED(argv);

    some_logging_1();
    some_logging_2();
    some_logging_3();

    return 0;
}
PANTHEIOS_CALL(int) pantheios_fe_init(
    void*   reserved
,   void**  ptoken
)
{
    STLSOFT_SUPPRESS_UNUSED(reserved);
    STLSOFT_SUPPRESS_UNUSED(ptoken);

    ++s_numInits;

    return 0;
}
PANTHEIOS_CALL(int) pantheios_fe_isSeverityLogged(
    void*   token
,   int     severity
,   int     backEndId
)
{
    STLSOFT_SUPPRESS_UNUSED(token);
    STLSOFT_SUPPRESS_UNUSED(severity);
    STLSOFT_SUPPRESS_UNUSED(backEndId);

    ++s_numISL;

    return 0;
}
static int main_(int argc, char** argv)
{
  // This goes only to debugger
#ifndef PANTHEIOS_USE_WIDE_STRINGS
  pantheios::log_NOTICE(PSTR("main("), pantheios::args(argc, argv), PSTR(")"));
#else /* ? !PANTHEIOS_USE_WIDE_STRINGS */
  STLSOFT_SUPPRESS_UNUSED(argc); STLSOFT_SUPPRESS_UNUSED(argv);
#endif /* !PANTHEIOS_USE_WIDE_STRINGS */


  // This goes to console and debugger
  pantheios::log(pantheios::notice(beid_Syslog), PSTR("Isn't targeted multiplexing great?!"));

  return EXIT_SUCCESS;
}
Beispiel #14
0
PANTHEIOS_CALL(int) pantheios_be_null_logEntry(
    void*               feToken
,   void*               beToken
,   int                 severity
,   pan_char_t const*   entry
,   size_t              cchEntry
)
{
    STLSOFT_SUPPRESS_UNUSED(feToken);
    STLSOFT_SUPPRESS_UNUSED(beToken);
    STLSOFT_SUPPRESS_UNUSED(severity);
    STLSOFT_SUPPRESS_UNUSED(entry);

    return (int)cchEntry;
}
Beispiel #15
0
void MatchEnd::setNext(Match *next)
{
    SHWILD_ASSERT(NULL == next);
    SHWILD_MESSAGE_ASSERT("WildEnd must always be the end", 0);

    STLSOFT_SUPPRESS_UNUSED(next);
}
Beispiel #16
0
PANTHEIOS_CALL(void) pantheios_fe_uninit(
    void* token
)
{
    PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_API(NULL == token, "token must be null");
    STLSOFT_SUPPRESS_UNUSED(token);
}
Beispiel #17
0
PANTHEIOS_CALL(int) pantheios_fe_isSeverityLogged(
    void*   token
,   int     severity
,   int     backEndId
)
{
    PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_API(NULL == token, "token must be null");
    /* PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_STATE_API(!pantheios_isInitialising(), "This cannot be called when Pantheios is initialising"); */
    /* PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_STATE_API(pantheios_isInitialised(), "This can only be called when Pantheios is initialised"); */

    STLSOFT_SUPPRESS_UNUSED(token);
    STLSOFT_SUPPRESS_UNUSED(severity);
    STLSOFT_SUPPRESS_UNUSED(backEndId);

    return (severity & 0x0f) <= pantheios_fe_severity_ceiling_;
}
Beispiel #18
0
    /// Unfortunately, something in this technique scares the Borland compilers (5.5
    /// and 5.51) into Internal compiler errors so the s_init variable in
    /// get_systeminfo_() is int rather than bool when compiling for borland.
    static SYSTEM_INFO const& get_systeminfo_()
    {
#if defined(STLSOFT_COMPILER_IS_MSVC) && \
    _MSC_VER >= 1310
  // Safe to suppress these warnings, because race-conditions are benign here
# pragma warning(push)
# pragma warning(disable : 4640)
#endif /* compiler */

        static SYSTEM_INFO  s_systeminfo;
#ifdef STLSOFT_COMPILER_IS_BORLAND
        /* WSCB: Borland has an internal compiler error if use ws_bool_t */
        static ws_int_t     s_init = (::GetSystemInfo(&s_systeminfo), ws_true_v);
#else /* ? compiler */
        static ws_bool_t    s_init = (::GetSystemInfo(&s_systeminfo), ws_true_v);
#endif /* compiler */

        STLSOFT_SUPPRESS_UNUSED(s_init);

        return s_systeminfo;

#if defined(STLSOFT_COMPILER_IS_MSVC) && \
    _MSC_VER >= 1310
# pragma warning(pop)
#endif /* compiler */
    }
PANTHEIOS_CALL(void) pantheios_fe_uninit(void* token)
{
    STLSOFT_SUPPRESS_UNUSED(token);

    if(0 == s_feInitValue)
    {
        XTESTS_FAIL_WITH_QUALIFIER("front-end uninitialisation failed", "front-end has not yet been initialised");
    }
    else if(0 == s_beInitValue)
    {
        XTESTS_FAIL_WITH_QUALIFIER("front-end uninitialisation failed", "back-end has not yet been initialised");
    }
    else if(1 == s_beInitValue)
    {
        XTESTS_FAIL_WITH_QUALIFIER("front-end uninitialisation failed", "back-end has not yet been uninitialised");
    }
    else if(2 != s_beInitValue)
    {
        XTESTS_FAIL_WITH_QUALIFIER("front-end uninitialisation failed", "back-end initialisation count suggests multiple initialisations");
    }
    else
    {
        ++s_feInitValue;
    }
}
Beispiel #20
0
inline /* static */ OSVERSIONINFO &system_version::get_versioninfo_()
{
    /// Unfortunately, something in this technique scares the Borland compilers (5.5
    /// and 5.51) into Internal compiler errors so the s_init variable in
    /// get_versioninfo_() is int rather than bool when compiling for borland.

#if !defined(STLSOFT_STRICT) && \
    defined(STLSOFT_COMPILER_IS_MSVC) && \
    _MSC_VER >= 1310
# pragma warning(push)
# pragma warning(disable : 4640)   /* "construction of local static object is not thread-safe" - since it is here! (As long as one uses a 'conformant' allocator) - maybe use a spin_mutex in future */
#endif /* compiler */

    static OSVERSIONINFO    s_versioninfo;
#if defined(STLSOFT_COMPILER_IS_BORLAND)
    /* WSCB: Borland has an internal compiler error if use ws_bool_t */
    static ws_int_t         s_init = (s_versioninfo.dwOSVersionInfoSize = sizeof(s_versioninfo), ::GetVersionEx(&s_versioninfo), ws_true_v);
#else /* ? compiler */
    static ws_bool_t        s_init = (s_versioninfo.dwOSVersionInfoSize = sizeof(s_versioninfo), ::GetVersionEx(&s_versioninfo), ws_true_v);
#endif /* compiler */

#if !defined(STLSOFT_STRICT) && \
    defined(STLSOFT_COMPILER_IS_MSVC) && \
    _MSC_VER >= 1310
# pragma warning(pop)
#endif /* compiler */

    STLSOFT_SUPPRESS_UNUSED(s_init); // Placate GCC

    return s_versioninfo;
}
Beispiel #21
0
int main(int argc, char **argv)
{
  try
  {
#ifndef PANTHEIOS_USE_WIDE_STRINGS
    pantheios::log_DEBUG("main(", pantheios::args(argc, argv), ")");
#else /* ? !PANTHEIOS_USE_WIDE_STRINGS */
    STLSOFT_SUPPRESS_UNUSED(argc); STLSOFT_SUPPRESS_UNUSED(argv);
#endif /* !PANTHEIOS_USE_WIDE_STRINGS */

    pantheios::log_NOTICE(PSTR("stmt 1"));

    // Set the file name for the local back-end, truncating the
    // file's existing contents, if any.
    pantheios_be_file_setFilePath(PSTR("log.local"), PANTHEIOS_BE_FILE_F_TRUNCATE, PANTHEIOS_BE_FILE_F_TRUNCATE, PANTHEIOS_BEID_LOCAL);

    pantheios::log_NOTICE(PSTR("stmt 2"));

    // Set the file name for the remote back-end.
    pantheios_be_file_setFilePath(PSTR("log.remote"), PANTHEIOS_BEID_REMOTE);

    pantheios::log_NOTICE(PSTR("stmt 3"));

    // Set the file name for all back-ends.
    pantheios_be_file_setFilePath(PSTR("log.all"));

    pantheios::log_NOTICE(PSTR("stmt 4"));

    pantheios::log_DEBUG(PSTR("exiting main()"));

    return EXIT_SUCCESS;
  }
  catch(std::bad_alloc&)
  {
    pantheios::log(pantheios::alert, PSTR("out of memory"));
  }
  catch(std::exception& x)
  {
  pantheios::log_CRITICAL(PSTR("Exception: "), pantheios::exception(x));
  }
  catch(...)
  {
    pantheios::logputs(pantheios::emergency, PSTR("Unexpected unknown error"));
  }

  return EXIT_FAILURE;
}
inline bool truncation_test_helper_runtime_test_different_sign_FROM_is_signed(FROM from, no_type, TO)
{
#ifdef _DEBUG
# if defined(STLSOFT_COMPILER_IS_MSVC)
	int const flags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
	_CrtSetDbgFlag(flags & ~(_CRTDBG_ALLOC_MEM_DF));
# endif /* VC++ */

    char const* TO_     =   typeid(TO).name();
    char const* FROM_   =   typeid(FROM).name();

    STLSOFT_SUPPRESS_UNUSED(TO_);
    STLSOFT_SUPPRESS_UNUSED(FROM_);
# if defined(STLSOFT_COMPILER_IS_MSVC)
	_CrtSetDbgFlag(flags);
# endif /* VC++ */
#endif /* _DEBUG */

    enum {  TO_is_signed            =   is_signed_type<TO>::value                   };
    enum {  FROM_is_signed          =   is_signed_type<FROM>::value                 };

    const ss_size_t sizeofFROM  =   sizeof(FROM);
    const ss_size_t sizeofTO    =   sizeof(TO);

    STLSOFT_SUPPRESS_UNUSED(sizeofFROM);
    STLSOFT_SUPPRESS_UNUSED(sizeofTO);

    STLSOFT_STATIC_ASSERT((0 == int(TO_is_signed)) != (0 == int(FROM_is_signed)));
    STLSOFT_STATIC_ASSERT(0 == int(FROM_is_signed));
    STLSOFT_STATIC_ASSERT(0 != int(TO_is_signed));

    // FROM is unsigned
    // TO is signed
    //
    // Truncation occurs if from > toMax

    FROM    toMax   =   static_cast<FROM>(limit_traits<TO>::maximum());

    if(from > toMax)
    {
        return false;
    }
    else
    {
        return true;
    }
}
static int teardown(void* param)
{
	STLSOFT_SUPPRESS_UNUSED(param);

	cstring_destroy(&string);

	return 0; /* Currently ignored by xTests */
}
static int pantheios_be_WindowsDebugger_init_(
    pan_char_t const*                       processIdentity
    ,   int                                     backEndId
    ,   pan_be_WindowsDebugger_init_t const*    init
    ,   void*                                   reserved
    ,   void**                                  ptoken
)
{
    PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_API(NULL != processIdentity, "process identity may not be the null string");
    PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_API('\0' != 0[processIdentity], "process identity may not be the empty string");
    STLSOFT_SUPPRESS_UNUSED(reserved);
    PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_API(NULL != ptoken, "token pointer may not be null");

    /* (i) apply Null Object (Variable) pattern */

    pan_be_WindowsDebugger_init_t init_;

    if(NULL == init)
    {
        pantheios_be_WindowsDebugger_getDefaultAppInit(&init_);

        init = &init_;

#ifdef PANTHEIOS_BE_USE_CALLBACK
        pantheios_be_WindowsDebugger_getAppInit(backEndId, &init_);
#endif /* PANTHEIOS_BE_USE_CALLBACK */
    }

    /* (ii) verify the version */

    if(init->version < 0x010001b8)
    {
        return PANTHEIOS_BE_INIT_RC_OLD_VERSION_NOT_SUPPORTED;
    }
    else if(init->version > PANTHEIOS_VER)
    {
        return PANTHEIOS_BE_INIT_RC_FUTURE_VERSION_REQUESTED;
    }

    /* (iii) create the context */

    WindowsDebugger_Context* ctxt = new WindowsDebugger_Context(processIdentity, backEndId, init);

#ifndef STLSOFT_CF_THROW_BAD_ALLOC
    if( NULL == ctxt ||
            NULL == ctxt->getProcessIdentity())
    {
        delete ctxt;

        return PANTHEIOS_INIT_RC_OUT_OF_MEMORY;
    }
#endif /* !STLSOFT_CF_THROW_BAD_ALLOC */

    *ptoken = ctxt;

    return 0;
}
    bool truncation_test(FROM from, TO dummy = TO())
    {
#ifdef _DEBUG
        char const  *TO_    =   typeid(TO).name();
        char const  *FROM_  =   typeid(FROM).name();

        STLSOFT_SUPPRESS_UNUSED(TO_);
        STLSOFT_SUPPRESS_UNUSED(FROM_);
#endif /* _DEBUG */

#if 0
        return truncation_test_v1<TO, FROM>(from, dummy);
#elif 0
        return truncation_test_v2<TO, FROM>(from, dummy);
#elif 1
        return truncation_test_v3<TO, FROM>(from, dummy);
#endif /* 0 */
    }
Beispiel #26
0
PANTHEIOS_CALL(int) pantheios_be_null_init(
    pan_char_t const*   processIdentity
,   int                 id
,   void*               unused
,   void*               reserved
,   void**              ptoken
)
{
    STLSOFT_SUPPRESS_UNUSED(processIdentity);
    STLSOFT_SUPPRESS_UNUSED(id);
    STLSOFT_SUPPRESS_UNUSED(unused);
    STLSOFT_SUPPRESS_UNUSED(reserved);

    PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_API(NULL != ptoken, "token pointer may not be null");

    *ptoken = NULL;

    return 0;
}
inline bool truncation_test_helper_runtime_test_same_sign(FROM from, yes_type, TO) // The use of the dummy variable is to fix a bug with VC++ 5-7.0
{
#ifdef STLSOFT_DEBUG
# if defined(STLSOFT_COMPILER_IS_MSVC)
    int const flags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
    _CrtSetDbgFlag(flags & ~(_CRTDBG_ALLOC_MEM_DF));
# endif /* VC++ */

    char const* TO_     =   typeid(TO).name();
    char const* FROM_   =   typeid(FROM).name();

    STLSOFT_SUPPRESS_UNUSED(TO_);
    STLSOFT_SUPPRESS_UNUSED(FROM_);
# if defined(STLSOFT_COMPILER_IS_MSVC)
    _CrtSetDbgFlag(flags);
# endif /* VC++ */
#endif /* STLSOFT_DEBUG */

    const ss_size_t sizeofFROM  =   sizeof(FROM);
    const ss_size_t sizeofTO    =   sizeof(TO);

    STLSOFT_STATIC_ASSERT(sizeofTO < sizeofFROM);
    STLSOFT_SUPPRESS_UNUSED(sizeofTO);
    STLSOFT_SUPPRESS_UNUSED(sizeofFROM);

    // This is a fully runtime test: does FROM fit into TO's limits?
    //
    // To do this we elicit TO's min and max. The values are held in
    // FROM, which involves no truncation because sizeof(FROM) > sizeof(TO)

    FROM    toMax   =   static_cast<FROM>(limit_traits<TO>::maximum());
    FROM    toMin   =   static_cast<FROM>(limit_traits<TO>::minimum());

    if( from < toMin ||
        from > toMax)
    {
        return false;
    }
    else
    {
        return true;
    }
}
static int pantheios_be_WindowsEventLog_init_(
    pan_char_t const*   processIdentity
,   int                 id
,   void const*         unused
,   void*               reserved
,   void**              ptoken
)
{
    PANTHEIOS_CONTRACT_ENFORCE_PRECONDITION_PARAMS_API(NULL != processIdentity, "process identity may not be NULL");

    STLSOFT_SUPPRESS_UNUSED(unused);
    STLSOFT_SUPPRESS_UNUSED(reserved);

    // (iii) create the context

    WindowsEventLog_Context* ctxt   =   new WindowsEventLog_Context(id);

#ifndef STLSOFT_CF_THROW_BAD_ALLOC
    if(NULL == ctxt)
    {
        delete ctxt;

        return PANTHEIOS_INIT_RC_OUT_OF_MEMORY;
    }
    else
#endif /* !STLSOFT_CF_THROW_BAD_ALLOC */
    {
        int res =   ctxt->Register(processIdentity);

        if(0 != res)
        {
            delete ctxt;

            return res;
        }
    }

    *ptoken = ctxt;

    return 0;
}
Beispiel #29
0
/** Writes a number of slices into a character array that must have
 * sufficient space.
 *
 * \param cchBuff The number of characters in the array pointed to by the
 *   <code>buff</code> parameter
 * \param buff A pointer to an array that has sufficient space to hold all
 *  the elements
 * \param numResults The number of entries in the array pointed to by the
 *   <code>results</code> parameter
 * \param results Pointer to an array of \link fastformat::ff_string_slice_t string_slice_t\endlink elements to be
 *   written into <code>buff</code>.
 */
inline size_t concat_slices(size_t cchBuff, ff_char_t* buff, size_t numResults, ff_string_slice_t const* results)
{
    STLSOFT_SUPPRESS_UNUSED(cchBuff);

    ff_char_t*  p       =   &buff[0];
    size_t      total   =   0;

    { for(size_t i = 0; i != numResults; ++i, ++results)
    {
        FASTFORMAT_CONTRACT_ENFORCE_PRECONDITION_STATE_INTERNAL(total + results->len <= cchBuff, "insufficient space in buffer to write the results");

        STLSOFT_SUPPRESS_UNUSED(total);

        ::memcpy(p, results->ptr, results->len * sizeof(ff_char_t));

        p       +=  results->len;
        total   +=  results->len;
    }}

    return total;
}
ff_illformed_handler_info_t ximpl_core::fastformat_impl_handlers_getIllformedDefaultHandler(void* token)
{
    FASTFORMAT_COVER_MARK_ENTRY();

    FASTFORMAT_CONTRACT_ENFORCE_PRECONDITION_PARAMS_INTERNAL(NULL != token, "token must not be null");
    STLSOFT_SUPPRESS_UNUSED(token);

    ff_illformed_handler_info_t r;

    r.param     =   NULL;

#ifdef STLSOFT_CF_EXCEPTION_SUPPORT
    r.handler   =   fastformat_stock_illformedHandler_throw;

    STLSOFT_SUPPRESS_UNUSED(fastformat_stock_illformedHandler_ignore);
#else /* ? STLSOFT_CF_EXCEPTION_SUPPORT */
    r.handler   =   fastformat_stock_illformedHandler_ignore;

    STLSOFT_SUPPRESS_UNUSED(fastformat_stock_illformedHandler_throw);
#endif /* STLSOFT_CF_EXCEPTION_SUPPORT */

    return r;
}