Move autodisc to its own convenience library
[babeltrace.git] / src / cli / babeltrace2-cfg-cli-args.c
index e962ff361dfe48370f07ab5d33a0b09750300d02..81dd05bbb1ae856db79e8e2243a77524833c904f 100644 (file)
@@ -42,7 +42,8 @@
 #include "babeltrace2-cfg-cli-args-connect.h"
 #include "babeltrace2-cfg-cli-params-arg.h"
 #include "babeltrace2-plugins.h"
-#include "babeltrace2-cfg-src-auto-disc.h"
+#include "babeltrace2-query.h"
+#include "autodisc/autodisc.h"
 #include "common/version.h"
 
 static const int cli_default_log_level = BT_LOG_WARNING;
@@ -1415,7 +1416,7 @@ struct bt_config *bt_config_help_from_args(int argc, const char *argv[],
        struct bt_config *cfg = NULL;
        const char *non_opt = NULL;
        char *plugin_name = NULL, *comp_cls_name = NULL;
-       struct bt_argpar_parse_ret argpar_parse_ret;
+       struct bt_argpar_parse_ret argpar_parse_ret = { 0 };
 
        *retcode = 0;
        cfg = bt_config_help_create(initial_plugin_paths, default_log_level);
@@ -1584,7 +1585,7 @@ struct bt_config *bt_config_query_from_args(int argc, const char *argv[],
        const char *query_object = NULL;
        bt_value *params;
        GString *error_str = NULL;
-       struct bt_argpar_parse_ret argpar_parse_ret;
+       struct bt_argpar_parse_ret argpar_parse_ret = { 0 };
 
        params = bt_value_null;
        bt_value_get_ref(bt_value_null);
@@ -4267,9 +4268,25 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[],
                        }
                } else {
                        int status;
+                       size_t plugin_count;
+                       const bt_plugin **plugins;
+                       const bt_plugin *plugin;
+
+                       status = require_loaded_plugins(plugin_paths);
+                       if (status != 0) {
+                               goto error;
+                       }
+
+                       if (auto_source_discovery_restrict_plugin_name) {
+                               plugin_count = 1;
+                               plugin = find_loaded_plugin(auto_source_discovery_restrict_plugin_name);
+                               plugins = &plugin;
+                       } else {
+                               plugin_count = get_loaded_plugins_count();
+                               plugins = borrow_loaded_plugins();
+                       }
 
-                       status = auto_discover_source_components(plugin_paths, non_opts,
-                               auto_source_discovery_restrict_plugin_name,
+                       status = auto_discover_source_components(non_opts, plugins, plugin_count,
                                auto_source_discovery_restrict_component_class_name,
                                *default_log_level >= 0 ? *default_log_level : cli_default_log_level,
                                &auto_disc);
This page took 0.024147 seconds and 4 git commands to generate.