- opt_payload_field_names = 0;
- opt_context_field_names = 0;
- strlist = (char *) poptGetOptArg(*pc);
- if (!strlist) {
- return -EINVAL;
- }
- str = strtok_r(strlist, ",", &strctx);
- do {
- if (!strcmp(str, "all"))
- opt_all_field_names = 1;
- else if (!strcmp(str, "scope"))
- opt_scope_field_names = 1;
- else if (!strcmp(str, "context") || !strcmp(str, "ctx"))
- opt_context_field_names = 1;
- else if (!strcmp(str, "header"))
- opt_header_field_names = 1;
- else if (!strcmp(str, "payload") || !strcmp(str, "args") || !strcmp(str, "arg"))
- opt_payload_field_names = 1;
- else if (!strcmp(str, "none")) {
- opt_all_field_names = 0;
- opt_scope_field_names = 0;
- opt_context_field_names = 0;
- opt_header_field_names = 0;
- opt_payload_field_names = 0;
- } else {
- fprintf(stderr, "[error] unknown field name type %s\n", str);
- free(strlist);
- ret = -EINVAL;
+ if (bt_config_component->instance_name->len > 0) {
+ printf(" Name: %s\n",
+ bt_config_component->instance_name->str);
+ }
+
+ printf(" Parameters:\n");
+ print_value(bt_config_component->params, 8);
+}
+
+static
+void print_bt_config_components(GPtrArray *array)
+{
+ size_t i;
+
+ for (i = 0; i < array->len; i++) {
+ struct bt_config_component *cfg_component =
+ bt_config_get_component(array, i);
+ print_bt_config_component(cfg_component);
+ BT_PUT(cfg_component);
+ }
+}
+
+static
+void print_plugin_paths(struct bt_value *plugin_paths)
+{
+ printf(" Plugin paths:\n");
+ print_value(plugin_paths, 4);
+}
+
+static
+void print_cfg_convert(struct bt_config *cfg)
+{
+ size_t i;
+
+ printf(" Force correlate: %s\n",
+ cfg->cmd_data.convert.force_correlate ? "yes" : "no");
+ print_plugin_paths(cfg->cmd_data.convert.plugin_paths);
+ printf(" Source component instances:\n");
+ print_bt_config_components(cfg->cmd_data.convert.sources);
+
+ if (cfg->cmd_data.convert.filters->len > 0) {
+ printf(" Filter component instances:\n");
+ print_bt_config_components(cfg->cmd_data.convert.filters);
+ }
+
+ printf(" Sink component instances:\n");
+ print_bt_config_components(cfg->cmd_data.convert.sinks);
+ printf(" Connections:\n");
+
+ for (i = 0; i < cfg->cmd_data.convert.connections->len; i++) {
+ struct bt_config_connection *cfg_connection =
+ g_ptr_array_index(cfg->cmd_data.convert.connections,
+ i);
+
+ printf(" %s%s%s -> %s%s%s\n",
+ cfg_connection->src_instance_name->str,
+ cfg_connection->src_port_name->len > 0 ? "." : "",
+ cfg_connection->src_port_name->str,
+ cfg_connection->dst_instance_name->str,
+ cfg_connection->dst_port_name->len > 0 ? "." : "",
+ cfg_connection->dst_port_name->str);
+ }
+}
+
+static
+void print_cfg_list_plugins(struct bt_config *cfg)
+{
+ print_plugin_paths(cfg->cmd_data.list_plugins.plugin_paths);
+}
+
+static
+void print_cfg_help(struct bt_config *cfg)
+{
+ print_plugin_paths(cfg->cmd_data.help.plugin_paths);
+}
+
+static
+void print_cfg_query_info(struct bt_config *cfg)
+{
+ print_plugin_paths(cfg->cmd_data.query_info.plugin_paths);
+ printf(" Action: `%s`\n", cfg->cmd_data.query_info.action->str);
+ printf(" Component class:\n");
+ print_bt_config_component(cfg->cmd_data.query_info.cfg_component);
+}
+
+static
+void print_cfg(struct bt_config *cfg)
+{
+ if (!babeltrace_verbose) {
+ return;
+ }
+
+ printf("Configuration:\n");
+ printf(" Debug mode: %s\n", cfg->debug ? "yes" : "no");
+ printf(" Verbose mode: %s\n", cfg->verbose ? "yes" : "no");
+
+ switch (cfg->command) {
+ case BT_CONFIG_COMMAND_CONVERT:
+ print_cfg_convert(cfg);
+ break;
+ case BT_CONFIG_COMMAND_LIST_PLUGINS:
+ print_cfg_list_plugins(cfg);
+ break;
+ case BT_CONFIG_COMMAND_HELP:
+ print_cfg_help(cfg);
+ break;
+ case BT_CONFIG_COMMAND_QUERY_INFO:
+ print_cfg_query_info(cfg);
+ break;
+ default:
+ assert(false);
+ }
+}
+
+static
+struct bt_component *create_trimmer(struct bt_config_component *source_cfg)
+{
+ struct bt_component *trimmer = NULL;
+ struct bt_component_class *trimmer_class = NULL;
+ struct bt_value *trimmer_params = NULL;
+ struct bt_value *value;
+
+ trimmer_params = bt_value_map_create();
+ if (!trimmer_params) {
+ goto end;
+ }
+
+ value = bt_value_map_get(source_cfg->params, "begin");
+ if (value) {
+ enum bt_value_status ret;
+
+ ret = bt_value_map_insert(trimmer_params, "begin",
+ value);
+ BT_PUT(value);
+ if (ret) {
+ goto end;
+ }
+ }
+ value = bt_value_map_get(source_cfg->params, "end");
+ if (value) {
+ enum bt_value_status ret;
+
+ ret = bt_value_map_insert(trimmer_params, "end",
+ value);
+ BT_PUT(value);
+ if (ret) {
+ goto end;
+ }
+ }
+ value = bt_value_map_get(source_cfg->params, "clock-gmt");
+ if (value) {
+ enum bt_value_status ret;
+
+ ret = bt_value_map_insert(trimmer_params, "clock-gmt",
+ value);
+ BT_PUT(value);
+ if (ret) {