Jacek Caban : urlmon: URLDownloadToFileA code clean up.

Alexandre Julliard julliard at winehq.org
Mon Feb 18 08:50:37 CST 2008


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Feb 18 01:03:54 2008 +0100

urlmon: URLDownloadToFileA code clean up.

---

 dlls/urlmon/download.c    |   35 +++++++++++++++++++++++++++++++++
 dlls/urlmon/umon.c        |   47 ---------------------------------------------
 dlls/urlmon/urlmon_main.h |   13 ++++++++++++
 3 files changed, 48 insertions(+), 47 deletions(-)

diff --git a/dlls/urlmon/download.c b/dlls/urlmon/download.c
index a3ac35c..3082dd1 100644
--- a/dlls/urlmon/download.c
+++ b/dlls/urlmon/download.c
@@ -368,3 +368,38 @@ HRESULT WINAPI URLDownloadToFileW(LPUNKNOWN pCaller, LPCWSTR szURL, LPCWSTR szFi
 
     return hres == MK_S_ASYNCHRONOUS ? S_OK : hres;
 }
+
+/***********************************************************************
+ *           URLDownloadToFileA (URLMON.@)
+ *
+ * Downloads URL szURL to rile szFileName and call lpfnCB callback to
+ * report progress.
+ *
+ * PARAMS
+ *  pCaller    [I] controlling IUnknown interface.
+ *  szURL      [I] URL of the file to download
+ *  szFileName [I] file name to store the content of the URL
+ *  dwReserved [I] reserved - set to 0
+ *  lpfnCB     [I] callback for progress report
+ *
+ * RETURNS
+ *  S_OK on success
+ */
+HRESULT WINAPI URLDownloadToFileA(LPUNKNOWN pCaller, LPCSTR szURL, LPCSTR szFileName, DWORD dwReserved,
+        LPBINDSTATUSCALLBACK lpfnCB)
+{
+    LPWSTR urlW, file_nameW;
+    HRESULT hres;
+
+    TRACE("(%p %s %s %d %p)\n", pCaller, debugstr_a(szURL), debugstr_a(szFileName), dwReserved, lpfnCB);
+
+    urlW = heap_strdupAtoW(szURL);
+    file_nameW = heap_strdupAtoW(szFileName);
+
+    hres = URLDownloadToFileW(pCaller, urlW, file_nameW, dwReserved, lpfnCB);
+
+    heap_free(urlW);
+    heap_free(file_nameW);
+
+    return hres;
+}
diff --git a/dlls/urlmon/umon.c b/dlls/urlmon/umon.c
index abfce91..cb276af 100644
--- a/dlls/urlmon/umon.c
+++ b/dlls/urlmon/umon.c
@@ -1207,53 +1207,6 @@ HRESULT WINAPI MkParseDisplayNameEx(IBindCtx *pbc, LPCWSTR szDisplayName, ULONG
 
 
 /***********************************************************************
- *           URLDownloadToFileA (URLMON.@)
- *
- * Downloads URL szURL to rile szFileName and call lpfnCB callback to
- * report progress.
- *
- * PARAMS
- *  pCaller    [I] controlling IUnknown interface.
- *  szURL      [I] URL of the file to download
- *  szFileName [I] file name to store the content of the URL
- *  dwReserved [I] reserved - set to 0
- *  lpfnCB     [I] callback for progress report
- *
- * RETURNS
- *  S_OK on success
- *  E_OUTOFMEMORY when going out of memory
- */
-HRESULT WINAPI URLDownloadToFileA(LPUNKNOWN pCaller,
-				  LPCSTR szURL,
-				  LPCSTR szFileName,
-				  DWORD dwReserved,
-				  LPBINDSTATUSCALLBACK lpfnCB)
-{
-    UNICODE_STRING szURL_w, szFileName_w;
-
-    if ((szURL == NULL) || (szFileName == NULL)) {
-	FIXME("(%p,%s,%s,%08x,%p) cannot accept NULL strings !\n", pCaller, debugstr_a(szURL), debugstr_a(szFileName), dwReserved, lpfnCB);
-	return E_INVALIDARG; /* The error code is not specified in this case... */
-    }
-    
-    if (RtlCreateUnicodeStringFromAsciiz(&szURL_w, szURL)) {
-	if (RtlCreateUnicodeStringFromAsciiz(&szFileName_w, szFileName)) {
-	    HRESULT ret = URLDownloadToFileW(pCaller, szURL_w.Buffer, szFileName_w.Buffer, dwReserved, lpfnCB);
-
-	    RtlFreeUnicodeString(&szURL_w);
-	    RtlFreeUnicodeString(&szFileName_w);
-	    
-	    return ret;
-	} else {
-	    RtlFreeUnicodeString(&szURL_w);
-	}
-    }
-    
-    FIXME("(%p,%s,%s,%08x,%p) could not allocate W strings !\n", pCaller, szURL, szFileName, dwReserved, lpfnCB);
-    return E_OUTOFMEMORY;
-}
-
-/***********************************************************************
  *           URLDownloadToCacheFileA (URLMON.@)
  */
 HRESULT WINAPI URLDownloadToCacheFileA(LPUNKNOWN lpUnkCaller, LPCSTR szURL, LPSTR szFileName,
diff --git a/dlls/urlmon/urlmon_main.h b/dlls/urlmon/urlmon_main.h
index 87e74f9..0e5ebff 100644
--- a/dlls/urlmon/urlmon_main.h
+++ b/dlls/urlmon/urlmon_main.h
@@ -110,4 +110,17 @@ static inline LPWSTR heap_strdupW(LPCWSTR str)
     return ret;
 }
 
+static inline LPWSTR heap_strdupAtoW(const char *str)
+{
+    LPWSTR ret = NULL;
+
+    if(str) {
+        DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
+        ret = heap_alloc(len*sizeof(WCHAR));
+        MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
+    }
+
+    return ret;
+}
+
 #endif /* __WINE_URLMON_MAIN_H */




More information about the wine-cvs mailing list