Changeset 37951 in vbox for trunk/src/VBox/Runtime/common/misc
- Timestamp:
- Jul 14, 2011 10:13:59 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/message.cpp
r28800 r37951 37 37 38 38 39 /******************************************************************************* 40 * Global Variables * 41 *******************************************************************************/ 42 /** The program name we're using. */ 43 static const char * volatile g_pszProgName = NULL; 44 /** Custom program name set via RTMsgSetProgName. */ 45 static char g_szProgName[128]; 46 47 48 RTDECL(int) RTMsgSetProgName(const char *pszFormat, ...) 49 { 50 g_pszProgName = &g_szrtProcExePath[g_offrtProcName]; 51 52 va_list va; 53 va_start(va, pszFormat); 54 RTStrPrintfV(g_szProgName, sizeof(g_szProgName) - 1, pszFormat, va); 55 va_end(va); 56 57 g_pszProgName = g_szProgName; 58 59 return VINF_SUCCESS; 60 } 61 RT_EXPORT_SYMBOL(RTMsgSetProgName); 62 63 39 64 static int rtMsgWorker(PRTSTREAM pDst, const char *pszPrefix, const char *pszFormat, va_list va) 40 65 { … … 44 69 else 45 70 { 71 const char *pszProgName = g_pszProgName; 72 if (!pszProgName) 73 g_pszProgName = pszProgName = &g_szrtProcExePath[g_offrtProcName]; 74 46 75 char *pszMsg; 47 76 ssize_t cch = RTStrAPrintfV(&pszMsg, pszFormat, va); … … 55 84 if (!pszEnd) 56 85 { 57 RTStrmPrintf(pDst, "%s: %s%s\n", &g_szrtProcExePath[g_offrtProcName], pszPrefix, psz);86 RTStrmPrintf(pDst, "%s: %s%s\n", pszProgName, pszPrefix, psz); 58 87 break; 59 88 } … … 63 92 { 64 93 *pszEnd = '\0'; 65 RTStrmPrintf(pDst, "%s: %s%s\n", &g_szrtProcExePath[g_offrtProcName], pszPrefix, psz);94 RTStrmPrintf(pDst, "%s: %s%s\n", pszProgName, pszPrefix, psz); 66 95 } 67 96 psz = pszEnd + 1; … … 72 101 { 73 102 /* Simple fallback for handling out-of-memory conditions. */ 74 RTStrmPrintf(pDst, "%s: %s", &g_szrtProcExePath[g_offrtProcName], pszPrefix);103 RTStrmPrintf(pDst, "%s: %s", pszProgName, pszPrefix); 75 104 RTStrmPrintfV(pDst, pszFormat, va); 76 105 if (!strchr(pszFormat, '\n'))
Note:
See TracChangeset
for help on using the changeset viewer.