updated to new format / exdll
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1124 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
78fe6c27bf
commit
e17d08dc60
3 changed files with 20 additions and 97 deletions
|
@ -1,5 +1,5 @@
|
||||||
NSIS-DL 1.1 - http downloading DLL for NSIS
|
NSIS-DL 1.1 - http downloading DLL for NSIS
|
||||||
Copyright (C) 2001 Yaroslav Faybishenko & Justin Frankel
|
Copyright (C) 2001-2002 Yaroslav Faybishenko & Justin Frankel
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
This software is provided 'as-is', without any express or implied
|
||||||
warranty. In no event will the authors be held liable for any damages
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
@ -24,38 +24,19 @@ This dll can be used from NSIS to download files via http.
|
||||||
|
|
||||||
How to use (for another example, see waplugin.nsi in the nsis directory):
|
How to use (for another example, see waplugin.nsi in the nsis directory):
|
||||||
|
|
||||||
Pass the url and filename on the stack
|
|
||||||
You can also pass /TIMEOUT=### to set the timeout in milliseconds
|
You can also pass /TIMEOUT=### to set the timeout in milliseconds
|
||||||
Result is returned in $0
|
Result is returned in $0
|
||||||
"cancel" if cancelled
|
"cancel" if cancelled
|
||||||
"success" if success
|
"success" if success
|
||||||
otherwise, an error string describing the error
|
otherwise, an error string describing the error
|
||||||
|
|
||||||
Example:
|
NSISDLL::download http://www.nullsoft.com/free/nsis/nsis198.exe poo.exe
|
||||||
; pack the dll in the install file
|
or
|
||||||
File /oname=$TEMP\nsdtmp09.dll nsisdl.dll
|
NSISDLL::download /TIMEOUT=30000 http://www.nullsoft.com/free/nsis/nsis198.exe poo.exe
|
||||||
|
|
||||||
; make the call to download
|
|
||||||
Push "http://www.xcf.berkeley.edu/~yaroslav/photos/mike/mike1-full.jpg"
|
|
||||||
Push "$INSTDIR\test.jpg"
|
|
||||||
; Push /TIMEOUT=10000 ; 10 seconds timeout
|
|
||||||
CallInstDLL $TEMP\nsdtmp09.dll download ; for a quiet install, use download_quiet
|
|
||||||
|
|
||||||
; delete DLL from temporary directory
|
then, check $0 for errors:
|
||||||
Delete $TEMP\nsdtmp09.dll
|
|
||||||
|
|
||||||
; check if download succeeded
|
StrCmp $0 "success" yay
|
||||||
StrCmp $0 "success" successful
|
Abort "Error downloading file
|
||||||
StrCmp $0 "cancel" cancelled
|
yay:
|
||||||
|
|
||||||
; we failed
|
|
||||||
DetailPrint "Download failed: $0"
|
|
||||||
goto done
|
|
||||||
|
|
||||||
cancelled:
|
|
||||||
DetailPrint "Download cancelled"
|
|
||||||
goto done
|
|
||||||
successful:
|
|
||||||
DetailPrint "Download successful"
|
|
||||||
ExecShell $INSTDIR\test.jpg
|
|
||||||
goto done
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "httpget.h"
|
#include "httpget.h"
|
||||||
|
#include "../exdll/exdll.h"
|
||||||
|
|
||||||
int g_timeout_ms=30000;
|
int g_timeout_ms=30000;
|
||||||
|
|
||||||
|
@ -42,51 +43,11 @@ void *operator new( unsigned int num_bytes )
|
||||||
}
|
}
|
||||||
void operator delete( void *p ) { if (p) GlobalFree(p); }
|
void operator delete( void *p ) { if (p) GlobalFree(p); }
|
||||||
|
|
||||||
typedef struct _stack_t {
|
|
||||||
struct _stack_t *next;
|
|
||||||
char text[1]; // this should be the length of string_size
|
|
||||||
} stack_t;
|
|
||||||
|
|
||||||
static int popstring(char *str); // 0 on success, 1 on empty stack
|
|
||||||
static void setuservariable(int varnum, char *var);
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
INST_0, // $0
|
|
||||||
INST_1, // $1
|
|
||||||
INST_2, // $2
|
|
||||||
INST_3, // $3
|
|
||||||
INST_4, // $4
|
|
||||||
INST_5, // $5
|
|
||||||
INST_6, // $6
|
|
||||||
INST_7, // $7
|
|
||||||
INST_8, // $8
|
|
||||||
INST_9, // $9
|
|
||||||
INST_R0, // $R0
|
|
||||||
INST_R1, // $R1
|
|
||||||
INST_R2, // $R2
|
|
||||||
INST_R3, // $R3
|
|
||||||
INST_R4, // $R4
|
|
||||||
INST_R5, // $R5
|
|
||||||
INST_R6, // $R6
|
|
||||||
INST_R7, // $R7
|
|
||||||
INST_R8, // $R8
|
|
||||||
INST_R9, // $R9
|
|
||||||
INST_CMDLINE, // $CMDLINE
|
|
||||||
INST_INSTDIR, // $INSTDIR
|
|
||||||
INST_OUTDIR, // $OUTDIR
|
|
||||||
INST_EXEDIR, // $EXEDIR
|
|
||||||
__INST_LAST
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
HANDLE hModule;
|
HANDLE hModule;
|
||||||
HWND g_parent;
|
HWND g_parent;
|
||||||
HWND g_dialog;
|
HWND g_dialog;
|
||||||
HWND g_childwnd;
|
HWND g_childwnd;
|
||||||
int g_stringsize;
|
|
||||||
stack_t **g_stacktop;
|
|
||||||
char *g_variables;
|
|
||||||
static int g_cancelled;
|
static int g_cancelled;
|
||||||
|
|
||||||
BOOL CALLBACK DownloadDialogProc(HWND hwndDlg,
|
BOOL CALLBACK DownloadDialogProc(HWND hwndDlg,
|
||||||
|
@ -338,7 +299,7 @@ extern "C"
|
||||||
{
|
{
|
||||||
|
|
||||||
__declspec(dllexport) void download (HWND parent,
|
__declspec(dllexport) void download (HWND parent,
|
||||||
int stringsize,
|
int string_size,
|
||||||
char *variables,
|
char *variables,
|
||||||
stack_t **stacktop)
|
stack_t **stacktop)
|
||||||
{
|
{
|
||||||
|
@ -350,17 +311,15 @@ __declspec(dllexport) void download (HWND parent,
|
||||||
HWND hwndB=0;
|
HWND hwndB=0;
|
||||||
|
|
||||||
g_parent = parent;
|
g_parent = parent;
|
||||||
g_stringsize = stringsize;
|
EXDLL_INIT();
|
||||||
g_variables = variables;
|
|
||||||
g_stacktop = stacktop;
|
|
||||||
|
|
||||||
popstring (filename);
|
popstring(url);
|
||||||
lstrcpyn(buf, filename, 10);
|
lstrcpyn(buf, url, 10);
|
||||||
if (!lstrcmp(buf, "/TIMEOUT=")) {
|
if (!lstrcmp(buf, "/TIMEOUT=")) {
|
||||||
g_timeout_ms=my_atoi(filename+9);
|
g_timeout_ms=my_atoi(url+9);
|
||||||
popstring (filename);
|
popstring(url);
|
||||||
}
|
}
|
||||||
popstring (url);
|
popstring(filename);
|
||||||
|
|
||||||
HANDLE hFile = CreateFile(filename,GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_ALWAYS,0,NULL);
|
HANDLE hFile = CreateFile(filename,GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_ALWAYS,0,NULL);
|
||||||
|
|
||||||
|
@ -449,24 +408,3 @@ __declspec(dllexport) void download_quiet(HWND parent,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// utility functions (not required but often useful)
|
|
||||||
static
|
|
||||||
int popstring(char *str)
|
|
||||||
{
|
|
||||||
stack_t *th;
|
|
||||||
if (!g_stacktop || !*g_stacktop) return 1;
|
|
||||||
th=(*g_stacktop);
|
|
||||||
lstrcpy(str,th->text);
|
|
||||||
*g_stacktop = th->next;
|
|
||||||
GlobalFree((HGLOBAL)th);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
void setuservariable(int varnum, char *var)
|
|
||||||
{
|
|
||||||
if (var != NULL && varnum >= 0 && varnum < __INST_LAST) {
|
|
||||||
lstrcpy (g_variables + varnum*g_stringsize, var);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -125,6 +125,10 @@ SOURCE=.\connection.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\ExDLL\exdll.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\httpget.h
|
SOURCE=.\httpget.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue