home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 March / CMCD0304.ISO / Software / Freeware / Programare / nullsoft / nsis20.exe / Source / Plugins.h < prev    next >
C/C++ Source or Header  |  2004-01-30  |  2KB  |  67 lines

  1. #ifndef __X18_PLUGINS_H
  2. #define __X18_PLUGINS_H
  3.  
  4. #include "Platform.h"
  5. #include "strlist.h"
  6.  
  7. struct plugin {
  8.   int name;
  9.   int path;
  10.   int dataHandle;
  11.   int unDataHandle;
  12. };
  13.  
  14. class PluginsList : public SortedStringListND<struct plugin>
  15. {
  16.   public:
  17.     PluginsList() { }
  18.     ~PluginsList() { }
  19.  
  20.     int add(const char *name, const char *path)
  21.     {
  22.       int pos=SortedStringListND<struct plugin>::add(name);
  23.       if (pos == -1) return 1;
  24.  
  25.       ((struct plugin*)gr.get())[pos].path=strings.add(path, strlen(path)+1);
  26.       ((struct plugin*)gr.get())[pos].dataHandle=-1;
  27.       ((struct plugin*)gr.get())[pos].unDataHandle=-1;
  28.  
  29.       return 0;
  30.     }
  31.  
  32.     char *get(char **name, int *dataHandle=0, int *uninstDataHandle=0)
  33.     {
  34.       if (dataHandle) *dataHandle=-1;
  35.       if (uninstDataHandle) *uninstDataHandle=-1;
  36.       int v=SortedStringListND<struct plugin>::find(*name);
  37.       if (v==-1) return NULL;
  38.       strcpy(*name, (char*)strings.get()+((struct plugin*)gr.get())[v].name);
  39.       if (dataHandle) *dataHandle=((struct plugin*)gr.get())[v].dataHandle;
  40.       if (uninstDataHandle) *uninstDataHandle=((struct plugin*)gr.get())[v].unDataHandle;
  41.       return (char*)strings.get()+((struct plugin*)gr.get())[v].path;
  42.     }
  43.  
  44.     void setDataHandle(const char *name, int dataHandle, int uninstDataHandle)
  45.     {
  46.       int v=SortedStringListND<struct plugin>::find(name);
  47.       if (v==-1) return;
  48.       ((struct plugin*)gr.get())[v].dataHandle=dataHandle;
  49.       ((struct plugin*)gr.get())[v].unDataHandle=uninstDataHandle;
  50.     }
  51. };
  52.  
  53. class Plugins
  54. {
  55.   public:
  56.     void  FindCommands(char*,bool);
  57.     bool  IsPluginCommand(char*);
  58.     char* GetPluginDll(int, char**, int*);
  59.     void  SetDllDataHandle(int, char*, int);
  60.  
  61.   protected:
  62.     PluginsList m_list;
  63.  
  64.     void GetExports(char*,bool);
  65. };
  66.  
  67. #endif