Implement logging in msiexec.

Correct MsiEnableLog{A,W} prototype.
This commit is contained in:
Vincent Béron 2004-07-23 23:28:45 +00:00 committed by Alexandre Julliard
parent 72984f105d
commit d2df24b90f
4 changed files with 101 additions and 26 deletions

View File

@ -747,12 +747,12 @@ UINT WINAPI MsiDatabaseImportW(LPCWSTR szFolderPath, LPCWSTR szFilename)
return ERROR_CALL_NOT_IMPLEMENTED;
}
UINT WINAPI MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, BOOL fAppend)
UINT WINAPI MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, DWORD attributes)
{
LPWSTR szwLogFile = NULL;
UINT hr = ERROR_INSTALL_FAILURE;
FIXME("%08lx %s %d\n", dwLogMode, debugstr_a(szLogFile), fAppend);
FIXME("%08lx %s %08lx\n", dwLogMode, debugstr_a(szLogFile), attributes);
if( szLogFile )
{
@ -765,7 +765,7 @@ UINT WINAPI MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, BOOL fAppend)
return ERROR_INVALID_PARAMETER;
}
hr = MsiEnableLogW( dwLogMode, szwLogFile, fAppend );
hr = MsiEnableLogW( dwLogMode, szwLogFile, attributes );
end:
if( szwLogFile )
@ -774,12 +774,12 @@ end:
return hr;
}
UINT WINAPI MsiEnableLogW(DWORD dwLogMode, LPCWSTR szLogFile, BOOL fAppend)
UINT WINAPI MsiEnableLogW(DWORD dwLogMode, LPCWSTR szLogFile, DWORD attributes)
{
HANDLE the_file = INVALID_HANDLE_VALUE;
TRACE("%08lx %s %d\n", dwLogMode, debugstr_w(szLogFile), fAppend);
TRACE("%08lx %s %08lx\n", dwLogMode, debugstr_w(szLogFile), attributes);
strcpyW(gszLogFile,szLogFile);
if (!fAppend)
if (!(attributes & INSTALLLOGATTRIBUTES_APPEND))
DeleteFileW(szLogFile);
the_file = CreateFileW(szLogFile, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);

View File

@ -117,6 +117,12 @@ typedef enum tagINSTALLLOGMODE
INSTALLLOGMODE_SHOWDIALOG = (1 << (INSTALLMESSAGE_SHOWDIALOG >> 24))
} INSTALLLOGMODE;
typedef enum tagINSTALLLOGATTRIBUTES
{
INSTALLLOGATTRIBUTES_APPEND = 0x00000001,
INSTALLLOGATTRIBUTES_FLUSHEACHLINE = 0x00000002
} INSTALLLOGATTRIBUTES;
typedef enum tagADVERTISEFLAGS
{
ADVERTISEFLAGS_MACHINEASSIGN = 0,
@ -214,8 +220,8 @@ UINT WINAPI MsiGetProductInfoA(LPCSTR szProduct, LPCSTR szAttribute, LPSTR szBuf
UINT WINAPI MsiGetProductInfoW(LPCWSTR szProduct, LPCWSTR szAttribute, LPWSTR szBuffer, DWORD *pcchValueBuf);
#define MsiGetProductInfo WINELIB_NAME_AW(MsiGetProductInfo)
UINT WINAPI MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, BOOL fAppend);
UINT WINAPI MsiEnableLogW(DWORD dwLogMode, LPCWSTR szLogFile, BOOL fAppend);
UINT WINAPI MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, DWORD attributes);
UINT WINAPI MsiEnableLogW(DWORD dwLogMode, LPCWSTR szLogFile, DWORD attributes);
#define MsiEnableLog WINELIB_NAME_AW(MsiEnableLog)
INSTALLUI_HANDLERA WINAPI MsiSetExternalUIA(INSTALLUI_HANDLERA, DWORD, LPVOID);

View File

@ -140,6 +140,10 @@ int main(int argc, char *argv[])
LPSTR Transforms = HeapAlloc(GetProcessHeap(), 0, 1);
LANGID Language = 0;
DWORD LogMode = 0;
LPSTR LogFileName = NULL;
DWORD LogAttributes = 0;
INSTALLUILEVEL InstallUILevel = 0, retInstallUILevel;
LPSTR DllName = NULL;
@ -366,12 +370,93 @@ int main(int argc, char *argv[])
}
else if(!strncasecmp(argv[i], "/l", 2))
{
int j;
int len = strlen(argv[i]);
for(j = 2; j < len; j++)
{
switch(argv[i][j])
{
case 'I':
case 'i':
LogMode |= INSTALLLOGMODE_INFO;
break;
case 'W':
case 'w':
LogMode |= INSTALLLOGMODE_WARNING;
break;
case 'E':
case 'e':
LogMode |= INSTALLLOGMODE_ERROR;
break;
case 'A':
case 'a':
LogMode |= INSTALLLOGMODE_ACTIONSTART;
break;
case 'R':
case 'r':
LogMode |= INSTALLLOGMODE_ACTIONDATA;
break;
case 'U':
case 'u':
LogMode |= INSTALLLOGMODE_USER;
break;
case 'C':
case 'c':
LogMode |= INSTALLLOGMODE_COMMONDATA;
break;
case 'M':
case 'm':
LogMode |= INSTALLLOGMODE_FATALEXIT;
break;
case 'O':
case 'o':
LogMode |= INSTALLLOGMODE_OUTOFDISKSPACE;
break;
case 'P':
case 'p':
LogMode |= INSTALLLOGMODE_PROPERTYDUMP;
break;
case 'V':
case 'v':
LogMode |= INSTALLLOGMODE_VERBOSE;
break;
case '*':
LogMode = INSTALLLOGMODE_FATALEXIT |
INSTALLLOGMODE_ERROR |
INSTALLLOGMODE_WARNING |
INSTALLLOGMODE_USER |
INSTALLLOGMODE_INFO |
INSTALLLOGMODE_RESOLVESOURCE |
INSTALLLOGMODE_OUTOFDISKSPACE |
INSTALLLOGMODE_ACTIONSTART |
INSTALLLOGMODE_ACTIONDATA |
INSTALLLOGMODE_COMMONDATA |
INSTALLLOGMODE_PROPERTYDUMP |
INSTALLLOGMODE_PROGRESS |
INSTALLLOGMODE_INITIALIZE |
INSTALLLOGMODE_TERMINATE |
INSTALLLOGMODE_SHOWDIALOG;
break;
case '+':
LogAttributes |= INSTALLLOGATTRIBUTES_APPEND;
break;
case '!':
LogAttributes |= INSTALLLOGATTRIBUTES_FLUSHEACHLINE;
break;
default:
break;
}
}
i++;
if(i >= argc)
ShowUsage(1);
WINE_TRACE("argv[%d] = %s\n", i, argv[i]);
WINE_FIXME("Logging not yet implemented\n");
ExitProcess(1);
LogFileName = argv[i];
if(MsiEnableLogA(LogMode, LogFileName, LogAttributes) != ERROR_SUCCESS)
{
fprintf(stderr, "Logging in %s (0x%08lx, %lu) failed\n", LogFileName, LogMode, LogAttributes);
ExitProcess(1);
}
}
else if(!strcasecmp(argv[i], "/p"))
{

View File

@ -20,19 +20,3 @@
typedef HRESULT (*DLLREGISTERSERVER)(void);
typedef HRESULT (*DLLUNREGISTERSERVER)(void);
/* Logging flags */
#define LOG_STATUS_MESSAGES 0x00000001
#define LOG_NONFATAL_WARNINGS 0x00000002
#define LOG_ALL_ERROR_MESSAGES 0x00000004
#define LOG_STARTUP_OF_ACTIONS 0x00000008
#define LOG_ACTION_SPECIFIC_RECORDS 0x00000010
#define LOG_USER_REQUESTS 0x00000020
#define LOG_INITIAL_USER_INTERFACE_PARAMETERS 0x00000040
#define LOG_OUT_OF_MEMORY 0x00000080
#define LOG_TERMINAL_PROPERTIES 0x00000100
#define LOG_VERBOSE_OUTPUT 0x00000200
#define LOG_APPEND_TO_EXISTING_FILE 0x00000400
#define LOG_FLUSH_EACH_LINE 0x00000800
#define LOG_WILDCARD 0x000001ff