Rename: "float value" -> "real value"
[babeltrace.git] / cli / babeltrace-cfg-cli-args.c
index 58739d26d51f8f850aeab06a60bbb29e15812f7d..f15455c758c11b911656c0204b44a4b2769d1d01 100644 (file)
@@ -28,7 +28,7 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
-#include <assert.h>
+#include <babeltrace/assert-internal.h>
 #include <stdio.h>
 #include <stdbool.h>
 #include <inttypes.h>
@@ -41,6 +41,7 @@
 #include "babeltrace-cfg.h"
 #include "babeltrace-cfg-cli-args.h"
 #include "babeltrace-cfg-cli-args-connect.h"
+#include "version.h"
 
 /*
  * Error printf() macro which prepends "Error: " the first time it's
@@ -297,7 +298,7 @@ int ini_handle_state(struct ini_parsing_state *state)
                }
                case G_TOKEN_FLOAT:
                        /* Positive floating point number */
-                       value = bt_value_float_create_init(
+                       value = bt_value_real_create_init(
                                state->scanner->value.v_float);
                        break;
                case G_TOKEN_STRING:
@@ -371,7 +372,7 @@ int ini_handle_state(struct ini_parsing_state *state)
                }
                case G_TOKEN_FLOAT:
                        /* Negative floating point number */
-                       value = bt_value_float_create_init(
+                       value = bt_value_real_create_init(
                                -state->scanner->value.v_float);
                        break;
                default:
@@ -607,10 +608,10 @@ void plugin_comp_cls_names(const char *arg, char **name, char **plugin,
        GString *gs_comp_cls = NULL;
        size_t end_pos;
 
-       assert(arg);
-       assert(plugin);
-       assert(comp_cls);
-       assert(comp_cls_type);
+       BT_ASSERT(arg);
+       BT_ASSERT(plugin);
+       BT_ASSERT(comp_cls);
+       BT_ASSERT(comp_cls_type);
 
        if (!bt_common_string_is_printable(arg)) {
                printf_err("Argument contains a non-printable character\n");
@@ -729,7 +730,11 @@ end:
 static
 void print_version(void)
 {
-       puts("Babeltrace " VERSION);
+       if (GIT_VERSION[0] == '\0') {
+               puts("Babeltrace " VERSION);
+       } else {
+               puts("Babeltrace " VERSION  " - " GIT_VERSION);
+       }
 }
 
 /*
@@ -784,7 +789,8 @@ struct bt_config_component *bt_config_component_create(
                goto error;
        }
 
-       bt_object_init(cfg_component, bt_config_component_destroy);
+       bt_object_init_shared(&cfg_component->base,
+               bt_config_component_destroy);
        cfg_component->type = type;
        cfg_component->plugin_name = g_string_new(plugin_name);
        if (!cfg_component->plugin_name) {
@@ -1186,9 +1192,9 @@ end:
 static
 void append_param_arg(GString *params_arg, const char *key, const char *value)
 {
-       assert(params_arg);
-       assert(key);
-       assert(value);
+       BT_ASSERT(params_arg);
+       BT_ASSERT(key);
+       BT_ASSERT(value);
 
        if (params_arg->len != 0) {
                g_string_append_c(params_arg, ',');
@@ -1494,7 +1500,7 @@ struct bt_config *bt_config_base_create(enum bt_config_command command,
                goto error;
        }
 
-       bt_object_init(cfg, bt_config_destroy);
+       bt_object_init_shared(&cfg->base, bt_config_destroy);
        cfg->command = command;
        cfg->command_needs_plugins = needs_plugins;
 
@@ -2078,7 +2084,7 @@ struct bt_config *bt_config_query_from_args(int argc, const char *argv[],
                        goto error;
                }
 
-               assert(params);
+               BT_ASSERT(params);
                BT_MOVE(cfg->cmd_data.query.cfg_component->params, params);
        } else {
                print_query_usage(stdout);
@@ -2497,7 +2503,7 @@ struct bt_config *bt_config_run_from_args(int argc, const char *argv[],
                                abort();
                        }
 
-                       assert(cur_base_params);
+                       BT_ASSERT(cur_base_params);
                        bt_put(cur_cfg_comp->params);
                        cur_cfg_comp->params = bt_value_copy(cur_base_params);
                        if (!cur_cfg_comp->params) {
@@ -2723,10 +2729,10 @@ struct bt_config *bt_config_run_from_args_array(struct bt_value *run_args,
                struct bt_value *arg_value = bt_value_array_get(run_args, i);
                const char *arg;
 
-               assert(arg_value);
+               BT_ASSERT(arg_value);
                ret = bt_value_string_get(arg_value, &arg);
-               assert(ret == 0);
-               assert(arg);
+               BT_ASSERT(ret == 0);
+               BT_ASSERT(arg);
                argv[i + 1] = arg;
                bt_put(arg_value);
        }
@@ -3047,7 +3053,7 @@ int append_run_args_for_implicit_component(
                        goto error;
                }
 
-               assert(bt_value_is_string(elem));
+               BT_ASSERT(bt_value_is_string(elem));
                if (bt_value_string_get(elem, &arg)) {
                        goto error;
                }
@@ -3072,7 +3078,7 @@ end:
 static
 void finalize_implicit_component_args(struct implicit_component_args *args)
 {
-       assert(args);
+       BT_ASSERT(args);
 
        if (args->comp_arg) {
                g_string_free(args->comp_arg, TRUE);
@@ -3128,9 +3134,9 @@ static
 void append_implicit_component_param(struct implicit_component_args *args,
        const char *key, const char *value)
 {
-       assert(args);
-       assert(key);
-       assert(value);
+       BT_ASSERT(args);
+       BT_ASSERT(key);
+       BT_ASSERT(value);
        append_param_arg(args->params_arg, key, value);
 }
 
@@ -3140,9 +3146,9 @@ int append_implicit_component_extra_param(struct implicit_component_args *args,
 {
        int ret = 0;
 
-       assert(args);
-       assert(key);
-       assert(value);
+       BT_ASSERT(args);
+       BT_ASSERT(key);
+       BT_ASSERT(value);
 
        if (bt_value_array_append_string(args->extra_params, "--key")) {
                print_err_oom();
@@ -3361,9 +3367,9 @@ int convert_auto_connect(struct bt_value *run_args,
        GList *filter_prev;
        GList *sink_at = sink_names;
 
-       assert(source_names);
-       assert(filter_names);
-       assert(sink_names);
+       BT_ASSERT(source_names);
+       BT_ASSERT(filter_names);
+       BT_ASSERT(sink_names);
 
        /* Connect all sources to the first filter */
        for (source_at = source_names; source_at != NULL; source_at = g_list_next(source_at)) {
@@ -3422,7 +3428,7 @@ int split_timerange(const char *arg, char **begin, char **end)
        GString *g_begin = NULL;
        GString *g_end = NULL;
 
-       assert(arg);
+       BT_ASSERT(arg);
 
        if (*ch == '[') {
                ch++;
@@ -3440,8 +3446,8 @@ int split_timerange(const char *arg, char **begin, char **end)
                goto error;
        }
 
-       assert(begin);
-       assert(end);
+       BT_ASSERT(begin);
+       BT_ASSERT(end);
        *begin = g_begin->str;
        *end = g_end->str;
        g_string_free(g_begin, FALSE);
@@ -3471,7 +3477,7 @@ int g_list_prepend_gstring(GList **list, const char *string)
        int ret = 0;
        GString *gs = g_string_new(string);
 
-       assert(list);
+       BT_ASSERT(list);
 
        if (!gs) {
                print_err_oom();
@@ -4668,9 +4674,9 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[],
                        GString *quoted = NULL;
                        const char *arg_to_print;
 
-                       assert(arg_value);
+                       BT_ASSERT(arg_value);
                        ret = bt_value_string_get(arg_value, &arg);
-                       assert(ret == 0);
+                       BT_ASSERT(ret == 0);
                        BT_PUT(arg_value);
 
                        if (print_run_args) {
@@ -4769,7 +4775,7 @@ void print_gen_usage(FILE *fp)
        fprintf(fp, "\n");
        fprintf(fp, "  -d, --debug          Enable debug mode (same as --log-level=V)\n");
        fprintf(fp, "  -h, --help           Show this help and quit\n");
-       fprintf(fp, "      --log-level=LVL  Set all log levels to LVL (`N`, `V`, `D`,\n");
+       fprintf(fp, "  -l, --log-level=LVL  Set all log levels to LVL (`N`, `V`, `D`,\n");
        fprintf(fp, "                       `I`, `W` (default), `E`, or `F`)\n");
        fprintf(fp, "  -v, --verbose        Enable verbose mode (same as --log-level=I)\n");
        fprintf(fp, "  -V, --version        Show version and quit\n");
@@ -4876,7 +4882,8 @@ struct bt_config *bt_config_cli_args_create(int argc, const char *argv[],
                                 */
                                log_level = 'I';
                        }
-               } else if (strcmp(cur_arg, "--log-level") == 0) {
+               } else if (strcmp(cur_arg, "--log-level") == 0 ||
+                               strcmp(cur_arg, "-l") == 0) {
                        if (!next_arg) {
                                printf_err("Missing log level value for --log-level option\n");
                                *retcode = 1;
@@ -4895,6 +4902,16 @@ struct bt_config *bt_config_cli_args_create(int argc, const char *argv[],
                } else if (strncmp(cur_arg, "--log-level=", 12) == 0) {
                        const char *arg = &cur_arg[12];
 
+                       log_level = log_level_from_arg(arg);
+                       if (log_level == 'U') {
+                               printf_err("Invalid argument for --log-level option:\n    %s\n",
+                                       arg);
+                               *retcode = 1;
+                               goto end;
+                       }
+               } else if (strncmp(cur_arg, "-l", 2) == 0) {
+                       const char *arg = &cur_arg[2];
+
                        log_level = log_level_from_arg(arg);
                        if (log_level == 'U') {
                                printf_err("Invalid argument for --log-level option:\n    %s\n",
@@ -4954,8 +4971,8 @@ struct bt_config *bt_config_cli_args_create(int argc, const char *argv[],
                goto end;
        }
 
-       assert(command_argv);
-       assert(command_argc >= 0);
+       BT_ASSERT(command_argv);
+       BT_ASSERT(command_argc >= 0);
 
        switch (command_type) {
        case COMMAND_TYPE_RUN:
This page took 0.031077 seconds and 4 git commands to generate.