diff --git a/Examples/makensis.nsi b/Examples/makensis.nsi index 1ca03707..f9f43904 100644 --- a/Examples/makensis.nsi +++ b/Examples/makensis.nsi @@ -1,5 +1,5 @@ !define VER_MAJOR 2 -!define VER_MINOR 0a5 +!define VER_MINOR 0a6 !ifdef NO_COMPRESSION SetCompress off diff --git a/Source/Plugins.cpp b/Source/Plugins.cpp index 76725055..2eb88f2b 100644 --- a/Source/Plugins.cpp +++ b/Source/Plugins.cpp @@ -113,9 +113,9 @@ void Plugins::GetExports(char* pathToDll,bool displayInfo) char *name = (char*)exports + names[j] - ExportDirVA; wsprintf(signature, "%s::%s", dllName, name); m_commands.add(signature, pathToDll); - DLL newDll = {new char[lstrlen(dllName)], false}; - lstrcpy(newDll.name, dllName); - m_storedDLLs.push_back(newDll); + char *dll = new char[lstrlen(dllName)]; + lstrcpy(dll, dllName); + m_storedDLLs.push_back(dll); if (displayInfo) fprintf(g_output, " - %s\n", signature); } @@ -156,22 +156,32 @@ char* Plugins::GetPluginDll(char* command) return 0; } -void Plugins::DLLStored(char* dllName) +void Plugins::StoreInstDLL(char* dllName) { - for (int i = 0; i < m_storedDLLs.size(); i++) { - if (!strcmp(m_storedDLLs[i].name, dllName)) { - m_storedDLLs[i].stored = true; + for (int i = 0; i < m_installDLLs.size(); i++) + if (!strcmp(m_installDLLs[i], dllName)) return; - } - } + m_installDLLs.push_back(strdup(dllName)); } -bool Plugins::IsDLLStored(char* dllName) +void Plugins::StoreUninstDLL(char* dllName) { - for (int i = 0; i < m_storedDLLs.size(); i++) - if (!strcmp(m_storedDLLs[i].name, dllName)) - return m_storedDLLs[i].stored; - return false; + for (int i = 0; i < m_uninstallDLLs.size(); i++) + if (!strcmp(m_uninstallDLLs[i], dllName)) + return; + m_uninstallDLLs.push_back(strdup(dllName)); +} + +char* Plugins::GetInstDLL(int i) +{ + if (i >= 0 && i < m_installDLLs.size()) return m_installDLLs[i]; + else return 0; +} + +char* Plugins::GetUninstDLL(int i) +{ + if (i >= 0 && i < m_uninstallDLLs.size()) return m_uninstallDLLs[i]; + else return 0; } #endif \ No newline at end of file diff --git a/Source/Plugins.h b/Source/Plugins.h index 42d57b83..875b02fa 100644 --- a/Source/Plugins.h +++ b/Source/Plugins.h @@ -9,23 +9,22 @@ #include "strlist.h" #include -struct DLL { - char *name; - bool stored; -}; - class Plugins { public: void FindCommands(char*,bool); bool IsPluginCommand(char*); char* GetPluginDll(char*); - void DLLStored(char*); - bool IsDLLStored(char*); + void StoreInstDLL(char*); + void StoreUninstDLL(char*); + char* GetInstDLL(int); + char* GetUninstDLL(int); protected: - DefineList m_commands; - std::vector m_storedDLLs; + DefineList m_commands; + std::vector m_storedDLLs; + std::vector m_installDLLs; + std::vector m_uninstallDLLs; void GetExports(char*,bool); }; diff --git a/Source/build.cpp b/Source/build.cpp index 1c0b9a92..7964c136 100644 --- a/Source/build.cpp +++ b/Source/build.cpp @@ -1054,6 +1054,12 @@ int CEXEBuild::write_output(void) return PS_ERROR; } +#ifdef NSIS_CONFIG_PLUGIN_SUPPORT + // Added by Amir Szekely 9th August 2002 + int err=add_plugin_initializer(); + if (err != PS_OK) return err; +#endif //NSIS_CONFIG_PLUGIN_SUPPORT + // Added by Amir Szekely 3rd August 2002 if (WriteStringTables() == PS_ERROR) return PS_ERROR; @@ -1849,4 +1855,99 @@ void CEXEBuild::build_plugin_table(void) } } } + +int CEXEBuild::add_plugin_initializer(void) +{ + if (!plugin_used) return PS_OK; + + SCRIPT_MSG("Adding plug-ins initializing function...\n"); + + bool uninstall = false; + + int ret, i; + entry ent; + int zero_offset; + + ret=add_function("Initialize_____Plugins"); + if (ret != PS_OK) return ret; +again: + zero_offset=add_string("$0"); + // StrCmp $PLUGINSDIR "" + ent.which=EW_STRCMP; + ent.offsets[0]=add_string("$PLUGINSDIR"); + ent.offsets[1]=add_string(""); + ent.offsets[2]=0; + ent.offsets[3]=ns_label.add("Initialize_____Plugins_done",0); + ret=add_entry(&ent); + if (ret != PS_OK) return ret; + // Push $0 + ent.which=EW_PUSHPOP; + ent.offsets[0]=zero_offset; + ent.offsets[1]=0; + ret=add_entry(&ent); + if (ret != PS_OK) return ret; + // Get temp file name + ent.which=EW_GETTEMPFILENAME; + ent.offsets[0]=0; // $0 + ret=add_entry(&ent); + if (ret != PS_OK) return ret; + // Delete the temp file created + ent.which=EW_DELETEFILE; + ent.offsets[0]=zero_offset; + ent.offsets[1]=0; + ret=add_entry(&ent); + if (ret != PS_OK) return ret; + // Craete a dir instead of that temp file + ent.which=EW_CREATEDIR; + ent.offsets[0]=zero_offset; + ent.offsets[1]=0; + ret=add_entry(&ent); + if (ret != PS_OK) return ret; + // Copy $0 to $PLUGINSDIR + ent.which=EW_PLUGINCOMMANDPREP; + ret=add_entry(&ent); + if (ret != PS_OK) return ret; + // Pop $0 + ent.which=EW_PUSHPOP; + ent.offsets[0]=0; // $0 + ent.offsets[1]=1; + ent.offsets[2]=0; + ret=add_entry(&ent); + if (ret != PS_OK) return ret; + + int files_added; + if (uninstall) { + char* dll; + for (i = 0; dll = m_plugins.GetUninstDLL(i); i++) { + char tempPath[NSIS_MAX_STRLEN]; + wsprintf(tempPath,"$PLUGINSDIR%s",strrchr(dll,'\\')); + ret=do_add_file(dll,0,0,0,&files_added,tempPath); + if (ret != PS_OK) return ret; + } + } + else { + char* dll; + for (i = 0; dll = m_plugins.GetInstDLL(i); i++) { + char tempPath[NSIS_MAX_STRLEN]; + wsprintf(tempPath,"$PLUGINSDIR%s",strrchr(dll,'\\')); + ret=do_add_file(dll,0,0,0,&files_added,tempPath); + if (ret != PS_OK) return ret; + } + } + + if (add_label("Initialize_____Plugins_done")) return PS_ERROR; + + ret=function_end(); + if (ret != PS_OK) return ret; + + if (uninstaller_writes_used && !uninstall) { + add_function("un.Initialize_____Plugins"); + uninstall = true; + goto again; + } + + SCRIPT_MSG("Done!\n"); + + return PS_OK; +} #endif // NSIS_CONFIG_PLUGIN_SUPPORT \ No newline at end of file diff --git a/Source/build.h b/Source/build.h index ef67078f..4bcbfb2e 100644 --- a/Source/build.h +++ b/Source/build.h @@ -85,6 +85,11 @@ class CEXEBuild { int do_add_file(const char *lgss, int attrib, int recurse, int linecnt, int *total_files, const char *name_override=0); GrowBuf m_linebuild; // used for concatenating lines +#ifdef NSIS_CONFIG_PLUGIN_SUPPORT + // Added by Amir Szekely 9th August 2002 + int add_plugin_initializer(void); +#endif //NSIS_CONFIG_PLUGIN_SUPPORT + void ERROR_MSG(const char *s, ...); void SCRIPT_MSG(const char *s, ...); void INFO_MSG(const char *s, ...); diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c index 73947622..5499dbcd 100644 --- a/Source/exehead/Ui.c +++ b/Source/exehead/Ui.c @@ -300,7 +300,7 @@ int ui_doinstall(void) { // Added by Amir Szekely 3rd August 2002 // Multilingual support - char pa=1; + char pa=0; int num=g_inst_header->str_tables_num; LANGID user_lang=GetUserDefaultLangID(); int size=num*sizeof(common_strings); @@ -327,14 +327,14 @@ lang_again: #ifdef NSIS_CONFIG_UNINSTALL_SUPPORT cur_uninstall_strings_table+=size; #endif - pa--; + pa++; break; } common_strings_tables[size].lang_id&=0x3ff; // primary lang } - if (pa) { + if (!pa) { user_lang&=0x3ff; // primary lang - pa--; + pa++; goto lang_again; } } diff --git a/Source/makenssi.cpp b/Source/makenssi.cpp index 99683ff0..ed53db06 100644 --- a/Source/makenssi.cpp +++ b/Source/makenssi.cpp @@ -1,4 +1,4 @@ -const char *NSIS_VERSION="v2.0a5"; +const char *NSIS_VERSION="v2.0a6"; /* Nullsoft "SuperPimp" Installation System - makensis.cpp - installer compiler code diff --git a/Source/script.cpp b/Source/script.cpp index b09fab5b..7b75475e 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -3296,71 +3296,26 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char return PS_ERROR; case TOK__PLUGINCOMMAND: { - static int zero_offset; - if (!zero_offset) zero_offset=add_string("$0"); int ret; char* dllPath = m_plugins.GetPluginDll(line.gettoken_str(0)); if (dllPath) { - if (!plugin_used) { - // If no plugin was called up until now init the plugin stuff - // Push $0 - ent.which=EW_PUSHPOP; - ent.offsets[0]=zero_offset; - ent.offsets[1]=0; - ret=add_entry(&ent); - if (ret != PS_OK) return ret; - // Get temp file name - ent.which=EW_GETTEMPFILENAME; - ent.offsets[0]=0; // $0 - ret=add_entry(&ent); - if (ret != PS_OK) return ret; - // Delete the temp file created - ent.which=EW_DELETEFILE; - ent.offsets[0]=zero_offset; - ent.offsets[1]=0; - ret=add_entry(&ent); - if (ret != PS_OK) return ret; - // Craete a dir instead of that temp file - ent.which=EW_CREATEDIR; - ent.offsets[0]=zero_offset; - ent.offsets[1]=0; - ret=add_entry(&ent); - if (ret != PS_OK) return ret; - // Copy $0 to $PLUGINSDIR - ent.which=EW_PLUGINCOMMANDPREP; - ret=add_entry(&ent); - if (ret != PS_OK) return ret; - // Pop $0 - ent.which=EW_PUSHPOP; - ent.offsets[0]=0; // $0 - ent.offsets[1]=1; - ent.offsets[2]=0; - ret=add_entry(&ent); - if (ret != PS_OK) return ret; - // We need to do all of this only once - plugin_used = true; - } + plugin_used = true; + + ent.which=EW_CALL; + ent.offsets[0]=ns_func.add(uninstall_mode?"un.Initialize_____Plugins":"Initialize_____Plugins",0); + ret=add_entry(&ent); + if (ret != PS_OK) return ret; // DLL name on the user machine char tempDLL[NSIS_MAX_STRLEN]; wsprintf(tempDLL, "$PLUGINSDIR%s", strrchr(dllPath,'\\')); int tempDLLtab = add_string(tempDLL); - // Add the DLL if not already added - if (!m_plugins.IsDLLStored(strrchr(dllPath,'\\')+1)) - { - int error; - int files_added; - if (PS_OK != (error = do_add_file(dllPath,0,0,0,&files_added,tempDLL))) - { - ERROR_MSG("Error: Failed to auto include plugin file \"%s\"\n",dllPath); - return error; - } - - m_plugins.DLLStored(strrchr(dllPath,'\\')+1); - } + // Store the DLL + if (uninstall_mode) m_plugins.StoreUninstDLL(dllPath); + else m_plugins.StoreInstDLL(dllPath); // Finally call the DLL char* command = strstr(line.gettoken_str(0),"::");