Move to kernel style SPDX license identifiers
[babeltrace.git] / src / plugins / text / details / write.c
index 7b52335c817c733927bfa7139ceb86839fa726cc..51490a14d8b92b149966c5bdbdb9f57a475dd7ce 100644 (file)
@@ -1,26 +1,11 @@
 /*
- * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * SPDX-License-Identifier: MIT
  *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
  */
 
 #include <babeltrace2/babeltrace.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <string.h>
 
@@ -101,7 +86,7 @@ void format_uint(char *buf, uint64_t value, unsigned int base)
 
                break;
        default:
-               abort();
+               bt_common_abort();
        }
 
        sprintf(buf_start, spec, value);
@@ -154,7 +139,7 @@ void format_int(char *buf, int64_t value, unsigned int base)
 
                break;
        default:
-               abort();
+               bt_common_abort();
        }
 
        sprintf(buf_start, spec, abs_value);
@@ -214,7 +199,8 @@ static inline
 void write_obj_type_name(struct details_write_ctx *ctx, const char *name)
 {
        g_string_append_printf(ctx->str, "%s%s%s%s",
-               color_fg_yellow(ctx), color_bold(ctx), name, color_reset(ctx));
+               color_bold(ctx), color_fg_bright_yellow(ctx), name,
+               color_reset(ctx));
 }
 
 static inline
@@ -243,7 +229,7 @@ static inline
 void write_none_prop_value(struct details_write_ctx *ctx, const char *value)
 {
        g_string_append_printf(ctx->str, "%s%s%s%s",
-               color_bold(ctx), color_fg_magenta(ctx),
+               color_bold(ctx), color_fg_bright_magenta(ctx),
                value, color_reset(ctx));
 }
 
@@ -326,10 +312,10 @@ void write_bool_prop_value(struct details_write_ctx *ctx, bt_bool prop_value)
        g_string_append(ctx->str, color_bold(ctx));
 
        if (prop_value) {
-               g_string_append(ctx->str, color_fg_green(ctx));
+               g_string_append(ctx->str, color_fg_bright_green(ctx));
                str = "Yes";
        } else {
-               g_string_append(ctx->str, color_fg_red(ctx));
+               g_string_append(ctx->str, color_fg_bright_red(ctx));
                str = "No";
        }
 
@@ -368,14 +354,14 @@ gint compare_strings(const char **a, const char **b)
 }
 
 static
-bt_bool map_value_foreach_add_key_to_array(const char *key,
-               const bt_value *object, void *data)
+bt_value_map_foreach_entry_const_func_status map_value_foreach_add_key_to_array(
+               const char *key, const bt_value *object, void *data)
 {
        GPtrArray *keys = data;
 
        BT_ASSERT_DBG(keys);
        g_ptr_array_add(keys, (void *) key);
-       return BT_TRUE;
+       return BT_VALUE_MAP_FOREACH_ENTRY_CONST_FUNC_STATUS_OK;
 }
 
 static
@@ -482,7 +468,7 @@ void write_value(struct details_write_ctx *ctx, const bt_value *value,
                break;
        }
        default:
-               abort();
+               bt_common_abort();
        }
 
        g_ptr_array_free(keys, TRUE);
@@ -530,7 +516,7 @@ void write_int_field_class_props(struct details_write_ctx *ctx,
                write_uint_prop_value(ctx, 16);
                break;
        default:
-               abort();
+               bt_common_abort();
        }
 
        if (close) {
@@ -787,7 +773,7 @@ void write_field_path(struct details_write_ctx *ctx,
                write_str_prop_value(ctx, "Event payload");
                break;
        default:
-               abort();
+               bt_common_abort();
        }
 
        g_string_append(ctx->str, ": ");
@@ -809,7 +795,7 @@ void write_field_path(struct details_write_ctx *ctx,
                        write_str_prop_value(ctx, "<current>");
                        break;
                default:
-                       abort();
+                       bt_common_abort();
                }
        }
 
@@ -974,7 +960,7 @@ void write_field_class(struct details_write_ctx *ctx, const bt_field_class *fc)
                type = "Variant (signed integer selector)";
                break;
        default:
-               abort();
+               bt_common_abort();
        }
 
        g_string_append_printf(ctx->str, "%s%s%s",
@@ -1316,7 +1302,7 @@ void write_event_class(struct details_write_ctx *ctx, const bt_event_class *ec)
                        ll_str = "Debug";
                        break;
                default:
-                       abort();
+                       bt_common_abort();
                }
 
                write_str_prop_line(ctx, "Log level", ll_str);
@@ -1689,7 +1675,8 @@ void write_time_str(struct details_write_ctx *ctx, const char *str)
        }
 
        g_string_append_printf(ctx->str, "[%s%s%s%s]",
-               color_bold(ctx), color_fg_blue(ctx), str, color_reset(ctx));
+               color_bold(ctx), color_fg_bright_blue(ctx), str,
+               color_reset(ctx));
 
        if (ctx->details_comp->cfg.compact) {
                write_sp(ctx);
@@ -1714,7 +1701,7 @@ void write_time(struct details_write_ctx *ctx, const bt_clock_snapshot *cs)
 
        format_uint(buf, bt_clock_snapshot_get_value(cs), 10);
        g_string_append_printf(ctx->str, "[%s%s%s%s%s",
-               color_bold(ctx), color_fg_blue(ctx), buf,
+               color_bold(ctx), color_fg_bright_blue(ctx), buf,
                color_reset(ctx),
                ctx->details_comp->cfg.compact ? "" : " cycles");
        cs_status = bt_clock_snapshot_get_ns_from_origin(cs, &ns_from_origin);
@@ -1722,7 +1709,7 @@ void write_time(struct details_write_ctx *ctx, const bt_clock_snapshot *cs)
                format_int(buf, ns_from_origin, 10);
                g_string_append_printf(ctx->str, "%s %s%s%s%s%s",
                        ctx->details_comp->cfg.compact ? "" : ",",
-                       color_bold(ctx), color_fg_blue(ctx), buf,
+                       color_bold(ctx), color_fg_bright_blue(ctx), buf,
                        color_reset(ctx),
                        ctx->details_comp->cfg.compact ? "" : " ns from origin");
        }
@@ -1755,22 +1742,25 @@ int write_message_follow_tag(struct details_write_ctx *ctx,
 
        if (ctx->details_comp->cfg.compact) {
                g_string_append_printf(ctx->str,
-                       "%s{%s%" PRIu64 " %" PRIu64 " %" PRIu64 "%s%s}%s ",
+                       "%s{%s%s%" PRIu64 " %" PRIu64 " %" PRIu64 "%s%s}%s ",
                        color_fg_cyan(ctx), color_bold(ctx),
+                       color_fg_bright_cyan(ctx),
                        unique_trace_id, bt_stream_class_get_id(sc),
                        bt_stream_get_id(stream),
                        color_reset(ctx), color_fg_cyan(ctx), color_reset(ctx));
        } else {
                g_string_append_printf(ctx->str,
-                       "%s{Trace %s%" PRIu64 "%s%s, Stream class ID %s%" PRIu64 "%s%s, Stream ID %s%" PRIu64 "%s%s}%s\n",
+                       "%s{Trace %s%s%" PRIu64 "%s%s, Stream class ID %s%s%" PRIu64 "%s%s, Stream ID %s%s%" PRIu64 "%s%s}%s\n",
+                       color_fg_cyan(ctx),
+                       color_bold(ctx), color_fg_bright_cyan(ctx),
+                       unique_trace_id, color_reset(ctx),
+                       color_fg_cyan(ctx),
+                       color_bold(ctx), color_fg_bright_cyan(ctx),
+                       bt_stream_class_get_id(sc), color_reset(ctx),
                        color_fg_cyan(ctx),
-                       color_bold(ctx), unique_trace_id,
-                       color_reset(ctx), color_fg_cyan(ctx),
-                       color_bold(ctx), bt_stream_class_get_id(sc),
-                       color_reset(ctx), color_fg_cyan(ctx),
-                       color_bold(ctx), bt_stream_get_id(stream),
-                       color_reset(ctx), color_fg_cyan(ctx),
-                       color_reset(ctx));
+                       color_bold(ctx), color_fg_bright_cyan(ctx),
+                       bt_stream_get_id(stream), color_reset(ctx),
+                       color_fg_cyan(ctx), color_reset(ctx));
        }
 
 end:
@@ -1822,7 +1812,7 @@ void write_field(struct details_write_ctx *ctx, const bt_field *field,
                        fmt_base = 16;
                        break;
                default:
-                       abort();
+                       bt_common_abort();
                }
 
                if (bt_field_class_type_is(fc_type,
@@ -1917,7 +1907,7 @@ void write_field(struct details_write_ctx *ctx, const bt_field *field,
                        bt_field_variant_borrow_selected_option_field_const(
                                field), NULL);
        } else {
-               abort();
+               bt_common_abort();
        }
 }
 
@@ -2135,7 +2125,7 @@ void write_trace(struct details_write_ctx *ctx, const bt_trace *trace)
                                write_str_prop_value(ctx,
                                        bt_value_string_get(value));
                        } else {
-                               abort();
+                               bt_common_abort();
                        }
 
                        write_nl(ctx);
@@ -2506,7 +2496,7 @@ int write_message_iterator_inactivity_message(struct details_write_ctx *ctx,
 {
        int ret = 0;
        const bt_clock_snapshot *cs =
-               bt_message_message_iterator_inactivity_borrow_default_clock_snapshot_const(
+               bt_message_message_iterator_inactivity_borrow_clock_snapshot_const(
                        msg);
 
        /* Write time */
@@ -2574,7 +2564,7 @@ int details_write_message(struct details_comp *details_comp,
                ret = write_discarded_packets_message(&ctx, msg);
                break;
        default:
-               abort();
+               bt_common_abort();
        }
 
        /*
This page took 0.027588 seconds and 4 git commands to generate.