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.

428 lines
12 KiB

  1. /*****************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /*****************************************************************/
  5. /*
  6. * loglm.hxx
  7. * This file contains class definitions of LM event log classes.
  8. * LM_EVENT_LOG
  9. * LM_AUDIT_LOG
  10. * LM_ERROR_LOG
  11. *
  12. * History:
  13. * DavidHov 6/6/91 Created
  14. * Yi-HsinS 10/15/91 Modified for event viewer
  15. * Yi-HsinS 12/15/91 Separated from eventlog.hxx
  16. * terryk 12/20/91 Added WriteTextEntry
  17. * Yi-HsinS 1/15/92 Added Backup, SeekOldestLogEntry,
  18. * SeekNewestLogEntry and modified
  19. * parameters to WriteTextEntry
  20. * JonN 6/22/00 WriteTextEntry no longer supported
  21. *
  22. */
  23. #ifndef _LOGLM_HXX_
  24. #define _LOGLM_HXX_
  25. #include "eventlog.hxx"
  26. /*************************************************************************
  27. NAME: LM_EVENT_LOG
  28. SYNOPSIS: The common base class for LM audit log and LM error log
  29. INTERFACE: protected:
  30. I_Next() - Helper method for reading the log file.
  31. I_Open() - Helper method for opening the log for reading.
  32. I_Close()- Helper method for closing the log.
  33. QueryEntriesInBuffer() - Query the number of entries
  34. contained in the buffer.
  35. CreateCurrentRawEntry() - Create a RAW_LOG_ENTRY for the current
  36. log entry. This is used when filtering log files.
  37. SetPos() - Set the position for the next read.
  38. LM_EVENT_LOG() - Constructor
  39. The constructor is protected so that no one can
  40. instantiate an object of this class.
  41. public:
  42. ~LM_EVENT_LOG() - Virtual destructor
  43. Clear() - Clear the event log
  44. Reset() - Reset to the beginning or end of log depending
  45. on direction
  46. QueryPos() - Get the position of the current event log entry
  47. relative to the beginning or the end of the file
  48. depending on the direction
  49. SeekOldestLogEntry() - Get the oldest log entry in the log
  50. SeekNewestLogEntry() - Get the newest log entry in the log
  51. QueryNumberOfEntries() - Get the approximate number of
  52. entries in the log.
  53. CreateCurrentFormatEntry() - Create a FORMATTED_LOG_ENTRY for
  54. the current log entry.
  55. WriteTextEntry() - Write the current log entry to a text file
  56. JonN 6/22/00 WriteTextEntry no longer supported
  57. QueryCurrentEntrylData() -
  58. Retrieve the raw data of the current log entry
  59. QueryCurrentEntryDesc() -
  60. Get the description of the current log entry
  61. QueryCurrentEntryTime() -
  62. Get the time of the current log entry
  63. PARENT: EVENT_LOG
  64. USES:
  65. CAVEATS:
  66. NOTES:
  67. HISTORY:
  68. Yi-HsinS 10/15/91 Created
  69. **************************************************************************/
  70. DLL_CLASS LM_EVENT_LOG: public EVENT_LOG
  71. {
  72. protected:
  73. /*
  74. * Handle to the LM event log
  75. */
  76. HLOG _hLog;
  77. /*
  78. * Pointer to buffer holding a whole amount of event log entries
  79. * returned by a Net API call.
  80. * ( fixed size header plus the variable portion )
  81. */
  82. BYTE *_pbBuf;
  83. /*
  84. * The record number of the current entry from the beginning if the
  85. * direction is EVLOG_FWD or end of the file if the direction
  86. * is EVLOG_BACK.
  87. */
  88. ULONG _ulRecordNum;
  89. /*
  90. * The record number of the first log entry contained in the buffer.
  91. * Note: The buffer contains a whole number of entries.
  92. */
  93. ULONG _ulStartRecordNum;
  94. /*
  95. * The number of bytes returned from the last NetXXXRead
  96. */
  97. UINT _cbReturned;
  98. /*
  99. * The number of bytes still available
  100. */
  101. UINT _cbTotalAvail;
  102. /*
  103. * the offset(bytes) in the buffer in which the next log entry starts
  104. */
  105. UINT _cbOffset;
  106. virtual APIERR I_Next( BOOL *pfContinue,
  107. ULONG ulBufferSize = BIG_BUF_DEFAULT_SIZE ) = 0;
  108. virtual APIERR I_Open ( VOID );
  109. virtual APIERR I_Close( VOID );
  110. virtual ULONG QueryEntriesInBuffer( VOID ) = 0;
  111. virtual APIERR CreateCurrentRawEntry( RAW_LOG_ENTRY *pRawLogEntry ) = 0;
  112. virtual VOID SetPos( const LOG_ENTRY_NUMBER &logEntryNum, BOOL fForceRead ) = 0;
  113. /*
  114. * Constructor : takes a server name,
  115. * and an optional direction which defaults to EVLOG_FWD,
  116. * and an optional module( used only in LM2.1) which
  117. * defaults to NULL.
  118. */
  119. LM_EVENT_LOG( const TCHAR *pszServer,
  120. EVLOG_DIRECTION evdir = EVLOG_FWD,
  121. const TCHAR *pszModule = NULL);
  122. public:
  123. virtual ~LM_EVENT_LOG();
  124. /*
  125. * See comments in EVENT_LOG
  126. */
  127. virtual APIERR Clear( const TCHAR *pszBackupFile = NULL ) = 0;
  128. virtual VOID Reset( VOID );
  129. virtual APIERR QueryPos( LOG_ENTRY_NUMBER *plogEntryNum );
  130. virtual APIERR SeekOldestLogEntry( VOID );
  131. virtual APIERR SeekNewestLogEntry( VOID );
  132. virtual APIERR QueryNumberOfEntries( ULONG *pcEntries );
  133. virtual APIERR CreateCurrentFormatEntry( FORMATTED_LOG_ENTRY
  134. **ppFmtLogEntry ) = 0;
  135. // JonN 6/22/00 WriteTextEntry no longer supported
  136. virtual APIERR WriteTextEntry( ULONG ulFileHandle,
  137. INTL_PROFILE &intlprof,
  138. TCHAR chSeparator ) = 0;
  139. virtual ULONG QueryCurrentEntryData( BYTE **ppbDataOut ) = 0;
  140. virtual APIERR QueryCurrentEntryDesc( NLS_STR *pnlsDesc ) = 0;
  141. virtual ULONG QueryCurrentEntryTime( VOID ) = 0;
  142. };
  143. typedef struct audit_entry AUDIT_ENTRY;
  144. typedef struct error_log ERROR_ENTRY;
  145. /*************************************************************************
  146. NAME: LM_AUDIT_LOG
  147. SYNOPSIS: The class for LM audit log
  148. INTERFACE:
  149. protected:
  150. I_Next() - Helper method for reading the log file.
  151. This is a virtual method called by Next() in
  152. EVENT_LOG class.
  153. QueryEntriesInBuffer() - Query the number of entries
  154. contained in the buffer.
  155. CreateCurrentRawEntry() - Create a RAW_LOG_ENTRY for the current
  156. log entry. This is used when filtering log files.
  157. SetPos() - Set the position for the next read.
  158. public:
  159. LM_AUDIT_LOG() - Constructor
  160. ~LM_AUDIT_LOG() - Virtual destructor
  161. Clear() - Clear the log
  162. Reset() - Reset to the beginning or the end of the log depending
  163. on direction
  164. QuerySrcSupportedCategoryList() - Get the categories supported
  165. by the LM audit log.
  166. CreateCurrentFormatEntry() - Create a FORMATTED_LOG_ENTRY for
  167. the current log entry.
  168. WriteTextEntry() - Write the current log entry to a text file
  169. JonN 6/22/00 WriteTextEntry no longer supported
  170. QueryCurrentEntrylData() -
  171. Retrieve the raw data of the current log entry
  172. QueryCurrentEntryDesc() -
  173. Get the description of the current log entry
  174. QueryCurrentEntryTime() -
  175. Get the time of the current log entry
  176. PARENT: LM_EVENT_LOG
  177. USES: STRLIST
  178. CAVEATS:
  179. NOTES:
  180. HISTORY:
  181. Yi-HsinS 10/15/91 Created
  182. **************************************************************************/
  183. DLL_CLASS LM_AUDIT_LOG: public LM_EVENT_LOG
  184. {
  185. private:
  186. /*
  187. * Points to the current audit entry in the buffer _pbBuf in LM_EVENT_LOG
  188. */
  189. AUDIT_ENTRY *_pAE;
  190. /*
  191. * Points to a string list containing the categories supported by
  192. * LM audit logs.
  193. */
  194. STRLIST *_pstrlstCategory;
  195. protected:
  196. virtual APIERR I_Next( BOOL *pfContinue,
  197. ULONG ulBufferSize = BIG_BUF_DEFAULT_SIZE );
  198. virtual ULONG QueryEntriesInBuffer( VOID );
  199. virtual APIERR CreateCurrentRawEntry( RAW_LOG_ENTRY *pRawLogEntry );
  200. virtual VOID SetPos( const LOG_ENTRY_NUMBER &logEntryNum, BOOL fForceRead );
  201. /*
  202. * Get the audit entry type of the current log entry
  203. */
  204. MSGID QueryCurrentEntryCategory( VOID );
  205. /*
  206. * Helper method to map permissions to a readable string.
  207. */
  208. APIERR PermMap( UINT uiPerm, NLS_STR *pnlsPerm );
  209. public:
  210. /*
  211. * Constructor : takes a server name,
  212. * and an optional direction which defaults to EVLOG_FWD,
  213. * and an optional module which defaults to NULL.
  214. */
  215. LM_AUDIT_LOG( const TCHAR *pszServer,
  216. EVLOG_DIRECTION evdir = EVLOG_FWD,
  217. const TCHAR *pszModule = NULL);
  218. virtual ~LM_AUDIT_LOG();
  219. /*
  220. * See comments in EVENT_LOG
  221. */
  222. virtual APIERR Clear( const TCHAR *pszBackupFile = NULL );
  223. virtual VOID Reset( VOID );
  224. virtual APIERR QuerySrcSupportedCategoryList( const NLS_STR &nlsSource,
  225. STRLIST **ppstrlstCategory );
  226. virtual APIERR CreateCurrentFormatEntry( FORMATTED_LOG_ENTRY
  227. **ppFmtLogEntry);
  228. // JonN 6/22/00 WriteTextEntry no longer supported
  229. virtual APIERR WriteTextEntry( ULONG ulFileHandle,
  230. INTL_PROFILE &intlprof,
  231. TCHAR chSeparator );
  232. virtual ULONG QueryCurrentEntryData( BYTE **pbDataOut );
  233. virtual APIERR QueryCurrentEntryDesc( NLS_STR *pnlsDesc );
  234. virtual ULONG QueryCurrentEntryTime( VOID );
  235. };
  236. /*************************************************************************
  237. NAME: LM_ERROR_LOG
  238. SYNOPSIS: The class for LM error log
  239. INTERFACE: protected:
  240. I_Next() - Helper function for reading the log file.
  241. This is a virtual method called by Next() in
  242. EVENT_LOG class.
  243. CreateCurrentRawEntry() - Create a RAW_LOG_ENTRY for the current
  244. log entry. This is used when filtering log files.
  245. SetPos() - Set the position for the next read.
  246. NextString() - Iterator for returning the strings in the
  247. current log entry.
  248. public:
  249. LM_ERROR_LOG() - Constructor
  250. ~LM_ERROR_LOG() - Virtual destructor
  251. Clear() - Clear the log
  252. Reset() - Reset to the beginning or the end of the log
  253. depending on direction.
  254. CreateCurrentFormatEntry() - Create a FORMATTED_LOG_ENTRY for
  255. the current log entry.
  256. WriteTextEntry() - Write the current log entry to a text file
  257. JonN 6/22/00 WriteTextEntry no longer supported
  258. QueryCurrentEntrylData() -
  259. Retrieve the raw data of the current log entry
  260. QueryCurrentEntryDesc() -
  261. Get the description of the current log entry
  262. QueryCurrentEntryTime() -
  263. Get the time of the current log entry
  264. PARENT: LM_EVENT_LOG
  265. USES:
  266. CAVEATS:
  267. NOTES:
  268. HISTORY:
  269. Yi-HsinS 10/15/91 Created
  270. **************************************************************************/
  271. DLL_CLASS LM_ERROR_LOG: public LM_EVENT_LOG
  272. {
  273. private:
  274. /*
  275. * Points to the current error log entry in the buffer _pbBuf
  276. * in LM_EVENT_LOG
  277. */
  278. ERROR_ENTRY *_pEE;
  279. /*
  280. * The index of the next string to be retrieved by NextString()
  281. */
  282. UINT _iStrings;
  283. protected:
  284. virtual APIERR I_Next( BOOL *pfContinue,
  285. ULONG ulBufferSize = BIG_BUF_DEFAULT_SIZE );
  286. virtual APIERR CreateCurrentRawEntry( RAW_LOG_ENTRY *pRawLogEntry );
  287. virtual VOID SetPos( const LOG_ENTRY_NUMBER &logEntryNum, BOOL fForceRead );
  288. virtual ULONG QueryEntriesInBuffer( VOID );
  289. /*
  290. * Iterator to return the next string in the current error log.
  291. * Returns FALSE if some error occurs or if there are no more strings left.
  292. * Need to QueryLastError() to distinguish between the two cases.
  293. */
  294. APIERR NextString( BOOL *pfContinue, NLS_STR **ppnlsString );
  295. public:
  296. /*
  297. * Constructor : takes a server name,
  298. * and an optional direction which defaults to EVLOG_FWD.
  299. * and an optional module (ignored in the error log )
  300. * which defaults to NULL.
  301. */
  302. LM_ERROR_LOG( const TCHAR *pszServer,
  303. EVLOG_DIRECTION evdir = EVLOG_FWD,
  304. const TCHAR *pszModule = NULL );
  305. virtual ~LM_ERROR_LOG();
  306. /*
  307. * See comments in EVENT_LOG
  308. */
  309. virtual APIERR Clear( const TCHAR *pszBackupFile = NULL );
  310. virtual VOID Reset( VOID );
  311. virtual APIERR CreateCurrentFormatEntry(FORMATTED_LOG_ENTRY
  312. **ppFmtLogEntry);
  313. // JonN 6/22/00 WriteTextEntry no longer supported
  314. virtual APIERR WriteTextEntry( ULONG ulFileHandle, INTL_PROFILE
  315. &intlprof, TCHAR chSeparator );
  316. virtual ULONG QueryCurrentEntryData( BYTE **ppbDataOut );
  317. virtual APIERR QueryCurrentEntryDesc( NLS_STR *pnlsDesc );
  318. virtual ULONG QueryCurrentEntryTime( VOID );
  319. };
  320. #endif