| 1 |
/* |
| 2 |
* Plugins.h |
| 3 |
* |
| 4 |
* This file is a part of NSIS. |
| 5 |
* |
| 6 |
* Copyright (C) 1999-2026 Nullsoft and Contributors |
| 7 |
* |
| 8 |
* Licensed under the zlib/libpng license (the "License"); |
| 9 |
* you may not use this file except in compliance with the License. |
| 10 |
* |
| 11 |
* Licence details can be found in the file COPYING. |
| 12 |
* |
| 13 |
* This software is provided 'as-is', without any express or implied |
| 14 |
* warranty. |
| 15 |
* |
| 16 |
*/ |
| 17 |
|
| 18 |
#ifndef NSIS_EXEHEADPLUGINS_H |
| 19 |
#define NSIS_EXEHEADPLUGINS_H |
| 20 |
|
| 21 |
#include <map> |
| 22 |
#include <set> |
| 23 |
#include "tstring.h" |
| 24 |
|
| 25 |
namespace STL |
| 26 |
{ |
| 27 |
template <class Arg1, class Arg2, class Result> |
| 28 |
struct binary_function |
| 29 |
{ |
| 30 |
typedef Arg1 first_argument_type; |
| 31 |
typedef Arg2 second_argument_type; |
| 32 |
typedef Result result_type; |
| 33 |
}; |
| 34 |
template<class S, class C> |
| 35 |
struct string_nocasecmpless : binary_function<S, S, bool> |
| 36 |
{ |
| 37 |
struct cmp : public binary_function<C, C, bool> |
| 38 |
{ |
| 39 |
bool operator() (const C&a, const C&b) const |
| 40 |
{ |
| 41 |
return tolower(a) < tolower(b); |
| 42 |
} |
| 43 |
}; |
| 44 |
bool operator() (const S&a,const S&b) const |
| 45 |
{ |
| 46 |
return std::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end(), cmp()); |
| 47 |
} |
| 48 |
}; |
| 49 |
} |
| 50 |
|
| 51 |
class Plugins |
| 52 |
{ |
| 53 |
public: |
| 54 |
typedef STL::string_nocasecmpless<tstring, tstring::value_type> strnocasecmp; |
| 55 |
|
| 56 |
Plugins() : m_initialized(false) {} |
| 57 |
|
| 58 |
bool Initialize(const TCHAR*arcsubdir, bool pe64, bool displayInfo); |
| 59 |
void AddPluginsDir(const tstring& path, bool pe64, bool displayInfo); |
| 60 |
bool FindDllPath(const tstring filename, tstring&dllPath); |
| 61 |
bool IsPluginCommand(const tstring& command) const; |
| 62 |
bool IsKnownPlugin(const tstring& token) const; |
| 63 |
bool GetCommandInfo(const tstring&command, tstring&canoniccmd, tstring&dllPath); |
| 64 |
int GetDllDataHandle(bool uninst, const tstring& command) const; |
| 65 |
void SetDllDataHandle(bool uninst, tstring&canoniccmd, int dataHandle); |
| 66 |
static bool IsPluginCallSyntax(const tstring& token); |
| 67 |
void PrintPluginDirs(); |
| 68 |
|
| 69 |
private: // methods |
| 70 |
void GetExports(const tstring &pathToDll, bool pe64, bool displayInfo); |
| 71 |
bool DllHasDataHandle(const tstring& dllnamelowercase) const; |
| 72 |
|
| 73 |
private: // data members |
| 74 |
std::set<tstring, strnocasecmp> m_commands; |
| 75 |
std::map<tstring, tstring, strnocasecmp> m_dllname_to_path; |
| 76 |
std::map<tstring, int, strnocasecmp> m_dllname_to_inst_datahandle; |
| 77 |
std::map<tstring, int, strnocasecmp> m_dllname_to_unst_datahandle; |
| 78 |
std::set<tstring, strnocasecmp> m_dllname_conflicts; |
| 79 |
bool m_initialized; |
| 80 |
}; |
| 81 |
|
| 82 |
#endif |