comparison common/logging.c @ 252:bd7fb50078b4

Add logging.h for some logging / debug functions The stuff from debug.h is now in logging.h
author Andre Heinecke <aheinecke@intevation.de>
date Tue, 01 Apr 2014 10:49:40 +0000
parents
children 17e1c8f37d72
comparison
equal deleted inserted replaced
251:c596568fa45b 252:bd7fb50078b4
1 #include "logging.h"
2 #include "strhelp.h"
3
4 #include <stdio.h>
5
6 #ifdef WIN32
7 char *
8 getLastErrorMsg()
9 {
10 LPWSTR bufPtr = NULL;
11 DWORD err = GetLastError();
12 char *retval = NULL;
13 FormatMessageW (FORMAT_MESSAGE_ALLOCATE_BUFFER |
14 FORMAT_MESSAGE_FROM_SYSTEM |
15 FORMAT_MESSAGE_IGNORE_INSERTS,
16 NULL, err, 0, (LPWSTR) &bufPtr, 0, NULL);
17 if (!bufPtr)
18 {
19 HMODULE hWinhttp = GetModuleHandleW (L"crypt32");
20 if (hWinhttp)
21 {
22 FormatMessageW (FORMAT_MESSAGE_ALLOCATE_BUFFER |
23 FORMAT_MESSAGE_FROM_HMODULE |
24 FORMAT_MESSAGE_IGNORE_INSERTS,
25 hWinhttp, HRESULT_CODE (err), 0,
26 (LPWSTR) &bufPtr, 0, NULL);
27 }
28 }
29 if (!bufPtr) {
30 fprintf (stderr, "Error getting last error for code: %lx \n", err);
31 return NULL;
32 }
33
34 retval = wchar_to_utf8(bufPtr, wcslen(bufPtr));
35 LocalFree (bufPtr);
36
37 return retval;
38 }
39
40 #endif

http://wald.intevation.org/projects/trustbridge/