static void log_openssl_error (const char * file, int line) { const unsigned long error_code = ERR_get_error (); if (tr_logLevelIsActive (TR_LOG_ERROR)) { char buf[512]; #ifndef TR_LIGHTWEIGHT static bool strings_loaded = false; if (!strings_loaded) { #if OPENSSL_VERSION_NUMBER < 0x10100000 ERR_load_crypto_strings (); #else OPENSSL_init_crypto (OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL); #endif strings_loaded = true; } #endif ERR_error_string_n (error_code, buf, sizeof (buf)); tr_logAddMessage (file, line, TR_LOG_ERROR, MY_NAME, "OpenSSL error: %s", buf); } }
static void do_log_system_error (const char * file, int line, tr_log_level level, DWORD code, const char * message) { char * const system_message = tr_win32_format_message (code); tr_logAddMessage (file, line, level, "[dtr_daemon] %s (0x%08lx): %s", message, code, system_message); tr_free (system_message); }
static void log_cyassl_error(int error_code, char const* file, int line) { if (tr_logLevelIsActive(TR_LOG_ERROR)) { #if API_VERSION_HEX >= 0x03004000 char const* error_message = API(GetErrorString)(error_code); #elif API_VERSION_HEX >= 0x03000002 char const* error_message = CTaoCryptGetErrorString(error_code); #else char error_message[CYASSL_MAX_ERROR_SZ]; CTaoCryptErrorString(error_code, error_message); #endif tr_logAddMessage(file, line, TR_LOG_ERROR, MY_NAME, "CyaSSL error: %s", error_message); } }
static void log_polarssl_error(int error_code, char const* file, int line) { if (tr_logLevelIsActive(TR_LOG_ERROR)) { char error_message[256]; #if defined(POLARSSL_IS_MBEDTLS) mbedtls_strerror(error_code, error_message, sizeof(error_message)); #elif API_VERSION_NUMBER >= 0x01030000 polarssl_strerror(error_code, error_message, sizeof(error_message)); #else error_strerror(error_code, error_message, sizeof(error_message)); #endif tr_logAddMessage(file, line, TR_LOG_ERROR, MY_NAME, "PolarSSL error: %s", error_message); } }
static void log_openssl_error (const char * file, int line) { const unsigned long error_code = ERR_get_error (); if (tr_logLevelIsActive (TR_LOG_ERROR)) { char buf[512]; #ifndef TR_LIGHTWEIGHT static bool strings_loaded = false; if (!strings_loaded) { ERR_load_crypto_strings (); strings_loaded = true; } #endif ERR_error_string_n (error_code, buf, sizeof (buf)); tr_logAddMessage (file, line, TR_LOG_ERROR, MY_NAME, "OpenSSL error: %s", buf); } }