X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lib%2Fplugin%2Fplugin.c;h=d85604afbd89a2e15ad15a5b402dbc19bcca72b0;hb=3230ee6b4f3a704958b761daecae835c56938bc9;hp=83f628cd8ef79fe387360ba3e55b9fcc1c95c515;hpb=6fbd4105b92d0da8b3c5818a5b7c5b07850f4a01;p=babeltrace.git diff --git a/lib/plugin/plugin.c b/lib/plugin/plugin.c index 83f628cd..d85604af 100644 --- a/lib/plugin/plugin.c +++ b/lib/plugin/plugin.c @@ -28,7 +28,7 @@ */ #include -#include +#include #include #include #include @@ -131,7 +131,7 @@ void free_plugins(struct bt_plugin **plugins) { } } -struct bt_plugin *bt_plugin_create_from_name(const char *plugin_name) +struct bt_plugin *bt_plugin_find(const char *plugin_name) { const char *system_plugin_dir; char *home_plugin_dir = NULL; @@ -246,6 +246,30 @@ end: return plugin; } +struct bt_component_class *bt_plugin_find_component_class( + const char *plugin_name, const char *comp_cls_name, + enum bt_component_class_type comp_cls_type) +{ + struct bt_plugin *plugin = NULL; + struct bt_component_class *comp_cls = NULL; + + if (!plugin_name || !comp_cls_name) { + goto end; + } + + plugin = bt_plugin_find(plugin_name); + if (!plugin) { + goto end; + } + + comp_cls = bt_plugin_get_component_class_by_name_and_type( + plugin, comp_cls_name, comp_cls_type); + +end: + bt_put(plugin); + return comp_cls; +} + /* Allocate dirent as recommended by READDIR(3), NOTES on readdir_r */ static struct dirent *alloc_dirent(const char *path) @@ -305,7 +329,8 @@ enum bt_plugin_status bt_plugin_create_append_all_from_dir( directory = opendir(file_path); if (!directory) { - perror("Failed to open plug-in directory"); + printf_verbose("Failed to open plugin directory \"%s\"\n", + file_path); ret = BT_PLUGIN_STATUS_ERROR; goto end; } @@ -530,7 +555,6 @@ enum bt_plugin_status bt_plugin_add_component_class( { enum bt_plugin_status status = BT_PLUGIN_STATUS_OK; struct bt_component_class *comp_class_dup = NULL; - int ret; int comp_class_index = -1; if (!plugin || !comp_class || plugin->frozen) { @@ -555,10 +579,7 @@ enum bt_plugin_status bt_plugin_add_component_class( /* Special case for a shared object plugin */ if (plugin->type == BT_PLUGIN_TYPE_SO) { - ret = bt_plugin_so_on_add_component_class(plugin, comp_class); - if (ret) { - goto error; - } + bt_plugin_so_on_add_component_class(plugin, comp_class); } goto end;