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.

294 lines
6.7 KiB

  1. #ifndef _winsevT_
  2. #define _WINSEVT_
  3. /*++
  4. Copyright (c) 1989 Microsoft Corporation
  5. Module Name:
  6. winsevt.h
  7. Abstract:
  8. Functions:
  9. Portability:
  10. This module is portable.
  11. Author:
  12. Pradeep Bahl (PradeepB) Dec-1992
  13. Revision History:
  14. Modification Date Person Description of Modification
  15. ------------------ ------- ---------------------------
  16. --*/
  17. #include "wins.h"
  18. /*
  19. defines
  20. */
  21. /*
  22. macros
  23. */
  24. #define WINSFILE TEXT(__FILE__)
  25. #define WINSLINE __LINE__
  26. /*
  27. WINSEVT_LOG_N_RET_IF_ERR_M -- Logs and Returns with indicated status if
  28. the return from the function is not as expected.
  29. */
  30. #if 0
  31. #define WINSEVT_LOG_N_RET_IF_ERR_M(Func_add, Success_Stat, Status_To_Ret, error_str_mo) \
  32. { \
  33. LONG Status_m; \
  34. if ((Status_m = (Func_add)) != (Success_Stat))\
  35. { \
  36. WinsEvtLogEvt(Status, EVENTLOG_ERROR_TYPE, \
  37. error_str, WINSFILE, WINSLINE); \
  38. return((Status_To_Ret)); \
  39. } \
  40. }
  41. #endif
  42. #define WINSEVT_LOG_PRINT_D_M(_pStr) \
  43. { \
  44. if (WinsCnf.LogDetailedEvts > 0) \
  45. { \
  46. WINSEVT_LOG_PRINT_M((_pStr)); \
  47. } \
  48. }
  49. #define WINSEVT_LOG_PRINT_M(_pStr) { \
  50. WINSEVT_STRS_T EvtStrs; \
  51. EvtStrs.NoOfStrs = 1; \
  52. EvtStrs.pStr[0] = _pStr; \
  53. WinsEvtLogEvt(WINS_SUCCESS, \
  54. EVENTLOG_INFORMATION_TYPE, \
  55. WINS_EVT_PRINT, \
  56. WINSFILE, WINSLINE, &EvtStrs); \
  57. }
  58. #define WINSEVT_LOG_INFO_D_M(Status, EvtId) \
  59. { \
  60. if (WinsCnf.LogDetailedEvts > 0) \
  61. { \
  62. WINSEVT_LOG_INFO_M((Status), (EvtId)); \
  63. } \
  64. }
  65. #define WINSEVT_LOG_INFO_M(Status, EvtId) \
  66. { \
  67. LONG Status_m; \
  68. Status_m = (Status); \
  69. WinsEvtLogEvt(Status_m, EVENTLOG_INFORMATION_TYPE, \
  70. (EvtId), WINSFILE, WINSLINE, NULL); \
  71. }
  72. /*
  73. WINSEVT_LOG_M -- Logs the indicated event
  74. */
  75. #define WINSEVT_LOG_D_M(Status, EvtId) \
  76. { \
  77. if (WinsCnf.LogDetailedEvts > 0) \
  78. { \
  79. WINSEVT_LOG_M((Status), (EvtId)); \
  80. } \
  81. }
  82. #define WINSEVT_LOG_M(Status, EvtId) \
  83. { \
  84. LONG Status_m; \
  85. Status_m = (Status); \
  86. WinsEvtLogEvt(Status_m, EVENTLOG_ERROR_TYPE, \
  87. (EvtId), WINSFILE, WINSLINE, NULL); \
  88. }
  89. //
  90. // log one or more strings specified by the EvtStr structure pointed
  91. // to by pStr (Message is an error message)
  92. //
  93. #define WINSEVT_LOG_STR_D_M(EvtId, pStr) \
  94. { \
  95. if (WinsCnf.LogDetailedEvts > 0) \
  96. { \
  97. WINSEVT_LOG_STR_M((EvtId), (pStr)); \
  98. } \
  99. }
  100. #define WINSEVT_LOG_STR_M(EvtId, pStr) \
  101. WinsEvtLogEvt(WINS_FAILURE, EVENTLOG_ERROR_TYPE, \
  102. (EvtId), WINSFILE, WINSLINE, (pStr));
  103. //
  104. // log one or more strings specified by the EvtStr structure pointed
  105. // to by pStr (Message is an informational message)
  106. //
  107. #define WINSEVT_LOG_INFO_STR_D_M(EvtId, pStr) \
  108. { \
  109. if (WinsCnf.LogDetailedEvts > 0) \
  110. { \
  111. WINSEVT_LOG_INFO_STR_M((EvtId), (pStr)); \
  112. } \
  113. }
  114. #define WINSEVT_LOG_INFO_STR_M(EvtId, pStr) \
  115. WinsEvtLogEvt(WINS_SUCCESS, EVENTLOG_INFORMATION_TYPE, \
  116. (EvtId), WINSFILE, WINSLINE, (pStr));
  117. /*
  118. WINSEVT_LOG_IF_ERR_M -- Logs the indicated event
  119. */
  120. #define WINSEVT_LOG_IF_ERR_D_M(Status, EvtId) \
  121. { \
  122. if (WinsCnf.LogDetailedEvts > 0) \
  123. { \
  124. WINSEVT_LOG_IF_ERR_M((Status), (EvtId)); \
  125. } \
  126. }
  127. #define WINSEVT_LOG_IF_ERR_M(Status, Event_id) \
  128. { \
  129. LONG Status_m; \
  130. Status_m = (Status); \
  131. if (Status_m != WINS_SUCCESS) \
  132. { \
  133. WinsEvtLogEvt(Status_m, EVENTLOG_ERROR_TYPE, \
  134. (Event_id), WINSFILE, WINSLINE, NULL); \
  135. } \
  136. }
  137. /*
  138. WINSEVT_LOG_N_RET_M -- Logs and Returns with indicated status if
  139. the return from the function is not as expected.
  140. */
  141. #define WINSEVT_LOG_N_RET_D_M(Func, EvtId, RetStat) \
  142. { \
  143. if (WinsCnf.LogDetailedEvts > 0) \
  144. { \
  145. WINSEVT_LOG_N_RET_M((Func), (EvtId), (RetStat));\
  146. } \
  147. }
  148. #define WINSEVT_LOG_N_RET_M(Func, Event_id, ret_stat) \
  149. { \
  150. LONG Status_m; \
  151. if (Status_m = (Func)) \
  152. { \
  153. WinsEvtLogEvt(Status_m, EVENTLOG_ERROR_TYPE, \
  154. (Event_id), WINSFILE, WINSLINE, NULL); \
  155. return(ret_stat); \
  156. } \
  157. }
  158. /*
  159. WINSEVT_LOG_N_EXIT_M -- Logs and exit
  160. */
  161. #define WINSEVT_LOG_N_EXIT_D_M(Func, EvtId, RetStat) \
  162. { \
  163. if (WinsCnf.LogDetailedEvts > 0) \
  164. { \
  165. WINSEVT_LOG_N_EXIT_M((Func), (EvtId), (RetStat));\
  166. } \
  167. }
  168. #define WINSEVT_LOG_N_EXIT_M(Func, Event_id, ret_stat) \
  169. { \
  170. LONG Status_m; \
  171. if ((Status_m = (Func)) != (WINS_SUCCESS)) \
  172. { \
  173. WinsEvtLogEvt(Status_m, EVENTLOG_ERROR_TYPE,\
  174. (Event_id), WINSFILE, WINSLINE, NULL); \
  175. Exitprocess(1); \
  176. } \
  177. }
  178. #define WINSEVT_LOG_DET_EVT_M1(_Type, _EvtId, _Fmt, _D1) \
  179. if (WinsCnf.LogDetailedEvts > 0) \
  180. { \
  181. WinsEvtLogDetEvt((_Type), (_EvtId), __FILE__, __LINE__, (_Fmt), (_D1)); \
  182. }
  183. #define WINSEVT_LOG_DET_EVT_M2(_Type, _EvtId, _Fmt, _D1, _D2) \
  184. if (WinsCnf.LogDetailedEvts > 0) \
  185. { \
  186. WinsEvtLogDetEvt((_Type), (_EvtId), __FILE__, __LINE__, (_Fmt), (_D1), (_D2)); \
  187. }
  188. #define WINSEVT_LOG_DET_EVT_M3(_Type, _EvtId, _Fmt, _D1, _D2, _D3) \
  189. if (WinsCnf.LogDetailedEvts > 0) \
  190. { \
  191. WinsEvtLogDetEvt((_Type), (_EvtId), __FILE__, __LINE__, (_Fmt), (_D1), (_D2), (_D3)); \
  192. }
  193. #define WINSEVT_LOG_DET_EVT_M3(_Type, _EvtId, _Fmt, _D1, _D2, _D3) \
  194. if (WinsCnf.LogDetailedEvts > 0) \
  195. { \
  196. WinsEvtLogDetEvt((_Type), (_EvtId), __FILE__, __LINE__, (_Fmt), (_D1), (_D2), (_D3)); \
  197. }
  198. //
  199. // Max. number of strings that can be logged
  200. //
  201. #define MAX_NO_STRINGS 5
  202. /*
  203. externs
  204. */
  205. /*
  206. structure definitions
  207. */
  208. typedef struct _WINSEVT_STRS_T {
  209. DWORD NoOfStrs;
  210. LPTSTR pStr[MAX_NO_STRINGS];
  211. } WINSEVT_STRS_T, *PWINSEVT_STRS_T;
  212. /*
  213. function definitions
  214. */
  215. extern
  216. VOID
  217. WinsEvtLogEvt
  218. (
  219. LONG StatusCode,
  220. WORD EvtTyp,
  221. DWORD EvtId,
  222. LPTSTR pFileStr, //change to LPTSTR later
  223. DWORD LineNumber,
  224. PWINSEVT_STRS_T pStr
  225. );
  226. extern
  227. VOID
  228. WinsEvtLogDetEvt(
  229. BOOL fInfo,
  230. DWORD EvtId,
  231. LPTSTR pFileStr,
  232. DWORD LineNumber,
  233. LPSTR pFormat,
  234. ...
  235. );
  236. VOID
  237. WinsLogAdminEvent(
  238. IN DWORD EventId,
  239. IN DWORD StrArgs,
  240. IN ...
  241. );
  242. #endif //_WINSEVT_
  243.