#include <glib.h>
#include "babeltrace-cfg.h"
+#define DEFAULT_SOURCE_COMPONENT_NAME "ctf.fs"
+
/*
* Error printf() macro which prepends "Error: " the first time it's
* called. This gives a nicer feel than having a bunch of error prefixes
enum legacy_output_format legacy_output_format =
LEGACY_OUTPUT_FORMAT_NONE;
struct bt_value *legacy_input_paths = NULL;
+ struct bt_config_component *implicit_source_comp = NULL;
struct bt_config_component *cur_cfg_comp = NULL;
+ bool cur_is_implicit_source = false;
+ bool use_implicit_source = false;
enum bt_config_component_dest cur_cfg_comp_dest =
BT_CONFIG_COMPONENT_DEST_SOURCE;
struct bt_value *cur_base_params = NULL;
goto error;
}
+ /* Note: implicit source never gets positional base params. */
+ implicit_source_comp = bt_config_component_from_arg(DEFAULT_SOURCE_COMPONENT_NAME);
+ if (implicit_source_comp) {
+ cur_cfg_comp = implicit_source_comp;
+ cur_is_implicit_source = true;
+ use_implicit_source = true;
+ } else {
+ printf_debug("Cannot find implicit source plugin \"%s\"",
+ DEFAULT_SOURCE_COMPONENT_NAME);
+ }
+
/* Parse options */
pc = poptGetContext(NULL, argc, (const char **) argv, long_options, 0);
if (!pc) {
}
}
+ use_implicit_source = false;
+
/* Non-legacy: try to create a component config */
- if (cur_cfg_comp) {
+ if (cur_cfg_comp && !cur_is_implicit_source) {
add_cfg_comp(cfg, cur_cfg_comp,
cur_cfg_comp_dest);
}
arg);
goto error;
}
+ cur_is_implicit_source = false;
assert(cur_base_params);
bt_put(cur_cfg_comp->params);
}
/* Non-legacy: try to create a component config */
- if (cur_cfg_comp) {
+ if (cur_cfg_comp && !cur_is_implicit_source) {
add_cfg_comp(cfg, cur_cfg_comp,
cur_cfg_comp_dest);
}
arg);
goto error;
}
+ cur_is_implicit_source = false;
assert(cur_base_params);
bt_put(cur_cfg_comp->params);
struct bt_value *params_to_set;
if (!cur_cfg_comp) {
- printf_err("--params option must follow a --source or --sink option\n");
+ printf_err("Can not apply parameter to unavailable default source component \"%s\".\n",
+ DEFAULT_SOURCE_COMPONENT_NAME);
goto error;
}
}
case OPT_PATH:
if (!cur_cfg_comp) {
- printf_err("--path option must follow a --source or --sink option\n");
+ printf_err("Can not apply parameter to unavailable default source component \"%s\".\n",
+ DEFAULT_SOURCE_COMPONENT_NAME);
goto error;
}
break;
case OPT_BEGIN:
if (!cur_cfg_comp) {
- //TODO
- printf_err("Unimplemented: apply to default source\n");
+ printf_err("Can not apply parameter to unavailable default source component \"%s\".\n",
+ DEFAULT_SOURCE_COMPONENT_NAME);
goto error;
}
if (cur_cfg_comp_dest != BT_CONFIG_COMPONENT_DEST_SOURCE) {
break;
case OPT_END:
if (!cur_cfg_comp) {
- //TODO
- printf_err("Unimplemented: apply to default source\n");
+ printf_err("Can not apply parameter to unavailable default source component \"%s\".\n",
+ DEFAULT_SOURCE_COMPONENT_NAME);
goto error;
}
if (cur_cfg_comp_dest != BT_CONFIG_COMPONENT_DEST_SOURCE) {
const char *begin, *end;
if (!cur_cfg_comp) {
- //TODO
- printf_err("Unimplemented: apply to default source\n");
+ printf_err("Can not apply parameter to unavailable default source component \"%s\".\n",
+ DEFAULT_SOURCE_COMPONENT_NAME);
goto error;
}
if (cur_cfg_comp_dest != BT_CONFIG_COMPONENT_DEST_SOURCE) {
}
/* Append current component configuration, if any */
- if (cur_cfg_comp) {
+ if (cur_cfg_comp && !cur_is_implicit_source) {
add_cfg_comp(cfg, cur_cfg_comp, cur_cfg_comp_dest);
- cur_cfg_comp = NULL;
+ }
+ cur_cfg_comp = NULL;
+
+ if (use_implicit_source) {
+ add_cfg_comp(cfg, implicit_source_comp,
+ BT_CONFIG_COMPONENT_DEST_SOURCE);
+ implicit_source_comp = NULL;
+ } else {
+ if (implicit_source_comp
+ && !bt_value_map_is_empty(implicit_source_comp->params)) {
+ printf_err("Arguments specified for implicit source, but an explicit source has been specified, overriding it\n");
+ goto error;
+ }
}
/* Check for option parsing error */
}
free(arg);
+ BT_PUT(implicit_source_comp);
BT_PUT(cur_cfg_comp);
BT_PUT(cur_base_params);
BT_PUT(text_legacy_opts.names);