VirtualBox

source: vbox/trunk/src/VBox/Runtime/win/errmsgwin.cpp@ 5938

Last change on this file since 5938 was 4071, checked in by vboxsync, 17 years ago

Biggest check-in ever. New source code headers for all (C) innotek files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1/* $Id: errmsgwin.cpp 4071 2007-08-07 17:07:59Z 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
18/*******************************************************************************
19* Header Files *
20*******************************************************************************/
21#include <windows.h>
22
23#include <iprt/err.h>
24#include <iprt/asm.h>
25#include <iprt/string.h>
26#include <iprt/err.h>
27#include <VBox/err.h>
28
29
30/*******************************************************************************
31* Global Variables *
32*******************************************************************************/
33/** Array of messages.
34 * The data is generated by a sed script.
35 */
36static const RTWINERRMSG g_aStatusMsgs[] =
37{
38#include "errmsgcomdata.h"
39 { NULL, NULL, 0 }
40};
41
42
43/** Temporary buffers to format unknown messages in.
44 * @{
45 */
46static char g_aszUnknownStr[4][64];
47static RTWINERRMSG g_aUnknownMsgs[4] =
48{
49 { &g_aszUnknownStr[0][0], &g_aszUnknownStr[0][0], 0 },
50 { &g_aszUnknownStr[1][0], &g_aszUnknownStr[1][0], 0 },
51 { &g_aszUnknownStr[2][0], &g_aszUnknownStr[2][0], 0 },
52 { &g_aszUnknownStr[3][0], &g_aszUnknownStr[3][0], 0 }
53};
54/** Last used index in g_aUnknownMsgs. */
55static volatile uint32_t g_iUnknownMsgs;
56/** @} */
57
58
59/**
60 * Get the message corresponding to a given status code.
61 *
62 * @returns Pointer to read-only message description.
63 * @param rc The status code.
64 */
65RTDECL(PCRTWINERRMSG) RTErrWinGet(long rc)
66{
67 unsigned i;
68 for (i = 0; i < ELEMENTS(g_aStatusMsgs); i++)
69 {
70 if (g_aStatusMsgs[i].iCode == rc)
71 {
72 return &g_aStatusMsgs[i];
73 }
74 }
75
76 /*
77 * Need to use the temporary stuff.
78 */
79 int iMsg = ASMAtomicXchgU32(&g_iUnknownMsgs, (g_iUnknownMsgs + 1) % ELEMENTS(g_aUnknownMsgs));
80 RTStrPrintf(&g_aszUnknownStr[iMsg][0], sizeof(g_aszUnknownStr[iMsg]), "Unknown Status 0x%X\n", rc);
81 return &g_aUnknownMsgs[iMsg];
82}
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