(5th) Janitorial dlls/advapi32/registry.c W->A cleanup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hope this one makes everyone happy<g>


Change Log: Janitorial. Get rid of W->A calls

Files Changed: dlls/advapi32/registry.c

--

Tony Lambregts

Index: Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/advapi32/Makefile.in,v
retrieving revision 1.17
diff -u -r1.17 Makefile.in
--- Makefile.in	25 Oct 2002 19:17:33 -0000	1.17
+++ Makefile.in	10 Mar 2003 06:22:56 -0000
@@ -4,7 +4,7 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = advapi32.dll
-IMPORTS   = kernel32 ntdll
+IMPORTS   = kernel32 ntdll user32
 
 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 -r1.50 registry.c
--- registry.c	20 Jan 2003 23:23:12 -0000	1.50
+++ registry.c	10 Mar 2003 06:22:59 -0000
@@ -37,6 +37,8 @@
 #include "wine/server.h"
 #include "wine/debug.h"
 #include "winternl.h"
+#include "thread.h"
+#include "winuser.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,
+        wsprintfW( nameW, 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,25 @@
 
 
 /******************************************************************************
- *           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)
+    {
+        SetLastError(ERROR_PATH_NOT_FOUND);
+        return FALSE;
+    }
+
+    RtlInitAnsiString(&fileA, file);
+    RtlAnsiStringToUnicodeString(fileW, &fileA, FALSE);
+    if (fileW) return RegSaveKeyW(hkey, fileW->Buffer, sa);
+    return FALSE;
+
 }
 
 
@@ -1819,7 +1836,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));

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux