OpenCPN Partial API docs
plugin_blacklist.h
1 /***************************************************************************
2  *
3  * Project: OpenCPN
4  * Purpose: Plugin blacklist for plugins which can or should not be loaded
5  * Author: Alec Leamas
6  *
7  ***************************************************************************
8  * Copyright (C) 2022 by Alec Leamas *
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  * This program is distributed in the hope that it will be useful, *
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18  * GNU General Public License for more details. *
19  * *
20  * You should have received a copy of the GNU General Public License *
21  * along with this program; if not, write to the *
22  * Free Software Foundation, Inc., *
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
24  **************************************************************************/
25 
26 #ifndef PLUGIN_BLACKLIST_H
27 #define PLUGIN_BLACKLIST_H
28 
29 #include <string>
30 #include <sstream>
31 #include <memory>
32 
33 // Handle gnu's major/minor macros
34 #ifdef major
35 #define gnu_major major
36 #define gnu_minor minor
37 #undef major
38 #undef minor
39 #endif
40 
41 typedef enum class plug_status {
42  unblocked,
43  unloadable,
44  hard,
45  soft
46 } plug_status;
47 
48 typedef struct plug_data {
49  std::string name;
50  int major;
51  int minor;
52 
53  plug_data(std::string n, int _major, int _minor)
54  : name(n), major(_major), minor(_minor) {}
55 
56 } plug_data;
57 
58 
69 public:
70  virtual ~AbstractBlacklist() = default;
71 
73  virtual plug_status get_status(const std::string& name,
74  int _major, int _minor) = 0;
75 
77  virtual plug_status get_status(const plug_data pd) = 0;
78 
80  virtual plug_data get_library_data(const std::string& library_file) = 0;
81 
86  virtual bool mark_unloadable(const std::string& path) = 0;
87 
92  virtual bool mark_unloadable(const std::string& name,
93  int major, int minor) = 0;
94 
96  virtual bool is_loadable(const std::string path) = 0;
97 
99  virtual std::string get_message(plug_status sts, const plug_data& data) = 0;
100 };
101 
102 std::unique_ptr<AbstractBlacklist> blacklist_factory();
103 
104 #ifdef gnu_major
105 #define major gnu_major
106 #define minor gnu_minor
107 #endif
108 
109 #endif // PLUGIN_BLACKLIST_H
Plugins could be blacklisted in runtime if they are unloadable or in hardcoded, compile-time list.
virtual bool is_loadable(const std::string path)=0
Return true iff plugin (a path) is loadable.
virtual bool mark_unloadable(const std::string &name, int major, int minor)=0
Given plugin name and version mark it as unloadable.
virtual bool mark_unloadable(const std::string &path)=0
Given a path, mark filename as unloadable.
virtual plug_status get_status(const std::string &name, int _major, int _minor)=0
Return status for given official plugin name and version.
virtual std::string get_message(plug_status sts, const plug_data &data)=0
Return plugin-specific message, possibly "".
virtual plug_data get_library_data(const std::string &library_file)=0
Best effort attempt to get data for a library file.
virtual plug_status get_status(const plug_data pd)=0
Return status for given official plugin name and version.