Source code of Windows XP (NT5)
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.

55 lines
1.1 KiB

  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. va_list arglist;
  11. TCHAR pFilePath[_MAX_PATH+1];
  12. LPTSTR pFileName;
  13. _tcscpy(pFilePath, _T(__FILE__));
  14. pFileName = _tcsrchr(pFilePath, '\\');
  15. if (pFileName == NULL)
  16. pFileName = pFilePath;
  17. else
  18. pFileName++;
  19. va_start(arglist, cstrMsg);
  20. printf("[%s:%d] ", pFileName, __LINE__);
  21. _vtprintf(cstrMsg, arglist);
  22. exit(-1);
  23. }
  24. }
  25. DWORD _Err(DWORD dwErrCode,
  26. LPCTSTR cstrMsg,
  27. ...)
  28. {
  29. va_list arglist;
  30. va_start(arglist, cstrMsg);
  31. printf("[Err%05u] ", dwErrCode);
  32. _vtprintf(cstrMsg, arglist);
  33. fflush(stdout);
  34. return dwErrCode;
  35. }
  36. DWORD _Wrn(DWORD dwWarnCode,
  37. LPCTSTR cstrMsg,
  38. ...)
  39. {
  40. va_list arglist;
  41. va_start(arglist, cstrMsg);
  42. printf("[Wrn%02u] ", dwWarnCode);
  43. _vtprintf(cstrMsg, arglist);
  44. fflush(stdout);
  45. return dwWarnCode;
  46. }