Dynamic allocation of needed user variables (exehead grew 512 bytes).
Independed user vars in uninstaller and installer git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2656 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
2ff0e96a38
commit
ab91077049
10 changed files with 197 additions and 92 deletions
|
@ -98,9 +98,13 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
|
|||
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT
|
||||
unsigned int verify_time=GetTickCount()+1000;
|
||||
#endif
|
||||
char *cmdline=state_command_line;
|
||||
|
||||
char *realcmds;
|
||||
char seekchar=' ';
|
||||
char *cmdline;
|
||||
#ifdef NSIS_SUPPORT_NAMED_USERVARS
|
||||
g_usrvars = (NSIS_STRING*)my_GlobalAlloc(USER_VARS_COUNT*sizeof(NSIS_STRING));
|
||||
#endif
|
||||
|
||||
InitCommonControls();
|
||||
|
||||
|
@ -108,40 +112,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
|
|||
|
||||
lstrcpyn(state_command_line,GetCommandLine(),NSIS_MAX_STRLEN);
|
||||
|
||||
if (*cmdline == '\"') seekchar = *cmdline++;
|
||||
|
||||
while (*cmdline && *cmdline != seekchar) cmdline=CharNext(cmdline);
|
||||
cmdline=CharNext(cmdline);
|
||||
realcmds=cmdline;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
// skip over any spaces
|
||||
while (*cmdline == ' ') cmdline=CharNext(cmdline);
|
||||
if (cmdline[0] != '/') break;
|
||||
cmdline++;
|
||||
|
||||
#define END_OF_ARG(c) (((c)|' ')==' ')
|
||||
|
||||
#if defined(NSIS_CONFIG_VISIBLE_SUPPORT) && defined(NSIS_CONFIG_SILENT_SUPPORT)
|
||||
if (cmdline[0] == 'S' && END_OF_ARG(cmdline[1])) silent++;
|
||||
#endif//NSIS_CONFIG_SILENT_SUPPORT && NSIS_CONFIG_VISIBLE_SUPPORT
|
||||
#ifdef NSIS_CONFIG_CRC_SUPPORT
|
||||
if (*(DWORD*)cmdline == CHAR4_TO_DWORD('N','C','R','C') && END_OF_ARG(cmdline[4])) no_crc++;
|
||||
#endif//NSIS_CONFIG_CRC_SUPPORT
|
||||
|
||||
if (*(WORD*)cmdline == CHAR2_TO_WORD('D','='))
|
||||
{
|
||||
cmdline[-2]=0; // keep this from being passed to uninstaller if necessary
|
||||
mystrcpy(state_install_directory,cmdline+2);
|
||||
cmdline=""; // prevent further processing of cmdline
|
||||
break; // not necessary, but for some reason makes smaller exe :)
|
||||
}
|
||||
|
||||
// skip over our parm
|
||||
while (!END_OF_ARG(*cmdline)) cmdline=CharNext(cmdline);
|
||||
}
|
||||
|
||||
mystrcpy(g_caption,_LANG_GENERIC_ERROR);
|
||||
|
||||
g_hInstance=GetModuleHandle(NULL);
|
||||
|
@ -269,14 +239,49 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
|
|||
}
|
||||
if (m_Err) goto end;
|
||||
|
||||
cmdline = state_command_line;
|
||||
if (*cmdline == '\"') seekchar = *cmdline++;
|
||||
|
||||
while (*cmdline && *cmdline != seekchar) cmdline=CharNext(cmdline);
|
||||
cmdline=CharNext(cmdline);
|
||||
realcmds=cmdline;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
// skip over any spaces
|
||||
while (*cmdline == ' ') cmdline=CharNext(cmdline);
|
||||
if (cmdline[0] != '/') break;
|
||||
cmdline++;
|
||||
|
||||
#define END_OF_ARG(c) (((c)|' ')==' ')
|
||||
|
||||
#if defined(NSIS_CONFIG_VISIBLE_SUPPORT) && defined(NSIS_CONFIG_SILENT_SUPPORT)
|
||||
if (cmdline[0] == 'S' && END_OF_ARG(cmdline[1])) silent++;
|
||||
#endif//NSIS_CONFIG_SILENT_SUPPORT && NSIS_CONFIG_VISIBLE_SUPPORT
|
||||
#ifdef NSIS_CONFIG_CRC_SUPPORT
|
||||
if (*(DWORD*)cmdline == CHAR4_TO_DWORD('N','C','R','C') && END_OF_ARG(cmdline[4])) no_crc++;
|
||||
#endif//NSIS_CONFIG_CRC_SUPPORT
|
||||
|
||||
if (*(WORD*)cmdline == CHAR2_TO_WORD('D','='))
|
||||
{
|
||||
cmdline[-2]=0; // keep this from being passed to uninstaller if necessary
|
||||
mystrcpy(state_install_directory,cmdline+2);
|
||||
cmdline=""; // prevent further processing of cmdline
|
||||
break; // not necessary, but for some reason makes smaller exe :)
|
||||
}
|
||||
|
||||
// skip over our parm
|
||||
while (!END_OF_ARG(*cmdline)) cmdline=CharNext(cmdline);
|
||||
}
|
||||
|
||||
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||
if (g_is_uninstaller)
|
||||
{
|
||||
char *p=cmdline;
|
||||
while (*p) p++;
|
||||
|
||||
while (p >= cmdline && (p[0] != '_' || p[1] != '?' || p[2] != '=')) p--;
|
||||
|
||||
while (p >= cmdline && (p[0] != '_' || p[1] != '?' || p[2] != '=')) p--;
|
||||
|
||||
if (p >= cmdline)
|
||||
{
|
||||
*(p-1)=0; // terminate before the " _?="
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
#define USER_VARS_COUNT 26
|
||||
|
||||
typedef char NSIS_STRING[NSIS_MAX_STRLEN];
|
||||
|
||||
// MAX_NAMED_USER_VARS defines the maximum of named user variables
|
||||
// the complier also use this value to abort if exceded
|
||||
// The real maximum is (0x0FFF - USER_VARS_COUNT) = 4069
|
||||
|
|
|
@ -52,7 +52,17 @@ int NSISCALL isheader(firstheader *h)
|
|||
#ifdef NSIS_CONFIG_COMPRESSION_SUPPORT
|
||||
static z_stream g_inflate_stream;
|
||||
#endif
|
||||
|
||||
/*
|
||||
void DEBUG(const char* Frm, ...)
|
||||
{
|
||||
char Buf[1024];
|
||||
va_list va;
|
||||
va_start(va, Frm);
|
||||
wvsprintf(Buf, Frm, va);
|
||||
MessageBox(0, Buf, 0, 0);
|
||||
va_end(va);
|
||||
}
|
||||
*/
|
||||
const char * NSISCALL loadHeaders(void)
|
||||
{
|
||||
void *data;
|
||||
|
@ -60,7 +70,13 @@ const char * NSISCALL loadHeaders(void)
|
|||
|
||||
if (!ReadSelfFile((LPVOID)&h,sizeof(h)) || !isheader(&h)) return _LANG_INVALIDCRC;
|
||||
|
||||
#ifdef NSIS_SUPPORT_NAMED_USERVARS
|
||||
//DEBUG("Needed size is : %i", h.length_of_header + h.length_of_uservars);
|
||||
g_usrvars = (NSIS_STRING*)GlobalReAlloc(g_usrvars, h.length_of_header + h.length_of_uservars, GMEM_MOVEABLE);
|
||||
data = (void*)(g_usrvars[0]+h.length_of_uservars);
|
||||
#else
|
||||
data=(void*)my_GlobalAlloc(h.length_of_header);
|
||||
#endif
|
||||
|
||||
#ifdef NSIS_CONFIG_COMPRESSION_SUPPORT
|
||||
inflateInit(&g_inflate_stream);
|
||||
|
|
|
@ -204,6 +204,10 @@ typedef struct
|
|||
|
||||
// these point to the header+sections+entries+stringtable in the datablock
|
||||
int length_of_header;
|
||||
#ifdef NSIS_SUPPORT_NAMED_USERVARS
|
||||
// this store the sized needed to store all user vars
|
||||
int length_of_uservars;
|
||||
#endif
|
||||
|
||||
// this specifies the length of all the data (including the firstheader and CRC)
|
||||
int length_of_all_following_data;
|
||||
|
|
|
@ -1,16 +1,24 @@
|
|||
extern char temp_directory[NSIS_MAX_STRLEN];
|
||||
#ifdef NSIS_SUPPORT_NAMED_USERVARS
|
||||
extern char g_usrvars[MAX_NAMED_USER_VARS+USER_VARS_COUNT][NSIS_MAX_STRLEN];
|
||||
extern NSIS_STRING *g_usrvars;
|
||||
#define state_command_line g_usrvars[20]
|
||||
#define state_install_directory g_usrvars[21]
|
||||
#define state_output_directory g_usrvars[22]
|
||||
#define state_exe_directory g_usrvars[23]
|
||||
#define state_language g_usrvars[24]
|
||||
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
|
||||
#define state_plugins_dir g_usrvars[25]
|
||||
#endif
|
||||
#else
|
||||
extern char g_usrvars[USER_VARS_COUNT][NSIS_MAX_STRLEN];
|
||||
#endif
|
||||
extern char *state_command_line;
|
||||
extern char *state_install_directory;
|
||||
extern char *state_output_directory;
|
||||
extern char *state_exe_directory;
|
||||
extern char *state_language;
|
||||
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
|
||||
extern char *state_plugins_dir;
|
||||
extern char g_usrvars[USER_VARS_COUNT][NSIS_MAX_STRLEN];
|
||||
extern char *state_command_line;
|
||||
extern char *state_install_directory;
|
||||
extern char *state_output_directory;
|
||||
extern char *state_exe_directory;
|
||||
extern char *state_language;
|
||||
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
|
||||
extern char *state_plugins_dir;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern char g_caption[NSIS_MAX_STRLEN*2];
|
||||
|
|
|
@ -15,19 +15,18 @@ char g_log_file[1024];
|
|||
#endif
|
||||
|
||||
char temp_directory[NSIS_MAX_STRLEN];
|
||||
|
||||
#ifdef NSIS_SUPPORT_NAMED_USERVARS
|
||||
char g_usrvars[MAX_NAMED_USER_VARS+USER_VARS_COUNT][NSIS_MAX_STRLEN];
|
||||
NSIS_STRING *g_usrvars;
|
||||
#else
|
||||
char g_usrvars[USER_VARS_COUNT][NSIS_MAX_STRLEN];
|
||||
#endif
|
||||
char *state_command_line=g_usrvars[20];
|
||||
char *state_install_directory=g_usrvars[21];
|
||||
char *state_output_directory=g_usrvars[22];
|
||||
char *state_exe_directory=g_usrvars[23];
|
||||
char *state_language=g_usrvars[24];
|
||||
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
|
||||
char *state_plugins_dir=g_usrvars[25];
|
||||
char g_usrvars[USER_VARS_COUNT][NSIS_MAX_STRLEN];
|
||||
char *state_command_line=g_usrvars[20];
|
||||
char *state_install_directory=g_usrvars[21];
|
||||
char *state_output_directory=g_usrvars[22];
|
||||
char *state_exe_directory=g_usrvars[23];
|
||||
char *state_language=g_usrvars[24];
|
||||
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
|
||||
char *state_plugins_dir=g_usrvars[25];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
HANDLE g_hInstance;
|
||||
|
@ -611,8 +610,6 @@ char * NSISCALL process_string(const char *in)
|
|||
|
||||
default:
|
||||
mystrcpy(out, g_usrvars[nVarIdx]);
|
||||
break;
|
||||
|
||||
} // switch
|
||||
// validate the directory name
|
||||
if (nVarIdx > 21 && nVarIdx < 36 ) { // only if not $0 to $R9, $CMDLINE, or $HWNDPARENT and not great than $SYSDIR
|
||||
|
@ -624,9 +621,8 @@ char * NSISCALL process_string(const char *in)
|
|||
#ifdef NSIS_SUPPORT_LANG_IN_STRINGS
|
||||
else if ( nVarIdx == LANG_CODES_START )
|
||||
{
|
||||
char *p;
|
||||
nVarIdx = *(short*)in; in+=sizeof(WORD);
|
||||
p = process_string(GetStringFromStringTab(nVarIdx), out-ps_tmpbuf);
|
||||
process_string(GetStringFromStringTab(nVarIdx), out-ps_tmpbuf);
|
||||
out+=mystrlen(out);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue