advpack: Forward AddDelBackupEntryA to its unicode counterpart.

This commit is contained in:
James Hawkins 2006-03-22 13:51:44 -06:00 committed by Alexandre Julliard
parent dc8e564f9e
commit ca3ad7d6dc
2 changed files with 77 additions and 16 deletions

View File

@ -1,5 +1,5 @@
@ stdcall AddDelBackupEntryA(str str str long) @ stdcall AddDelBackupEntryA(str str str long)
# stdcall AddDelBackupEntryW(wstr wstr wstr long) @ stdcall AddDelBackupEntryW(wstr wstr wstr long)
@ stdcall AddDelBackupEntry(str str str long) AddDelBackupEntryA @ stdcall AddDelBackupEntry(str str str long) AddDelBackupEntryA
@ stdcall AdvInstallFileA(long str str str str long long) @ stdcall AdvInstallFileA(long str str str str long long)
# stdcall AdvInstallFileW(long wstr wstr wstr wstr long long) # stdcall AdvInstallFileW(long wstr wstr wstr wstr long long)

View File

@ -26,15 +26,70 @@
#include "winuser.h" #include "winuser.h"
#include "winreg.h" #include "winreg.h"
#include "winver.h" #include "winver.h"
#include "winternl.h"
#include "setupapi.h" #include "setupapi.h"
#include "advpub.h" #include "advpub.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(advpack); WINE_DEFAULT_DEBUG_CHANNEL(advpack);
/* converts an ansi double null-terminated list to a unicode list */
static LPWSTR ansi_to_unicode_list(LPCSTR ansi_list)
{
DWORD len, wlen = 0;
LPWSTR list;
LPCSTR ptr = ansi_list;
while (*ptr) ptr += lstrlenA(ptr) + 1;
len = ptr + 1 - ansi_list;
wlen = MultiByteToWideChar(CP_ACP, 0, ansi_list, len, NULL, 0);
list = HeapAlloc(GetProcessHeap(), 0, wlen * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, ansi_list, len, list, wlen);
return list;
}
/*********************************************************************** /***********************************************************************
* AddDelBackupEntryA (ADVPACK.@) * AddDelBackupEntryA (ADVPACK.@)
* *
* See AddDelBackupEntryW.
*/
HRESULT WINAPI AddDelBackupEntryA(LPCSTR lpcszFileList, LPCSTR lpcszBackupDir,
LPCSTR lpcszBaseName, DWORD dwFlags)
{
UNICODE_STRING backupdir, basename;
LPWSTR filelist, backup;
HRESULT res;
TRACE("(%p, %p, %p, %ld)\n", lpcszFileList, lpcszBackupDir,
lpcszBaseName, dwFlags);
if (lpcszFileList)
filelist = ansi_to_unicode_list(lpcszFileList);
else
filelist = NULL;
RtlCreateUnicodeStringFromAsciiz(&backupdir, lpcszBackupDir);
RtlCreateUnicodeStringFromAsciiz(&basename, lpcszBaseName);
if (lpcszBackupDir)
backup = backupdir.Buffer;
else
backup = NULL;
res = AddDelBackupEntryW(filelist, backup, basename.Buffer, dwFlags);
HeapFree(GetProcessHeap(), 0, filelist);
RtlFreeUnicodeString(&backupdir);
RtlFreeUnicodeString(&basename);
return res;
}
/***********************************************************************
* AddDelBackupEntryW (ADVPACK.@)
*
* Either appends the files in the file list to the backup section of * Either appends the files in the file list to the backup section of
* the specified INI, or deletes the entries from the INI file. * the specified INI, or deletes the entries from the INI file.
* *
@ -56,13 +111,19 @@ WINE_DEFAULT_DEBUG_CHANNEL(advpack);
* If lpcszBackupDir is NULL, the INI file is assumed to exist in * If lpcszBackupDir is NULL, the INI file is assumed to exist in
* c:\windows or created there if it does not exist. * c:\windows or created there if it does not exist.
*/ */
HRESULT WINAPI AddDelBackupEntryA(LPCSTR lpcszFileList, LPCSTR lpcszBackupDir, HRESULT WINAPI AddDelBackupEntryW(LPCWSTR lpcszFileList, LPCWSTR lpcszBackupDir,
LPCSTR lpcszBaseName, DWORD dwFlags) LPCWSTR lpcszBaseName, DWORD dwFlags)
{ {
CHAR szIniPath[MAX_PATH]; WCHAR szIniPath[MAX_PATH];
LPSTR szString = NULL; LPWSTR szString = NULL;
const char szBackupEntry[] = "-1,0,0,0,0,0,-1"; static const WCHAR szBackupEntry[] = {
'-','1',',','0',',','0',',','0',',','0',',','0',',','-','1',0
};
static const WCHAR backslash[] = {'\\',0};
static const WCHAR ini[] = {'.','i','n','i',0};
static const WCHAR backup[] = {'b','a','c','k','u','p',0};
TRACE("(%p, %p, %p, %ld)\n", lpcszFileList, lpcszBackupDir, TRACE("(%p, %p, %p, %ld)\n", lpcszFileList, lpcszBackupDir,
lpcszBaseName, dwFlags); lpcszBaseName, dwFlags);
@ -71,30 +132,30 @@ HRESULT WINAPI AddDelBackupEntryA(LPCSTR lpcszFileList, LPCSTR lpcszBackupDir,
return S_OK; return S_OK;
if (lpcszBackupDir) if (lpcszBackupDir)
lstrcpyA(szIniPath, lpcszBackupDir); lstrcpyW(szIniPath, lpcszBackupDir);
else else
GetWindowsDirectoryA(szIniPath, MAX_PATH); GetWindowsDirectoryW(szIniPath, MAX_PATH);
lstrcatA(szIniPath, "\\"); lstrcatW(szIniPath, backslash);
lstrcatA(szIniPath, lpcszBaseName); lstrcatW(szIniPath, lpcszBaseName);
lstrcatA(szIniPath, ".ini"); lstrcatW(szIniPath, ini);
SetFileAttributesA(szIniPath, FILE_ATTRIBUTE_NORMAL); SetFileAttributesW(szIniPath, FILE_ATTRIBUTE_NORMAL);
if (dwFlags & AADBE_ADD_ENTRY) if (dwFlags & AADBE_ADD_ENTRY)
szString = (LPSTR)szBackupEntry; szString = (LPWSTR)szBackupEntry;
else if (dwFlags & AADBE_DEL_ENTRY) else if (dwFlags & AADBE_DEL_ENTRY)
szString = NULL; szString = NULL;
/* add or delete the INI entries */ /* add or delete the INI entries */
while (*lpcszFileList) while (*lpcszFileList)
{ {
WritePrivateProfileStringA("backup", lpcszFileList, szString, szIniPath); WritePrivateProfileStringW(backup, lpcszFileList, szString, szIniPath);
lpcszFileList += lstrlenA(lpcszFileList) + 1; lpcszFileList += lstrlenW(lpcszFileList) + 1;
} }
/* hide the INI file */ /* hide the INI file */
SetFileAttributesA(szIniPath, FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN); SetFileAttributesW(szIniPath, FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN);
return S_OK; return S_OK;
} }