VirtualBox

source: vbox/trunk/src/VBox/Runtime/win32/errmsgwin.cpp@ 4014

Last change on this file since 4014 was 2981, checked in by vboxsync, 17 years ago

InnoTek -> innotek: all the headers and comments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.7 KB
Line 
1/* $Id: errmsgwin.cpp 2981 2007-06-01 16:01:28Z vboxsync $ */
2/** @file
3 * innotek Portable Runtime - Status code messages.
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22/*******************************************************************************
23* Header Files *
24*******************************************************************************/
25#include <windows.h>
26
27#include <iprt/err.h>
28#include <iprt/asm.h>
29#include <iprt/string.h>
30#include <iprt/err.h>
31#include <VBox/err.h>
32
33
34/*******************************************************************************
35* Global Variables *
36*******************************************************************************/
37/** Array of messages.
38 * The data is generated by a sed script.
39 */
40static const RTWINERRMSG g_aStatusMsgs[] =
41{
42#include "errmsgcomdata.h"
43 { NULL, NULL, 0 }
44};
45
46
47/** Temporary buffers to format unknown messages in.
48 * @{
49 */
50static char g_aszUnknownStr[4][64];
51static RTWINERRMSG g_aUnknownMsgs[4] =
52{
53 { &g_aszUnknownStr[0][0], &g_aszUnknownStr[0][0], 0 },
54 { &g_aszUnknownStr[1][0], &g_aszUnknownStr[1][0], 0 },
55 { &g_aszUnknownStr[2][0], &g_aszUnknownStr[2][0], 0 },
56 { &g_aszUnknownStr[3][0], &g_aszUnknownStr[3][0], 0 }
57};
58/** Last used index in g_aUnknownMsgs. */
59static volatile uint32_t g_iUnknownMsgs;
60/** @} */
61
62
63/**
64 * Get the message corresponding to a given status code.
65 *
66 * @returns Pointer to read-only message description.
67 * @param rc The status code.
68 */
69RTDECL(PCRTWINERRMSG) RTErrWinGet(long rc)
70{
71 unsigned i;
72 for (i = 0; i < ELEMENTS(g_aStatusMsgs); i++)
73 {
74 if (g_aStatusMsgs[i].iCode == rc)
75 {
76 return &g_aStatusMsgs[i];
77 }
78 }
79
80 /*
81 * Need to use the temporary stuff.
82 */
83 int iMsg = ASMAtomicXchgU32(&g_iUnknownMsgs, (g_iUnknownMsgs + 1) % ELEMENTS(g_aUnknownMsgs));
84 RTStrPrintf(&g_aszUnknownStr[iMsg][0], sizeof(g_aszUnknownStr[iMsg]), "Unknown Status 0x%X\n", rc);
85 return &g_aUnknownMsgs[iMsg];
86}
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