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.

190 lines
6.7 KiB

  1. /////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998 Active Voice Corporation. All Rights Reserved.
  4. //
  5. // Active Agent(r) and Unified Communications(tm) are trademarks of Active Voice Corporation.
  6. //
  7. // Other brand and product names used herein are trademarks of their respective owners.
  8. //
  9. // The entire program and user interface including the structure, sequence, selection,
  10. // and arrangement of the dialog, the exclusively "yes" and "no" choices represented
  11. // by "1" and "2," and each dialog message are protected by copyrights registered in
  12. // the United States and by international treaties.
  13. //
  14. // Protected by one or more of the following United States patents: 5,070,526, 5,488,650,
  15. // 5,434,906, 5,581,604, 5,533,102, 5,568,540, 5,625,676, 5,651,054.
  16. //
  17. // Active Voice Corporation
  18. // Seattle, Washington
  19. // USA
  20. //
  21. /////////////////////////////////////////////////////////////////////////////////////////
  22. ////
  23. // trace.h - interface for debugging trace functions in trace.c
  24. ////
  25. #ifndef __TRACE_H__
  26. #define __TRACE_H__
  27. #include "winlocal.h"
  28. #define TRACE_VERSION 0x00000100
  29. // handle to trace engine
  30. //
  31. DECLARE_HANDLE32(HTRACE);
  32. #define TRACE_MINLEVEL 0
  33. #define TRACE_MAXLEVEL 9
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37. // TraceInit - initialize trace engine
  38. // <dwVersion> (i) must be TRACE_VERSION
  39. // <hInst> (i) instance of calling module
  40. // return handle to trace engine (NULL if error)
  41. //
  42. // NOTE: The level and destination of trace output is determined
  43. // by values found in the file TRACE.INI in the Windows directory.
  44. // TRACE.INI is expected to have the following format:
  45. //
  46. // [TRACE]
  47. // Level=0 {TRACE_MINLEVEL...TRACE_MAXLEVEL}
  48. // OutputTo= OutputDebugString()
  49. // =COM1 COM1:9600,n,8,1
  50. // =COM2:2400,n,8,1 specified comm device
  51. #ifdef TRACE_OUTPUTFILE
  52. // =filename specified file
  53. #endif
  54. #ifdef _WIN32
  55. // =console stdout
  56. #endif
  57. //
  58. #ifdef NOTRACE
  59. #define TraceInit(dwVersion, hInst) 1
  60. #else
  61. HTRACE DLLEXPORT WINAPI TraceInit(DWORD dwVersion, HINSTANCE hInst);
  62. #endif
  63. // TraceTerm - shut down trace engine
  64. // <hTrace> (i) handle returned from TraceInit or NULL
  65. // return 0 if success
  66. //
  67. #ifdef NOTRACE
  68. #define TraceTerm(hTrace) 0
  69. #else
  70. int DLLEXPORT WINAPI TraceTerm(HTRACE hTrace);
  71. #endif
  72. // TraceGetLevel - get current trace level
  73. // <hTrace> (i) handle returned from TraceInit or NULL
  74. // return trace level (-1 if error)
  75. //
  76. #ifdef NOTRACE
  77. #define TraceGetLevel(hTrace) 0
  78. #else
  79. int DLLEXPORT WINAPI TraceGetLevel(HTRACE hTrace);
  80. #endif
  81. // TraceSetLevel - set new trace level (-1 if error)
  82. // <hTrace> (i) handle returned from TraceInit or NULL
  83. // <nLevel> (i) new trace level {TRACE_MINLEVEL...TRACE_MAXLEVEL}
  84. // return 0 if success
  85. //
  86. #ifdef NOTRACE
  87. #define TraceSetLevel(hTrace) 0
  88. #else
  89. int DLLEXPORT WINAPI TraceSetLevel(HTRACE hTrace, int nLevel);
  90. #endif
  91. // TraceOutput - output debug string
  92. // <hTrace> (i) handle returned from TraceInit or NULL
  93. // <nLevel> (i) output only if current trace level is >= nLevel
  94. // <lpszText> (i) string to output
  95. // return 0 if success
  96. //
  97. #ifdef NOTRACE
  98. #define TraceOutput(hTrace, nLevel, lpszText) 0
  99. #else
  100. int DLLEXPORT WINAPI TraceOutput(HTRACE hTrace, int nLevel, LPCTSTR lpszText);
  101. #endif
  102. // TracePrintf - output formatted debug string
  103. // <hTrace> (i) handle returned from TraceInit or NULL
  104. // <nLevel> (i) output only if current trace level is >= nLevel
  105. // <lpszFormat,...> (i) format string and arguments to output
  106. // return 0 if success
  107. //
  108. #ifdef NOTRACE
  109. #define TracePrintf_0(hTrace, nLevel, lpszFormat) 0
  110. #define TracePrintf_1(hTrace, nLevel, lpszFormat, p1) 0
  111. #define TracePrintf_2(hTrace, nLevel, lpszFormat, p1, p2) 0
  112. #define TracePrintf_3(hTrace, nLevel, lpszFormat, p1, p2, p3) 0
  113. #define TracePrintf_4(hTrace, nLevel, lpszFormat, p1, p2, p3, p4) 0
  114. #define TracePrintf_5(hTrace, nLevel, lpszFormat, p1, p2, p3, p4, p5) 0
  115. #define TracePrintf_6(hTrace, nLevel, lpszFormat, p1, p2, p3, p4, p5, p6) 0
  116. #define TracePrintf_7(hTrace, nLevel, lpszFormat, p1, p2, p3, p4, p5, p6, p7) 0
  117. #define TracePrintf_8(hTrace, nLevel, lpszFormat, p1, p2, p3, p4, p5, p6, p7, p8) 0
  118. #define TracePrintf_9(hTrace, nLevel, lpszFormat, p1, p2, p3, p4, p5, p6, p7, p8, p9) 0
  119. #else
  120. int DLLEXPORT FAR CDECL TracePrintf(HTRACE hTrace, int nLevel, LPCTSTR lpszFormat, ...);
  121. #define TracePrintf_0(hTrace, nLevel, lpszFormat) \
  122. TracePrintf(hTrace, nLevel, lpszFormat)
  123. #define TracePrintf_1(hTrace, nLevel, lpszFormat, p1) \
  124. TracePrintf(hTrace, nLevel, lpszFormat, p1)
  125. #define TracePrintf_2(hTrace, nLevel, lpszFormat, p1, p2) \
  126. TracePrintf(hTrace, nLevel, lpszFormat, p1, p2)
  127. #define TracePrintf_3(hTrace, nLevel, lpszFormat, p1, p2, p3) \
  128. TracePrintf(hTrace, nLevel, lpszFormat, p1, p2, p3)
  129. #define TracePrintf_4(hTrace, nLevel, lpszFormat, p1, p2, p3, p4) \
  130. TracePrintf(hTrace, nLevel, lpszFormat, p1, p2, p3, p4)
  131. #define TracePrintf_5(hTrace, nLevel, lpszFormat, p1, p2, p3, p4, p5) \
  132. TracePrintf(hTrace, nLevel, lpszFormat, p1, p2, p3, p4, p5)
  133. #define TracePrintf_6(hTrace, nLevel, lpszFormat, p1, p2, p3, p4, p5, p6) \
  134. TracePrintf(hTrace, nLevel, lpszFormat, p1, p2, p3, p4, p5, p6)
  135. #define TracePrintf_7(hTrace, nLevel, lpszFormat, p1, p2, p3, p4, p5, p6, p7) \
  136. TracePrintf(hTrace, nLevel, lpszFormat, p1, p2, p3, p4, p5, p6, p7)
  137. #define TracePrintf_8(hTrace, nLevel, lpszFormat, p1, p2, p3, p4, p5, p6, p7, p8) \
  138. TracePrintf(hTrace, nLevel, lpszFormat, p1, p2, p3, p4, p5, p6, p7, p8)
  139. #define TracePrintf_9(hTrace, nLevel, lpszFormat, p1, p2, p3, p4, p5, p6, p7, p8, p9) \
  140. TracePrintf(hTrace, nLevel, lpszFormat, p1, p2, p3, p4, p5, p6, p7, p8, p9)
  141. #endif
  142. // TracePosition - output current source file name and line number
  143. // <hTrace> (i) handle returned from TraceInit or NULL
  144. // <nLevel> (i) output only if current trace level is >= nLevel
  145. // return 0 if success
  146. //
  147. #ifdef NOTRACE
  148. #define TracePosition(hTrace, nLevel)
  149. #else
  150. #define TracePosition(hTrace, nLevel) TracePrintf(hTrace, nLevel, \
  151. TEXT("%s(%u) : *** TracePosition\n"), (LPSTR) __FILE__, (unsigned) __LINE__)
  152. #endif
  153. // TraceFALSE - output file and line number, return FALSE
  154. // <hTrace> (i) handle returned from TraceInit or NULL
  155. // return FALSE
  156. //
  157. // NOTE: Useful for tracking down where a function failure originates.
  158. // For example,
  159. //
  160. // if (Function(a, b, c) != 0)
  161. // fSuccess = TraceFALSE(NULL);
  162. //
  163. #ifdef NOTRACE
  164. #define TraceFALSE(hTrace) FALSE
  165. #define TraceTRUE(hTrace) TRUE
  166. #else
  167. #define TraceFALSE(hTrace) (TracePosition(hTrace, 3), FALSE)
  168. #define TraceTRUE(hTrace) (TracePosition(hTrace, 3), TRUE)
  169. #endif
  170. #ifdef __cplusplus
  171. }
  172. #endif
  173. #endif // __TRACE_H__