+ enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ enum bt_value_status status;
+ bool value, found;
+ char *str = NULL;
+
+ text->plugin_opt_map = bt_value_map_create();
+ if (!text->plugin_opt_map) {
+ ret = BT_COMPONENT_STATUS_ERROR;
+ goto end;
+ }
+ ret = add_params_to_map(text->plugin_opt_map);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ /* Report unknown parameters. */
+ status = bt_value_map_foreach(params, check_param_exists, text);
+ switch (status) {
+ case BT_VALUE_STATUS_OK:
+ break;
+ default:
+ ret = BT_COMPONENT_STATUS_ERROR;
+ goto end;
+ }
+ /* Known parameters. */
+ ret = apply_one_string("output-path",
+ params,
+ &text->options.output_path);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+
+ ret = apply_one_string("debug-info-dir",
+ params,
+ &text->options.debug_info_dir);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+
+ ret = apply_one_string("debug-info-target-prefix",
+ params,
+ &text->options.debug_info_target_prefix);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+
+ value = false; /* Default. */
+ ret = apply_one_bool("debug-info-full-path", params, &value, NULL);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ text->options.debug_info_full_path = value;
+
+ value = false; /* Default. */
+ ret = apply_one_bool("no-delta", params, &value, NULL);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ text->options.print_delta_field = !value; /* Reverse logic. */
+
+ value = false; /* Default. */
+ ret = apply_one_bool("clock-cycles", params, &value, NULL);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ text->options.print_timestamp_cycles = value;
+
+ value = false; /* Default. */
+ ret = apply_one_bool("clock-seconds", params, &value, NULL);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ text->options.clock_seconds = value;
+
+ value = false; /* Default. */
+ ret = apply_one_bool("clock-date", params, &value, NULL);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ text->options.clock_date = value;
+
+ value = false; /* Default. */
+ ret = apply_one_bool("clock-gmt", params, &value, NULL);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ text->options.clock_gmt = value;
+
+ /* Names. */
+ ret = apply_one_string("name-default", params, &str);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ if (!str) {
+ text->options.name_default = TEXT_DEFAULT_UNSET;
+ } else if (!strcmp(str, "show")) {
+ text->options.name_default = TEXT_DEFAULT_SHOW;
+ } else if (!strcmp(str, "hide")) {
+ text->options.name_default = TEXT_DEFAULT_HIDE;
+ } else {
+ ret = BT_COMPONENT_STATUS_ERROR;
+ goto end;
+ }
+ g_free(str);
+ str = NULL;
+
+ switch (text->options.name_default) {
+ case TEXT_DEFAULT_UNSET:
+ text->options.print_payload_field_names = true;
+ text->options.print_context_field_names = true;
+ text->options.print_header_field_names = false;
+ text->options.print_scope_field_names = false;
+ break;
+ case TEXT_DEFAULT_SHOW:
+ text->options.print_payload_field_names = true;
+ text->options.print_context_field_names = true;
+ text->options.print_header_field_names = true;
+ text->options.print_scope_field_names = true;
+ break;
+ case TEXT_DEFAULT_HIDE:
+ text->options.print_payload_field_names = false;
+ text->options.print_context_field_names = false;
+ text->options.print_header_field_names = false;
+ text->options.print_scope_field_names = false;
+ break;
+ default:
+ ret = BT_COMPONENT_STATUS_ERROR;
+ goto end;
+ }
+
+ value = false;
+ found = false;
+ ret = apply_one_bool("name-payload", params, &value, &found);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ if (found) {
+ text->options.print_payload_field_names = value;
+ }
+
+ value = false;
+ found = false;
+ ret = apply_one_bool("name-context", params, &value, &found);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ if (found) {
+ text->options.print_context_field_names = value;
+ }
+
+ value = false;
+ found = false;
+ ret = apply_one_bool("name-header", params, &value, &found);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ if (found) {
+ text->options.print_header_field_names = value;
+ }
+
+ value = false;
+ found = false;
+ ret = apply_one_bool("name-scope", params, &value, &found);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ if (found) {
+ text->options.print_scope_field_names = value;
+ }
+
+ /* Fields. */
+ ret = apply_one_string("field-default", params, &str);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ if (!str) {
+ text->options.field_default = TEXT_DEFAULT_UNSET;
+ } else if (!strcmp(str, "show")) {
+ text->options.field_default = TEXT_DEFAULT_SHOW;
+ } else if (!strcmp(str, "hide")) {
+ text->options.field_default = TEXT_DEFAULT_HIDE;
+ } else {
+ ret = BT_COMPONENT_STATUS_ERROR;
+ goto end;
+ }
+ g_free(str);
+ str = NULL;
+
+ switch (text->options.field_default) {
+ case TEXT_DEFAULT_UNSET:
+ text->options.print_trace_field = false;
+ text->options.print_trace_hostname_field = true;
+ text->options.print_trace_domain_field = false;
+ text->options.print_trace_procname_field = true;
+ text->options.print_trace_vpid_field = true;
+ text->options.print_loglevel_field = false;
+ text->options.print_emf_field = false;
+ text->options.print_emf_field = false;
+ text->options.print_callsite_field = false;
+ break;
+ case TEXT_DEFAULT_SHOW:
+ text->options.print_trace_field = true;
+ text->options.print_trace_hostname_field = true;
+ text->options.print_trace_domain_field = true;
+ text->options.print_trace_procname_field = true;
+ text->options.print_trace_vpid_field = true;
+ text->options.print_loglevel_field = true;
+ text->options.print_emf_field = true;
+ text->options.print_emf_field = true;
+ text->options.print_callsite_field = true;
+ break;
+ case TEXT_DEFAULT_HIDE:
+ text->options.print_trace_field = false;
+ text->options.print_trace_hostname_field = false;
+ text->options.print_trace_domain_field = false;
+ text->options.print_trace_procname_field = false;
+ text->options.print_trace_vpid_field = false;
+ text->options.print_loglevel_field = false;
+ text->options.print_emf_field = false;
+ text->options.print_emf_field = false;
+ text->options.print_callsite_field = false;
+ break;
+ default:
+ ret = BT_COMPONENT_STATUS_ERROR;
+ goto end;
+ }
+
+ value = false;
+ found = false;
+ ret = apply_one_bool("field-trace", params, &value, &found);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ if (found) {
+ text->options.print_trace_field = value;
+ }
+
+ value = false;
+ found = false;
+ ret = apply_one_bool("field-trace:hostname", params, &value, &found);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ if (found) {
+ text->options.print_trace_hostname_field = value;
+ }
+
+ value = false;
+ found = false;
+ ret = apply_one_bool("field-trace:domain", params, &value, &found);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ if (found) {
+ text->options.print_trace_domain_field = value;
+ }
+
+ value = false;
+ found = false;
+ ret = apply_one_bool("field-trace:procname", params, &value, &found);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ if (found) {
+ text->options.print_trace_procname_field = value;
+ }
+
+ value = false;
+ found = false;
+ ret = apply_one_bool("field-trace:vpid", params, &value, &found);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ if (found) {
+ text->options.print_trace_vpid_field = value;
+ }
+
+ value = false;
+ found = false;
+ ret = apply_one_bool("field-loglevel", params, &value, &found);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ if (found) {
+ text->options.print_loglevel_field = value;
+ }
+
+ value = false;
+ found = false;
+ ret = apply_one_bool("field-emf", params, &value, &found);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ if (found) {
+ text->options.print_emf_field = value;
+ }
+
+ value = false;
+ found = false;
+ ret = apply_one_bool("field-emf", params, &value, &found);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ if (found) {
+ text->options.print_emf_field = value;
+ }
+
+ value = false;
+ found = false;
+ ret = apply_one_bool("field-callsite", params, &value, &found);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ if (found) {
+ text->options.print_callsite_field = value;
+ }
+end:
+ bt_put(text->plugin_opt_map);
+ text->plugin_opt_map = NULL;
+ g_free(str);
+ return ret;