Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
994 B

  1. #include <precomp.h>
  2. // Positive Assert: it checks for the condition bCond
  3. // and exits the program if it is not TRUE
  4. VOID _Asrt(BOOL bCond,
  5. LPCTSTR cstrMsg,
  6. ...)
  7. {
  8. if (!bCond)
  9. {
  10. DWORD dwErr = GetLastError();
  11. va_list arglist;
  12. va_start(arglist, cstrMsg);
  13. _vftprintf(stderr, cstrMsg, arglist);
  14. if (dwErr == ERROR_SUCCESS)
  15. dwErr = ERROR_GEN_FAILURE;
  16. exit(dwErr);
  17. }
  18. }
  19. DWORD _Err(DWORD dwErrCode,
  20. LPCTSTR cstrMsg,
  21. ...)
  22. {
  23. va_list arglist;
  24. va_start(arglist, cstrMsg);
  25. _ftprintf(stderr, _T("[Err%u] "), dwErrCode);
  26. _vftprintf(stderr, cstrMsg, arglist);
  27. fflush(stdout);
  28. SetLastError(dwErrCode);
  29. return dwErrCode;
  30. }
  31. DWORD _Wrn(DWORD dwWarnCode,
  32. LPCTSTR cstrMsg,
  33. ...)
  34. {
  35. va_list arglist;
  36. va_start(arglist, cstrMsg);
  37. _ftprintf(stderr, _T("[Wrn%u] "), dwWarnCode);
  38. _vftprintf(stderr, cstrMsg, arglist);
  39. fflush(stdout);
  40. return dwWarnCode;
  41. }