From 01e4b9b9ac22ee7bc2cc77cb2fb140b1fed28b2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Wed, 11 Jul 2007 09:04:22 +0000 Subject: [PATCH] Write source file and line in the setup install log svn path=/trunk/; revision=27587 --- reactos/dll/win32/syssetup/logfile.c | 68 ++++++++++++------- reactos/dll/win32/syssetup/syssetup.def | 2 +- reactos/dll/win32/syssetup/wizard.c | 2 +- .../include/reactos/libs/syssetup/syssetup.h | 18 +++-- 4 files changed, 56 insertions(+), 34 deletions(-) diff --git a/reactos/dll/win32/syssetup/logfile.c b/reactos/dll/win32/syssetup/logfile.c index c374b4feea2..6edd6c52a99 100644 --- a/reactos/dll/win32/syssetup/logfile.c +++ b/reactos/dll/win32/syssetup/logfile.c @@ -16,8 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id$ - * +/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries * PURPOSE: Log file functions @@ -33,7 +32,6 @@ #include - /* GLOBALS ******************************************************************/ HANDLE hLogFile = NULL; @@ -41,28 +39,26 @@ HANDLE hLogFile = NULL; /* FUNCTIONS ****************************************************************/ -BOOL STDCALL +BOOL WINAPI InitializeSetupActionLog (BOOL bDeleteOldLogFile) { WCHAR szFileName[MAX_PATH]; - GetWindowsDirectoryW (szFileName, - MAX_PATH); + GetWindowsDirectoryW(szFileName, MAX_PATH); - if (szFileName[wcslen (szFileName)] != L'\\') + if (szFileName[wcslen(szFileName)] != L'\\') { wcsncat(szFileName, - L"\\", - MAX_PATH); + L"\\", + MAX_PATH); } wcsncat(szFileName, L"setuplog.txt", - MAX_PATH); + MAX_PATH); - if (bDeleteOldLogFile != FALSE) + if (bDeleteOldLogFile) { - SetFileAttributesW(szFileName, - FILE_ATTRIBUTE_NORMAL); + SetFileAttributesW(szFileName, FILE_ATTRIBUTE_NORMAL); DeleteFileW(szFileName); } @@ -83,8 +79,8 @@ InitializeSetupActionLog (BOOL bDeleteOldLogFile) } -VOID STDCALL -TerminateSetupActionLog (VOID) +VOID WINAPI +TerminateSetupActionLog(VOID) { if (hLogFile != NULL) { @@ -94,16 +90,19 @@ TerminateSetupActionLog (VOID) } -BOOL STDCALL -LogItem(DWORD dwSeverity, - LPWSTR lpMessageText) +BOOL WINAPI +SYSSETUP_LogItem(IN const LPSTR lpFileName, + IN DWORD dwLineNumber, + IN DWORD dwSeverity, + IN LPWSTR lpMessageText) { - LPSTR lpNewLine = "\r\n"; - LPSTR lpSeverityString; + const LPCSTR lpNewLine = "\r\n"; + LPCSTR lpSeverityString; LPSTR lpMessageString; DWORD dwMessageLength; DWORD dwMessageSize; DWORD dwWritten; + CHAR Buffer[6]; /* Get the severity code string */ switch (dwSeverity) @@ -136,13 +135,11 @@ LogItem(DWORD dwSeverity, dwMessageLength); /* Allocate message string buffer */ - lpMessageString = (LPSTR) HeapAlloc(GetProcessHeap (), + lpMessageString = (LPSTR) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwMessageSize); - if (lpMessageString == NULL) - { + if (!lpMessageString) return FALSE; - } /* Convert unicode to ansi */ RtlUnicodeToMultiByteN(lpMessageString, @@ -157,6 +154,27 @@ LogItem(DWORD dwSeverity, NULL, FILE_END); + /* Write file name */ + WriteFile(hLogFile, + lpFileName, + strlen(lpFileName), + &dwWritten, + NULL); + + /* Write comma */ + WriteFile(hLogFile, ",", 1, &dwWritten, NULL); + + /* Write line number */ + snprintf(Buffer, sizeof(Buffer), "%lu", dwLineNumber); + WriteFile(hLogFile, + Buffer, + strlen(Buffer), + &dwWritten, + NULL); + + /* Write comma */ + WriteFile(hLogFile, ",", 1, &dwWritten, NULL); + /* Write severity code */ WriteFile(hLogFile, lpSeverityString, @@ -174,7 +192,7 @@ LogItem(DWORD dwSeverity, /* Write newline */ WriteFile(hLogFile, lpNewLine, - 2, + sizeof(lpNewLine), &dwWritten, NULL); diff --git a/reactos/dll/win32/syssetup/syssetup.def b/reactos/dll/win32/syssetup/syssetup.def index 7bb773198ec..b34614eb81f 100644 --- a/reactos/dll/win32/syssetup/syssetup.def +++ b/reactos/dll/win32/syssetup/syssetup.def @@ -7,7 +7,7 @@ InitializeSetupActionLog@4 InstallLiveCD@4 InstallReactOS@4 KeyboardClassInstaller@12 -LogItem@8 +;LogItem@8 ;LogItem0 ;LogItem1 ;LogItem2 diff --git a/reactos/dll/win32/syssetup/wizard.c b/reactos/dll/win32/syssetup/wizard.c index 5f76f9cd112..4c5c8a85051 100644 --- a/reactos/dll/win32/syssetup/wizard.c +++ b/reactos/dll/win32/syssetup/wizard.c @@ -572,7 +572,7 @@ ComputerPageDlgProc(HWND hwndDlg, TCHAR Password2[15]; PWCHAR Password; WCHAR Title[64]; - WCHAR EmptyComputerName[256], EmptyPassword[256], NotMatchPassword[256], WrongPassword[256]; + WCHAR EmptyComputerName[256], NotMatchPassword[256], WrongPassword[256]; DWORD Length; LPNMHDR lpnm; diff --git a/reactos/include/reactos/libs/syssetup/syssetup.h b/reactos/include/reactos/libs/syssetup/syssetup.h index 04c829a3c1a..aaf90f5436c 100644 --- a/reactos/include/reactos/libs/syssetup/syssetup.h +++ b/reactos/include/reactos/libs/syssetup/syssetup.h @@ -39,16 +39,20 @@ InstallReactOS (HINSTANCE hInstance); #define SYSSETUP_SEVERITY_FATAL_ERROR 3 -BOOL STDCALL -InitializeSetupActionLog (BOOL bDeleteOldLogFile); +BOOL WINAPI +InitializeSetupActionLog(IN BOOL bDeleteOldLogFile); -VOID STDCALL -TerminateSetupActionLog (VOID); +VOID WINAPI +TerminateSetupActionLog(VOID); -BOOL STDCALL -LogItem (DWORD dwSeverity, - LPWSTR lpMessageText); +BOOL WINAPI +SYSSETUP_LogItem(IN const LPSTR lpFileName, + IN DWORD dwLineNumber, + IN DWORD dwSeverity, + IN LPWSTR lpMessageText); +#define LogItem(dwSeverity, lpMessageText) \ + SYSSETUP_LogItem(__FILE__, __LINE__, dwSeverity, lpMessageText) #endif /* __SYSSETUP_H_INCLUDED__ */