Changeset 27128 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- Mar 5, 2010 11:49:44 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/message.cpp
r26683 r27128 41 41 42 42 43 static int rtMsgWorker(PRTSTREAM pDst, const char *pszPrefix, const char *pszFormat, va_list va) 44 { 45 if ( !*pszFormat 46 || !strcmp(pszFormat, "\n")) 47 RTStrmPrintf(pDst, "\n"); 48 else 49 { 50 char *pszMsg; 51 ssize_t cch = RTStrAPrintfV(&pszMsg, pszFormat, va); 52 if (cch >= 0) 53 { 54 /* print it line by line. */ 55 char *psz = pszMsg; 56 do 57 { 58 char *pszEnd = strchr(psz, '\n'); 59 if (!pszEnd) 60 { 61 RTStrmPrintf(pDst, "%s: %s%s\n", pszPrefix, &g_szrtProcExePath[g_offrtProcName], psz); 62 break; 63 } 64 if (pszEnd == psz) 65 RTStrmPrintf(pDst, "\n"); 66 else 67 { 68 *pszEnd = '\0'; 69 RTStrmPrintf(pDst, "%s: %s%s\n", pszPrefix, &g_szrtProcExePath[g_offrtProcName], psz); 70 } 71 psz = pszEnd + 1; 72 } while (*psz); 73 RTStrFree(pszMsg); 74 } 75 else 76 { 77 /* Simple fallback for handling out-of-memory conditions. */ 78 RTStrmPrintf(pDst, "%s: %s", pszPrefix, &g_szrtProcExePath[g_offrtProcName]); 79 RTStrmPrintfV(pDst, pszFormat, va); 80 if (!strchr(pszFormat, '\n')) 81 RTStrmPrintf(pDst, "\n"); 82 } 83 } 84 85 return VINF_SUCCESS; 86 } 87 43 88 RTDECL(int) RTMsgError(const char *pszFormat, ...) 44 89 { … … 54 99 RTDECL(int) RTMsgErrorV(const char *pszFormat, va_list va) 55 100 { 56 if ( !*pszFormat 57 || !strcmp(pszFormat, "\n")) 58 RTStrmPrintf(g_pStdErr, "\n"); 59 else 60 { 61 char *pszMsg; 62 ssize_t cch = RTStrAPrintfV(&pszMsg, pszFormat, va); 63 if (cch >= 0) 64 { 65 /* print it line by line. */ 66 char *psz = pszMsg; 67 do 68 { 69 char *pszEnd = strchr(psz, '\n'); 70 if (!pszEnd) 71 { 72 RTStrmPrintf(g_pStdErr, "%s: error: %s\n", &g_szrtProcExePath[g_offrtProcName], psz); 73 break; 74 } 75 if (pszEnd == psz) 76 RTStrmPrintf(g_pStdErr, "\n"); 77 else 78 { 79 *pszEnd = '\0'; 80 RTStrmPrintf(g_pStdErr, "%s: error: %s\n", &g_szrtProcExePath[g_offrtProcName], psz); 81 } 82 psz = pszEnd + 1; 83 } while (*psz); 84 RTStrFree(pszMsg); 85 } 86 else 87 { 88 /* Simple fallback for handling out-of-memory conditions. */ 89 RTStrmPrintf(g_pStdErr, "%s: error: ", &g_szrtProcExePath[g_offrtProcName]); 90 RTStrmPrintfV(g_pStdErr, pszFormat, va); 91 if (!strchr(pszFormat, '\n')) 92 RTStrmPrintf(g_pStdErr, "\n"); 93 } 94 } 95 96 return VINF_SUCCESS; 101 return rtMsgWorker(g_pStdErr, " error:", pszFormat, va); 97 102 } 98 103 RT_EXPORT_SYMBOL(RTMsgErrorV); … … 131 136 RT_EXPORT_SYMBOL(RTMsgInitFailure); 132 137 138 139 RTDECL(int) RTMsgWarning(const char *pszFormat, ...) 140 { 141 va_list va; 142 va_start(va, pszFormat); 143 int rc = RTMsgWarningV(pszFormat, va); 144 va_end(va); 145 return rc; 146 } 147 RT_EXPORT_SYMBOL(RTMsgInfo); 148 149 150 RTDECL(int) RTMsgWarningV(const char *pszFormat, va_list va) 151 { 152 return rtMsgWorker(g_pStdErr, " warning:", pszFormat, va); 153 } 154 RT_EXPORT_SYMBOL(RTMsgWarningV); 155 156 157 RTDECL(int) RTMsgInfo(const char *pszFormat, ...) 158 { 159 va_list va; 160 va_start(va, pszFormat); 161 int rc = RTMsgInfoV(pszFormat, va); 162 va_end(va); 163 return rc; 164 } 165 RT_EXPORT_SYMBOL(RTMsgInfo); 166 167 168 RTDECL(int) RTMsgInfoV(const char *pszFormat, va_list va) 169 { 170 return rtMsgWorker(g_pStdOut, " info:", pszFormat, va); 171 } 172 RT_EXPORT_SYMBOL(RTMsgInfoV); 173
Note:
See TracChangeset
for help on using the changeset viewer.