(5th) Janitorial dlls/advapi32/registry.c W->A cleanup
Tony Lambregts
tony_lambregts at telusplanet.net
Thu Mar 13 14:51:13 CST 2003
My thanks to Dmitry: This time using snprintfW.
Change Log: Janitorial. Get rid of W->A calls
Files Changed: dlls/advapi32/registry.c
--
Tony Lambregts
-------------- next part --------------
Index: Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/advapi32/Makefile.in,v
retrieving revision 1.17
diff -u -u -r1.17 Makefile.in
--- Makefile.in 25 Oct 2002 19:17:33 -0000 1.17
+++ Makefile.in 13 Mar 2003 20:47:33 -0000
@@ -5,6 +5,7 @@
VPATH = @srcdir@
MODULE = advapi32.dll
IMPORTS = kernel32 ntdll
+EXTRALIBS = $(LIBUNICODE)
LDDLLFLAGS = @LDDLLFLAGS@
SYMBOLFILE = $(MODULE).tmp.o
Index: registry.c
===================================================================
RCS file: /home/wine/wine/dlls/advapi32/registry.c,v
retrieving revision 1.50
diff -u -u -r1.50 registry.c
--- registry.c 20 Jan 2003 23:23:12 -0000 1.50
+++ registry.c 13 Mar 2003 20:47:34 -0000
@@ -37,6 +37,8 @@
#include "wine/server.h"
#include "wine/debug.h"
#include "winternl.h"
+#include "thread.h"
+#include "file.h"
WINE_DEFAULT_DEBUG_CHANNEL(reg);
@@ -1536,39 +1538,42 @@
/******************************************************************************
- * RegSaveKeyA [ADVAPI32.@]
+ * RegSaveKeyW [ADVAPI32.@]
*
* PARAMS
* hkey [I] Handle of key where save begins
* lpFile [I] Address of filename to save to
* sa [I] Address of security structure
*/
-LONG WINAPI RegSaveKeyA( HKEY hkey, LPCSTR file, LPSECURITY_ATTRIBUTES sa )
+LONG WINAPI RegSaveKeyW( HKEY hkey, LPCWSTR file, LPSECURITY_ATTRIBUTES sa )
{
- char buffer[1024];
+ static const WCHAR format[] =
+ {'r','e','g','%','0','4','x','.','t','m','p',0};
+ WCHAR buffer[1024];
int count = 0;
- LPSTR name;
+ LPWSTR nameW;
DWORD ret, err;
HANDLE handle;
- TRACE( "(%p,%s,%p)\n", hkey, debugstr_a(file), sa );
+ TRACE( "(%p,%s,%p)\n", hkey, debugstr_w(file), sa );
if (!file || !*file) return ERROR_INVALID_PARAMETER;
if (!(hkey = get_special_root_hkey( hkey ))) return ERROR_INVALID_HANDLE;
err = GetLastError();
- GetFullPathNameA( file, sizeof(buffer), buffer, &name );
+ GetFullPathNameW( file, sizeof(buffer), buffer, &nameW );
+
for (;;)
{
- sprintf( name, "reg%04x.tmp", count++ );
- handle = CreateFileA( buffer, GENERIC_WRITE, 0, NULL,
+ snprintfW( nameW, MAX_PATHNAME_LEN, format, count++ );
+ handle = CreateFileW( buffer, GENERIC_WRITE, 0, NULL,
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 );
if (handle != INVALID_HANDLE_VALUE) break;
if ((ret = GetLastError()) != ERROR_ALREADY_EXISTS) goto done;
/* Something gone haywire ? Please report if this happens abnormally */
if (count >= 100)
- MESSAGE("Wow, we are already fiddling with a temp file %s with an ordinal as high as %d !\nYou might want to delete all corresponding temp files in that directory.\n", buffer, count);
+ MESSAGE("Wow, we are already fiddling with a temp file %s with an ordinal as high as %d !\nYou might want to delete all corresponding temp files in that directory.\n", debugstr_w(buffer), count);
}
SERVER_START_REQ( save_registry )
@@ -1582,13 +1587,14 @@
CloseHandle( handle );
if (!ret)
{
- if (!MoveFileExA( buffer, file, MOVEFILE_REPLACE_EXISTING ))
+ if (!MoveFileExW( buffer, file, MOVEFILE_REPLACE_EXISTING ))
{
- ERR( "Failed to move %s to %s\n", buffer, file );
+ ERR( "Failed to move %s to %s\n", debugstr_w(buffer),
+ debugstr_w(file) );
ret = GetLastError();
}
}
- if (ret) DeleteFileA( buffer );
+ if (ret) DeleteFileW( buffer );
done:
SetLastError( err ); /* restore last error code */
@@ -1597,14 +1603,26 @@
/******************************************************************************
- * RegSaveKeyW [ADVAPI32.@]
+ * RegSaveKeyA [ADVAPI32.@]
*/
-LONG WINAPI RegSaveKeyW( HKEY hkey, LPCWSTR file, LPSECURITY_ATTRIBUTES sa )
+LONG WINAPI RegSaveKeyA( HKEY hkey, LPCSTR file, LPSECURITY_ATTRIBUTES sa )
{
- LPSTR fileA = HEAP_strdupWtoA( GetProcessHeap(), 0, file );
- DWORD ret = RegSaveKeyA( hkey, fileA, sa );
- if (fileA) HeapFree( GetProcessHeap(), 0, fileA );
- return ret;
+
+ UNICODE_STRING *fileW = &NtCurrentTeb()->StaticUnicodeString;
+ STRING fileA;
+
+ if (!file || !*file)
+ {
+ return FALSE;
+ }
+
+ RtlInitAnsiString(&fileA, file);
+ if (!RtlAnsiStringToUnicodeString(fileW, &fileA, FALSE));
+ {
+ return RegSaveKeyW(hkey, fileW->Buffer, sa);
+ }
+ return FALSE;
+
}
@@ -1819,7 +1837,7 @@
if (!lpMachineName || !*lpMachineName) {
/* Use the local machine name */
- return RegOpenKeyA( hKey, "", phkResult );
+ return RegOpenKeyW( hKey, NULL, phkResult );
}
FIXME("Cannot connect to %s\n",debugstr_w(lpMachineName));
More information about the wine-patches
mailing list