Changeset 8402 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Apr 26, 2008 5:13:38 AM (17 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/Makefile.kmk
r8400 r8402 257 257 VBox/RTAssertDoBreakpoint-vbox.cpp \ 258 258 VBox/log-vbox.cpp 259 ifneq ($(BUILD_TARGET),win) 260 RuntimeR3_SOURCES += \ 261 common/err/errmsgxpcom.cpp 262 endif 259 263 260 264 RuntimeR3_SOURCES.win = \ -
trunk/src/VBox/Runtime/common/err/errmsgxpcom.cpp
r8400 r8402 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - Status code messages .3 * IPRT - Status code messages for XPCOM. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2006-200 7Sun Microsystems, Inc.7 * Copyright (C) 2006-2008 Sun Microsystems, Inc. 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 32 32 * Header Files * 33 33 *******************************************************************************/ 34 #include <windows.h>34 //#include <some xpcom header.h> 35 35 36 36 #include <iprt/err.h> … … 38 38 #include <iprt/string.h> 39 39 #include <iprt/err.h> 40 #include <VBox/err.h>41 40 42 41 … … 47 46 * The data is generated by a sed script. 48 47 */ 49 static const RT WINERRMSG g_aStatusMsgs[] =48 static const RTCOMERRMSG g_aStatusMsgs[] = 50 49 { 51 #include "errmsgcomdata.h"50 //#include "errmsgxpcomdata.h" 52 51 { NULL, NULL, 0 } 53 52 }; … … 58 57 */ 59 58 static char g_aszUnknownStr[4][64]; 60 static RT WINERRMSG g_aUnknownMsgs[4] =59 static RTCOMERRMSG g_aUnknownMsgs[4] = 61 60 { 62 61 { &g_aszUnknownStr[0][0], &g_aszUnknownStr[0][0], 0 }, … … 70 69 71 70 72 /** 73 * Get the message corresponding to a given status code. 74 * 75 * @returns Pointer to read-only message description. 76 * @param rc The status code. 77 */ 78 RTDECL(PCRTWINERRMSG) RTErrWinGet(long rc) 71 RTDECL(PCRTCOMERRMSG) RTErrCOMGet(uint32_t rc) 79 72 { 80 73 unsigned i; 81 for (i = 0; i < ELEMENTS(g_aStatusMsgs); i++) 82 { 74 for (i = 0; i < RT_ELEMENTS(g_aStatusMsgs); i++) 83 75 if (g_aStatusMsgs[i].iCode == rc) 84 {85 76 return &g_aStatusMsgs[i]; 86 }87 }88 77 89 78 /* 90 79 * Need to use the temporary stuff. 91 80 */ 92 int iMsg = ASMAtomicXchgU32(&g_iUnknownMsgs, (g_iUnknownMsgs + 1) % ELEMENTS(g_aUnknownMsgs));81 int32_t iMsg = (ASMAtomicIncU32(&g_iUnknownMsgs) - 1) % RT_ELEMENTS(g_aUnknownMsgs); 93 82 RTStrPrintf(&g_aszUnknownStr[iMsg][0], sizeof(g_aszUnknownStr[iMsg]), "Unknown Status 0x%X\n", rc); 94 83 return &g_aUnknownMsgs[iMsg]; 95 84 } 85 -
trunk/src/VBox/Runtime/common/string/strformatrt.cpp
r8245 r8402 117 117 * error code define + full description. 118 118 * 119 * - \%Rhrc - Takes a COM/XPCOM status code as argument. Will insert the status 120 * code define corresponding to the Windows error code. 121 * - \%Rhrf - Takes a COM/XPCOM status code as argument. Will insert the 122 * full description of the specified status code. 123 * - \%Rhra - Takes a COM/XPCOM error code as argument. Will insert the 124 * error code define + full description. 125 * 119 126 * On other platforms, \%Rw? simply prints the argument in a form of 0xXXXXXXXX. 120 *121 * @todo (r=dmik) Add a cross-platform \%Rcomr? that will fall back to \%Rw? on122 * Win32 platforms and will interpret XPCOM result codes on all other.123 127 * 124 128 * … … 486 490 487 491 /* 488 * hex dumping .492 * hex dumping and COM/XPCOM. 489 493 */ 490 494 case 'h': … … 567 571 } 568 572 573 574 #ifdef IN_RING3 575 /* 576 * XPCOM / COM status code: %Rhrc, %Rhrf, %Rhra 577 * ASSUMES: If Windows Then COM else XPCOM. 578 */ 579 case 'r': 580 { 581 582 char ch = *(*ppszFormat)++; 583 uint32_t hrc = va_arg(*pArgs, uint32_t); 584 PCRTCOMERRMSG pMsg = RTErrCOMGet(hrc); 585 switch (ch) 586 { 587 case 'c': 588 return pfnOutput(pvArgOutput, pMsg->pszDefine, strlen(pMsg->pszDefine)); 589 case 'f': 590 return pfnOutput(pvArgOutput, pMsg->pszMsgFull,strlen(pMsg->pszMsgFull)); 591 case 'a': 592 return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "%s (0x%08X) - %s", pMsg->pszDefine, hrc, pMsg->pszMsgFull); 593 default: 594 AssertMsgFailed(("Invalid status code format type '%.10s'!\n", pszFormatOrg)); 595 return 0; 596 } 597 break; 598 } 599 #endif /* IN_RING3 */ 600 569 601 default: 570 602 AssertMsgFailed(("Invalid status code format type '%.10s'!\n", ch, pszFormatOrg)); … … 622 654 long rc = va_arg(*pArgs, long); 623 655 char ch = *(*ppszFormat)++; 624 # if defined(RT_OS_WINDOWS)656 # if defined(RT_OS_WINDOWS) 625 657 PCRTWINERRMSG pMsg = RTErrWinGet(rc); 626 # endif658 # endif 627 659 switch (ch) 628 660 { 629 # if defined(RT_OS_WINDOWS)661 # if defined(RT_OS_WINDOWS) 630 662 case 'c': 631 663 return pfnOutput(pvArgOutput, pMsg->pszDefine, strlen(pMsg->pszDefine)); … … 634 666 case 'a': 635 667 return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "%s (0x%08X) - %s", pMsg->pszDefine, rc, pMsg->pszMsgFull); 636 # else668 # else 637 669 case 'c': 638 670 case 'f': 639 671 case 'a': 640 672 return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "0x%08X", rc); 641 # endif673 # endif 642 674 default: 643 675 AssertMsgFailed(("Invalid status code format type '%.10s'!\n", pszFormatOrg)); -
trunk/src/VBox/Runtime/win/errmsgwin.cpp
r8245 r8402 38 38 #include <iprt/string.h> 39 39 #include <iprt/err.h> 40 #include <VBox/err.h>41 40 42 41 … … 79 78 { 80 79 unsigned i; 81 for (i = 0; i < ELEMENTS(g_aStatusMsgs); i++) 82 { 80 for (i = 0; i < RT_ELEMENTS(g_aStatusMsgs); i++) 83 81 if (g_aStatusMsgs[i].iCode == rc) 84 {85 82 return &g_aStatusMsgs[i]; 86 }87 }88 83 89 84 /* 90 85 * Need to use the temporary stuff. 91 86 */ 92 int iMsg = ASMAtomicXchgU32(&g_iUnknownMsgs, (g_iUnknownMsgs + 1) % ELEMENTS(g_aUnknownMsgs));87 int32_t iMsg = (ASMAtomicIncU32(&g_iUnknownMsgs) - 1) % RT_ELEMENTS(g_aUnknownMsgs); 93 88 RTStrPrintf(&g_aszUnknownStr[iMsg][0], sizeof(g_aszUnknownStr[iMsg]), "Unknown Status 0x%X\n", rc); 94 89 return &g_aUnknownMsgs[iMsg]; 95 90 } 91 92 93 RTDECL(PCRTCOMERRMSG) RTErrCOMGet(uint32_t rc) 94 { 95 return RTErrWinGet((long)rc); 96 } 97
Note:
See TracChangeset
for help on using the changeset viewer.