Instant saving of 0.5K - use of stdcall calling convention to

reduce code overhead associated with managing the stack


git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@694 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
eccles 2002-08-19 23:18:19 +00:00
parent 7a2cf3e5b8
commit 34db30b2ce
17 changed files with 154 additions and 118 deletions

View file

@ -26,7 +26,7 @@ using namespace std;
#ifdef NSIS_CONFIG_CRC_SUPPORT
extern "C"
{
unsigned long CRC32(unsigned long crc, const unsigned char *buf, unsigned int len);
unsigned long NSISCALL CRC32(unsigned long crc, const unsigned char *buf, unsigned int len);
};
#endif
@ -40,7 +40,7 @@ extern "C"
#define IS_PS_ELSE(x) (( x ) >= PS_ELSE && ( x ) <= PS_ELSE_IF1)
class CEXEBuild {
public:
public:
CEXEBuild();
~CEXEBuild();
@ -60,7 +60,7 @@ class CEXEBuild {
// it is as if they are concatenated)
int process_script(FILE *fp, char *curfilename, int *lineptr);
int process_oneline(char *line, char *curfilename, int lineptr);
// you only get to call write_output once, so use it wisely.
int write_output(void);
@ -160,7 +160,7 @@ class CEXEBuild {
int has_called_write_output;
char build_packname[1024], build_packcmd[1024];
int build_overwrite, build_compress, build_crcchk,
int build_overwrite, build_compress, build_crcchk,
build_datesave, build_optimize_datablock;
header build_header;
@ -178,7 +178,7 @@ class CEXEBuild {
StringList m_macro_entry;
int db_opt_save, db_comp_save, db_full_size, db_opt_save_u,
int db_opt_save, db_comp_save, db_full_size, db_opt_save_u,
db_comp_save_u, db_full_size_u;
int build_sections_req,build_sections_div;
@ -193,7 +193,7 @@ class CEXEBuild {
StringList build_strlist,ubuild_strlist;
MMapBuf build_datablock, ubuild_datablock; // use GrowBuf here instead of MMapBuf if you want
IGrowBuf *cur_datablock;
IGrowBuf *cur_datablock;
unsigned char *header_data_new;
int exeheader_size_new;

View file

@ -2,7 +2,7 @@
#ifdef NSIS_CONFIG_CRC_SUPPORT
// this is based on the (slow,small) CRC32 implementation from zlib.
unsigned long CRC32(unsigned long crc, const unsigned char *buf, unsigned int len)
unsigned long NSISCALL CRC32(unsigned long crc, const unsigned char *buf, unsigned int len)
{
static unsigned long crc_table[256];

View file

@ -33,7 +33,7 @@
#include "ui.h"
#include "lang.h"
extern unsigned long CRC32(unsigned long crc, const unsigned char *buf, unsigned int len);
extern unsigned long NSISCALL CRC32(unsigned long crc, const unsigned char *buf, unsigned int len);
#if !defined(NSIS_CONFIG_VISIBLE_SUPPORT) && !defined(NSIS_CONFIG_SILENT_SUPPORT)
#error One of NSIS_CONFIG_SILENT_SUPPORT or NSIS_CONFIG_VISIBLE_SUPPORT must be defined.

View file

@ -83,7 +83,7 @@ static BOOL CALLBACK UninstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
static DWORD WINAPI install_thread(LPVOID p);
HWND bgWnd_Init(HINSTANCE hInstance, char *title, int color1, int color2, int);
HWND NSISCALL bgWnd_Init(HINSTANCE hInstance, char *title, int color1, int color2, int);
HWND insthwnd, insthwnd2,insthwndbutton;
@ -104,30 +104,30 @@ HWND m_curwnd;
static int m_whichcfg;
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT
static BOOL SetDlgItemTextFromLang(HWND dlg, WORD id, langid_t lid) {
static BOOL NSISCALL SetDlgItemTextFromLang(HWND dlg, WORD id, langid_t lid) {
return SetDlgItemText(dlg,id,STR(GetLangString(lid)));
}
static BOOL SetUITextFromLang(HWND defhw, WORD def, WORD custom, langid_t lid) {
return SetDlgItemTextFromLang(custom?g_hwnd:defhw,custom?custom:def,lid);
static BOOL NSISCALL SetUITextFromLang(HWND defhw, WORD def, WORD custom, langid_t lid) {
return SetDlgItemTextFromLang(custom?g_hwnd:defhw,(WORD)(custom?custom:def),lid);
}
// no tab
static BOOL SetUITextNT(HWND defhw, WORD def, WORD custom, const char *text) {
static BOOL NSISCALL SetUITextNT(HWND defhw, WORD def, WORD custom, const char *text) {
return SetDlgItemText(custom?g_hwnd:defhw,custom?custom:def,text);
}
static UINT GetUIText(WORD def, WORD custom, char *str, int max_size) {
static UINT NSISCALL GetUIText(WORD def, WORD custom, char *str, int max_size) {
return GetDlgItemText(custom?g_hwnd:m_curwnd,custom?custom:def,str,max_size);
}
static HWND GetUIItem(HWND defhw, WORD def, WORD custom) {
static HWND NSISCALL GetUIItem(HWND defhw, WORD def, WORD custom) {
return GetDlgItem(custom?g_hwnd:defhw,custom?custom:def);
}
#endif
#ifdef NSIS_CONFIG_LOG
static void build_g_logfile()
void NSISCALL build_g_logfile()
{
addtrailingslash(mystrcpy(g_log_file,state_install_directory));
lstrcat(g_log_file,"install.log");
@ -135,7 +135,7 @@ static void build_g_logfile()
#endif
#ifdef NSIS_CONFIG_COMPONENTPAGE
static void SetChildrenStates(HWND hWnd, TV_ITEM *pItem, int iState) {
static void NSISCALL SetChildrenStates(HWND hWnd, TV_ITEM *pItem, int iState) {
HTREEITEM hItem;
int l=0;
@ -165,7 +165,7 @@ static void SetChildrenStates(HWND hWnd, TV_ITEM *pItem, int iState) {
}
}
static void SetParentState(HWND hWnd, TV_ITEM *pItem) {
static void NSISCALL SetParentState(HWND hWnd, TV_ITEM *pItem) {
HTREEITEM hItem;
int iState = 0, iStatePrev = 0;
@ -204,7 +204,7 @@ static void SetParentState(HWND hWnd, TV_ITEM *pItem) {
}
static void CheckTreeItem(HWND hWnd, TV_ITEM *pItem, int checked) {
static void NSISCALL CheckTreeItem(HWND hWnd, TV_ITEM *pItem, int checked) {
HTREEITEM hItem = pItem->hItem;
int l=0;
@ -227,7 +227,7 @@ static void CheckTreeItem(HWND hWnd, TV_ITEM *pItem, int checked) {
#endif//NSIS_CONFIG_COMPONENTPAGE
int ui_doinstall(void)
int NSISCALL ui_doinstall(void)
{
g_autoclose=g_inst_cmnheader->misc_flags&1;
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
@ -641,7 +641,7 @@ static BOOL CALLBACK UninstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
#endif
static void inttosizestr(int kb, char *str)
static void NSISCALL inttosizestr(int kb, char *str)
{
str += mystrlen(str);
if (kb < 1024) wsprintf(str,"%dKB",kb);
@ -1130,12 +1130,12 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
int ui_st_updateflag=0x3;
void update_status_text_from_lang(langid_t id, const char *text2)
void NSISCALL update_status_text_from_lang(langid_t id, const char *text2)
{
update_status_text(STR(GetLangString(id)), text2);
}
void update_status_text(const char *text1, const char *text2)
void NSISCALL update_status_text(const char *text1, const char *text2)
{
static LVITEM new_item = {LVIF_TEXT,0,0,0,0,ps_tmpbuf};
RECT r;

View file

@ -62,7 +62,7 @@ static LRESULT CALLBACK BG_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
}
HWND bgWnd_Init(HINSTANCE hInstance, char *title, int color1, int color2, int color3)
HWND NSISCALL bgWnd_Init(HINSTANCE hInstance, char *title, int color1, int color2, int color3)
{
RECT vp;
char classname[4]="_Nb";

View file

@ -3,6 +3,22 @@
#ifndef APSTUDIO_INVOKED // keep msdev's resource editor from mangling the .rc file
// Added by Dave Laundon 19th August 2002
// For all internal functions, use of stdcall calling convention moves the
// responsibility for tidying the stack to callee from caller, reducing the code
// involved considerably. Gives an instant saving of 0.5K.
// NB - the zlib and bzip2 portions have been given the same treatment, but with
// project compiler-options settings and/or project-wide defines.
// NB - safer for NSIS's routines to be defined explicitly to avoid problems
// calling DLL functions.
#if defined(_WIN32) && ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED))
#define NSISCALL __stdcall // Ordinary functions
#define NSISCALLV __cdecl // Variable-argument-list functions
#else
#define NSISCALL
#define NSISCALLV
#endif
// NSIS_MAX_STRLEN defines the maximum string length for internal variables
// and stack entries. 1024 should be plenty, but if you are doing crazy registry
// shit, you might want to bump it up. Generally it adds about 16-32x the memory,
@ -11,13 +27,13 @@
#define NSIS_MAX_STRLEN 1024
// NSIS_MAX_INST_TYPES specified the maximum install types.
// NSIS_MAX_INST_TYPES specified the maximum install types.
// note that this should not exceed 30, ever.
#define NSIS_MAX_INST_TYPES 8
// NSIS_CONFIG_UNINSTALL_SUPPORT enables the uninstaller
// support. Comment it out if your installers don't need
// uninstallers
// uninstallers
// adds approximately 2kb.
#define NSIS_CONFIG_UNINSTALL_SUPPORT
@ -66,7 +82,7 @@
// the expense of speed. not recommended.
// #define NSIS_COMPRESS_BZIP2_SMALLMODE
// if NSIS_COMPRESS_BZIP2_LEVEL is defined, it overrides the default bzip2
// if NSIS_COMPRESS_BZIP2_LEVEL is defined, it overrides the default bzip2
// compression window size of 9 (1-9 is valid)
// 9 uses the most memory, but typically compresses best (recommended).
// 1 uses the least memory, but typically compresses the worst.
@ -196,7 +212,7 @@
// temporary file name.
// - Any parameters following the command will be pushed onto
// the stack in left to right order.
// - The command will then be invoked in the dll as if
// - The command will then be invoked in the dll as if
// "CallInstDLL dll command" had been invoked.
// - When the installer exits any extracted temporary dlls will
// be deleted.

View file

@ -39,7 +39,7 @@ char plugins_temp_dir[NSIS_MAX_STRLEN]="";
extern HWND m_curwnd;
static WIN32_FIND_DATA *file_exists(char *buf)
static WIN32_FIND_DATA * NSISCALL file_exists(char *buf)
{
HANDLE h;
static WIN32_FIND_DATA fd;
@ -56,7 +56,7 @@ static WIN32_FIND_DATA *file_exists(char *buf)
// based loosely on code from Tim Kosse
// in win9x this isn't necessary (RegDeleteKey() can delete a tree of keys),
// but in win2k you need to do this manually.
static LONG myRegDeleteKeyEx(HKEY thiskey, LPCTSTR lpSubKey, int onlyifempty)
static LONG NSISCALL myRegDeleteKeyEx(HKEY thiskey, LPCTSTR lpSubKey, int onlyifempty)
{
HKEY key;
int retval=RegOpenKeyEx(thiskey,lpSubKey,0,KEY_ALL_ACCESS,&key);
@ -82,15 +82,15 @@ static LONG myRegDeleteKeyEx(HKEY thiskey, LPCTSTR lpSubKey, int onlyifempty)
extern char g_all_user_var_flag;
static int ExecuteEntry(entry *entries, int pos);
static int NSISCALL ExecuteEntry(entry *entries, int pos);
static int resolveaddr(int v)
static int NSISCALL resolveaddr(int v)
{
if (v<0) return myatoi(g_usrvars[-(v+1)]); // if <0, that means we
return v;
}
int ExecuteCodeSegment(entry *entries, int pos, HWND hwndProgress)
int NSISCALL ExecuteCodeSegment(entry *entries, int pos, HWND hwndProgress)
{
while (pos >= 0)
{
@ -124,7 +124,7 @@ int ExecuteCodeSegment(entry *entries, int pos, HWND hwndProgress)
// returns EXEC_ERROR on error
// returns 0, advance position by 1
// otherwise, returns new_position+1
static int ExecuteEntry(entry *entries, int pos)
static int NSISCALL ExecuteEntry(entry *entries, int pos)
{
static char buf[NSIS_MAX_STRLEN],buf2[NSIS_MAX_STRLEN],buf3[NSIS_MAX_STRLEN],buf4[NSIS_MAX_STRLEN];
int *parms=entries[pos].offsets;
@ -1301,7 +1301,7 @@ static int ExecuteEntry(entry *entries, int pos)
log_printf2("settings logging to %d",parms[1]);
log_dolog=parms[1];
log_printf2("logging set to %d",parms[1]);
if (!g_log_file && log_dolg) build_g_logfile();
if (!g_log_file && log_dolog) build_g_logfile();
}
else
{

View file

@ -1,7 +1,7 @@
#ifndef _EXEC_H_
#define _EXEC_H_
int ExecuteCodeSegment(entry *entries, int pos, HWND hwndProgress); // returns 0 on success
int NSISCALL ExecuteCodeSegment(entry *entries, int pos, HWND hwndProgress); // returns 0 on success
#endif//_EXEC_H_
#endif//_EXEC_H_

View file

@ -39,7 +39,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /Gd /W3 /GX /O1 /Oy /D "_WINDOWS" /D "EXEHEAD" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "WIN32_LEAN_AND_MEAN" /D "NSIS_COMPRESS_USE_BZIP2" /FD /c
# ADD CPP /nologo /W3 /GX /O1 /Oy /D "_WINDOWS" /D "EXEHEAD" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "WIN32_LEAN_AND_MEAN" /D "NSIS_COMPRESS_USE_BZIP2" /FD /c
# SUBTRACT CPP /Fr /YX /Yc /Yu
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@ -96,22 +96,27 @@ SOURCE=..\zlib\Zlib.h
# Begin Source File
SOURCE=..\zlib\INFBLOCK.C
# ADD CPP /Gz
# End Source File
# Begin Source File
SOURCE=..\zlib\INFCODES.C
# ADD CPP /Gz
# End Source File
# Begin Source File
SOURCE=..\zlib\INFLATE.C
# ADD CPP /Gz
# End Source File
# Begin Source File
SOURCE=..\zlib\INFTREES.C
# ADD CPP /Gz
# End Source File
# Begin Source File
SOURCE=..\zlib\INFUTIL.C
# ADD CPP /Gz
# End Source File
# End Group
# Begin Group "bzip2"
@ -120,6 +125,7 @@ SOURCE=..\zlib\INFUTIL.C
# Begin Source File
SOURCE=..\bzip2\bzlib.c
# ADD CPP /Gz
# End Source File
# Begin Source File
@ -132,14 +138,17 @@ SOURCE=..\bzip2\bzlib_private.h
# Begin Source File
SOURCE=..\bzip2\decompress.c
# ADD CPP /Gz
# End Source File
# Begin Source File
SOURCE=..\bzip2\huffman.c
# ADD CPP /Gz
# End Source File
# Begin Source File
SOURCE=..\bzip2\randtable.c
# ADD CPP /Gz
# End Source File
# End Group
# Begin Source File

View file

@ -39,7 +39,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /Gd /W3 /GX /O1 /Oy /D "_WINDOWS" /D "EXEHEAD" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "WIN32_LEAN_AND_MEAN" /D "NSIS_COMPRESS_USE_ZLIB" /FD /c
# ADD CPP /nologo /W3 /GX /O1 /Oy /D "_WINDOWS" /D "EXEHEAD" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "WIN32_LEAN_AND_MEAN" /D "NSIS_COMPRESS_USE_ZLIB" /D ZEXPORT=__stdcall /FD /c
# SUBTRACT CPP /Fr /YX /Yc /Yu
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@ -96,22 +96,27 @@ SOURCE=..\zlib\Zlib.h
# Begin Source File
SOURCE=..\zlib\INFBLOCK.C
# ADD CPP /Gz
# End Source File
# Begin Source File
SOURCE=..\zlib\INFCODES.C
# ADD CPP /Gz
# End Source File
# Begin Source File
SOURCE=..\zlib\INFLATE.C
# ADD CPP /Gz
# End Source File
# Begin Source File
SOURCE=..\zlib\INFTREES.C
# ADD CPP /Gz
# End Source File
# Begin Source File
SOURCE=..\zlib\INFUTIL.C
# ADD CPP /Gz
# End Source File
# End Group
# Begin Group "bzip2"
@ -120,6 +125,7 @@ SOURCE=..\zlib\INFUTIL.C
# Begin Source File
SOURCE=..\bzip2\bzlib.c
# ADD CPP /Gz
# End Source File
# Begin Source File
@ -132,14 +138,17 @@ SOURCE=..\bzip2\bzlib_private.h
# Begin Source File
SOURCE=..\bzip2\decompress.c
# ADD CPP /Gz
# End Source File
# Begin Source File
SOURCE=..\bzip2\huffman.c
# ADD CPP /Gz
# End Source File
# Begin Source File
SOURCE=..\bzip2\randtable.c
# ADD CPP /Gz
# End Source File
# End Group
# Begin Source File

View file

@ -33,7 +33,7 @@ HANDLE dbd_hFile=INVALID_HANDLE_VALUE;
static int dbd_size, dbd_pos, dbd_srcpos, dbd_fulllen;
#endif//NSIS_COMPRESS_WHOLE
int isheader(firstheader *h)
int NSISCALL isheader(firstheader *h)
{
if ((h->flags & (~FH_FLAGS_MASK)) ||
h->siginfo != FH_SIG ||
@ -48,7 +48,7 @@ int isheader(firstheader *h)
static z_stream g_inflate_stream;
#endif
int loadHeaders(void)
int NSISCALL loadHeaders(void)
{
DWORD r;
void *data;
@ -70,7 +70,7 @@ int loadHeaders(void)
GetTempPath(sizeof(fn),fn);
GetTempFileName(fn,"nsi",0,fno);
dbd_hFile=CreateFile(fno,GENERIC_WRITE|GENERIC_READ,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_TEMPORARY|FILE_FLAG_DELETE_ON_CLOSE,NULL);
if (dbd_hFile == INVALID_HANDLE_VALUE)
if (dbd_hFile == INVALID_HANDLE_VALUE)
{
my_MessageBox("Error writing temp file",MB_OK);
return -1;
@ -111,7 +111,7 @@ int loadHeaders(void)
return 0;
}
const char *GetStringFromStringTab(int offs)
const char * NSISCALL GetStringFromStringTab(int offs)
{
if (offs < 0) return "";
return g_db_strtab+offs;
@ -124,7 +124,7 @@ const char *GetStringFromStringTab(int offs)
#ifndef NSIS_COMPRESS_WHOLE
static int _dodecomp(int offset, HANDLE hFileOut, char *outbuf, int outbuflen)
static int NSISCALL _dodecomp(int offset, HANDLE hFileOut, char *outbuf, int outbuflen)
{
static char inbuffer[IBUFSIZE+OBUFSIZE];
char *outbuffer;
@ -135,7 +135,7 @@ static int _dodecomp(int offset, HANDLE hFileOut, char *outbuf, int outbuflen)
outbuffer = outbuf?outbuf:(inbuffer+IBUFSIZE);
if (offset>=0)
if (offset>=0)
{
/*
int lp=SetFilePointer(g_db_hFile,0,NULL,FILE_CURRENT);
@ -224,7 +224,7 @@ static int _dodecomp(int offset, HANDLE hFileOut, char *outbuf, int outbuflen)
static char _inbuffer[IBUFSIZE];
static char _outbuffer[OBUFSIZE];
static int __ensuredata(int amount)
static int NSISCALL __ensuredata(int amount)
{
int needed=amount-(dbd_size-dbd_pos);
if (needed>0)
@ -270,7 +270,7 @@ static int __ensuredata(int amount)
}
static int _dodecomp(int offset, HANDLE hFileOut, char *outbuf, int outbuflen)
static int NSISCALL _dodecomp(int offset, HANDLE hFileOut, char *outbuf, int outbuflen)
{
DWORD r;
int input_len;
@ -312,12 +312,12 @@ static int _dodecomp(int offset, HANDLE hFileOut, char *outbuf, int outbuflen)
#endif//NSIS_COMPRESS_WHOLE
int GetCompressedDataFromDataBlock(int offset, HANDLE hFileOut)
int NSISCALL GetCompressedDataFromDataBlock(int offset, HANDLE hFileOut)
{
return _dodecomp(offset,hFileOut,NULL,0);
}
int GetCompressedDataFromDataBlockToMemory(int offset, char *out, int out_len)
int NSISCALL GetCompressedDataFromDataBlockToMemory(int offset, char *out, int out_len)
{
return _dodecomp(offset,NULL,out,out_len);
}

View file

@ -393,20 +393,20 @@ typedef struct
// the following are only used/implemented in exehead, not makensis.
int isheader(firstheader *h); // returns 0 on not header, length_of_datablock on success
int NSISCALL isheader(firstheader *h); // returns 0 on not header, length_of_datablock on success
// returns nonzero on error
// returns 0 on success
// on success, m_header will be set to a pointer that should eventually be GlobalFree()'d.
// (or m_uninstheader)
int loadHeaders(void);
int NSISCALL loadHeaders(void);
extern HANDLE g_db_hFile;
extern int g_quit_flag;
const char *GetStringFromStringTab(int offs);
int GetCompressedDataFromDataBlock(int offset, HANDLE hFileOut);
int GetCompressedDataFromDataBlockToMemory(int offset, char *out, int out_len);
const char * NSISCALL GetStringFromStringTab(int offs);
int NSISCALL GetCompressedDataFromDataBlock(int offset, HANDLE hFileOut);
int NSISCALL GetCompressedDataFromDataBlockToMemory(int offset, char *out, int out_len);
// $0..$9, $INSTDIR, etc are encoded as ASCII bytes starting from this value.
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT

View file

@ -7,9 +7,9 @@
extern common_strings *cur_common_strings_table;
extern char *cur_install_strings_table; // installer_strings/uninstall_strings depending on installer type
int ui_doinstall(void);
void update_status_text_from_lang(langid_t id, const char *text2);
void update_status_text(const char *text1, const char *text2);
int NSISCALL ui_doinstall(void);
void NSISCALL update_status_text_from_lang(langid_t id, const char *text2);
void NSISCALL update_status_text(const char *text1, const char *text2);
extern int ui_st_updateflag;
extern char g_autoclose;
@ -25,4 +25,8 @@ extern entry *g_inst_entry;
extern int g_is_uninstaller;
#endif
#ifdef NSIS_CONFIG_LOG
void NSISCALL build_g_logfile(void);
#endif
#endif//_UI_H_

View file

@ -20,7 +20,7 @@ char g_usrvars[24][NSIS_MAX_STRLEN];
HANDLE g_hInstance;
HANDLE myCreateProcess(char *cmd, char *dir)
HANDLE NSISCALL myCreateProcess(char *cmd, char *dir)
{
PROCESS_INFORMATION ProcInfo={0,};
STARTUPINFO StartUp={sizeof(StartUp),};
@ -30,12 +30,12 @@ HANDLE myCreateProcess(char *cmd, char *dir)
return ProcInfo.hProcess;
}
int my_MessageBox(const char *text, UINT type) {
int NSISCALL my_MessageBox(const char *text, UINT type) {
return MessageBox(g_hwnd, text, g_caption, type);
}
#ifdef NSIS_SUPPORT_RMDIR
void doRMDir(char *buf, int recurse)
void NSISCALL doRMDir(char *buf, int recurse)
{
if (recurse && is_valid_instpath(buf))
{
@ -72,17 +72,17 @@ void doRMDir(char *buf, int recurse)
}
#endif//NSIS_SUPPORT_RMDIR
void addtrailingslash(char *str)
void NSISCALL addtrailingslash(char *str)
{
if (lastchar(str)!='\\') lstrcat(str,"\\");
}
char lastchar(const char *str)
char NSISCALL lastchar(const char *str)
{
return *CharPrev(str,str+mystrlen(str));
}
void trimslashtoend(char *buf)
void NSISCALL trimslashtoend(char *buf)
{
char *p=scanendslash(buf);
if (p<buf) p=buf;
@ -90,7 +90,7 @@ void trimslashtoend(char *buf)
}
char *scanendslash(const char *str)
char * NSISCALL scanendslash(const char *str)
{
char *s=CharPrev(str,str+mystrlen(str));
if (!*str) return (char*)str-1;
@ -104,12 +104,12 @@ char *scanendslash(const char *str)
}
}
int validpathspec(char *ubuf)
int NSISCALL validpathspec(char *ubuf)
{
return ((ubuf[0]=='\\' && ubuf[1]=='\\') || (ubuf[0] && *CharNext(ubuf)==':'));
}
int is_valid_instpath(char *s)
int NSISCALL is_valid_instpath(char *s)
{
int ivp=0;
// if 8 is set, req is 0, which means rootdirs are not allowed.
@ -143,7 +143,7 @@ int is_valid_instpath(char *s)
return ivp;
}
static char *findinmem(char *a, char *b, int len_of_a)
static char * NSISCALL findinmem(char *a, char *b, int len_of_a)
{
if (len_of_a<0) len_of_a=mystrlen(a);
len_of_a -= mystrlen(b);
@ -163,7 +163,7 @@ static char *findinmem(char *a, char *b, int len_of_a)
}
void *mini_memcpy(void *out, const void *in, int len)
void * NSISCALL mini_memcpy(void *out, const void *in, int len)
{
char *c_out=(char*)out;
char *c_in=(char *)in;
@ -175,13 +175,13 @@ void *mini_memcpy(void *out, const void *in, int len)
}
HANDLE myOpenFile(const char *fn, DWORD da, DWORD cd)
HANDLE NSISCALL myOpenFile(const char *fn, DWORD da, DWORD cd)
{
return CreateFile(fn,da,FILE_SHARE_READ,NULL,cd,0,NULL);
}
#ifdef NSIS_SUPPORT_MOVEONREBOOT
BOOL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew)
BOOL NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew)
{
BOOL fOk = 0;
HMODULE hLib=LoadLibrary("kernel32.dll");
@ -277,7 +277,7 @@ BOOL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew)
}
#endif
void recursive_create_directory(char *directory)
void NSISCALL recursive_create_directory(char *directory)
{
char *tp;
char *p;
@ -311,7 +311,7 @@ void recursive_create_directory(char *directory)
}
void myRegGetStr(HKEY root, const char *sub, const char *name, char *out)
void NSISCALL myRegGetStr(HKEY root, const char *sub, const char *name, char *out)
{
HKEY hKey;
*out=0;
@ -328,7 +328,7 @@ void myRegGetStr(HKEY root, const char *sub, const char *name, char *out)
char g_all_user_var_flag;
static void queryShellFolders(const char *name, char *out)
static void NSISCALL queryShellFolders(const char *name, char *out)
{
char f=g_all_user_var_flag;
again:
@ -349,28 +349,28 @@ again:
char ps_tmpbuf[NSIS_MAX_STRLEN*2];
void process_string_fromtab(char *out, int offs)
void NSISCALL process_string_fromtab(char *out, int offs)
{
process_string(ps_tmpbuf,GetStringFromStringTab(offs));
lstrcpyn(out,ps_tmpbuf,NSIS_MAX_STRLEN);
}
void process_string_from_lang(char *out, langid_t id)
void NSISCALL process_string_from_lang(char *out, langid_t id)
{
process_string_fromtab(out, GetLangString(id));
}
// Retrieve the string offset associated with the language string ID given
int GetLangString(langid_t id)
int NSISCALL GetLangString(langid_t id)
{
return (int)id < 0 ?
*((int *)cur_install_strings_table - 1 - (int)id) :
*((int *)cur_common_strings_table + (int)id);
}
void myitoa(char *s, int d) { wsprintf(s,"%d",d); }
void NSISCALL myitoa(char *s, int d) { wsprintf(s,"%d",d); }
int myatoi(char *s)
int NSISCALL myatoi(char *s)
{
unsigned int v=0;
if (*s == '0' && (s[1] == 'x' || s[1] == 'X'))
@ -418,25 +418,25 @@ int myatoi(char *s)
// Straight copies of selected shell functions. Calling local functions
// requires less code than DLL functions. For the savings to outweigh the cost
// of a new function there should be about a couple of dozen or so calls.
char *mystrcpy(char *out, const char *in)
char * NSISCALL mystrcpy(char *out, const char *in)
{
return lstrcpy(out, in);
}
int mystrlen(const char *in)
int NSISCALL mystrlen(const char *in)
{
return lstrlen(in);
}
int process_string_fromtab_toint(int offs)
int NSISCALL process_string_fromtab_toint(int offs)
{
process_string(ps_tmpbuf,GetStringFromStringTab(offs));
return myatoi(ps_tmpbuf);
}
// Dave Laundon's simplified process_string
void process_string(char *out, const char *in)
void NSISCALL process_string(char *out, const char *in)
{
char *outsave = out;
while (*in && out - outsave < NSIS_MAX_STRLEN)
@ -555,7 +555,7 @@ void process_string(char *out, const char *in)
char log_text[4096];
int log_dolog;
void log_write(int close)
void NSISCALL log_write(int close)
{
extern char g_log_file[1024];
static HANDLE fp=INVALID_HANDLE_VALUE;
@ -589,7 +589,7 @@ void log_write(int close)
#endif
#ifdef NSIS_SUPPORT_CREATESHORTCUT
int CreateShortCut(HWND hwnd, LPCSTR pszShortcutFile, LPCSTR pszIconFile, int iconindex, LPCSTR pszExe, LPCSTR pszArg, LPCSTR workingdir, int showmode, int hotkey)
int NSISCALL CreateShortCut(HWND hwnd, LPCSTR pszShortcutFile, LPCSTR pszIconFile, int iconindex, LPCSTR pszExe, LPCSTR pszArg, LPCSTR workingdir, int showmode, int hotkey)
{
HRESULT hres;
int rv=1;

View file

@ -1,23 +1,23 @@
#include "config.h"
#include "lang.h"
void recursive_create_directory(char *directory);
void NSISCALL recursive_create_directory(char *directory);
extern char ps_tmpbuf[NSIS_MAX_STRLEN*2];
void process_string(char *out, const char *in);
void process_string_fromtab(char *out, int offs);
void process_string_from_lang(char *out, langid_t id);
int GetLangString(langid_t id);
int process_string_fromtab_toint(int offs);
void myRegGetStr(HKEY root, const char *sub, const char *name, char *out);
int myatoi(char *s);
void myitoa(char *s, int d);
char *mystrcpy(char *out, const char *in);
int mystrlen(const char *in);
void NSISCALL process_string(char *out, const char *in);
void NSISCALL process_string_fromtab(char *out, int offs);
void NSISCALL process_string_from_lang(char *out, langid_t id);
int NSISCALL GetLangString(langid_t id);
int NSISCALL process_string_fromtab_toint(int offs);
void NSISCALL myRegGetStr(HKEY root, const char *sub, const char *name, char *out);
int NSISCALL myatoi(char *s);
void NSISCALL myitoa(char *s, int d);
char * NSISCALL mystrcpy(char *out, const char *in);
int NSISCALL mystrlen(const char *in);
#ifdef NSIS_CONFIG_LOG
extern char log_text[NSIS_MAX_STRLEN*4];
void log_write(int close);
void NSISCALL log_write(int close);
#define log_printf(x1) wsprintf(log_text,x1); log_write(0)
#define log_printf2(x1,x2) wsprintf(log_text,x1,x2); log_write(0)
#define log_printf3(x1,x2,x3) wsprintf(log_text,x1,x2,x3); log_write(0)
@ -37,18 +37,18 @@ extern char g_log_file[1024];
#define log_printf8(x1,x2,x3,x4,x5,x6,x7,x8)
#endif
HANDLE myCreateProcess(char *cmd, char *dir);
int my_MessageBox(const char *text, UINT type);
HANDLE NSISCALL myCreateProcess(char *cmd, char *dir);
int NSISCALL my_MessageBox(const char *text, UINT type);
void doRMDir(char *buf, int recurse);
void NSISCALL doRMDir(char *buf, int recurse);
HANDLE myOpenFile(const char *fn, DWORD da, DWORD cd);
int CreateShortCut(HWND hwnd, LPCSTR pszShortcutFile, LPCSTR pszIconFile, int iconindex, LPCSTR pszExe, LPCSTR pszArg, LPCSTR workingdir, int showmode, int hotkey);
int validpathspec(char *ubuf);
void addtrailingslash(char *str);
char lastchar(const char *str);
void trimslashtoend(char *buf);
char *scanendslash(const char *str);
int is_valid_instpath(char *s);
BOOL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew);
void *mini_memcpy(void *out, const void *in, int len);
HANDLE NSISCALL myOpenFile(const char *fn, DWORD da, DWORD cd);
int NSISCALL CreateShortCut(HWND hwnd, LPCSTR pszShortcutFile, LPCSTR pszIconFile, int iconindex, LPCSTR pszExe, LPCSTR pszArg, LPCSTR workingdir, int showmode, int hotkey);
int NSISCALL validpathspec(char *ubuf);
void NSISCALL addtrailingslash(char *str);
char NSISCALL lastchar(const char *str);
void NSISCALL trimslashtoend(char *buf);
char * NSISCALL scanendslash(const char *str);
int NSISCALL is_valid_instpath(char *s);
BOOL NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew);
void * NSISCALL mini_memcpy(void *out, const void *in, int len);

View file

@ -32,7 +32,7 @@ struct internal_state {
};
int inflateReset(z_streamp z)
int ZEXPORT inflateReset(z_streamp z)
{
if (z == Z_NULL || z->state == Z_NULL)
return Z_STREAM_ERROR;
@ -42,7 +42,7 @@ int inflateReset(z_streamp z)
}
int inflateInit(z_streamp z)
int ZEXPORT inflateInit(z_streamp z)
{
int inflate_blocks_getssize(void);
void inflate_blocks_init(z_streamp z,inflate_blocks_statef *s);
@ -57,7 +57,7 @@ int inflateInit(z_streamp z)
}
int inflate(z_streamp z)
int ZEXPORT inflate(z_streamp z)
{
return inflate_blocks(&z->state->blocks, z, Z_OK);
}

View file

@ -1,6 +1,6 @@
/*
Note: this version of zlib has been hacked up quite a bit in order to reduce
the size of the EXE header and to remove what we didn't need.
Note: this version of zlib has been hacked up quite a bit in order to reduce
the size of the EXE header and to remove what we didn't need.
For the complete real thing, go to:
http://www.info-zip.org/pub/infozip/zlib/
@ -115,7 +115,7 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
int inflate(z_streamp z);
int ZEXPORT inflate(z_streamp z);
ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
int level,
@ -126,7 +126,7 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
int inflateReset(z_streamp z);
int ZEXPORT inflateReset(z_streamp z);
/* various hacks, don't look :) */
@ -147,8 +147,6 @@ ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
#define deflateInit(strm, level) \
deflateInit_((strm), (level), "", sizeof(z_stream))
extern int inflateInit(z_streamp z);
#ifdef __cplusplus
}