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.

150 lines
3.4 KiB

  1. #ifndef _SETUPLOG_
  2. #define _SETUPLOG_
  3. #include <windows.h>
  4. #include <setupapi.h>
  5. //
  6. // File names for the 2 log files.
  7. //
  8. #define SETUPLOG_ACTION_FILENAME TEXT("setupact.log")
  9. #define SETUPLOG_ERROR_FILENAME TEXT("setuperr.log")
  10. //
  11. // String used to separate items in the log.
  12. //
  13. #define SETUPLOG_ITEM_TERMINATOR TEXT("\r\n***\r\n\r\n")
  14. //
  15. // Value to be used as a MessageString to indicate that the MessageId should
  16. // be used instead.
  17. //
  18. #define SETUPLOG_USE_MESSAGEID (PTSTR)(1)
  19. //
  20. // The LogSeverity type and its associated values are defined in setupapi.h.
  21. // The high order word of the LogSeverity is reserved for the following flags.
  22. //
  23. #define SETUPLOG_SINGLE_MESSAGE 0x00010000
  24. typedef PVOID (*PSPLOG_OPENFILE_ROUTINE) (
  25. IN LPCTSTR Filename,
  26. IN BOOL WipeLogFile
  27. );
  28. typedef UINT (*PSPLOG_CLOSEFILE_ROUTINE) (
  29. IN PVOID LogFile
  30. );
  31. typedef PVOID (*PSPLOG_ALLOC_ROUTINE) (
  32. IN DWORD Size
  33. );
  34. typedef VOID (*PSPLOG_FREE_ROUTINE) (
  35. IN CONST VOID *p
  36. );
  37. typedef PTSTR (*PSPLOG_FORMAT_ROUTINE) (
  38. IN LPCTSTR MessageString,
  39. IN UINT MessageId,
  40. IN va_list *ArgumentList
  41. );
  42. typedef BOOL (*PSPLOG_WRITE_ROUTINE) (
  43. IN PVOID LogFile,
  44. IN LPCTSTR Buffer
  45. );
  46. typedef BOOL (*PSPLOG_ACQUIRELOCK_ROUTINE) (
  47. IN PVOID Mutex
  48. );
  49. typedef BOOL (*PSPLOG_RELEASELOCK_ROUTINE) (
  50. IN PVOID Mutex
  51. );
  52. typedef struct _SETUPLOG_CONTEXT {
  53. PSPLOG_OPENFILE_ROUTINE OpenFile;
  54. PSPLOG_CLOSEFILE_ROUTINE CloseFile;
  55. PSPLOG_ALLOC_ROUTINE AllocMem;
  56. PSPLOG_FREE_ROUTINE FreeMem;
  57. PSPLOG_FORMAT_ROUTINE Format;
  58. PSPLOG_WRITE_ROUTINE Write;
  59. PSPLOG_ACQUIRELOCK_ROUTINE Lock;
  60. PSPLOG_RELEASELOCK_ROUTINE Unlock;
  61. PVOID hActionLog;
  62. PVOID hErrorLog;
  63. PVOID Mutex;
  64. LogSeverity WorstError;
  65. LPCTSTR SeverityDescriptions[LogSevMaximum];
  66. } SETUPLOG_CONTEXT, *PSETUPLOG_CONTEXT;
  67. //
  68. // API's for setuplog.lib
  69. //
  70. BOOL
  71. SetuplogInitializeEx(
  72. IN PSETUPLOG_CONTEXT SetuplogContext,
  73. IN BOOL WipeLogFile,
  74. IN LPCTSTR ActionFilename,
  75. IN LPCTSTR ErrorFilename,
  76. IN PVOID Reserved1,
  77. IN DWORD Reserved2
  78. );
  79. BOOL
  80. SetuplogInitialize(
  81. IN PSETUPLOG_CONTEXT SetuplogContext,
  82. IN BOOL WipeLogFile
  83. );
  84. PTSTR
  85. SetuplogFormatMessageWithContextV(
  86. IN PSETUPLOG_CONTEXT MyContext,
  87. IN DWORD Flags,
  88. IN LPCTSTR MessageString,
  89. IN UINT MessageId,
  90. IN va_list *ArgumentList
  91. );
  92. PTSTR
  93. SetuplogFormatMessageV(
  94. IN DWORD Flags,
  95. IN LPCTSTR MessageString,
  96. IN UINT MessageId,
  97. IN va_list *ArgumentList
  98. );
  99. PTSTR
  100. SetuplogFormatMessage(
  101. IN DWORD Flags,
  102. IN LPCTSTR MessageString,
  103. IN UINT MessageId,
  104. ...
  105. );
  106. BOOL
  107. SetuplogErrorV(
  108. IN LogSeverity Severity,
  109. IN LPCTSTR MessageString,
  110. IN UINT MessageId, OPTIONAL
  111. IN va_list *ArgumentList
  112. );
  113. BOOL
  114. SetuplogError(
  115. IN LogSeverity Severity,
  116. IN LPCTSTR MessageString,
  117. IN UINT MessageId, OPTIONAL
  118. ...
  119. );
  120. BOOL
  121. SetuplogTerminate(
  122. VOID
  123. );
  124. #endif // _SETUPLOG_