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.

194 lines
5.7 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORP., 1997
  4. *
  5. * TITLE: WiaLog.h
  6. *
  7. * VERSION: 1.0
  8. *
  9. * AUTHOR: CoopP
  10. *
  11. * DATE: 20 Aug, 1999
  12. *
  13. * DESCRIPTION:
  14. * Declarations and definitions for the WIA logging object.
  15. *
  16. *******************************************************************************/
  17. #ifndef WIALOG_H
  18. #define WIALOG_H
  19. #include <wia.h>
  20. // Flush state
  21. #ifdef WINNT
  22. #define FLUSH_STATE FALSE
  23. #else
  24. // Must be TRUE for Win9x
  25. #define FLUSH_STATE TRUE
  26. #endif
  27. #define MAX_TEXT_BUFFER 1024
  28. #define MAX_NAME_BUFFER 64
  29. #define NUM_BYTES_TO_LOCK_LOW 4096
  30. #define NUM_BYTES_TO_LOCK_HIGH 0
  31. #define WIA_MAX_LOG_SIZE 1000000
  32. #define MAX_SIG_LEN 64
  33. // Type of logging
  34. #define WIALOG_TRACE 0x00000001
  35. #define WIALOG_WARNING 0x00000002
  36. #define WIALOG_ERROR 0x00000004
  37. // level of detail for TRACE logging
  38. #define WIALOG_LEVEL1 1 // Entry and Exit point of each function/method
  39. #define WIALOG_LEVEL2 2 // LEVEL 1, + traces within the function/method
  40. #define WIALOG_LEVEL3 3 // LEVEL 1, LEVEL 2, and any extra debugging information
  41. #define WIALOG_LEVEL4 4 // USER DEFINED data + all LEVELS of tracing
  42. #define WIALOG_NO_RESOURCE_ID 0
  43. #define WIALOG_NO_LEVEL 0
  44. // format details for logging
  45. #define WIALOG_ADD_TIME 0x00010000
  46. #define WIALOG_ADD_MODULE 0x00020000
  47. #define WIALOG_ADD_THREAD 0x00040000
  48. #define WIALOG_ADD_THREADTIME 0x00080000
  49. #define WIALOG_LOG_TOUI 0x00100000
  50. #define WIALOG_MESSAGE_TYPE_MASK 0x0000ffff
  51. #define WIALOG_MESSAGE_FLAGS_MASK 0xffff0000
  52. #define WIALOG_CHECK_TRUNCATE_ON_BOOT 0x00000001
  53. #define WIALOG_DEBUGGER 0x00000008
  54. #define WIALOG_UI 0x00000016
  55. #define MAX_TRUNCATE_SIZE 350000
  56. //
  57. // NB!!! Move this to the IDL as soon as IWiaLogEx is in
  58. //
  59. // This struct is used to match a MethodId / MethodName pair
  60. //
  61. typedef struct _MapTableEntry {
  62. LONG lSize;
  63. LONG lMethodId;
  64. BSTR bstrMethodName;
  65. } MapTableEntry;
  66. typedef struct _MappingTable {
  67. LONG lSize;
  68. LONG lNumEntries;
  69. MapTableEntry *pEntries;
  70. } MappingTable;
  71. class CFactory;
  72. class CWiaLog : public IWiaLog,
  73. public IWiaLogEx
  74. {
  75. public:
  76. //
  77. // IWiaLog public methods
  78. //
  79. static HRESULT CreateInstance(const IID& iid, void** ppv);
  80. private:
  81. //
  82. // IUnknown methods
  83. //
  84. HRESULT _stdcall QueryInterface(const IID& iid, void** ppv);
  85. ULONG _stdcall AddRef();
  86. ULONG _stdcall Release();
  87. friend CFactory;
  88. //
  89. // Construction / Destruction
  90. //
  91. CWiaLog();
  92. ~CWiaLog();
  93. //
  94. // IWiaLog private methods (exposed to the client)
  95. //
  96. HRESULT _stdcall InitializeLog (LONG hInstance);
  97. HRESULT _stdcall Log (LONG lFlags, LONG lResID, LONG lDetail, BSTR bstrText);
  98. HRESULT _stdcall hResult(HRESULT hr);
  99. //
  100. // IWiaLogEx private methods (exposed to the client)
  101. //
  102. HRESULT _stdcall InitializeLogEx (BYTE* hInstance);
  103. HRESULT _stdcall LogEx (LONG lMethodId, LONG lFlags, LONG lResID, LONG lDetail, BSTR bstrText);
  104. HRESULT _stdcall hResultEx (LONG lMethodId, HRESULT hr);
  105. HRESULT _stdcall UpdateSettingsEx (LONG lCount, LONG *plMethodIds);
  106. HRESULT _stdcall ExportMappingTableEx(MappingTable **ppTable);
  107. //
  108. // IWiaLog private methods (not exposed to the client)
  109. //
  110. HRESULT Initialize();
  111. HRESULT Trace (BSTR bstrText, LONG lDetail = 0, LONG lMethodId = 0);
  112. HRESULT Warning(BSTR bstrText, LONG lMethodId = 0);
  113. HRESULT Error (BSTR bstrText, LONG lMethodId = 0);
  114. //
  115. // IWiaLog private helpers (not exposed to the client)
  116. //
  117. BOOL OpenLogFile();
  118. VOID WriteStringToLog(LPTSTR pszTextBuffer,BOOL fFlush = FALSE);
  119. VOID WriteLogSessionHeader();
  120. BOOL QueryLoggingSettings();
  121. VOID ConstructText();
  122. BOOL FormatDLLName(HINSTANCE hInstance,TCHAR *pchBuffer,INT cbBuffer);
  123. BOOL FormatStdTime(const SYSTEMTIME *pstNow,TCHAR *pchBuffer);
  124. BOOL NeedsToBeFreed(BSTR* pBSTR);
  125. VOID ProcessTruncation();
  126. //
  127. // member variables
  128. //
  129. ULONG m_cRef; // Reference count for this object.
  130. ITypeInfo* m_pITypeInfo; // Pointer to type information.
  131. DWORD m_dwReportMode; // bit mask, describing which messages types get reported
  132. DWORD m_dwMaxSize; // maximum size ( in bytes ) of LOG file
  133. HANDLE m_hLogFile; // handle to active log file
  134. HINSTANCE m_hInstance; // handle to caller's instance
  135. TCHAR m_szFmtDLLName[MAX_NAME_BUFFER]; // calling DLL's name
  136. LONG m_lDetail; // level of detailing for TRACE
  137. TCHAR m_szLogFilePath[MAX_PATH]; // log file path
  138. BOOL m_bLogToDebugger; // log to the debugger
  139. BOOL m_bLogToUI; // log to a UI, (window?)
  140. TCHAR m_szKeyName[MAX_NAME_BUFFER]; // KEY name (registry)
  141. BOOL m_bLoggerInitialized; // Logger has valid data to function correctly
  142. TCHAR m_szModeText[MAX_PATH * 2]; // Formatted logging text
  143. TCHAR m_szTextBuffer[MAX_PATH]; // shared temporary text buffer
  144. TCHAR m_szColumnHeader[MAX_PATH]; // column header information
  145. BOOL m_bTruncate; // Truncate file on BOOT
  146. BOOL m_bClear; // Clear Log file on BOOT
  147. };
  148. //
  149. // TEMPROARY ONLY!!!!
  150. // Define CWiaLogProc to be CWiaLogProcEx. This is only until drivers are moved over to the new system!
  151. //
  152. #define CWiaLogProc CWiaLogProcEx
  153. #endif