Fix typos
[babeltrace.git] / src / common / common.h
index 2cad30767a28fad9581130c6c53e8f6e40e3ba3f..f546b6314f3fb17b24f8b2fe6b427adb3955659b 100644 (file)
@@ -113,14 +113,12 @@ struct bt_common_lttng_live_url_parts {
  * Checks if the current process has setuid or setgid access rights.
  * Returns `true` if so.
  */
-BT_HIDDEN
 bool bt_common_is_setuid_setgid(void);
 
 /*
  * Returns the system-wide plugin path, e.g.
  * `/usr/lib/babeltrace2/plugins`. Do not free the return value.
  */
-BT_HIDDEN
 const char *bt_common_get_system_plugin_path(void);
 
 /*
@@ -128,7 +126,6 @@ const char *bt_common_get_system_plugin_path(void);
  * `/home/user/.local/lib/babeltrace2/plugins`. You need to free the
  * return value.
  */
-BT_HIDDEN
 char *bt_common_get_home_plugin_path(int log_level);
 
 /*
@@ -136,92 +133,64 @@ char *bt_common_get_home_plugin_path(int log_level);
  * `paths` is a list of directories separated by `:`. Returns 0 on
  * success.
  */
-BT_HIDDEN
 int bt_common_append_plugin_path_dirs(const char *paths, GPtrArray *dirs);
 
 /*
  * Returns `true` if terminal color codes are supported for this
  * process.
  */
-BT_HIDDEN
 bool bt_common_colors_supported(void);
 
-BT_HIDDEN
 const char *bt_common_color_reset(void);
 
-BT_HIDDEN
 const char *bt_common_color_bold(void);
 
-BT_HIDDEN
 const char *bt_common_color_fg_default(void);
 
-BT_HIDDEN
 const char *bt_common_color_fg_red(void);
 
-BT_HIDDEN
 const char *bt_common_color_fg_green(void);
 
-BT_HIDDEN
 const char *bt_common_color_fg_yellow(void);
 
-BT_HIDDEN
 const char *bt_common_color_fg_blue(void);
 
-BT_HIDDEN
 const char *bt_common_color_fg_magenta(void);
 
-BT_HIDDEN
 const char *bt_common_color_fg_cyan(void);
 
-BT_HIDDEN
 const char *bt_common_color_fg_light_gray(void);
 
-BT_HIDDEN
 const char *bt_common_color_fg_bright_red(void);
 
-BT_HIDDEN
 const char *bt_common_color_fg_bright_green(void);
 
-BT_HIDDEN
 const char *bt_common_color_fg_bright_yellow(void);
 
-BT_HIDDEN
 const char *bt_common_color_fg_bright_blue(void);
 
-BT_HIDDEN
 const char *bt_common_color_fg_bright_magenta(void);
 
-BT_HIDDEN
 const char *bt_common_color_fg_bright_cyan(void);
 
-BT_HIDDEN
 const char *bt_common_color_fg_bright_light_gray(void);
 
-BT_HIDDEN
 const char *bt_common_color_bg_default(void);
 
-BT_HIDDEN
 const char *bt_common_color_bg_red(void);
 
-BT_HIDDEN
 const char *bt_common_color_bg_green(void);
 
-BT_HIDDEN
 const char *bt_common_color_bg_yellow(void);
 
-BT_HIDDEN
 const char *bt_common_color_bg_blue(void);
 
-BT_HIDDEN
 const char *bt_common_color_bg_magenta(void);
 
-BT_HIDDEN
 const char *bt_common_color_bg_cyan(void);
 
-BT_HIDDEN
 const char *bt_common_color_bg_light_gray(void);
 
-BT_HIDDEN
 void bt_common_color_get_codes(struct bt_common_color_codes *codes,
                enum bt_common_color_when use_colors);
 
@@ -231,7 +200,6 @@ void bt_common_color_get_codes(struct bt_common_color_codes *codes,
  * found in `escapable_chars`, and sets `*end_pos` to the position of
  * the end (from `input`). The caller owns the returned GString.
  */
-BT_HIDDEN
 GString *bt_common_string_until(const char *input, const char *escapable_chars,
                     const char *end_chars, size_t *end_pos);
 
@@ -242,21 +210,18 @@ GString *bt_common_string_until(const char *input, const char *escapable_chars,
  * prepend and append them manually, although they are not always
  * required. The caller owns the returned GString.
  */
-BT_HIDDEN
 GString *bt_common_shell_quote(const char *input, bool with_single_quotes);
 
 /*
  * Returns `true` if `input` is a string made only of printable
  * characters.
  */
-BT_HIDDEN
 bool bt_common_string_is_printable(const char *input);
 
 /*
  * Destroys the parts of an LTTng live URL as returned by
  * bt_common_parse_lttng_live_url().
  */
-BT_HIDDEN
 void bt_common_destroy_lttng_live_url_parts(
                struct bt_common_lttng_live_url_parts *parts);
 
@@ -266,7 +231,6 @@ void bt_common_destroy_lttng_live_url_parts(
  * up to `error_buf_size` bytes. You must destroy the returned value
  * with bt_common_destroy_lttng_live_url_parts().
  */
-BT_HIDDEN
 struct bt_common_lttng_live_url_parts bt_common_parse_lttng_live_url(
                const char *url, char *error_buf, size_t error_buf_size);
 
@@ -274,14 +238,12 @@ struct bt_common_lttng_live_url_parts bt_common_parse_lttng_live_url(
  * Normalizes (in place) a star globbing pattern to be used with
  * bt_common_star_glob_match(). This function always succeeds.
  */
-BT_HIDDEN
 void bt_common_normalize_star_glob_pattern(char *pattern);
 
 /*
  * Returns `true` if `candidate` (of size `candidate_len`) matches
  * the star globbing pattern `pattern` (of size `pattern_len`).
  */
-BT_HIDDEN
 bool bt_common_star_glob_match(const char *pattern, size_t pattern_len,
                 const char *candidate, size_t candidate_len);
 
@@ -297,7 +259,6 @@ bool bt_common_star_glob_match(const char *pattern, size_t pattern_len,
  *
  * The caller owns the returned GString.
  */
-BT_HIDDEN
 GString *bt_common_normalize_path(const char *path, const char *wd);
 
 typedef void (* bt_common_handle_custom_specifier_func)(void *priv_data,
@@ -352,7 +313,6 @@ typedef void (* bt_common_handle_custom_specifier_func)(void *priv_data,
  * do not return error codes: they abort when there's any error (bad
  * format string, for example).
  */
-BT_HIDDEN
 void bt_common_custom_vsnprintf(char *buf, size_t buf_size,
                char intro,
                bt_common_handle_custom_specifier_func handle_specifier,
@@ -361,7 +321,6 @@ void bt_common_custom_vsnprintf(char *buf, size_t buf_size,
 /*
  * Variadic form of bt_common_custom_vsnprintf().
  */
-BT_HIDDEN
 void bt_common_custom_snprintf(char *buf, size_t buf_size,
                char intro,
                bt_common_handle_custom_specifier_func handle_specifier,
@@ -370,13 +329,12 @@ void bt_common_custom_snprintf(char *buf, size_t buf_size,
 /*
  * Returns the system page size.
  */
-BT_HIDDEN
 size_t bt_common_get_page_size(int log_level);
 
 /*
  * Adds the digit separator `sep` as many times as needed to form groups
  * of `digits_per_group` digits within `str`. `str` must have enough
- * room to accomodate the new separators, that is:
+ * room to accommodate the new separators, that is:
  *
  *     strlen(str) + (strlen(str) / digits_per_group) + 1
  *
@@ -386,7 +344,6 @@ size_t bt_common_get_page_size(int log_level);
  * `strlen(str)` must not be 0. `digits_per_group` must not be 0. `sep`
  * must not be `\0`.
  */
-BT_HIDDEN
 void bt_common_sep_digits(char *str, unsigned int digits_per_group, char sep);
 
 /*
@@ -402,7 +359,6 @@ void bt_common_sep_digits(char *str, unsigned int digits_per_group, char sep);
  *
  * The returned string, on success, is owned by the caller.
  */
-BT_HIDDEN
 GString *bt_common_fold(const char *str, unsigned int total_length,
                unsigned int indent);
 
@@ -410,7 +366,6 @@ GString *bt_common_fold(const char *str, unsigned int total_length,
  * Writes the terminal's width to `*width`, its height to `*height`,
  * and returns 0 on success, or returns -1 on error.
  */
-BT_HIDDEN
 int bt_common_get_term_size(unsigned int *width, unsigned int *height);
 
 /*
@@ -419,19 +374,24 @@ int bt_common_get_term_size(unsigned int *width, unsigned int *height);
  *
  * This function does NOT rewind `fp` once it's done or on error.
  */
-BT_HIDDEN
 int bt_common_append_file_content_to_g_string(GString *str, FILE *fp);
 
-BT_HIDDEN
 void bt_common_abort(void) __attribute__((noreturn));
 
+#if (!defined(BT_LOG_WRITE_CUR_LVL) && !defined(BT_LOG_WRITE_ERRNO_CUR_LVL))
+#define BT_LOG_LEVEL_UNUSED_ATTR __attribute__((unused))
+#else
+#define BT_LOG_LEVEL_UNUSED_ATTR
+#endif
+
 /*
  * Wraps read() function to handle EINTR and partial reads.
  * On success, it returns `count` received as parameter. On error, it returns a
  * value smaller than the requested `count`.
  */
 static inline
-ssize_t bt_common_read(int fd, void *buf, size_t count, int log_level)
+ssize_t bt_common_read(int fd, void *buf, size_t count,
+               int log_level BT_LOG_LEVEL_UNUSED_ATTR)
 {
        size_t i = 0;
        ssize_t ret;
@@ -453,8 +413,8 @@ ssize_t bt_common_read(int fd, void *buf, size_t count, int log_level)
                                /* retry operation */
                                continue;
                        } else {
-#ifdef BT_LOG_WRITE_ERRNO_CUR_LVL
-                               BT_LOG_WRITE_ERRNO_CUR_LVL(BT_LOG_ERROR,
+#ifdef BT_LOG_WRITE_ERRNO_PRINTF_CUR_LVL
+                               BT_LOG_WRITE_ERRNO_PRINTF_CUR_LVL(BT_LOG_ERROR,
                                        log_level, BT_LOG_TAG,
                                        "Error while reading", ": fd=%d", fd);
 #endif
@@ -719,8 +679,6 @@ const char *bt_common_func_status_string(int status)
        switch (status) {
        case __BT_FUNC_STATUS_OVERFLOW_ERROR:
                return "OVERFLOW";
-       case __BT_FUNC_STATUS_UNKNOWN_OBJECT:
-               return "UNKNOWN_OBJECT";
        case __BT_FUNC_STATUS_MEMORY_ERROR:
                return "MEMORY_ERROR";
        case __BT_FUNC_STATUS_USER_ERROR:
@@ -733,10 +691,14 @@ const char *bt_common_func_status_string(int status)
                return "END";
        case __BT_FUNC_STATUS_NOT_FOUND:
                return "NOT_FOUND";
-       case __BT_FUNC_STATUS_AGAIN:
-               return "AGAIN";
        case __BT_FUNC_STATUS_INTERRUPTED:
                return "INTERRUPTED";
+       case __BT_FUNC_STATUS_NO_MATCH:
+               return "NO_MATCH";
+       case __BT_FUNC_STATUS_AGAIN:
+               return "AGAIN";
+       case __BT_FUNC_STATUS_UNKNOWN_OBJECT:
+               return "UNKNOWN_OBJECT";
        }
 
        bt_common_abort();
@@ -837,7 +799,7 @@ end:
  * bt_g_string_append_printf cannot be inlined because it expects a
  * variadic argument list.
  */
-BT_HIDDEN __BT_ATTR_FORMAT_PRINTF(2, 3)
+__BT_ATTR_FORMAT_PRINTF(2, 3)
 int bt_common_g_string_append_printf(GString *str, const char *fmt, ...);
 
 static inline
@@ -895,6 +857,31 @@ const char *bt_common_component_class_type_string(
        bt_common_abort();
 }
 
+static inline
+const char *bt_common_message_type_string(enum bt_message_type type)
+{
+       switch (type) {
+       case BT_MESSAGE_TYPE_STREAM_BEGINNING:
+               return "STREAM_BEGINNING";
+       case BT_MESSAGE_TYPE_STREAM_END:
+               return "STREAM_END";
+       case BT_MESSAGE_TYPE_EVENT:
+               return "EVENT";
+       case BT_MESSAGE_TYPE_PACKET_BEGINNING:
+               return "PACKET_BEGINNING";
+       case BT_MESSAGE_TYPE_PACKET_END:
+               return "PACKET_END";
+       case BT_MESSAGE_TYPE_DISCARDED_EVENTS:
+               return "DISCARDED_EVENTS";
+       case BT_MESSAGE_TYPE_DISCARDED_PACKETS:
+               return "DISCARDED_PACKETS";
+       case BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY:
+               return "MESSAGE_ITERATOR_INACTIVITY";
+       }
+
+       bt_common_abort();
+}
+
 #ifdef __cplusplus
 }
 #endif
This page took 0.031338 seconds and 4 git commands to generate.