From 58613ba2100154117afdffe63853bbb95a2901da Mon Sep 17 00:00:00 2001 From: Szymon Tokarz Date: Sun, 19 Jun 2016 00:50:49 +0000 Subject: Gadu-Gadu protocol Fix strerror related loging - GG\libgadu code uses ansi logging (enabled only in debug mode) - use: as_strerror(errno) to properly override strerror(errno) - use properly strerror, _tcserror, as_strerror, ws_strerror in GG code git-svn-id: http://svn.miranda-ng.org/main/trunk@17008 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Gadu-Gadu/src/gg.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'protocols/Gadu-Gadu/src/gg.cpp') diff --git a/protocols/Gadu-Gadu/src/gg.cpp b/protocols/Gadu-Gadu/src/gg.cpp index e218ad8cde..feb65aa5d9 100644 --- a/protocols/Gadu-Gadu/src/gg.cpp +++ b/protocols/Gadu-Gadu/src/gg.cpp @@ -75,6 +75,26 @@ TCHAR* ws_strerror(int code) return _tcserror(code); } +char* as_strerror(int code) +{ + static char err_desc[160]; + + // Not a windows error display WinSock + if (code == 0) + { + char buff[128]; + int len = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, WSAGetLastError(), 0, buff, _countof(buff), NULL); + if (len == 0) + mir_snprintf(err_desc, "WinSock %u: Unknown error.", WSAGetLastError()); + else + mir_snprintf(err_desc, "WinSock %d: %s", WSAGetLastError(), buff); + return err_desc; + } + + // Return normal error + return strerror(code); +} + ////////////////////////////////////////////////////////// // Build the crc table void crc_gentable(void) -- cgit v1.2.3