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