VirtualBox

source: kBuild/trunk/src/kmk/w32/subproc/w32err.c@ 1101

Last change on this file since 1101 was 503, checked in by bird, 18 years ago

Untested merge with GNU Make v3.81 (vendor/gnumake/2005-05-16 -> vendor/gnumake/current).

  • Property svn:eol-style set to native
File size: 2.1 KB
Line 
1/* Error handling for Windows
2Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
32006 Free Software Foundation, Inc.
4This file is part of GNU Make.
5
6GNU Make is free software; you can redistribute it and/or modify it under the
7terms of the GNU General Public License as published by the Free Software
8Foundation; either version 2, or (at your option) any later version.
9
10GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
11WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License along with
15GNU Make; see the file COPYING. If not, write to the Free Software
16Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */
17
18#include <windows.h>
19#include "w32err.h"
20
21/*
22 * Description: the windows32 version of perror()
23 *
24 * Returns: a pointer to a static error
25 *
26 * Notes/Dependencies: I got this from
27 * comp.os.ms-windows.programmer.win32
28 */
29char *
30map_windows32_error_to_string (DWORD ercode) {
31/* __declspec (thread) necessary if you will use multiple threads on MSVC */
32#ifdef _MSC_VER
33__declspec (thread) static char szMessageBuffer[128];
34#else
35static char szMessageBuffer[128];
36#endif
37 /* Fill message buffer with a default message in
38 * case FormatMessage fails
39 */
40 wsprintf (szMessageBuffer, "Error %ld\n", ercode);
41
42 /*
43 * Special code for winsock error handling.
44 */
45 if (ercode > WSABASEERR) {
46 HMODULE hModule = GetModuleHandle("wsock32");
47 if (hModule != NULL) {
48 FormatMessage(FORMAT_MESSAGE_FROM_HMODULE,
49 hModule,
50 ercode,
51 LANG_NEUTRAL,
52 szMessageBuffer,
53 sizeof(szMessageBuffer),
54 NULL);
55 FreeLibrary(hModule);
56 }
57 } else {
58 /*
59 * Default system message handling
60 */
61 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
62 NULL,
63 ercode,
64 LANG_NEUTRAL,
65 szMessageBuffer,
66 sizeof(szMessageBuffer),
67 NULL);
68 }
69 return szMessageBuffer;
70}
71
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette