12#define URLDownloadToFile URLDownloadToFileW
14#define URLDownloadToFile URLDownloadToFileA
17#define DWNL_E_LASTERROR 0
18#define DWNL_E_NEEDTARGETFILENAME -1
19#define DWNL_E_UNSUPPORTEDSCHEME -2
35#define impl_to_interface(impl,iface) (struct iface *)(&(impl)->lp##iface##Vtbl)
36#define interface_to_impl(instance,iface) ((CBindStatusCallback*)((ULONG_PTR)instance - FIELD_OFFSET(CBindStatusCallback,lp##iface##Vtbl)))
75 Percentage = (
UINT)((
This->Progress * 100) /
This->Size);
131 &IID_IBindStatusCallback) ||
175 switch (ulStatusCode)
177 case BINDSTATUS_FINDINGRESOURCE:
178 if (!
This->bResolving)
187 case BINDSTATUS_CONNECTING:
191 This->szMimeType[0] =
L'\0';
192 if (
This->bResolving)
203 case BINDSTATUS_REDIRECTING:
208 This->szMimeType[0] =
L'\0';
212 case BINDSTATUS_SENDINGREQUEST:
214 This->szMimeType[0] =
L'\0';
215 if (
This->bResolving ||
This->bConnecting)
218 if (!
This->bSendingReq)
224 case BINDSTATUS_MIMETYPEAVAILABLE:
228 case BINDSTATUS_BEGINDOWNLOADDATA:
232 if (
This->bSendingReq)
235 if (!
This->bBeginTransfer &&
This->Size != 0)
237 if (
This->szMimeType[0] !=
L'\0')
248 case BINDSTATUS_ENDDOWNLOADDATA:
252 case BINDSTATUS_DOWNLOADINGDATA:
283 FORMATETC* pformatetc,
366 if (pszFile !=
NULL && pszFile[0] ==
L'\0')
395 wcscpy(szUserName,
L"anonymous");
403 pszFilePart =
wcsrchr(szUrlPath,
L'/');
404 if (pszFilePart !=
NULL)
407 if (pszFilePart ==
NULL && pszFile ==
NULL)
411 pszFile = pszFilePart;
420 dwUrlLen =
sizeof(szUrl) /
sizeof(szUrl[0]);
433 dwUrlLen =
sizeof(szUrl) /
sizeof(szUrl[0]);
443 IBindStatusCallback_Release(pbsc);
447 IBindStatusCallback_Release(pbsc);
unsigned long long UINT64
#define InterlockedIncrement
#define InterlockedDecrement
void ConPuts(FILE *fp, LPCWSTR psz)
#define ConInitStdStreams()
void ConPrintf(FILE *fp, LPCWSTR psz,...)
void ConResPrintf(FILE *fp, UINT nID,...)
#define IDS_CONNECTING_TO_FULL
#define IDS_REDIRECTING_TO
#define IDS_BYTES_DOWNLOADED_FULL
#define IDS_BYTES_DOWNLOADED
#define IDS_ERROR_DOWNLOAD
#define IDS_ERROR_PROTOCOL
#define IDS_CONNECTING_TO
#define IDS_ERROR_FILENAME
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
#define STDMETHODCALLTYPE
#define HeapFree(x, y, z)
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
#define INTERNET_MAX_URL_LENGTH
static HRESULT STDMETHODCALLTYPE CBindStatusCallback_GetPriority(IBindStatusCallback *iface, LONG *pnPriority)
static int download_file(IN LPCWSTR pszUrl, IN LPCWSTR pszFile OPTIONAL)
static HRESULT STDMETHODCALLTYPE CBindStatusCallback_OnObjectAvailable(IBindStatusCallback *iface, REFIID riid, IUnknown *punk)
static ULONG STDMETHODCALLTYPE CBindStatusCallback_AddRef(IBindStatusCallback *iface)
#define DWNL_E_NEEDTARGETFILENAME
static HRESULT STDMETHODCALLTYPE CBindStatusCallback_OnDataAvailable(IBindStatusCallback *iface, DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
static HRESULT STDMETHODCALLTYPE CBindStatusCallback_OnLowResource(IBindStatusCallback *iface, DWORD reserved)
static HRESULT STDMETHODCALLTYPE CBindStatusCallback_GetBindInfo(IBindStatusCallback *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
static HRESULT STDMETHODCALLTYPE CBindStatusCallback_OnStartBinding(IBindStatusCallback *iface, DWORD dwReserved, IBinding *pib)
#define DWNL_E_UNSUPPORTEDSCHEME
static void CBindStatusCallback_Destroy(CBindStatusCallback *This)
static HRESULT STDMETHODCALLTYPE CBindStatusCallback_OnStopBinding(IBindStatusCallback *iface, HRESULT hresult, LPCWSTR szError)
static HRESULT STDMETHODCALLTYPE CBindStatusCallback_OnProgress(IBindStatusCallback *iface, ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
static int print_err(int iErr)
static const struct IBindStatusCallbackVtbl vtblIBindStatusCallback
#define impl_to_interface(impl, iface)
#define URLDownloadToFile
static void CBindStatusCallback_UpdateProgress(CBindStatusCallback *This)
static void write_status(LPCWSTR lpFmt,...)
static ULONG STDMETHODCALLTYPE CBindStatusCallback_Release(IBindStatusCallback *iface)
#define interface_to_impl(instance, iface)
static IBindStatusCallback * CreateBindStatusCallback(void)
static int get_display_url(IN LPURL_COMPONENTS purl, OUT LPWSTR szBuffer, IN PDWORD pdwBufferSize)
static HRESULT STDMETHODCALLTYPE CBindStatusCallback_QueryInterface(IBindStatusCallback *iface, REFIID iid, PVOID *pvObject)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
#define IsEqualIID(riid1, riid2)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
PULONG MinorVersion OPTIONAL
STRSAFEAPI StringCbVPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat, va_list argList)
const IBindStatusCallbackVtbl * lpIBindStatusCallbackVtbl
#define STD_OUTPUT_HANDLE
DWORD WINAPI GetLastError(void)
#define INTERNET_SCHEME_FTP
#define INTERNET_SCHEME_HTTP
#define INTERNET_SCHEME_HTTPS
#define INTERNET_MAX_PASSWORD_LENGTH
#define INTERNET_MAX_HOST_NAME_LENGTH
#define InternetCreateUrl
#define INTERNET_MAX_USER_NAME_LENGTH
#define INTERNET_MAX_PATH_LENGTH
#define INTERNET_MAX_SCHEME_LENGTH
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)