Case insensitive plug-in function names

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1988 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2002-12-21 09:14:28 +00:00
parent f8b521e30e
commit 69ef5ba1ab
3 changed files with 43 additions and 17 deletions

View file

@ -136,13 +136,17 @@ void Plugins::GetExports(char* pathToDll,bool displayInfo)
bool Plugins::IsPluginCommand(char* token) bool Plugins::IsPluginCommand(char* token)
{ {
return GetPluginDll(0, token, 0) ? true : false; return GetPluginDll(0, &token, 0) ? true : false;
} }
char* Plugins::GetPluginDll(int uninst, char* command, int* dataHandle) char* Plugins::GetPluginDll(int uninst, char** command, int* dataHandle)
{ {
char* ret = m_commands.find(command, dataHandle); int idx = 0;
if (dataHandle && ret) { char* ret = m_commands.find(*command, &idx);
if (ret && dataHandle) {
int v = m_commands.defines.idx2pos(idx);
if (v < 0) return 0;
strcpy(*command, m_commands.defines.get() + v);
if (uninst) *dataHandle = ((int*)m_uninstDataHandles.get())[*dataHandle]; if (uninst) *dataHandle = ((int*)m_uninstDataHandles.get())[*dataHandle];
else *dataHandle = ((int*)m_dataHandles.get())[*dataHandle]; else *dataHandle = ((int*)m_dataHandles.get())[*dataHandle];
} }

View file

@ -14,7 +14,7 @@ class Plugins
public: public:
void FindCommands(char*,bool); void FindCommands(char*,bool);
bool IsPluginCommand(char*); bool IsPluginCommand(char*);
char* GetPluginDll(int, char*, int*); char* GetPluginDll(int, char**, int*);
void SetDllDataHandle(int, char*, int); void SetDllDataHandle(int, char*, int);
protected: protected:

View file

@ -3810,10 +3810,12 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
case TOK__PLUGINCOMMAND: case TOK__PLUGINCOMMAND:
{ {
int ret, data_handle; int ret, data_handle;
char* command = strdup(line.gettoken_str(0));
char* dllPath = m_plugins.GetPluginDll(uninstall_mode, line.gettoken_str(0), &data_handle); char* dllPath = m_plugins.GetPluginDll(uninstall_mode, &command, &data_handle);
if (dllPath) if (dllPath)
{ {
SCRIPT_MSG(command);
if (uninstall_mode) uninst_plugin_used = true; if (uninstall_mode) uninst_plugin_used = true;
else plugin_used = true; else plugin_used = true;
@ -3821,7 +3823,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
ent.which=EW_CALL; ent.which=EW_CALL;
ent.offsets[0]=ns_func.add(uninstall_mode?"un.Initialize_____Plugins":"Initialize_____Plugins",0); ent.offsets[0]=ns_func.add(uninstall_mode?"un.Initialize_____Plugins":"Initialize_____Plugins",0);
ret=add_entry(&ent); ret=add_entry(&ent);
if (ret != PS_OK) return ret; if (ret != PS_OK) {
free(command);
return ret;
}
// DLL name on the user machine // DLL name on the user machine
char tempDLL[NSIS_MAX_STRLEN]; char tempDLL[NSIS_MAX_STRLEN];
@ -3836,7 +3841,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
int old_build_datesave=build_datesave; int old_build_datesave=build_datesave;
build_datesave=0; // off build_datesave=0; // off
ret=do_add_file(dllPath,0,0,linecnt,&files_added,tempDLL,2,&data_handle); // 2 means no size add ret=do_add_file(dllPath,0,0,linecnt,&files_added,tempDLL,2,&data_handle); // 2 means no size add
if (ret != PS_OK) return ret; if (ret != PS_OK) {
free(command);
return ret;
}
m_plugins.SetDllDataHandle(uninstall_mode, line.gettoken_str(0),data_handle); m_plugins.SetDllDataHandle(uninstall_mode, line.gettoken_str(0),data_handle);
build_overwrite=old_build_overwrite; build_overwrite=old_build_overwrite;
build_datesave=old_build_datesave; build_datesave=old_build_datesave;
@ -3848,7 +3856,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
ent.offsets[1]=add_string(tempDLL); ent.offsets[1]=add_string(tempDLL);
ent.offsets[2]=data_handle; ent.offsets[2]=data_handle;
ret=add_entry(&ent); ret=add_entry(&ent);
if (ret != PS_OK) return ret; if (ret != PS_OK) {
free(command);
return ret;
}
} }
// SetDetailsPrint lastused // SetDetailsPrint lastused
@ -3857,13 +3868,16 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
ent.offsets[1]=8; // lastused ent.offsets[1]=8; // lastused
ent.offsets[2]=0; ent.offsets[2]=0;
ret=add_entry(&ent); ret=add_entry(&ent);
if (ret != PS_OK) return ret; if (ret != PS_OK) {
free(command);
return ret;
}
// Call the DLL // Call the DLL
char* command = strstr(line.gettoken_str(0),"::"); char* funcname = strstr(command,"::");
if (command) command += 2; if (funcname) funcname += 2;
else command = line.gettoken_str(0); else funcname = command;
SCRIPT_MSG("Plugin Command: %s",command); SCRIPT_MSG("Plugin Command: %s",funcname);
int i = 1; int i = 1;
int nounload = 0; int nounload = 0;
@ -3883,7 +3897,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
if (!lstrcmpi(line.gettoken_str(w), "/NOUNLOAD")) nounloadmisused=1; if (!lstrcmpi(line.gettoken_str(w), "/NOUNLOAD")) nounloadmisused=1;
ent.offsets[1]=0; ent.offsets[1]=0;
ret=add_entry(&ent); ret=add_entry(&ent);
if (ret != PS_OK) return ret; if (ret != PS_OK) {
free(command);
return ret;
}
SCRIPT_MSG(" %s",line.gettoken_str(i)); SCRIPT_MSG(" %s",line.gettoken_str(i));
} }
SCRIPT_MSG("\n"); SCRIPT_MSG("\n");
@ -3893,11 +3910,16 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
// next, call it // next, call it
ent.which=EW_REGISTERDLL; ent.which=EW_REGISTERDLL;
ent.offsets[0]=add_string(tempDLL);; ent.offsets[0]=add_string(tempDLL);;
ent.offsets[1]=add_string(command); ent.offsets[1]=add_string(funcname);
ent.offsets[2]=0; ent.offsets[2]=0;
ent.offsets[3]=nounload|build_plugin_unload; ent.offsets[3]=nounload|build_plugin_unload;
ret=add_entry(&ent); ret=add_entry(&ent);
if (ret != PS_OK) return ret; if (ret != PS_OK) {
free(command);
return ret;
}
free(command);
return PS_OK; return PS_OK;
} }