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.

345 lines
10 KiB

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