MCPcopy Create free account
hub / github.com/BatchDrake/SigDigger / make

Method make

Suscan/Plugin.cpp:122–157  ·  view source on GitHub ↗

Static members

Source from the content-addressed store, hash-verified

120
121// Static members
122Plugin *
123Plugin::make(const char *path)
124{
125 void *handle = nullptr;
126 Plugin *plugin = nullptr;
127 const char *name;
128 const char *desc;
129
130 if ((handle = dlopen(path, RTLD_LAZY)) == nullptr) {
131 SU_ERROR("Cannot open %s: %s\n", path, dlerror());
132 return nullptr;
133 }
134
135 // Not an error, just not a plugin
136 if ((name = SCAST(
137 const char *,
138 dlsym(handle, SUSCAN_SYM_NAME(plugin_name)))) == nullptr) {
139 SU_WARNING("%s: not a plugin (no plugin name)\n", path);
140 goto done;
141 }
142
143 if ((desc = SCAST(
144 const char *,
145 dlsym(handle, SUSCAN_SYM_NAME(plugin_desc)))) == nullptr) {
146 SU_WARNING("%s: not a plugin (no plugin desc)\n", path);
147 goto done;
148 }
149
150 plugin = new Plugin(name, path, desc, handle);
151
152done:
153 if (plugin == nullptr && handle != nullptr)
154 dlclose(handle);
155
156 return plugin;
157}
158
159Plugin *
160Plugin::getDefaultPlugin()

Callers

nothing calls this directly

Calls 4

dlopenFunction · 0.85
dlerrorFunction · 0.85
dlsymFunction · 0.85
dlcloseFunction · 0.85

Tested by

no test coverage detected