Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
efe81255
Commit
efe81255
authored
Jul 15, 2003
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Authors: Mike McCormack <mike@codeweavers.com>, Lionel Ulmer <lionel.ulmer@free.fr>
Implement URLDownloadToFileA/W.
parent
7f3074d1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
221 additions
and
2 deletions
+221
-2
umon.c
dlls/urlmon/umon.c
+215
-0
urlmon.spec
dlls/urlmon/urlmon.spec
+2
-2
urlmon.h
include/urlmon.h
+4
-0
No files found.
dlls/urlmon/umon.c
View file @
efe81255
...
...
@@ -26,6 +26,7 @@
#define NONAMELESSSTRUCT
#include "windef.h"
#include "winbase.h"
#include "winternl.h"
#include "winuser.h"
#include "objbase.h"
#include "wine/debug.h"
...
...
@@ -1014,3 +1015,217 @@ void WINAPI ReleaseBindInfo(BINDINFO* pbindinfo)
{
FIXME
(
"(%p)stub!
\n
"
,
pbindinfo
);
}
/***********************************************************************
* 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,%08lx,%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,%08lx,%p) could not allocate W strings !
\n
"
,
pCaller
,
szURL
,
szFileName
,
dwReserved
,
lpfnCB
);
return
E_OUTOFMEMORY
;
}
/***********************************************************************
* URLDownloadToFileW (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
URLDownloadToFileW
(
LPUNKNOWN
pCaller
,
LPCWSTR
szURL
,
LPCWSTR
szFileName
,
DWORD
dwReserved
,
LPBINDSTATUSCALLBACK
lpfnCB
)
{
HINTERNET
hinternet
,
hcon
,
hreq
;
BOOL
r
;
CHAR
buffer
[
0x1000
];
DWORD
sz
,
total
,
written
;
DWORD
total_size
=
0xFFFFFFFF
,
arg_size
=
sizeof
(
total_size
);
URL_COMPONENTSW
url
;
WCHAR
host
[
0x80
],
path
[
0x100
];
HANDLE
hfile
;
WCHAR
wszAppName
[]
=
{
'u'
,
'r'
,
'l'
,
'm'
,
'o'
,
'n'
,
'.'
,
'd'
,
'l'
,
'l'
,
0
};
/* Note: all error codes would need to be checked agains real Windows behaviour... */
TRACE
(
"(%p,%s,%s,%08lx,%p) stub!
\n
"
,
pCaller
,
debugstr_w
(
szURL
),
debugstr_w
(
szFileName
),
dwReserved
,
lpfnCB
);
if
((
szURL
==
NULL
)
||
(
szFileName
==
NULL
))
{
FIXME
(
" cannot accept NULL strings !
\n
"
);
return
E_INVALIDARG
;
}
/* Would be better to use the application name here rather than 'urlmon' :-/ */
hinternet
=
InternetOpenW
(
wszAppName
,
INTERNET_OPEN_TYPE_PRECONFIG
,
NULL
,
NULL
,
0
);
if
(
hinternet
==
NULL
)
{
return
E_OUTOFMEMORY
;
}
memset
(
&
url
,
0
,
sizeof
(
url
));
url
.
dwStructSize
=
sizeof
(
url
);
url
.
lpszHostName
=
host
;
url
.
dwHostNameLength
=
sizeof
(
host
);
url
.
lpszUrlPath
=
path
;
url
.
dwUrlPathLength
=
sizeof
(
path
);
if
(
!
InternetCrackUrlW
(
szURL
,
0
,
0
,
&
url
))
{
InternetCloseHandle
(
hinternet
);
return
E_OUTOFMEMORY
;
}
if
(
lpfnCB
)
{
if
(
IBindStatusCallback_OnProgress
(
lpfnCB
,
0
,
0
,
BINDSTATUS_CONNECTING
,
url
.
lpszHostName
)
==
E_ABORT
)
{
InternetCloseHandle
(
hinternet
);
return
S_OK
;
}
}
hcon
=
InternetConnectW
(
hinternet
,
url
.
lpszHostName
,
url
.
nPort
,
url
.
lpszUserName
,
url
.
lpszPassword
,
INTERNET_SERVICE_HTTP
,
0
,
0
);
if
(
!
hcon
)
{
InternetCloseHandle
(
hinternet
);
return
E_OUTOFMEMORY
;
}
hreq
=
HttpOpenRequestW
(
hcon
,
NULL
,
url
.
lpszUrlPath
,
NULL
,
NULL
,
NULL
,
0
,
0
);
if
(
!
hreq
)
{
InternetCloseHandle
(
hinternet
);
InternetCloseHandle
(
hcon
);
return
E_OUTOFMEMORY
;
}
if
(
!
HttpSendRequestW
(
hreq
,
NULL
,
0
,
NULL
,
0
))
{
InternetCloseHandle
(
hinternet
);
InternetCloseHandle
(
hcon
);
InternetCloseHandle
(
hreq
);
return
E_OUTOFMEMORY
;
}
if
(
HttpQueryInfoW
(
hreq
,
HTTP_QUERY_CONTENT_LENGTH
|
HTTP_QUERY_FLAG_NUMBER
,
&
total_size
,
&
arg_size
,
NULL
))
{
TRACE
(
" total size : %ld
\n
"
,
total_size
);
}
hfile
=
CreateFileW
(
szFileName
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
if
(
hfile
==
INVALID_HANDLE_VALUE
)
{
return
E_ACCESSDENIED
;
}
if
(
lpfnCB
)
{
if
(
IBindStatusCallback_OnProgress
(
lpfnCB
,
0
,
total_size
!=
0xFFFFFFFF
?
total_size
:
0
,
BINDSTATUS_BEGINDOWNLOADDATA
,
szURL
)
==
E_ABORT
)
{
InternetCloseHandle
(
hreq
);
InternetCloseHandle
(
hcon
);
InternetCloseHandle
(
hinternet
);
CloseHandle
(
hfile
);
return
S_OK
;
}
}
total
=
0
;
while
(
1
)
{
r
=
InternetReadFile
(
hreq
,
buffer
,
sizeof
(
buffer
),
&
sz
);
if
(
!
r
)
{
InternetCloseHandle
(
hreq
);
InternetCloseHandle
(
hcon
);
InternetCloseHandle
(
hinternet
);
CloseHandle
(
hfile
);
return
E_OUTOFMEMORY
;
}
if
(
!
sz
)
break
;
total
+=
sz
;
if
(
lpfnCB
)
{
if
(
IBindStatusCallback_OnProgress
(
lpfnCB
,
total
,
total_size
!=
0xFFFFFFFF
?
total_size
:
0
,
BINDSTATUS_DOWNLOADINGDATA
,
szURL
)
==
E_ABORT
)
{
InternetCloseHandle
(
hreq
);
InternetCloseHandle
(
hcon
);
InternetCloseHandle
(
hinternet
);
CloseHandle
(
hfile
);
return
S_OK
;
}
}
if
(
!
WriteFile
(
hfile
,
buffer
,
sz
,
&
written
,
NULL
))
{
InternetCloseHandle
(
hreq
);
InternetCloseHandle
(
hcon
);
InternetCloseHandle
(
hinternet
);
CloseHandle
(
hfile
);
return
E_OUTOFMEMORY
;
}
}
if
(
lpfnCB
)
{
if
(
IBindStatusCallback_OnProgress
(
lpfnCB
,
total
,
total_size
!=
0xFFFFFFFF
?
total_size
:
0
,
BINDSTATUS_ENDDOWNLOADDATA
,
szURL
)
==
E_ABORT
)
{
InternetCloseHandle
(
hreq
);
InternetCloseHandle
(
hcon
);
InternetCloseHandle
(
hinternet
);
CloseHandle
(
hfile
);
return
S_OK
;
}
}
InternetCloseHandle
(
hreq
);
InternetCloseHandle
(
hcon
);
InternetCloseHandle
(
hinternet
);
CloseHandle
(
hfile
);
return
S_OK
;
}
dlls/urlmon/urlmon.spec
View file @
efe81255
...
...
@@ -61,8 +61,8 @@
@ stub URLDownloadA
@ stub URLDownloadToCacheFileA
@ stub URLDownloadToCacheFileW
@ st
ub URLDownloadToFileA
@ st
ub URLDownloadToFileW
@ st
dcall URLDownloadToFileA(ptr str str long ptr)
@ st
dcall URLDownloadToFileW(ptr wstr wstr long ptr)
@ stub URLDownloadW
@ stub URLOpenBlockingStreamA
@ stub URLOpenBlockingStreamW
...
...
include/urlmon.h
View file @
efe81255
...
...
@@ -312,6 +312,10 @@ HRESULT WINAPI CreateURLMoniker(IMoniker *pmkContext, LPCWSTR szURL, IMoniker **
HRESULT
WINAPI
RegisterBindStatusCallback
(
IBindCtx
*
pbc
,
IBindStatusCallback
*
pbsc
,
IBindStatusCallback
**
ppbsc
,
DWORD
dwReserved
);
HRESULT
WINAPI
CompareSecurityIds
(
BYTE
*
,
DWORD
,
BYTE
*
,
DWORD
,
DWORD
);
HRESULT
WINAPI
URLDownloadToFileA
(
LPUNKNOWN
pCaller
,
LPCSTR
szURL
,
LPCSTR
szFileName
,
DWORD
dwReserved
,
LPBINDSTATUSCALLBACK
lpfnCB
);
HRESULT
WINAPI
URLDownloadToFileW
(
LPUNKNOWN
pCaller
,
LPCWSTR
szURL
,
LPCWSTR
szFileName
,
DWORD
dwReserved
,
LPBINDSTATUSCALLBACK
lpfnCB
);
#ifdef __cplusplus
}
/* extern "C" */
#endif
/* defined(__cplusplus) */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment