Hans Leidekker : setupapi: Implement SetupGetTargetPath{A,W}.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Nov 17 04:54:10 CST 2006


Module: wine
Branch: master
Commit: 134c03b3bea0a33cd898b7974d1647d97ae83b75
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=134c03b3bea0a33cd898b7974d1647d97ae83b75

Author: Hans Leidekker <hans at it.vu.nl>
Date:   Thu Nov 16 14:26:01 2006 +0100

setupapi: Implement SetupGetTargetPath{A,W}.

---

 dlls/setupapi/query.c       |   91 +++++++++++++++++++++++++++++++++++++++++++
 dlls/setupapi/setupapi.spec |    4 +-
 include/setupapi.h          |    3 +
 3 files changed, 96 insertions(+), 2 deletions(-)

diff --git a/dlls/setupapi/query.c b/dlls/setupapi/query.c
index bda2f3a..82eb62d 100644
--- a/dlls/setupapi/query.c
+++ b/dlls/setupapi/query.c
@@ -516,3 +516,94 @@ BOOL WINAPI SetupGetSourceInfoW( HINF hi
     }
     return TRUE;
 }
+
+/***********************************************************************
+ *            SetupGetTargetPathA   (SETUPAPI.@)
+ */
+
+BOOL WINAPI SetupGetTargetPathA( HINF hinf, PINFCONTEXT context, PCSTR section, PSTR buffer,
+                                 DWORD buffer_size, PDWORD required_size )
+{
+    BOOL ret = FALSE;
+    WCHAR *sectionW = NULL, *bufferW = NULL;
+    DWORD required;
+    INT size;
+
+    TRACE("%p, %p, %s, %p, 0x%08x, %p\n", hinf, context, debugstr_a(section), buffer,
+          buffer_size, required_size);
+
+    if (section && !(sectionW = strdupAtoW( section )))
+        return FALSE;
+
+    if (!SetupGetTargetPathW( hinf, context, sectionW, NULL, 0, &required ))
+        goto done;
+
+    if (!(bufferW = HeapAlloc( GetProcessHeap(), 0, required * sizeof(WCHAR) )))
+        goto done;
+
+    if (!SetupGetTargetPathW( hinf, context, sectionW, bufferW, required, NULL ))
+        goto done;
+
+    size = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL );
+    if (required_size) *required_size = size;
+
+    if (buffer)
+    {
+        if (buffer_size >= size)
+            WideCharToMultiByte( CP_ACP, 0, bufferW, -1, buffer, buffer_size, NULL, NULL );
+        else
+        {
+            SetLastError( ERROR_INSUFFICIENT_BUFFER );
+            goto done;
+        }
+    }
+    ret = TRUE;
+
+ done:
+    HeapFree( GetProcessHeap(), 0, sectionW );
+    HeapFree( GetProcessHeap(), 0, bufferW );
+    return ret;
+}
+
+/***********************************************************************
+ *            SetupGetTargetPathW   (SETUPAPI.@)
+ */
+
+BOOL WINAPI SetupGetTargetPathW( HINF hinf, PINFCONTEXT context, PCWSTR section, PWSTR buffer,
+                                 DWORD buffer_size, PDWORD required_size )
+{
+    static const WCHAR destination_dirs[] =
+        {'D','e','s','t','i','n','a','t','i','o','n','D','i','r','s',0};
+    static const WCHAR default_dest_dir[]  =
+        {'D','e','f','a','u','l','t','D','e','s','t','D','i','r',0};
+
+    INFCONTEXT ctx;
+    WCHAR *dir;
+    INT size;
+
+    TRACE("%p, %p, %s, %p, 0x%08x, %p\n", hinf, context, debugstr_w(section), buffer,
+          buffer_size, required_size);
+
+    if (context && !SetupFindFirstLineW( hinf, destination_dirs, NULL, context )) return FALSE;
+    else if (section && !SetupFindFirstLineW( hinf, section, NULL, &ctx )) return FALSE;
+    else if (!SetupFindFirstLineW( hinf, destination_dirs, default_dest_dir, &ctx )) return FALSE;
+
+    if (!(dir = PARSER_get_dest_dir( context ? context : &ctx ))) return FALSE;
+
+    size = lstrlenW( dir ) + 1;
+    if (required_size) *required_size = size;
+
+    if (buffer)
+    {
+        if (buffer_size >= size)
+            lstrcpyW( buffer, dir );
+        else
+        {
+            SetLastError( ERROR_INSUFFICIENT_BUFFER );
+            HeapFree( GetProcessHeap(), 0, dir );
+            return FALSE;
+        }
+    }
+    HeapFree( GetProcessHeap(), 0, dir );
+    return TRUE;
+}
diff --git a/dlls/setupapi/setupapi.spec b/dlls/setupapi/setupapi.spec
index 0575339..f5e63fb 100644
--- a/dlls/setupapi/setupapi.spec
+++ b/dlls/setupapi/setupapi.spec
@@ -421,8 +421,8 @@
 @ stdcall SetupGetSourceInfoW(ptr long long ptr long ptr)
 @ stdcall SetupGetStringFieldA(ptr long ptr long ptr)
 @ stdcall SetupGetStringFieldW(ptr long ptr long ptr)
-@ stub SetupGetTargetPathA
-@ stub SetupGetTargetPathW
+@ stdcall SetupGetTargetPathA(ptr ptr str ptr long ptr)
+@ stdcall SetupGetTargetPathW(ptr ptr wstr ptr long ptr)
 @ stdcall SetupInitDefaultQueueCallback(long)
 @ stdcall SetupInitDefaultQueueCallbackEx(long long long long ptr)
 @ stdcall SetupInitializeFileLogA (str long)
diff --git a/include/setupapi.h b/include/setupapi.h
index 74faf64..d27cb9f 100644
--- a/include/setupapi.h
+++ b/include/setupapi.h
@@ -827,6 +827,9 @@ BOOL     WINAPI SetupGetSourceInfoW( HIN
 BOOL     WINAPI SetupGetStringFieldA( PINFCONTEXT context, DWORD index, PSTR buffer, DWORD size, PDWORD required );
 BOOL     WINAPI SetupGetStringFieldW( PINFCONTEXT context, DWORD index, PWSTR buffer, DWORD size, PDWORD required );
 #define         SetupGetStringField WINELIB_NAME_AW(SetupGetStringField)
+BOOL     WINAPI SetupGetTargetPathA( HINF hinf, PINFCONTEXT context, PCSTR section, PSTR buffer, DWORD buffer_size, PDWORD required_size );
+BOOL     WINAPI SetupGetTargetPathW( HINF hinf, PINFCONTEXT context, PCWSTR section, PWSTR buffer, DWORD buffer_size, PDWORD required_size );
+#define         SetupGetTargetPath WINELIB_NAME_AW(SetupGetTargetPath)
 PVOID    WINAPI SetupInitDefaultQueueCallback( HWND );
 PVOID    WINAPI SetupInitDefaultQueueCallbackEx( HWND, HWND, UINT, DWORD, PVOID );
 BOOL     WINAPI SetupInstallFilesFromInfSectionA( HINF, HINF, HSPFILEQ, PCSTR, PCSTR, UINT );




More information about the wine-cvs mailing list