mirror of
https://github.com/reactos/reactos.git
synced 2024-09-06 02:37:06 +00:00
Add a tiny command line download tool.
svn path=/trunk/; revision=28322
This commit is contained in:
parent
a8653e49fb
commit
cb14899998
47
reactos/base/applications/network/dwnl/dwnl.c
Normal file
47
reactos/base/applications/network/dwnl/dwnl.c
Normal file
|
@ -0,0 +1,47 @@
|
|||
#include <windows.h>
|
||||
#include <urlmon.h>
|
||||
#include <tchar.h>
|
||||
|
||||
HRESULT WINAPI URLDownloadToFileA(
|
||||
LPUNKNOWN pCaller,
|
||||
LPCSTR szURL,
|
||||
LPCSTR szFileName,
|
||||
DWORD dwReserved,
|
||||
LPBINDSTATUSCALLBACK lpfnCB);
|
||||
|
||||
// ToDo: Show status, get file name from webserver, better error reporting
|
||||
|
||||
int tmain(int argc, TCHAR **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(argc != 2)
|
||||
{
|
||||
_tprintf(TEXT("Usage: dwnl <url>"));
|
||||
return 2;
|
||||
}
|
||||
|
||||
TCHAR* filename = argv[1];
|
||||
for(i=_tcslen(argv[1]);i>0
|
||||
&&filename[i]!='/'
|
||||
&&filename[i]!='\\'
|
||||
&&filename[i]!='?'
|
||||
&&filename[i]!='*'
|
||||
&&filename[i]!=':'
|
||||
&&filename[i]!='\"'
|
||||
&&filename[i]!='<'
|
||||
&&filename[i]!='>'
|
||||
&&filename[i]!='|';i--);
|
||||
filename = &argv[1][i+1];
|
||||
|
||||
_tprintf("Downloading %s... ", filename);
|
||||
|
||||
if(URLDownloadToFileA(NULL, argv[1], filename, 0, NULL) != S_OK)
|
||||
{
|
||||
_tprintf("Failed.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
_tprintf("Finished.\n");
|
||||
return 0;
|
||||
}
|
12
reactos/base/applications/network/dwnl/dwnl.rbuild
Normal file
12
reactos/base/applications/network/dwnl/dwnl.rbuild
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">
|
||||
<module name="dwnl" type="win32cui" installbase="system32" installname="dwnl.exe">
|
||||
<include base="dwnl">.</include>
|
||||
<library>kernel32</library>
|
||||
<library>crtdll</library>
|
||||
<library>urlmon</library>
|
||||
<define name="__USE_W32API" />
|
||||
<define name="WINVER">0x0501</define>
|
||||
<define name="_WIN32_IE>0x0600</define>
|
||||
<file>dwnl.c</file>
|
||||
</module>
|
|
@ -4,6 +4,9 @@
|
|||
<directory name="arp">
|
||||
<xi:include href="arp/arp.rbuild" />
|
||||
</directory>
|
||||
<directory name="dwnl">
|
||||
<xi:include href="dwnl/dwnl.rbuild" />
|
||||
</directory>
|
||||
<directory name="finger">
|
||||
<xi:include href="finger/finger.rbuild" />
|
||||
</directory>
|
||||
|
|
Loading…
Reference in a new issue