diff --git a/Source/Plugins.cpp b/Source/Plugins.cpp index 10646e18..a6201b02 100644 --- a/Source/Plugins.cpp +++ b/Source/Plugins.cpp @@ -14,6 +14,38 @@ extern FILE *g_output; +int PluginsList::add(const char *name, const char *path) +{ + int pos=SortedStringListND::add(name); + if (pos == -1) return 1; + + ((struct plugin*)gr.get())[pos].path=strings.add(path, strlen(path)+1); + ((struct plugin*)gr.get())[pos].dataHandle=-1; + ((struct plugin*)gr.get())[pos].unDataHandle=-1; + + return 0; +} + +char* PluginsList::get(char **name, int *dataHandle/*=0*/, int *uninstDataHandle/*=0*/) +{ + if (dataHandle) *dataHandle=-1; + if (uninstDataHandle) *uninstDataHandle=-1; + int v=SortedStringListND::find(*name); + if (v==-1) return NULL; + strcpy(*name, (char*)strings.get()+((struct plugin*)gr.get())[v].name); + if (dataHandle) *dataHandle=((struct plugin*)gr.get())[v].dataHandle; + if (uninstDataHandle) *uninstDataHandle=((struct plugin*)gr.get())[v].unDataHandle; + return (char*)strings.get()+((struct plugin*)gr.get())[v].path; +} + +void PluginsList::setDataHandle(const char *name, int dataHandle, int uninstDataHandle) +{ + int v=SortedStringListND::find(name); + if (v==-1) return; + ((struct plugin*)gr.get())[v].dataHandle=dataHandle; + ((struct plugin*)gr.get())[v].unDataHandle=uninstDataHandle; +} + void Plugins::FindCommands(char* path, bool displayInfo) { if (path) diff --git a/Source/Plugins.h b/Source/Plugins.h index 341c42ed..f7ded200 100644 --- a/Source/Plugins.h +++ b/Source/Plugins.h @@ -14,40 +14,9 @@ struct plugin { class PluginsList : public SortedStringListND { public: - PluginsList() { } - ~PluginsList() { } - - int add(const char *name, const char *path) - { - int pos=SortedStringListND::add(name); - if (pos == -1) return 1; - - ((struct plugin*)gr.get())[pos].path=strings.add(path, strlen(path)+1); - ((struct plugin*)gr.get())[pos].dataHandle=-1; - ((struct plugin*)gr.get())[pos].unDataHandle=-1; - - return 0; - } - - char *get(char **name, int *dataHandle=0, int *uninstDataHandle=0) - { - if (dataHandle) *dataHandle=-1; - if (uninstDataHandle) *uninstDataHandle=-1; - int v=SortedStringListND::find(*name); - if (v==-1) return NULL; - strcpy(*name, (char*)strings.get()+((struct plugin*)gr.get())[v].name); - if (dataHandle) *dataHandle=((struct plugin*)gr.get())[v].dataHandle; - if (uninstDataHandle) *uninstDataHandle=((struct plugin*)gr.get())[v].unDataHandle; - return (char*)strings.get()+((struct plugin*)gr.get())[v].path; - } - - void setDataHandle(const char *name, int dataHandle, int uninstDataHandle) - { - int v=SortedStringListND::find(name); - if (v==-1) return; - ((struct plugin*)gr.get())[v].dataHandle=dataHandle; - ((struct plugin*)gr.get())[v].unDataHandle=uninstDataHandle; - } + int add(const char *name, const char *path); + char *get(char **name, int *dataHandle=0, int *uninstDataHandle=0); + void setDataHandle(const char *name, int dataHandle, int uninstDataHandle); }; class Plugins