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.

353 lines
11 KiB

  1. //+---------------------------------------------------------------------------
  2. // Copyright (C) 1991-1999, Microsoft Corporation.
  3. //
  4. // File: DEBNOT.h
  5. //
  6. // Contents: Private project-wide Win 4 definitions
  7. //
  8. // History: 23-Jul-91 KyleP Created.
  9. // 15-Oct-91 KevinRo Major changes and comments added
  10. // 18-Oct-91 vich Consolidated win4p.hxx
  11. // 22-Oct-91 SatoNa Added SHLSTRICT
  12. // 29-Apr-92 BartoszM Moved from win4p.h
  13. // 3-Jun-92 BruceFo Added SMUISTRICT
  14. // 17-Dec-92 AlexT Moved UN..._PARM out of DEVL==1
  15. // 30-Sep-93 KyleP DEVL obsolete
  16. // 18-Jun-94 AlexT Make Assert a better statement
  17. //
  18. //----------------------------------------------------------------------------
  19. #ifndef __DEBNOT_H__
  20. #define __DEBNOT_H__
  21. #if _MSC_VER > 1000
  22. #pragma once
  23. #endif
  24. #include <stdarg.h>
  25. //----------------------------------------------------------------------------
  26. // Parameter Macros
  27. //
  28. // To avoid compiler warnings for unimplemented functions, use
  29. // UNIMPLEMENTED_PARM(x) for each unreferenced parameter. This will
  30. // later be defined to nul to reveal functions that we forgot to implement.
  31. //
  32. // For functions which will never use a parameter, use
  33. // UNREFERENCED_PARM(x).
  34. //
  35. #define UNIMPLEMENTED_PARM(x) (x)
  36. #define UNREFERENCED_PARM(x) (x)
  37. //----------------------------------------------------------------------------
  38. //
  39. // New STRICT defines should be added in two places below:
  40. //
  41. // 1) Add the following within the ifdef ALLSTRICT/endif:
  42. //
  43. // #ifndef xxSTRICT
  44. // # define xxSTRICT
  45. // #endif
  46. //
  47. // These entries are in alphabetical order.
  48. //
  49. // 2) Add the following to the #if clause that defines ANYSTRICT:
  50. //
  51. // #if ... || defined(xxSTRICT) || ...
  52. //
  53. // so that ANYSTRICT is defined if any of the STRICT defines are.
  54. //
  55. #if defined(WIN32)
  56. #include <windef.h>
  57. #endif
  58. #ifndef EXPORTDEF
  59. #define EXPORTDEF
  60. #endif
  61. #ifndef EXPORTIMP
  62. #define EXPORTIMP
  63. #endif
  64. #ifndef EXPORTED
  65. #define EXPORTED _cdecl
  66. #endif
  67. #ifndef APINOT
  68. #if defined(_X86_) || defined(_IA64_)
  69. #define APINOT _stdcall
  70. #else
  71. #define APINOT _cdecl
  72. #endif
  73. #endif
  74. //
  75. // DEBUG -- DEBUG -- DEBUG -- DEBUG -- DEBUG
  76. //
  77. #if (DBG == 1) || (CIDBG == 1)
  78. //
  79. // Debug print functions.
  80. //
  81. #ifdef __cplusplus
  82. extern "C" {
  83. # define EXTRNC "C"
  84. #else
  85. # define EXTRNC
  86. #endif
  87. // vdprintf should only be called from xxDebugOut()
  88. EXPORTDEF void APINOT
  89. vdprintf(
  90. unsigned long ulCompMask,
  91. char const *pszComp,
  92. char const *ppszfmt,
  93. va_list ArgList);
  94. #define _Win4Assert Win4AssertEx
  95. EXPORTDEF void APINOT
  96. Win4AssertEx(
  97. char const *pszFile,
  98. int iLine,
  99. char const *pszMsg);
  100. EXPORTDEF int APINOT
  101. PopUpError(
  102. char const *pszMsg,
  103. int iLine,
  104. char const *pszFile);
  105. #define _SetWin4InfoLevel SetWin4InfoLevel
  106. EXPORTDEF unsigned long APINOT
  107. SetWin4InfoLevel(
  108. unsigned long ulNewLevel);
  109. EXPORTDEF unsigned long APINOT
  110. SetWin4InfoMask(
  111. unsigned long ulNewMask);
  112. #define _SetWin4AssertLevel SetWin4AssertLevel
  113. EXPORTDEF unsigned long APINOT
  114. SetWin4AssertLevel(
  115. unsigned long ulNewLevel);
  116. EXPORTDEF unsigned long APINOT
  117. SetWin4ExceptionLevel(
  118. unsigned long ulNewLevel);
  119. #ifdef __cplusplus
  120. }
  121. #endif // __cplusplus
  122. # define EXSTRICT // (EXception STRICT) - Enabled if ANYSTRICT is enabled
  123. # define Win4Assert(x) \
  124. (void)((x) || (Win4AssertEx(__FILE__, __LINE__, #x),0))
  125. # define Assert(x) \
  126. (void)((x) || (Win4AssertEx(__FILE__, __LINE__, #x),0))
  127. # define Verify(x) Assert(x)
  128. //
  129. // Debug print macros
  130. //
  131. # define DEB_ERROR 0x00000001 // exported error paths
  132. # define DEB_WARN 0x00000002 // exported warnings
  133. # define DEB_TRACE 0x00000004 // exported trace messages
  134. # define DEB_DBGOUT 0x00000010 // Output to debugger
  135. # define DEB_STDOUT 0x00000020 // Output to stdout
  136. # define DEB_IERROR 0x00000100 // internal error paths
  137. # define DEB_IWARN 0x00000200 // internal warnings
  138. # define DEB_ITRACE 0x00000400 // internal trace messages
  139. # define DEB_USER1 0x00010000 // User defined
  140. # define DEB_USER2 0x00020000 // User defined
  141. # define DEB_USER3 0x00040000 // User defined
  142. # define DEB_USER4 0x00080000 // User defined
  143. # define DEB_USER5 0x00100000 // User defined
  144. # define DEB_USER6 0x00200000 // User defined
  145. # define DEB_USER7 0x00400000 // User defined
  146. # define DEB_USER8 0x00800000 // User defined
  147. # define DEB_USER9 0x01000000 // User defined
  148. # define DEB_USER10 0x02000000 // User defined
  149. # define DEB_USER11 0x04000000 // User defined
  150. # define DEB_USER12 0x08000000 // User defined
  151. # define DEB_USER13 0x10000000 // User defined
  152. # define DEB_USER14 0x20000000 // User defined
  153. # define DEB_USER15 0x40000000 // User defined
  154. # define DEB_NOCOMPNAME 0x80000000 // suppress component name
  155. # define DEB_FORCE 0x7fffffff // force message
  156. # define ASSRT_MESSAGE 0x00000001 // Output a message
  157. # define ASSRT_BREAK 0x00000002 // Int 3 on assertion
  158. # define ASSRT_POPUP 0x00000004 // And popup message
  159. # define EXCEPT_MESSAGE 0x00000001 // Output a message
  160. # define EXCEPT_BREAK 0x00000002 // Int 3 on exception
  161. # define EXCEPT_POPUP 0x00000004 // Popup message
  162. # define EXCEPT_FAULT 0x00000008 // generate int 3 on access violation
  163. # define EXCEPT_VERBOSE 0x00000010 // Output message even for "quiet" exceptions
  164. //+----------------------------------------------------------------------
  165. //
  166. // DECLARE_DEBUG(comp)
  167. // DECLARE_INFOLEVEL(comp)
  168. //
  169. // This macro defines xxDebugOut where xx is the component prefix
  170. // to be defined. This declares a static variable 'xxInfoLevel', which
  171. // can be used to control the type of xxDebugOut messages printed to
  172. // the terminal. For example, xxInfoLevel may be set at the debug terminal.
  173. // This will enable the user to turn debugging messages on or off, based
  174. // on the type desired. The predefined types are defined below. Component
  175. // specific values should use the upper 24 bits
  176. //
  177. // To Use:
  178. //
  179. // 1) In your components main include file, include the line
  180. // DECLARE_DEBUG(comp)
  181. // where comp is your component prefix
  182. //
  183. // 2) In one of your components source files, include the line
  184. // DECLARE_INFOLEVEL(comp)
  185. // where comp is your component prefix. This will define the
  186. // global variable that will control output.
  187. //
  188. // It is suggested that any component define bits be combined with
  189. // existing bits. For example, if you had a specific error path that you
  190. // wanted, you might define DEB_<comp>_ERRORxxx as being
  191. //
  192. // (0x100 | DEB_ERROR)
  193. //
  194. // This way, we can turn on DEB_ERROR and get the error, or just 0x100
  195. // and get only your error.
  196. //
  197. // Define values that are specific to your xxInfoLevel variable in your
  198. // own file, like ciquery.hxx.
  199. //
  200. //-----------------------------------------------------------------------
  201. # ifndef DEF_INFOLEVEL
  202. # define DEF_INFOLEVEL (DEB_ERROR | DEB_WARN)
  203. # endif
  204. //
  205. // Back to the info level stuff.
  206. //
  207. //
  208. // For C++. and in a module which has access to GetProfileInt, automatically
  209. // initialise the info level from a setting in the [Cairo Infolevels] section
  210. // of win.ini
  211. //
  212. # if defined(__cplusplus) && defined(_CAIRO_) && !defined(KERNEL) && defined(GetProfileInt)
  213. # define DECLARE_INFOLEVEL(comp) \
  214. extern EXTRNC unsigned long comp##InfoLevel = GetProfileIntA ( \
  215. "Cairo Infolevels", \
  216. #comp, \
  217. DEF_INFOLEVEL ); \
  218. extern EXTRNC char *comp##InfoLevelString = #comp;
  219. # else
  220. // Simple initialisation
  221. # define DECLARE_INFOLEVEL(comp) \
  222. extern EXTRNC unsigned long comp##InfoLevel = DEF_INFOLEVEL; \
  223. extern EXTRNC char *comp##InfoLevelString = #comp;
  224. # endif
  225. # ifdef __cplusplus
  226. # define DECLARE_DEBUG(comp) \
  227. extern EXTRNC unsigned long comp##InfoLevel; \
  228. extern EXTRNC char *comp##InfoLevelString; \
  229. _inline void \
  230. comp##InlineDebugOut(unsigned long fDebugMask, char const *pszfmt, ...) \
  231. { \
  232. if (comp##InfoLevel & fDebugMask) \
  233. { \
  234. va_list va; \
  235. va_start (va, pszfmt); \
  236. vdprintf(fDebugMask, comp##InfoLevelString, pszfmt, va);\
  237. va_end(va); \
  238. } \
  239. } \
  240. \
  241. class comp##CDbgTrace\
  242. {\
  243. private:\
  244. unsigned long _ulFlags;\
  245. char const * const _pszName;\
  246. public:\
  247. comp##CDbgTrace(unsigned long ulFlags, char const * const pszName);\
  248. ~comp##CDbgTrace();\
  249. };\
  250. \
  251. inline comp##CDbgTrace::comp##CDbgTrace(\
  252. unsigned long ulFlags,\
  253. char const * const pszName)\
  254. : _ulFlags(ulFlags), _pszName(pszName)\
  255. {\
  256. comp##InlineDebugOut(_ulFlags, "Entering %s\n", _pszName);\
  257. }\
  258. \
  259. inline comp##CDbgTrace::~comp##CDbgTrace()\
  260. {\
  261. comp##InlineDebugOut(_ulFlags, "Exiting %s\n", _pszName);\
  262. }
  263. # else // ! __cplusplus
  264. # define DECLARE_DEBUG(comp) \
  265. extern EXTRNC unsigned long comp##InfoLevel; \
  266. extern EXTRNC char *comp##InfoLevelString; \
  267. _inline void \
  268. comp##InlineDebugOut(unsigned long fDebugMask, char const *pszfmt, ...) \
  269. { \
  270. if (comp##InfoLevel & fDebugMask) \
  271. { \
  272. va_list va; \
  273. va_start (va, pszfmt); \
  274. vdprintf(fDebugMask, comp##InfoLevelString, pszfmt, va);\
  275. va_end(va); \
  276. } \
  277. }
  278. # endif // ! __cplusplus
  279. #else // DBG == 0
  280. //
  281. // NO DEBUG -- NO DEBUG -- NO DEBUG -- NO DEBUG -- NO DEBUG
  282. //
  283. # define Win4Assert(x) NULL
  284. # define Assert(x) NULL
  285. # define Verify(x) (x)
  286. # define DECLARE_DEBUG(comp)
  287. # define DECLARE_INFOLEVEL(comp)
  288. #endif // DBG == 0
  289. #endif // __DEBNOT_H__