From 6d932bfaf11e4699355fedc45e28b353b8877130 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 18 Sep 2014 21:52:10 +0000 Subject: merge into trunk git-svn-id: http://svn.miranda-ng.org/main/trunk@10515 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/WhatsApp/src/utils.cpp | 86 +--------------------------------------- 1 file changed, 2 insertions(+), 84 deletions(-) (limited to 'protocols/WhatsApp/src/utils.cpp') diff --git a/protocols/WhatsApp/src/utils.cpp b/protocols/WhatsApp/src/utils.cpp index 9559fb3372..35d3ceb3a6 100644 --- a/protocols/WhatsApp/src/utils.cpp +++ b/protocols/WhatsApp/src/utils.cpp @@ -1,55 +1,5 @@ #include "common.h" -void UnixTimeToFileTime(time_t t, LPFILETIME pft) -{ - // Note that LONGLONG is a 64-bit value - LONGLONG ll; - - ll = Int32x32To64(t, 10000000) + 116444736000000000; - pft->dwLowDateTime = (DWORD)ll; - pft->dwHighDateTime = ll >> 32; -} - -DWORD utils::conversion::to_timestamp(std::string data) -{ - DWORD timestamp = NULL; - /* - if (!utils::conversion::from_string(timestamp, data, std::dec)) { - timestamp = static_cast(::time(NULL)); - } - */ - return timestamp; -} - -std::string utils::text::source_get_value(std::string* data, unsigned int argument_count, ...) -{ - va_list arg; - std::string ret; - std::string::size_type start = 0, end = 0; - - va_start(arg, argument_count); - - for (unsigned int i = argument_count; i > 0; i--) - { - if (i == 1) - { - end = data->find(va_arg(arg, char*), start); - if (start == std::string::npos || end == std::string::npos) - break; - ret = data->substr(start, end - start); - } else { - std::string term = va_arg(arg, char*); - start = data->find(term, start); - if (start == std::string::npos) - break; - start += term.length(); - } - } - - va_end(arg); - return ret; -} - std::string getLastErrorMsg() { // Retrieve the system error message for the last-error code @@ -67,43 +17,11 @@ std::string getLastErrorMsg() (LPSTR) &lpMsgBuf, 0, NULL ); - // Display the error message and exit the process - /* - lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT, - (lstrlen((LPCTSTR)lpMsgBuf) + lstrlen((LPCTSTR)lpszFunction) + 40) * sizeof(TCHAR)); - StringCchPrintf((LPTSTR)lpDisplayBuf, - LocalSize(lpDisplayBuf) / sizeof(TCHAR), - TEXT("%s"), - lpMsgBuf); - */ - std::string ret((LPSTR) lpMsgBuf); LocalFree(lpMsgBuf); - //LocalFree(lpDisplayBuf); - - //return std::string((LPCTSTR)lpDisplayBuf); return ret; } -int utils::debug::log(std::string file_name, std::string text) -{ - char szFile[MAX_PATH]; - GetModuleFileNameA(g_hInstance, szFile, SIZEOF(szFile)); - std::string path = szFile; - path = path.substr(0, path.rfind("\\")); - path = path.substr(0, path.rfind("\\") + 1); - path = path + file_name.c_str() + ".txt"; - - SYSTEMTIME time; - GetLocalTime(&time); - - std::ofstream out(path.c_str(), std::ios_base::out | std::ios_base::app | std::ios_base::ate); - out << "[" << (time.wHour < 10 ? "0" : "") << time.wHour << ":" << (time.wMinute < 10 ? "0" : "") << time.wMinute << ":" << (time.wSecond < 10 ? "0" : "") << time.wSecond << "] " << text << std::endl; - out.close(); - - return EXIT_SUCCESS; -} - BYTE* utils::md5string(const BYTE *data, int size, BYTE *digest) { mir_md5_state_t md5_state; @@ -118,10 +36,10 @@ BYTE* utils::md5string(const BYTE *data, int size, BYTE *digest) std::string base64_encode(void* pData, size_t len) { - return (char*)ptrA( mir_base64_encode((BYTE*)pData, (unsigned)len)); + return (char*)ptrA(mir_base64_encode((BYTE*)pData, (unsigned)len)); } -void md5_string(const std::string& data, BYTE digest[16]) +void md5_string(const std::string &data, BYTE digest[16]) { utils::md5string(data, digest); } -- cgit v1.2.3