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.

451 lines
12 KiB

  1. //+---------------------------------------------------------------------------
  2. // Copyright (C) 1991, Microsoft Corporation.
  3. //
  4. // File: formdeb.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. // 08-Aug-94 DonCl copied from cinc and renamed formdeb.h
  18. //
  19. //----------------------------------------------------------------------------
  20. #ifndef __FORMDEB_H__
  21. #define __FORMDEB_H__
  22. #define __DEBNOT_H__ // keep debnot.h from being included accidentally
  23. #include <stdarg.h>
  24. //----------------------------------------------------------------------------
  25. // Parameter Macros
  26. //
  27. // To avoid compiler warnings for unimplemented functions, use
  28. // UNIMPLEMENTED_PARM(x) for each unreferenced parameter. This will
  29. // later be defined to nul to reveal functions that we forgot to implement.
  30. //
  31. // For functions which will never use a parameter, use
  32. // UNREFERENCED_PARM(x).
  33. //
  34. #define UNIMPLEMENTED_PARM(x) (x)
  35. #define UNREFERENCED_PARM(x) (x)
  36. //----------------------------------------------------------------------------
  37. //
  38. // New STRICT defines should be added in two places below:
  39. //
  40. // 1) Add the following within the ifdef ALLSTRICT/endif:
  41. //
  42. // #ifndef xxSTRICT
  43. // # define xxSTRICT
  44. // #endif
  45. //
  46. // These entries are in alphabetical order.
  47. //
  48. // 2) Add the following to the #if clause that defines ANYSTRICT:
  49. //
  50. // #if ... || defined(xxSTRICT) || ...
  51. //
  52. // so that ANYSTRICT is defined if any of the STRICT defines are.
  53. //
  54. #if (DBG == 1) || (OFSDBG == 1)
  55. # ifndef CATSTRICT
  56. # define CATSTRICT
  57. # endif
  58. # ifndef CISTRICT
  59. # define CISTRICT
  60. # endif
  61. # ifndef CMSSTRICT
  62. # define CMSSTRICT
  63. # endif
  64. # ifndef DLOSSTRICT
  65. # define DLOSSTRICT
  66. # endif
  67. # ifndef EVSTRICT
  68. # define EVSTRICT
  69. # endif
  70. # ifndef ICLSTRICT
  71. # define ICLSTRICT
  72. # endif
  73. # ifndef INSSTRICT
  74. # define INSSTRICT
  75. # endif
  76. # ifndef JWSTRICT
  77. # define JWSTRICT
  78. # endif
  79. # ifndef NSSTRICT
  80. # define NSSTRICT
  81. # endif
  82. # ifndef OLSTRICT
  83. # define OLSTRICT
  84. # endif
  85. # ifndef OMSTRICT
  86. # define OMSTRICT
  87. # endif
  88. # ifndef REPLSTRICT
  89. # define REPLSTRICT
  90. # endif
  91. # ifndef SHLSTRICT
  92. # define SHLSTRICT
  93. # endif
  94. # ifndef SLSTRICT
  95. # define SLSTRICT
  96. # endif
  97. # ifndef SMUISTRICT
  98. # define SMUISTRICT
  99. # endif
  100. # ifndef SOMSTRICT
  101. # define SOMSTRICT
  102. # endif
  103. # ifndef VCSTRICT
  104. # define VCSTRICT
  105. # endif
  106. # ifndef VQSTRICT
  107. # define VQSTRICT
  108. # endif
  109. # ifndef WMASTRICT
  110. # define WMASTRICT
  111. # endif
  112. #endif // (DBG == 1) || (OFSDBG == 1)
  113. //
  114. // ANYSTRICT
  115. //
  116. #if defined(CATSTRICT) || \
  117. defined(CISTRICT) || \
  118. defined(CMSSTRICT) || \
  119. defined(DLOSSTRICT)|| \
  120. defined(ICLSTRICT) || \
  121. defined(INSSTRICT) || \
  122. defined(JWSTRICT) || \
  123. defined(NSSTRICT) || \
  124. defined(OLSTRICT) || \
  125. defined(OMSTRICT) || \
  126. defined(REPLSTRICT)|| \
  127. defined(SHLSTRICT) || \
  128. defined(SLSTRICT) || \
  129. defined(SMUISTRICT)|| \
  130. defined(SOMSTRICT) || \
  131. defined(VCSTRICT) || \
  132. defined(VQSTRICT) || \
  133. defined(WMASTRICT)
  134. # define ANYSTRICT
  135. #endif
  136. #if (DBG != 1 && OFSDBG != 1) && defined(ANYSTRICT)
  137. #pragma message Asserts are defined in a RETAIL build...
  138. #endif
  139. #if defined(WIN32)
  140. #include <windef.h>
  141. #endif
  142. #ifndef EXPORTDEF
  143. #define EXPORTDEF
  144. #endif
  145. #ifndef EXPORTIMP
  146. #define EXPORTIMP
  147. #endif
  148. #ifndef EXPORTED
  149. #define EXPORTED _cdecl
  150. #endif
  151. #ifndef APINOT
  152. #ifdef _X86_
  153. #define APINOT _stdcall
  154. #else
  155. #define APINOT _cdecl
  156. #endif
  157. #endif
  158. //
  159. // DEBUG -- DEBUG -- DEBUG -- DEBUG -- DEBUG
  160. //
  161. #if (DBG == 1) || (OFSDBG == 1)
  162. //
  163. // Debug print functions.
  164. //
  165. #ifdef __cplusplus
  166. extern "C" {
  167. # define EXTRNC "C"
  168. #else
  169. # define EXTRNC
  170. #endif
  171. // vdprintf should only be called from xxDebugOut()
  172. EXPORTDEF void APINOT
  173. vdprintf(
  174. unsigned long ulCompMask,
  175. char const *pszComp,
  176. char const *ppszfmt,
  177. va_list ArgList);
  178. #define _Win4Assert Win4AssertEx
  179. EXPORTDEF void APINOT
  180. Win4AssertEx(
  181. char const *pszFile,
  182. int iLine,
  183. char const *pszMsg);
  184. EXPORTDEF int APINOT
  185. PopUpError(
  186. char const *pszMsg,
  187. int iLine,
  188. char const *pszFile);
  189. #define _SetWin4InfoLevel SetWin4InfoLevel
  190. EXPORTDEF unsigned long APINOT
  191. SetWin4InfoLevel(
  192. unsigned long ulNewLevel);
  193. EXPORTDEF unsigned long APINOT
  194. SetWin4InfoMask(
  195. unsigned long ulNewMask);
  196. #define _SetWin4AssertLevel SetWin4AssertLevel
  197. EXPORTDEF unsigned long APINOT
  198. SetWin4AssertLevel(
  199. unsigned long ulNewLevel);
  200. EXPORTDEF unsigned long APINOT
  201. SetWin4ExceptionLevel(
  202. unsigned long ulNewLevel);
  203. #ifdef __cplusplus
  204. }
  205. #endif // __cplusplus
  206. # define EXSTRICT // (EXception STRICT) - Enabled if ANYSTRICT is enabled
  207. # define Win4Assert(x) \
  208. (void)((x) || (Win4AssertEx(__FILE__, __LINE__, #x),0))
  209. # define Assert(x) \
  210. (void)((x) || (Win4AssertEx(__FILE__, __LINE__, #x),0))
  211. # define Verify(x) Assert(x)
  212. //
  213. // Debug print macros
  214. //
  215. # define DEB_ERROR 0x00000001 // exported error paths
  216. # define DEB_WARN 0x00000002 // exported warnings
  217. # define DEB_TRACE 0x00000004 // exported trace messages
  218. # define DEB_DBGOUT 0x00000010 // Output to debugger
  219. # define DEB_STDOUT 0x00000020 // Output to stdout
  220. # define DEB_IERROR 0x00000100 // internal error paths
  221. # define DEB_IWARN 0x00000200 // internal warnings
  222. # define DEB_ITRACE 0x00000400 // internal trace messages
  223. # define DEB_USER1 0x00010000 // User defined
  224. # define DEB_USER2 0x00020000 // User defined
  225. # define DEB_USER3 0x00040000 // User defined
  226. # define DEB_USER4 0x00080000 // User defined
  227. # define DEB_USER5 0x00100000 // User defined
  228. # define DEB_USER6 0x00200000 // User defined
  229. # define DEB_USER7 0x00400000 // User defined
  230. # define DEB_USER8 0x00800000 // User defined
  231. # define DEB_USER9 0x01000000 // User defined
  232. # define DEB_USER10 0x02000000 // User defined
  233. # define DEB_USER11 0x04000000 // User defined
  234. # define DEB_USER12 0x08000000 // User defined
  235. # define DEB_USER13 0x10000000 // User defined
  236. # define DEB_USER14 0x20000000 // User defined
  237. # define DEB_USER15 0x40000000 // User defined
  238. # define DEB_NOCOMPNAME 0x80000000 // suppress component name
  239. # define DEB_FORCE 0x7fffffff // force message
  240. # define ASSRT_MESSAGE 0x00000001 // Output a message
  241. # define ASSRT_BREAK 0x00000002 // Int 3 on assertion
  242. # define ASSRT_POPUP 0x00000004 // And popup message
  243. # define EXCEPT_MESSAGE 0x00000001 // Output a message
  244. # define EXCEPT_BREAK 0x00000002 // Int 3 on exception
  245. # define EXCEPT_POPUP 0x00000004 // Popup message
  246. # define EXCEPT_FAULT 0x00000008 // generate int 3 on access violation
  247. //+----------------------------------------------------------------------
  248. //
  249. // DECLARE_DEBUG(comp)
  250. // DECLARE_INFOLEVEL(comp)
  251. //
  252. // This macro defines xxDebugOut where xx is the component prefix
  253. // to be defined. This declares a static variable 'xxInfoLevel', which
  254. // can be used to control the type of xxDebugOut messages printed to
  255. // the terminal. For example, xxInfoLevel may be set at the debug terminal.
  256. // This will enable the user to turn debugging messages on or off, based
  257. // on the type desired. The predefined types are defined below. Component
  258. // specific values should use the upper 24 bits
  259. //
  260. // To Use:
  261. //
  262. // 1) In your components main include file, include the line
  263. // DECLARE_DEBUG(comp)
  264. // where comp is your component prefix
  265. //
  266. // 2) In one of your components source files, include the line
  267. // DECLARE_INFOLEVEL(comp)
  268. // where comp is your component prefix. This will define the
  269. // global variable that will control output.
  270. //
  271. // It is suggested that any component define bits be combined with
  272. // existing bits. For example, if you had a specific error path that you
  273. // wanted, you might define DEB_<comp>_ERRORxxx as being
  274. //
  275. // (0x100 | DEB_ERROR)
  276. //
  277. // This way, we can turn on DEB_ERROR and get the error, or just 0x100
  278. // and get only your error.
  279. //
  280. // Define values that are specific to your xxInfoLevel variable in your
  281. // own file, like ciquery.hxx.
  282. //
  283. //-----------------------------------------------------------------------
  284. # ifndef DEF_INFOLEVEL
  285. # define DEF_INFOLEVEL (DEB_ERROR | DEB_WARN)
  286. # endif
  287. //
  288. // Back to the info level stuff.
  289. //
  290. # ifdef __cplusplus
  291. extern "C" {
  292. # endif // __cplusplus
  293. # define DECLARE_INFOLEVEL(comp) \
  294. extern EXTRNC unsigned long comp##InfoLevel = DEF_INFOLEVEL;\
  295. extern EXTRNC char *comp##InfoLevelString = #comp;
  296. # ifdef __cplusplus
  297. }
  298. # endif
  299. # ifdef __cplusplus
  300. # define DECLARE_DEBUG(comp) \
  301. extern EXTRNC unsigned long comp##InfoLevel; \
  302. extern EXTRNC char *comp##InfoLevelString; \
  303. _inline void \
  304. comp##InlineDebugOut(unsigned long fDebugMask, char const *pszfmt, ...) \
  305. { \
  306. if (comp##InfoLevel & fDebugMask) \
  307. { \
  308. va_list va; \
  309. va_start (va, pszfmt); \
  310. vdprintf(fDebugMask, comp##InfoLevelString, pszfmt, va);\
  311. va_end(va); \
  312. } \
  313. } \
  314. \
  315. class comp##CDbgTrace\
  316. {\
  317. private:\
  318. unsigned long _ulFlags;\
  319. char const * const _pszName;\
  320. public:\
  321. comp##CDbgTrace(unsigned long ulFlags, char const * const pszName);\
  322. ~comp##CDbgTrace();\
  323. };\
  324. \
  325. inline comp##CDbgTrace::comp##CDbgTrace(\
  326. unsigned long ulFlags,\
  327. char const * const pszName)\
  328. : _ulFlags(ulFlags), _pszName(pszName)\
  329. {\
  330. comp##InlineDebugOut(_ulFlags, "Entering %s\n", _pszName);\
  331. }\
  332. \
  333. inline comp##CDbgTrace::~comp##CDbgTrace()\
  334. {\
  335. comp##InlineDebugOut(_ulFlags, "Exiting %s\n", _pszName);\
  336. }
  337. # else // ! __cplusplus
  338. # define DECLARE_DEBUG(comp) \
  339. extern EXTRNC unsigned long comp##InfoLevel; \
  340. extern EXTRNC char *comp##InfoLevelString; \
  341. _inline void \
  342. comp##InlineDebugOut(unsigned long fDebugMask, char const *pszfmt, ...) \
  343. { \
  344. if (comp##InfoLevel & fDebugMask) \
  345. { \
  346. va_list va; \
  347. va_start (va, pszfmt); \
  348. vdprintf(fDebugMask, comp##InfoLevelString, pszfmt, va);\
  349. va_end(va); \
  350. } \
  351. }
  352. # endif // ! __cplusplus
  353. #else // DBG == 0
  354. //
  355. // NO DEBUG -- NO DEBUG -- NO DEBUG -- NO DEBUG -- NO DEBUG
  356. //
  357. # define Win4Assert(x) NULL
  358. # define Assert(x) NULL
  359. # define Verify(x) (x)
  360. # define DECLARE_DEBUG(comp)
  361. # define DECLARE_INFOLEVEL(comp)
  362. #endif // DBG == 0
  363. #endif // __DEBNOT_H__