VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/err/errmsgxpcom.cpp@ 96407

Last change on this file since 96407 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 10.9 KB
Line 
1/* $Id: errmsgxpcom.cpp 96407 2022-08-22 17:43:14Z vboxsync $ */
2/** @file
3 * IPRT - Status code messages for XPCOM.
4 */
5
6/*
7 * Copyright (C) 2006-2022 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37
38/*********************************************************************************************************************************
39* Header Files *
40*********************************************************************************************************************************/
41#include <iprt/errcore.h>
42#include "internal/iprt.h"
43
44#include <iprt/asm.h>
45#include <iprt/string.h>
46#include <iprt/errcore.h>
47
48
49/*********************************************************************************************************************************
50* Defined Constants And Macros *
51*********************************************************************************************************************************/
52typedef uint32_t VBOXSTATUSTYPE; /* used by errmsgvboxcomdata.h */
53
54
55/*********************************************************************************************************************************
56* Global Variables *
57*********************************************************************************************************************************/
58/** Array of messages.
59 * The data is generated by a sed script.
60 */
61static const RTCOMERRMSG g_aStatusMsgs[] =
62{
63#define MY_ERR(_def, _desc, _val) { _desc, _def, _val }
64
65 MY_ERR("NS_OK", "Success", UINT32_C(0x00000000)),
66 MY_ERR("NS_ERROR_NOT_IMPLEMENTED", "Not implemented", UINT32_C(0x80004001)),
67 MY_ERR("NS_ERROR_NO_INTERFACE", "Interface not supported", UINT32_C(0x80004002)),
68 MY_ERR("NS_ERROR_INVALID_POINTER", "Invalid pointer value", UINT32_C(0x80004003)),
69 MY_ERR("NS_ERROR_ABORT", "Operation aborted", UINT32_C(0x80004004)),
70 MY_ERR("NS_ERROR_FAILURE", "Operation failed", UINT32_C(0x80004005)),
71 MY_ERR("NS_ERROR_CALL_FAILED", "Call to remote object failed", UINT32_C(0x800706be)),
72 MY_ERR("NS_ERROR_UNEXPECTED", "Unexpected error", UINT32_C(0x8000ffff)),
73
74 MY_ERR("NS_ERROR_CANNOT_CONVERT_DATA", "Cannot convert data", UINT32_C(0x80010001)),
75 MY_ERR("NS_ERROR_OBJECT_IS_IMMUTABLE", "Object is immutable", UINT32_C(0x80010002)),
76 MY_ERR("NS_ERROR_LOSS_OF_SIGNIFICANT_DATA", "Loss of significant data", UINT32_C(0x80010003)),
77 MY_ERR("NS_ERROR_PROXY_INVALID_IN_PARAMETER", "Cannot proxy an IN parameter", UINT32_C(0x80010010)),
78 MY_ERR("NS_ERROR_PROXY_INVALID_OUT_PARAMETER", "Cannot proxy an OUT parameter", UINT32_C(0x80010011)),
79 MY_ERR("NS_SUCCESS_LOSS_OF_INSIGNIFICANT_DATA", "Loss of insignificant data", UINT32_C(0x00010001)),
80
81 MY_ERR("E_ACCESSDENIED", "Access denied", UINT32_C(0x80070005)), /* VirtualBox addition */
82 MY_ERR("NS_ERROR_OUT_OF_MEMORY", "Memory allocation failed", UINT32_C(0x8007000e)),
83 MY_ERR("NS_ERROR_INVALID_ARG", "Invalid argument value", UINT32_C(0x80070057)),
84
85 MY_ERR("NS_ERROR_NO_AGGREGATION", "Class does not allow aggregation", UINT32_C(0x80040110)),
86 MY_ERR("NS_ERROR_NOT_AVAILABLE", "Resource not available", UINT32_C(0x80040111)),
87 MY_ERR("NS_ERROR_FACTORY_NOT_REGISTERED", "Class not registered", UINT32_C(0x80040154)),
88 MY_ERR("NS_ERROR_FACTORY_REGISTER_AGAIN", "Cannot be registered, try again later", UINT32_C(0x80040155)),
89 MY_ERR("NS_ERROR_FACTORY_NOT_LOADED", "Dynamically loaded factory cannot be found", UINT32_C(0x800401f8)),
90 MY_ERR("NS_ERROR_FACTORY_EXISTS", "Factory already exists", UINT32_C(0xc1f30100)),
91 MY_ERR("NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT", "Factory does not support signatures", UINT32_C(0xc1f30101)),
92 MY_ERR("NS_ERROR_NOT_INITIALIZED", "Instance not initialized", UINT32_C(0xc1f30001)),
93 MY_ERR("NS_ERROR_ALREADY_INITIALIZED", "Instance already initialized", UINT32_C(0xc1f30002)),
94
95 MY_ERR("NS_BASE_STREAM_CLOSED", "Stream closed", UINT32_C(0x80470002)),
96 MY_ERR("NS_BASE_STREAM_OSERROR", "Operative system stream error", UINT32_C(0x80470003)),
97 MY_ERR("NS_BASE_STREAM_ILLEGAL_ARGS", "Illegal argument to stream method", UINT32_C(0x80470004)),
98 MY_ERR("NS_BASE_STREAM_NO_CONVERTER", "No stream converter", UINT32_C(0x80470005)),
99 MY_ERR("NS_BASE_STREAM_BAD_CONVERSION", "Badstream conversion", UINT32_C(0x80470006)),
100 MY_ERR("NS_BASE_STREAM_WOULD_BLOCK", "Stream operation would block", UINT32_C(0x80470007)),
101
102 MY_ERR("NS_ERROR_FILE_UNRECOGNIZED_PATH", "Unrecognized path", UINT32_C(0x80520001)),
103 MY_ERR("NS_ERROR_FILE_UNRESOLVABLE_SYMLINK", "NS_ERROR_FILE_UNRESOLVABLE_SYMLINK", UINT32_C(0x80520002)),
104 MY_ERR("NS_ERROR_FILE_EXECUTION_FAILED", "NS_ERROR_FILE_EXECUTION_FAILED", UINT32_C(0x80520003)),
105 MY_ERR("NS_ERROR_FILE_UNKNOWN_TYPE", "NS_ERROR_FILE_UNKNOWN_TYPE", UINT32_C(0x80520004)),
106 MY_ERR("NS_ERROR_FILE_DESTINATION_NOT_DIR", "NS_ERROR_FILE_DESTINATION_NOT_DIR", UINT32_C(0x80520005)),
107 MY_ERR("NS_ERROR_FILE_TARGET_DOES_NOT_EXIST", "NS_ERROR_FILE_TARGET_DOES_NOT_EXIST", UINT32_C(0x80520006)),
108 MY_ERR("NS_ERROR_FILE_COPY_OR_MOVE_FAILED", "NS_ERROR_FILE_COPY_OR_MOVE_FAILED", UINT32_C(0x80520007)),
109 MY_ERR("NS_ERROR_FILE_ALREADY_EXISTS", "NS_ERROR_FILE_ALREADY_EXISTS", UINT32_C(0x80520008)),
110 MY_ERR("NS_ERROR_FILE_INVALID_PATH", "NS_ERROR_FILE_INVALID_PATH", UINT32_C(0x80520009)),
111 MY_ERR("NS_ERROR_FILE_DISK_FULL", "NS_ERROR_FILE_DISK_FULL", UINT32_C(0x8052000a)),
112 MY_ERR("NS_ERROR_FILE_CORRUPTED", "NS_ERROR_FILE_CORRUPTED", UINT32_C(0x8052000b)),
113 MY_ERR("NS_ERROR_FILE_NOT_DIRECTORY", "NS_ERROR_FILE_NOT_DIRECTORY", UINT32_C(0x8052000c)),
114 MY_ERR("NS_ERROR_FILE_IS_DIRECTORY", "NS_ERROR_FILE_IS_DIRECTORY", UINT32_C(0x8052000d)),
115 MY_ERR("NS_ERROR_FILE_IS_LOCKED", "NS_ERROR_FILE_IS_LOCKED", UINT32_C(0x8052000e)),
116 MY_ERR("NS_ERROR_FILE_TOO_BIG", "NS_ERROR_FILE_TOO_BIG", UINT32_C(0x8052000f)),
117 MY_ERR("NS_ERROR_FILE_NO_DEVICE_SPACE", "NS_ERROR_FILE_NO_DEVICE_SPACE", UINT32_C(0x80520010)),
118 MY_ERR("NS_ERROR_FILE_NAME_TOO_LONG", "NS_ERROR_FILE_NAME_TOO_LONG", UINT32_C(0x80520011)),
119 MY_ERR("NS_ERROR_FILE_NOT_FOUND", "NS_ERROR_FILE_NOT_FOUND", UINT32_C(0x80520012)),
120 MY_ERR("NS_ERROR_FILE_READ_ONLY", "NS_ERROR_FILE_READ_ONLY", UINT32_C(0x80520013)),
121 MY_ERR("NS_ERROR_FILE_DIR_NOT_EMPTY", "NS_ERROR_FILE_DIR_NOT_EMPTY", UINT32_C(0x80520014)),
122 MY_ERR("NS_ERROR_FILE_ACCESS_DENIED", "NS_ERROR_FILE_ACCESS_DENIED", UINT32_C(0x80520015)),
123 MY_ERR("NS_SUCCESS_FILE_DIRECTORY_EMPTY", "NS_SUCCESS_FILE_DIRECTORY_EMPTY", UINT32_C(0x00520001)),
124 MY_ERR("NS_ERROR_SOCKET_FAIL", "IPC daemon socket error", UINT32_C(0xc1f30200)), /* new XPCOM error code */
125
126#if defined(VBOX) && !defined(IN_GUEST) && !defined(DOXYGEN_RUNNING)
127# include "errmsgvboxcomdata.h"
128#endif
129
130 { NULL, NULL, 0 }
131#undef MY_ERR
132};
133
134
135/** Temporary buffers to format unknown messages in.
136 * @{
137 */
138static char g_aszUnknownStr[8][64];
139static RTCOMERRMSG g_aUnknownMsgs[8] =
140{
141 { &g_aszUnknownStr[0][0], &g_aszUnknownStr[0][0], 0 },
142 { &g_aszUnknownStr[1][0], &g_aszUnknownStr[1][0], 0 },
143 { &g_aszUnknownStr[2][0], &g_aszUnknownStr[2][0], 0 },
144 { &g_aszUnknownStr[3][0], &g_aszUnknownStr[3][0], 0 },
145 { &g_aszUnknownStr[4][0], &g_aszUnknownStr[4][0], 0 },
146 { &g_aszUnknownStr[5][0], &g_aszUnknownStr[5][0], 0 },
147 { &g_aszUnknownStr[6][0], &g_aszUnknownStr[6][0], 0 },
148 { &g_aszUnknownStr[7][0], &g_aszUnknownStr[7][0], 0 }
149};
150/** Last used index in g_aUnknownMsgs. */
151static volatile uint32_t g_iUnknownMsgs;
152/** @} */
153
154
155RTDECL(PCRTCOMERRMSG) RTErrCOMGet(uint32_t rc)
156{
157 unsigned i;
158 for (i = 0; i < RT_ELEMENTS(g_aStatusMsgs) - 1; i++)
159 if (g_aStatusMsgs[i].iCode == rc)
160 return &g_aStatusMsgs[i];
161
162 /*
163 * Need to use the temporary stuff.
164 */
165 int32_t iMsg = (ASMAtomicIncU32(&g_iUnknownMsgs) - 1) % RT_ELEMENTS(g_aUnknownMsgs);
166 RTStrPrintf(&g_aszUnknownStr[iMsg][0], sizeof(g_aszUnknownStr[iMsg]), "Unknown Status 0x%X", rc);
167 return &g_aUnknownMsgs[iMsg];
168}
169RT_EXPORT_SYMBOL(RTErrCOMGet);
170
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