[96449] | 1 | /* $Id: NoCrtOutput.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
| 2 | /** @file
|
---|
| 3 | * NoCrtOutput - ErrorMsgXxx and PrintXxx functions for small EXEs.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2022-2023 Oracle and/or its affiliates.
|
---|
[96449] | 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 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
| 26 | */
|
---|
| 27 |
|
---|
| 28 | #ifndef GA_INCLUDED_WINNT_NoCrtOutput_h
|
---|
| 29 | #define GA_INCLUDED_WINNT_NoCrtOutput_h
|
---|
| 30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 31 | # pragma once
|
---|
| 32 | #endif
|
---|
| 33 |
|
---|
| 34 | #include <iprt/win/windows.h>
|
---|
| 35 | #include <iprt/string.h>
|
---|
| 36 | #include <iprt/utf16.h>
|
---|
| 37 |
|
---|
| 38 |
|
---|
| 39 | /** @name Output helpers
|
---|
| 40 | *
|
---|
| 41 | * The general ASSUMPTION here is that all strings are restricted to 7-bit
|
---|
| 42 | * ASCII, with the exception of wchar_t ones.
|
---|
| 43 | *
|
---|
| 44 | * @note We don't use printf, RTPrintf or similar not for masochistic reasons
|
---|
| 45 | * but to keep the binary small and make it easier to switch between CRT
|
---|
| 46 | * and IPRT w/ no-CRT.
|
---|
| 47 | *
|
---|
| 48 | * @{
|
---|
| 49 | */
|
---|
| 50 |
|
---|
| 51 | DECLINLINE(void) OutputWStr(HANDLE hDst, const wchar_t *pwszStr)
|
---|
| 52 | {
|
---|
| 53 | DWORD cbIgn;
|
---|
| 54 | if (GetConsoleMode(hDst, &cbIgn))
|
---|
| 55 | WriteConsoleW(hDst, pwszStr, (DWORD)RTUtf16Len(pwszStr), &cbIgn, NULL);
|
---|
| 56 | else
|
---|
| 57 | {
|
---|
| 58 | char *pszTmp;
|
---|
| 59 | int rc = RTUtf16ToUtf8(pwszStr, &pszTmp);
|
---|
| 60 | if (RT_SUCCESS(rc))
|
---|
| 61 | {
|
---|
| 62 | char *pszInCodepage;
|
---|
| 63 | rc = RTStrUtf8ToCurrentCP(&pszInCodepage, pszTmp);
|
---|
| 64 | if (RT_SUCCESS(rc))
|
---|
| 65 | {
|
---|
| 66 | WriteFile(hDst, pszInCodepage, (DWORD)strlen(pszInCodepage), &cbIgn, NULL);
|
---|
| 67 | RTStrFree(pszInCodepage);
|
---|
| 68 | }
|
---|
| 69 | else
|
---|
| 70 | WriteFile(hDst, RT_STR_TUPLE("<RTStrUtf8ToCurrentCP error>"), &cbIgn, NULL);
|
---|
| 71 | RTStrFree(pszTmp);
|
---|
| 72 | }
|
---|
| 73 | else
|
---|
| 74 | WriteFile(hDst, RT_STR_TUPLE("<RTUtf16ToUtf8 error>"), &cbIgn, NULL);
|
---|
| 75 | }
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 |
|
---|
| 79 | DECLINLINE(void) ErrorMsgBegin(const char *pszMsg)
|
---|
| 80 | {
|
---|
| 81 | HANDLE const hStdErr = GetStdHandle(STD_ERROR_HANDLE);
|
---|
| 82 | DWORD cbIgn;
|
---|
| 83 | WriteFile(hStdErr, RT_STR_TUPLE("error: "), &cbIgn, NULL);
|
---|
| 84 | WriteFile(hStdErr, pszMsg, (DWORD)strlen(pszMsg), &cbIgn, NULL);
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 |
|
---|
| 88 | DECLINLINE(void) ErrorMsgStr(const char *pszMsg)
|
---|
| 89 | {
|
---|
| 90 | HANDLE const hStdErr = GetStdHandle(STD_ERROR_HANDLE);
|
---|
| 91 | DWORD cbIgn;
|
---|
| 92 | WriteFile(hStdErr, pszMsg, (DWORD)strlen(pszMsg), &cbIgn, NULL);
|
---|
| 93 | }
|
---|
| 94 |
|
---|
| 95 |
|
---|
| 96 | DECLINLINE(void) ErrorMsgWStr(const wchar_t *pwszStr)
|
---|
| 97 | {
|
---|
| 98 | OutputWStr(GetStdHandle(STD_ERROR_HANDLE), pwszStr);
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 |
|
---|
| 102 | DECLINLINE(int) ErrorMsgEnd(const char *pszMsg)
|
---|
| 103 | {
|
---|
| 104 | HANDLE const hStdErr = GetStdHandle(STD_ERROR_HANDLE);
|
---|
| 105 | DWORD cbIgn;
|
---|
| 106 | if (pszMsg)
|
---|
| 107 | WriteFile(hStdErr, pszMsg, (DWORD)strlen(pszMsg), &cbIgn, NULL);
|
---|
| 108 | WriteFile(hStdErr, RT_STR_TUPLE("\r\n"), &cbIgn, NULL);
|
---|
| 109 | #ifdef EXIT_FAIL /* VBoxDrvInst.cpp speciality */
|
---|
| 110 | return EXIT_FAIL;
|
---|
| 111 | #else
|
---|
| 112 | return RTEXITCODE_FAILURE;
|
---|
| 113 | #endif
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 |
|
---|
| 117 | DECLINLINE(void) ErrorMsgU64(uint64_t uValue, bool fSigned = false)
|
---|
| 118 | {
|
---|
| 119 | char szVal[128];
|
---|
| 120 | RTStrFormatU64(szVal, sizeof(szVal), uValue, 10, 0, 0, fSigned ? RTSTR_F_VALSIGNED : 0);
|
---|
| 121 | ErrorMsgStr(szVal);
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 |
|
---|
| 125 | DECLINLINE(int) ErrorMsg(const char *pszMsg)
|
---|
| 126 | {
|
---|
| 127 | ErrorMsgBegin(pszMsg);
|
---|
| 128 | return ErrorMsgEnd(NULL);
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 |
|
---|
[96728] | 132 | DECLINLINE(int) ErrorMsgSU(const char *pszMsg1, uint64_t uValue1)
|
---|
| 133 | {
|
---|
| 134 | ErrorMsgBegin(pszMsg1);
|
---|
| 135 | ErrorMsgU64(uValue1);
|
---|
| 136 | return ErrorMsgEnd(NULL);
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 |
|
---|
[96449] | 140 | DECLINLINE(int) ErrorMsgSWS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3)
|
---|
| 141 | {
|
---|
| 142 | ErrorMsgBegin(pszMsg1);
|
---|
| 143 | ErrorMsgWStr(pwszMsg2);
|
---|
| 144 | return ErrorMsgEnd(pszMsg3);
|
---|
| 145 | }
|
---|
| 146 |
|
---|
| 147 |
|
---|
| 148 | DECLINLINE(int) ErrorMsgSWSWS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3,
|
---|
| 149 | const wchar_t *pwszMsg4, const char *pszMsg5)
|
---|
| 150 | {
|
---|
| 151 | ErrorMsgBegin(pszMsg1);
|
---|
| 152 | ErrorMsgWStr(pwszMsg2);
|
---|
| 153 | ErrorMsgStr(pszMsg3);
|
---|
| 154 | ErrorMsgWStr(pwszMsg4);
|
---|
| 155 | return ErrorMsgEnd(pszMsg5);
|
---|
| 156 | }
|
---|
| 157 |
|
---|
| 158 |
|
---|
[96605] | 159 | DECLINLINE(int) ErrorMsgSUSUS(const char *pszMsg1, uint64_t uValue1, const char *pszMsg2, uint64_t uValue2, const char *pszMsg3)
|
---|
| 160 | {
|
---|
| 161 | ErrorMsgBegin(pszMsg1);
|
---|
| 162 | ErrorMsgU64(uValue1);
|
---|
| 163 | ErrorMsgStr(pszMsg2);
|
---|
| 164 | ErrorMsgU64(uValue2);
|
---|
| 165 | return ErrorMsgEnd(pszMsg3);
|
---|
| 166 | }
|
---|
| 167 |
|
---|
| 168 |
|
---|
[96449] | 169 | DECLINLINE(void) ErrorMsgErrVal(uint32_t uErrVal, bool fSigned)
|
---|
| 170 | {
|
---|
| 171 | char szVal[128];
|
---|
| 172 | ssize_t cchVal = RTStrFormatU32(szVal, sizeof(szVal) - 1, uErrVal, 10, 0, 0, fSigned ? RTSTR_F_VALSIGNED : 0);
|
---|
| 173 | szVal[cchVal++] = '/';
|
---|
| 174 | szVal[cchVal] = '\0';
|
---|
| 175 | ErrorMsgStr(szVal);
|
---|
| 176 |
|
---|
| 177 | RTStrFormatU32(szVal, sizeof(szVal) - 1, uErrVal, 16, 0, 0, RTSTR_F_SPECIAL);
|
---|
| 178 | ErrorMsgStr(szVal);
|
---|
| 179 | }
|
---|
| 180 |
|
---|
| 181 |
|
---|
| 182 | DECLINLINE(int) ErrorMsgErr(const char *pszMsg, uint32_t uErrVal, const char *pszErrIntro, bool fSigned)
|
---|
| 183 | {
|
---|
| 184 | ErrorMsgBegin(pszMsg);
|
---|
| 185 | ErrorMsgStr(pszErrIntro);
|
---|
| 186 | ErrorMsgErrVal(uErrVal, fSigned);
|
---|
| 187 | return ErrorMsgEnd(")");
|
---|
| 188 | }
|
---|
| 189 |
|
---|
| 190 |
|
---|
| 191 | DECLINLINE(int) ErrorMsgRc(int rcExit, const char *pszMsg)
|
---|
| 192 | {
|
---|
| 193 | ErrorMsgBegin(pszMsg);
|
---|
| 194 | ErrorMsgEnd(NULL);
|
---|
| 195 | return rcExit;
|
---|
| 196 | }
|
---|
| 197 |
|
---|
| 198 |
|
---|
| 199 | DECLINLINE(int) ErrorMsgRcSUS(int rcExit, const char *pszMsg1, uint64_t uValue, const char *pszMsg2)
|
---|
| 200 | {
|
---|
| 201 | ErrorMsgBegin(pszMsg1);
|
---|
| 202 | ErrorMsgU64(uValue);
|
---|
| 203 | ErrorMsgEnd(pszMsg2);
|
---|
| 204 | return rcExit;
|
---|
| 205 | }
|
---|
| 206 |
|
---|
| 207 |
|
---|
| 208 | DECLINLINE(int) ErrorMsgVBoxErr(const char *pszMsg, int rc)
|
---|
| 209 | {
|
---|
| 210 | return ErrorMsgErr(pszMsg, rc, " (", true);
|
---|
| 211 | }
|
---|
| 212 |
|
---|
| 213 |
|
---|
| 214 | DECLINLINE(int) ErrorMsgLastErr(const char *pszMsg)
|
---|
| 215 | {
|
---|
| 216 | return ErrorMsgErr(pszMsg, GetLastError(), " (last error ", false);
|
---|
| 217 | }
|
---|
| 218 |
|
---|
| 219 |
|
---|
| 220 | DECLINLINE(int) ErrorMsgLastErrSUR(const char *pszMsg1, uint64_t uValue)
|
---|
| 221 | {
|
---|
| 222 | DWORD dwErr = GetLastError();
|
---|
| 223 | ErrorMsgBegin(pszMsg1);
|
---|
| 224 | ErrorMsgU64(uValue);
|
---|
| 225 | ErrorMsgStr(" (last error ");
|
---|
| 226 | ErrorMsgErrVal(dwErr, false);
|
---|
| 227 | return ErrorMsgEnd(")");
|
---|
| 228 | }
|
---|
| 229 |
|
---|
| 230 |
|
---|
| 231 | DECLINLINE(int) ErrorMsgLastErrSWS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3)
|
---|
| 232 | {
|
---|
| 233 | DWORD dwErr = GetLastError();
|
---|
| 234 | ErrorMsgBegin(pszMsg1);
|
---|
| 235 | ErrorMsgWStr(pwszMsg2);
|
---|
| 236 | ErrorMsgStr(pszMsg3);
|
---|
| 237 | ErrorMsgStr(" (last error ");
|
---|
| 238 | ErrorMsgErrVal(dwErr, false);
|
---|
| 239 | return ErrorMsgEnd(")");
|
---|
| 240 | }
|
---|
| 241 |
|
---|
| 242 |
|
---|
| 243 | DECLINLINE(int) ErrorMsgLastErrSWSWS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3,
|
---|
| 244 | const wchar_t *pwszMsg4, const char *pszMsg5)
|
---|
| 245 | {
|
---|
| 246 | DWORD dwErr = GetLastError();
|
---|
| 247 | ErrorMsgBegin(pszMsg1);
|
---|
| 248 | ErrorMsgWStr(pwszMsg2);
|
---|
| 249 | ErrorMsgStr(pszMsg3);
|
---|
| 250 | ErrorMsgWStr(pwszMsg4);
|
---|
| 251 | ErrorMsgStr(pszMsg5);
|
---|
| 252 | ErrorMsgStr(" (last error ");
|
---|
| 253 | ErrorMsgErrVal(dwErr, false);
|
---|
| 254 | return ErrorMsgEnd(")");
|
---|
| 255 | }
|
---|
| 256 |
|
---|
| 257 |
|
---|
| 258 | DECLINLINE(int) ErrorMsgLastErrSWSRSUS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3, const char *pszMsg4,
|
---|
| 259 | uint64_t uValue, const char *pszMsg5)
|
---|
| 260 | {
|
---|
| 261 | DWORD dwErr = GetLastError();
|
---|
| 262 | ErrorMsgBegin(pszMsg1);
|
---|
| 263 | ErrorMsgWStr(pwszMsg2);
|
---|
| 264 | ErrorMsgStr(pszMsg3);
|
---|
| 265 | ErrorMsgStr(" (last error ");
|
---|
| 266 | ErrorMsgErrVal(dwErr, false);
|
---|
| 267 | ErrorMsgStr(")");
|
---|
| 268 | ErrorMsgStr(pszMsg4);
|
---|
| 269 | ErrorMsgU64(uValue);
|
---|
| 270 | return ErrorMsgEnd(pszMsg5);
|
---|
| 271 | }
|
---|
| 272 |
|
---|
| 273 |
|
---|
| 274 | DECLINLINE(int) ErrorMsgLastErrSSS(const char *pszMsg1, const char *pszMsg2, const char *pszMsg3)
|
---|
| 275 | {
|
---|
| 276 | DWORD dwErr = GetLastError();
|
---|
| 277 | ErrorMsgBegin(pszMsg1);
|
---|
| 278 | ErrorMsgStr(pszMsg2);
|
---|
| 279 | ErrorMsgStr(pszMsg3);
|
---|
| 280 | ErrorMsgStr(" (last error ");
|
---|
| 281 | ErrorMsgErrVal(dwErr, false);
|
---|
| 282 | return ErrorMsgEnd(")");
|
---|
| 283 | }
|
---|
| 284 |
|
---|
| 285 |
|
---|
| 286 | DECLINLINE(int) ErrorMsgRcLastErr(int rcExit, const char *pszMsg)
|
---|
| 287 | {
|
---|
| 288 | ErrorMsgErr(pszMsg, GetLastError(), " (last error ", false);
|
---|
| 289 | return rcExit;
|
---|
| 290 | }
|
---|
| 291 |
|
---|
| 292 |
|
---|
| 293 | DECLINLINE(int) ErrorMsgRcLastErrSUR(int rcExit, const char *pszMsg1, uint64_t uValue)
|
---|
| 294 | {
|
---|
| 295 | ErrorMsgLastErrSUR(pszMsg1, uValue);
|
---|
| 296 | return rcExit;
|
---|
| 297 | }
|
---|
| 298 |
|
---|
| 299 |
|
---|
| 300 | static int ErrorMsgRcLastErrSWSR(int rcExit, const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3)
|
---|
| 301 | {
|
---|
| 302 | DWORD dwErr = GetLastError();
|
---|
| 303 | ErrorMsgBegin(pszMsg1);
|
---|
| 304 | ErrorMsgWStr(pwszMsg2);
|
---|
| 305 | ErrorMsgStr(pszMsg3);
|
---|
| 306 | ErrorMsgStr(" (last error ");
|
---|
| 307 | ErrorMsgErrVal(dwErr, false);
|
---|
| 308 | ErrorMsgEnd(")");
|
---|
| 309 | return rcExit;
|
---|
| 310 | }
|
---|
| 311 |
|
---|
| 312 |
|
---|
| 313 |
|
---|
| 314 | DECLINLINE(int) ErrorMsgLStatus(const char *pszMsg, LSTATUS lrc)
|
---|
| 315 | {
|
---|
| 316 | return ErrorMsgErr(pszMsg, (DWORD)lrc, " (", true);
|
---|
| 317 | }
|
---|
| 318 |
|
---|
| 319 |
|
---|
| 320 | DECLINLINE(int) ErrorMsgLStatusSWSRS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3,
|
---|
| 321 | LSTATUS lrc, const char *pszMsg4)
|
---|
| 322 | {
|
---|
| 323 | ErrorMsgBegin(pszMsg1);
|
---|
| 324 | ErrorMsgWStr(pwszMsg2);
|
---|
| 325 | ErrorMsgStr(pszMsg3);
|
---|
| 326 | ErrorMsgErrVal((DWORD)lrc, true);
|
---|
| 327 | return ErrorMsgEnd(pszMsg4);
|
---|
| 328 | }
|
---|
| 329 |
|
---|
| 330 |
|
---|
| 331 | DECLINLINE(int) ErrorMsgLStatusSWSWSRS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3, const wchar_t *pwszMsg4,
|
---|
| 332 | const char *pszMsg5, LSTATUS lrc, const char *pszMsg6)
|
---|
| 333 | {
|
---|
| 334 | ErrorMsgBegin(pszMsg1);
|
---|
| 335 | ErrorMsgWStr(pwszMsg2);
|
---|
| 336 | ErrorMsgStr(pszMsg3);
|
---|
| 337 | ErrorMsgWStr(pwszMsg4);
|
---|
| 338 | ErrorMsgStr(pszMsg5);
|
---|
| 339 | ErrorMsgErrVal((DWORD)lrc, true);
|
---|
| 340 | return ErrorMsgEnd(pszMsg6);
|
---|
| 341 | }
|
---|
| 342 |
|
---|
| 343 |
|
---|
| 344 | DECLINLINE(int) ErrorMsgLStatusSWSWSWSRS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3,
|
---|
| 345 | const wchar_t *pwszMsg4, const char *pszMsg5, const wchar_t *pwszMsg6,
|
---|
| 346 | const char *pszMsg7, LSTATUS lrc, const char *pszMsg8)
|
---|
| 347 | {
|
---|
| 348 | ErrorMsgBegin(pszMsg1);
|
---|
| 349 | ErrorMsgWStr(pwszMsg2);
|
---|
| 350 | ErrorMsgStr(pszMsg3);
|
---|
| 351 | ErrorMsgWStr(pwszMsg4);
|
---|
| 352 | ErrorMsgStr(pszMsg5);
|
---|
| 353 | ErrorMsgWStr(pwszMsg6);
|
---|
| 354 | ErrorMsgStr(pszMsg7);
|
---|
| 355 | ErrorMsgErrVal((DWORD)lrc, true);
|
---|
| 356 | return ErrorMsgEnd(pszMsg8);
|
---|
| 357 | }
|
---|
| 358 |
|
---|
| 359 |
|
---|
| 360 | DECLINLINE(int) ErrorMsgLStatusSWSWSWSWSRS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3,
|
---|
| 361 | const wchar_t *pwszMsg4, const char *pszMsg5, const wchar_t *pwszMsg6,
|
---|
| 362 | const char *pszMsg7, const wchar_t *pwszMsg8, const char *pszMsg9, LSTATUS lrc,
|
---|
| 363 | const char *pszMsg10)
|
---|
| 364 | {
|
---|
| 365 | ErrorMsgBegin(pszMsg1);
|
---|
| 366 | ErrorMsgWStr(pwszMsg2);
|
---|
| 367 | ErrorMsgStr(pszMsg3);
|
---|
| 368 | ErrorMsgWStr(pwszMsg4);
|
---|
| 369 | ErrorMsgStr(pszMsg5);
|
---|
| 370 | ErrorMsgWStr(pwszMsg6);
|
---|
| 371 | ErrorMsgStr(pszMsg7);
|
---|
| 372 | ErrorMsgWStr(pwszMsg8);
|
---|
| 373 | ErrorMsgStr(pszMsg9);
|
---|
| 374 | ErrorMsgErrVal((DWORD)lrc, true);
|
---|
| 375 | return ErrorMsgEnd(pszMsg10);
|
---|
| 376 | }
|
---|
| 377 |
|
---|
| 378 |
|
---|
| 379 | DECLINLINE(int) ErrorBadArg(const char *pszName, wchar_t const *pwszArg, const char *pszValues = NULL)
|
---|
| 380 | {
|
---|
| 381 | ErrorMsgBegin("Bad argument '");
|
---|
| 382 | ErrorMsgStr(pszName);
|
---|
| 383 | ErrorMsgStr("': ");
|
---|
| 384 | ErrorMsgWStr(pwszArg);
|
---|
| 385 | if (pszValues)
|
---|
| 386 | ErrorMsgStr(", expected: ");
|
---|
| 387 | return ErrorMsgEnd(pszValues);
|
---|
| 388 | }
|
---|
| 389 |
|
---|
| 390 |
|
---|
| 391 | /** Simple fputs(stdout) replacement. */
|
---|
| 392 | DECLINLINE(void) PrintStr(const char *pszMsg)
|
---|
| 393 | {
|
---|
| 394 | HANDLE const hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
---|
| 395 | DWORD cbIgn;
|
---|
| 396 | WriteFile(hStdOut, pszMsg, (DWORD)strlen(pszMsg), &cbIgn, NULL);
|
---|
| 397 | }
|
---|
| 398 |
|
---|
| 399 |
|
---|
| 400 | /** Simple fputs(stdout) replacement. */
|
---|
| 401 | DECLINLINE(void) PrintWStr(const wchar_t *pwszStr)
|
---|
| 402 | {
|
---|
| 403 | OutputWStr(GetStdHandle(STD_OUTPUT_HANDLE), pwszStr);
|
---|
| 404 | }
|
---|
| 405 |
|
---|
| 406 |
|
---|
| 407 | DECLINLINE(void) PrintX64(uint64_t uValue)
|
---|
| 408 | {
|
---|
| 409 | char szVal[128];
|
---|
| 410 | RTStrFormatU64(szVal, sizeof(szVal), uValue, 16, 0, 0, RTSTR_F_64BIT | RTSTR_F_SPECIAL);
|
---|
| 411 | PrintStr(szVal);
|
---|
| 412 | }
|
---|
| 413 |
|
---|
| 414 |
|
---|
| 415 | DECLINLINE(void) PrintSWS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3)
|
---|
| 416 | {
|
---|
| 417 | PrintStr(pszMsg1);
|
---|
| 418 | PrintWStr(pwszMsg2);
|
---|
| 419 | PrintStr(pszMsg3);
|
---|
| 420 | }
|
---|
| 421 |
|
---|
| 422 |
|
---|
| 423 | DECLINLINE(void) PrintSWSWS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3,
|
---|
| 424 | const wchar_t *pwszMsg4, const char *pszMsg5)
|
---|
| 425 | {
|
---|
| 426 | PrintStr(pszMsg1);
|
---|
| 427 | PrintWStr(pwszMsg2);
|
---|
| 428 | PrintStr(pszMsg3);
|
---|
| 429 | PrintWStr(pwszMsg4);
|
---|
| 430 | PrintStr(pszMsg5);
|
---|
| 431 | }
|
---|
| 432 |
|
---|
| 433 |
|
---|
| 434 | DECLINLINE(void) PrintSWSWSWS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3, const wchar_t *pwszMsg4,
|
---|
| 435 | const char *pszMsg5, const wchar_t *pwszMsg6, const char *pszMsg7)
|
---|
| 436 | {
|
---|
| 437 | PrintStr(pszMsg1);
|
---|
| 438 | PrintWStr(pwszMsg2);
|
---|
| 439 | PrintStr(pszMsg3);
|
---|
| 440 | PrintWStr(pwszMsg4);
|
---|
| 441 | PrintStr(pszMsg5);
|
---|
| 442 | PrintWStr(pwszMsg6);
|
---|
| 443 | PrintStr(pszMsg7);
|
---|
| 444 | }
|
---|
| 445 |
|
---|
| 446 |
|
---|
| 447 | DECLINLINE(void) PrintSWSWSWSWS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3, const wchar_t *pwszMsg4,
|
---|
| 448 | const char *pszMsg5, const wchar_t *pwszMsg6, const char *pszMsg7, const wchar_t *pwszMsg8,
|
---|
| 449 | const char *pszMsg9)
|
---|
| 450 | {
|
---|
| 451 | PrintStr(pszMsg1);
|
---|
| 452 | PrintWStr(pwszMsg2);
|
---|
| 453 | PrintStr(pszMsg3);
|
---|
| 454 | PrintWStr(pwszMsg4);
|
---|
| 455 | PrintStr(pszMsg5);
|
---|
| 456 | PrintWStr(pwszMsg6);
|
---|
| 457 | PrintStr(pszMsg7);
|
---|
| 458 | PrintWStr(pwszMsg8);
|
---|
| 459 | PrintStr(pszMsg9);
|
---|
| 460 | }
|
---|
| 461 |
|
---|
| 462 |
|
---|
| 463 | DECLINLINE(void) PrintSXS(const char *pszMsg1, uint64_t uValue, const char *pszMsg2)
|
---|
| 464 | {
|
---|
| 465 | PrintStr(pszMsg1);
|
---|
| 466 | PrintX64(uValue);
|
---|
| 467 | PrintStr(pszMsg2);
|
---|
| 468 | }
|
---|
| 469 |
|
---|
| 470 |
|
---|
| 471 | DECLINLINE(void) PrintSWSWSWSXS(const char *pszMsg1, const wchar_t *pwszMsg2, const char *pszMsg3, const wchar_t *pwszMsg4,
|
---|
| 472 | const char *pszMsg5, const wchar_t *pwszMsg6, const char *pszMsg7, uint64_t uValue,
|
---|
| 473 | const char *pszMsg8)
|
---|
| 474 | {
|
---|
| 475 | PrintStr(pszMsg1);
|
---|
| 476 | PrintWStr(pwszMsg2);
|
---|
| 477 | PrintStr(pszMsg3);
|
---|
| 478 | PrintWStr(pwszMsg4);
|
---|
| 479 | PrintStr(pszMsg5);
|
---|
| 480 | PrintWStr(pwszMsg6);
|
---|
| 481 | PrintStr(pszMsg7);
|
---|
| 482 | PrintX64(uValue);
|
---|
| 483 | PrintStr(pszMsg8);
|
---|
| 484 | }
|
---|
| 485 |
|
---|
| 486 | /** @} */
|
---|
| 487 |
|
---|
| 488 | #endif /* !GA_INCLUDED_WINNT_NoCrtOutput_h */
|
---|
| 489 |
|
---|