~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/3rdparty/qmake/w32/subproc/w32err.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <windows.h>
 
2
#include "w32err.h"
 
3
 
 
4
/*
 
5
 * Description: the windows32 version of perror()
 
6
 *
 
7
 * Returns:  a pointer to a static error
 
8
 *
 
9
 * Notes/Dependencies:  I got this from 
 
10
 *      comp.os.ms-windows.programmer.win32
 
11
 */
 
12
char * 
 
13
map_windows32_error_to_string (DWORD ercode) {
 
14
/* __declspec (thread) necessary if you will use multiple threads */
 
15
__declspec (thread) static char szMessageBuffer[128];
 
16
 
 
17
        /* Fill message buffer with a default message in 
 
18
         * case FormatMessage fails 
 
19
         */
 
20
    wsprintf (szMessageBuffer, "Error %ld", ercode);
 
21
 
 
22
        /*
 
23
         *  Special code for winsock error handling.
 
24
         */
 
25
        if (ercode > WSABASEERR) {
 
26
                HMODULE hModule = GetModuleHandle("wsock32");
 
27
                if (hModule != NULL) {
 
28
                        FormatMessage(FORMAT_MESSAGE_FROM_HMODULE,
 
29
                                hModule,
 
30
                                ercode,
 
31
                                LANG_NEUTRAL,
 
32
                                szMessageBuffer,
 
33
                                sizeof(szMessageBuffer),
 
34
                                NULL);
 
35
                        FreeLibrary(hModule);
 
36
                } 
 
37
        } else {
 
38
                /*
 
39
                 *  Default system message handling
 
40
                 */
 
41
        FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
 
42
                  NULL,
 
43
                  ercode,
 
44
                  LANG_NEUTRAL,
 
45
                  szMessageBuffer,
 
46
                  sizeof(szMessageBuffer),
 
47
                  NULL);
 
48
        }
 
49
    return szMessageBuffer;
 
50
}
 
51