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.

85 lines
1.7 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000-2001.
  5. //
  6. // File: debug.cpp
  7. //
  8. // Contents: Debugging support
  9. //
  10. //----------------------------------------------------------------------------
  11. #include "stdafx.h"
  12. #if DBG == 1
  13. static int indentLevel = 0;
  14. void __cdecl _TRACE (int level, const wchar_t *format, ... )
  15. {
  16. va_list arglist;
  17. WCHAR Buffer[512];
  18. int cb;
  19. // if ( level < 0 )
  20. // indentLevel += level;
  21. //
  22. // Format the output into a buffer and then print it.
  23. //
  24. // wstring strTabs;
  25. // for (int nLevel = 0; nLevel < indentLevel; nLevel++)
  26. // strTabs += L" ";
  27. // OutputDebugStringW (strTabs.c_str ());
  28. va_start(arglist, format);
  29. //This is not a safe usage. _vsnwprintf overflow returns -1. make sure Buffer is terminated. Raid #555867. Yanggao.
  30. cb = _vsnwprintf (Buffer, sizeof(Buffer)/sizeof(Buffer[0])-1, format, arglist);
  31. if ( cb > 0 )
  32. {
  33. OutputDebugStringW (Buffer);
  34. }
  35. va_end(arglist);
  36. // if ( level > 0 )
  37. // indentLevel += level;
  38. }
  39. PCSTR
  40. StripDirPrefixA(
  41. PCSTR pszPathName
  42. )
  43. /*++
  44. Routine Description:
  45. Strip the directory prefix off a filename (ANSI version)
  46. Arguments:
  47. pstrFilename - Pointer to filename string
  48. Return Value:
  49. Pointer to the last component of a filename (without directory prefix)
  50. --*/
  51. {
  52. DWORD dwLen = lstrlenA(pszPathName);
  53. pszPathName += dwLen - 1; // go to the end
  54. while (*pszPathName != '\\' && dwLen--)
  55. {
  56. pszPathName--;
  57. }
  58. return pszPathName + 1;
  59. }
  60. #endif // if DBG