From e17d08dc60015c9dca1d69adcc2713f32c37d35b Mon Sep 17 00:00:00 2001 From: justin1014 Date: Sat, 21 Sep 2002 18:57:02 +0000 Subject: [PATCH] updated to new format / exdll git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1124 212acab6-be3b-0410-9dea-997c60f758d6 --- Contrib/NSISdl/ReadMe.txt | 35 ++++-------------- Contrib/NSISdl/nsisdl.cpp | 78 ++++----------------------------------- Contrib/NSISdl/nsisdl.dsp | 4 ++ 3 files changed, 20 insertions(+), 97 deletions(-) diff --git a/Contrib/NSISdl/ReadMe.txt b/Contrib/NSISdl/ReadMe.txt index 5f7fb364..09f5c7fd 100644 --- a/Contrib/NSISdl/ReadMe.txt +++ b/Contrib/NSISdl/ReadMe.txt @@ -1,5 +1,5 @@ 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 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): - Pass the url and filename on the stack You can also pass /TIMEOUT=### to set the timeout in milliseconds Result is returned in $0 "cancel" if cancelled "success" if success otherwise, an error string describing the error -Example: - ; pack the dll in the install file - File /oname=$TEMP\nsdtmp09.dll nsisdl.dll + NSISDLL::download http://www.nullsoft.com/free/nsis/nsis198.exe poo.exe +or + 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 - Delete $TEMP\nsdtmp09.dll +then, check $0 for errors: - ; check if download succeeded - StrCmp $0 "success" successful - StrCmp $0 "cancel" cancelled - - ; we failed - DetailPrint "Download failed: $0" - goto done - - cancelled: - DetailPrint "Download cancelled" - goto done - successful: - DetailPrint "Download successful" - ExecShell $INSTDIR\test.jpg - goto done + StrCmp $0 "success" yay + Abort "Error downloading file + yay: \ No newline at end of file diff --git a/Contrib/NSISdl/nsisdl.cpp b/Contrib/NSISdl/nsisdl.cpp index 8b112576..999e670a 100644 --- a/Contrib/NSISdl/nsisdl.cpp +++ b/Contrib/NSISdl/nsisdl.cpp @@ -33,6 +33,7 @@ #include "util.h" #include "resource.h" #include "httpget.h" +#include "../exdll/exdll.h" 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); } -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; HWND g_parent; HWND g_dialog; HWND g_childwnd; -int g_stringsize; -stack_t **g_stacktop; -char *g_variables; static int g_cancelled; BOOL CALLBACK DownloadDialogProc(HWND hwndDlg, @@ -338,7 +299,7 @@ extern "C" { __declspec(dllexport) void download (HWND parent, - int stringsize, + int string_size, char *variables, stack_t **stacktop) { @@ -350,17 +311,15 @@ __declspec(dllexport) void download (HWND parent, HWND hwndB=0; g_parent = parent; - g_stringsize = stringsize; - g_variables = variables; - g_stacktop = stacktop; + EXDLL_INIT(); - popstring (filename); - lstrcpyn(buf, filename, 10); + popstring(url); + lstrcpyn(buf, url, 10); if (!lstrcmp(buf, "/TIMEOUT=")) { - g_timeout_ms=my_atoi(filename+9); - popstring (filename); + g_timeout_ms=my_atoi(url+9); + popstring(url); } - popstring (url); + popstring(filename); 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); - - } -} diff --git a/Contrib/NSISdl/nsisdl.dsp b/Contrib/NSISdl/nsisdl.dsp index 722a1962..fe8e4206 100644 --- a/Contrib/NSISdl/nsisdl.dsp +++ b/Contrib/NSISdl/nsisdl.dsp @@ -125,6 +125,10 @@ SOURCE=.\connection.h # End Source File # Begin Source File +SOURCE=..\ExDLL\exdll.h +# End Source File +# Begin Source File + SOURCE=.\httpget.h # End Source File # Begin Source File