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.

126 lines
2.6 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1993 **/
  4. /**********************************************************************/
  5. /*
  6. debug.c
  7. This module contains debug support routines for the FTPD Service.
  8. FILE HISTORY:
  9. KeithMo 07-Mar-1993 Created.
  10. */
  11. #include <windows.h>
  12. #include <string.h>
  13. #include <stdio.h>
  14. #include <stdarg.h>
  15. #include "debug.h"
  16. #if DBG
  17. //
  18. // Private constants.
  19. //
  20. #define MAX_PRINTF_OUTPUT 1024 // characters
  21. #define FTPD_OUTPUT_LABEL "FTPD"
  22. //
  23. // Private types.
  24. //
  25. //
  26. // Private globals.
  27. //
  28. //
  29. // Public functions.
  30. //
  31. /*******************************************************************
  32. NAME: FtpdAssert
  33. SYNOPSIS: Called if an assertion fails. Displays the failed
  34. assertion, file name, and line number. Gives the
  35. user the opportunity to ignore the assertion or
  36. break into the debugger.
  37. ENTRY: pAssertion - The text of the failed expression.
  38. pFileName - The containing source file.
  39. nLineNumber - The guilty line number.
  40. HISTORY:
  41. KeithMo 07-Mar-1993 Created.
  42. ********************************************************************/
  43. void FtpdAssert( void * pAssertion,
  44. void * pFileName,
  45. long nLineNumber )
  46. {
  47. char szOutput[MAX_PRINTF_OUTPUT];
  48. sprintf( szOutput,
  49. "\n*** Assertion failed: %s\n*** Source File: %s, line %ld\n\n",
  50. pAssertion,
  51. pFileName,
  52. nLineNumber );
  53. OutputDebugString( szOutput );
  54. DebugBreak();
  55. } // FtpdAssert
  56. /*******************************************************************
  57. NAME: FtpdPrintf
  58. SYNOPSIS: Customized debug output routine.
  59. ENTRY: Usual printf-style parameters.
  60. HISTORY:
  61. KeithMo 07-Mar-1993 Created.
  62. ********************************************************************/
  63. void FtpdPrintf( char * pszFormat,
  64. ... )
  65. {
  66. char szOutput[MAX_PRINTF_OUTPUT];
  67. va_list ArgList;
  68. sprintf( szOutput,
  69. "%s (%lu): ",
  70. FTPD_OUTPUT_LABEL,
  71. GetCurrentThreadId() );
  72. va_start( ArgList, pszFormat );
  73. vsprintf( szOutput + strlen(szOutput), pszFormat, ArgList );
  74. va_end( ArgList );
  75. IF_DEBUG( OUTPUT_TO_DEBUGGER )
  76. {
  77. OutputDebugString( szOutput );
  78. }
  79. } // FtpdPrintf
  80. //
  81. // Private functions.
  82. //
  83. #endif // DBG