| 155 | } |
| 156 | |
| 157 | static int install_plugin(const char *file_name, const char *plugin_name) |
| 158 | { |
| 159 | void *handle; |
| 160 | comdb2_plugin_t *plugin; |
| 161 | comdb2_plugin_t *tmp; |
| 162 | |
| 163 | handle = dlopen(file_name, RTLD_LAZY); |
| 164 | if (!handle) { |
| 165 | logmsg(LOGMSG_FATAL, "dlopen() failed: %s\n", dlerror()); |
| 166 | exit(1); |
| 167 | } |
| 168 | |
| 169 | plugin = (comdb2_plugin_t *)dlsym(handle, "comdb2_plugin"); |
| 170 | if (!plugin) { |
| 171 | logmsg(LOGMSG_FATAL, "dlsym() failed: %s\n", dlerror()); |
| 172 | exit(1); |
| 173 | } |
| 174 | |
| 175 | tmp = NULL; |
| 176 | while (plugin->name) { |
| 177 | if (strcmp(plugin_name, plugin->name) == 0) { |
| 178 | tmp = plugin; |
| 179 | break; |
| 180 | } |
| 181 | ++plugin; |
| 182 | } |
| 183 | |
| 184 | if (tmp == NULL) { |
| 185 | logmsg(LOGMSG_ERROR, "Plugin %s not found in the shared object file.\n", |
| 186 | plugin_name); |
| 187 | return 1; |
| 188 | } else if (install_plugin_int(tmp)) { |
| 189 | logmsg(LOGMSG_ERROR, "Failed to install plugin %s.\n", plugin_name); |
| 190 | return 1; |
| 191 | } |
| 192 | |
| 193 | return 0; |
| 194 | } |
| 195 | |
| 196 | static int install_all_plugins(const char *file_name) |
| 197 | { |
no test coverage detected