54 using comin::into_string;
59 for (
int i = 0; i < num_plugins; ++i) {
60 auto name = into_string(plugin_list[i].name);
61 auto plugin_library = into_string(plugin_list[i].plugin_library);
62 auto constructor = into_string(plugin_list[i].primary_constructor);
65 if (plugin_library.empty()) {
66 dlhandle = dlopen(
nullptr, RTLD_NOW);
68 dlhandle = dlopen(plugin_library.c_str(), RTLD_NOW);
72 if (plugin_library.empty()) {
74 }
else if (
auto pos = plugin_library.rfind(
'/');
75 pos != std::string::npos) {
76 name = std::string(plugin_library, pos + 1);
78 name = plugin_library;
80 name +=
"(" + constructor +
")";
85 "Cannot load plugin <%s>: %s", name.c_str(),
90 auto primary_constructor =
91 reinterpret_cast<void (*)()
>(dlsym(dlhandle, constructor.c_str()));
93 if (!primary_constructor) {
95 "comin_plugin_primaryconstructor",
96 "Cannot load plugin <%s> primary constructor '%s': %s",
97 name.c_str(), constructor.c_str(), dlerror());
101 if (plugin_list[i].log_severity < COMIN_SEVERITY_DEBUG ||
102 plugin_list[i].log_severity > COMIN_SEVERITY_ERROR) {
104 "Plugin <%s> log severity %d out of range.",
109 static_cast<t_comin_log_severity
>(plugin_list[i].
log_severity);
111 t_comin_plugin_info info;
112 info.comm = into_string(plugin_list[i].comm);
113 info.errors_return =
false;
115 info.log_severity = severity;
116 info.name = std::move(name);
117 info.options = into_string(plugin_list[i].options);
119 state.plugin_info.push_back(std::move(info));
122 primary_constructor();
125 comin::logging::message(0,
" Complete primary constructors");