VirtualBox

source: kBuild/vendor/gnumake/3.82/w32/subproc/w32err.c@ 2579

Last change on this file since 2579 was 2579, checked in by bird, 13 years ago

Importing make-3.82.tar.bz2 (md5sum 1a11100f3c63fcf5753818e59d63088f) with --auto-props but no keywords.

  • Property svn:eol-style set to native
File size: 2.0 KB
Line 
1/* Error handling for Windows
2Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
32006, 2007, 2008, 2009, 2010 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 3 of the License, or (at your option) any later
9version.
10
11GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License along with
16this program. If not, see <http://www.gnu.org/licenses/>. */
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}
Note: See TracBrowser for help on using the repository browser.

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