.gitignore: add some missing files
[babeltrace.git] / src / common / common.h
index b447ec889e51fa68d2ed5963b073b95759aec8f2..4c91dfd649c200d51045f017cf083c5f52c4bb19 100644 (file)
@@ -5,8 +5,8 @@
  * Copyright (c) 2018 Philippe Proulx <pproulx@efficios.com>
  */
 
-#ifndef BABELTRACE_COMMON_INTERNAL_H
-#define BABELTRACE_COMMON_INTERNAL_H
+#ifndef BABELTRACE_COMMON_COMMON_H
+#define BABELTRACE_COMMON_COMMON_H
 
 #include <errno.h>
 #include <glib.h>
@@ -318,14 +318,6 @@ void bt_common_custom_vsnprintf(char *buf, size_t buf_size,
                bt_common_handle_custom_specifier_func handle_specifier,
                void *priv_data, const char *fmt, va_list *args);
 
-/*
- * Variadic form of bt_common_custom_vsnprintf().
- */
-void bt_common_custom_snprintf(char *buf, size_t buf_size,
-               char intro,
-               bt_common_handle_custom_specifier_func handle_specifier,
-               void *priv_data, const char *fmt, ...);
-
 /*
  * Returns the system page size.
  */
@@ -334,7 +326,7 @@ 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
  *
@@ -378,58 +370,6 @@ int bt_common_append_file_content_to_g_string(GString *str, FILE *fp);
 
 void bt_common_abort(void) __attribute__((noreturn));
 
-/*
- * 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)
-{
-       size_t i = 0;
-       ssize_t ret;
-
-       BT_ASSERT_DBG(buf);
-
-       /* Never return an overflow value. */
-       BT_ASSERT_DBG(count <= SSIZE_MAX);
-
-       do {
-               ret = read(fd, ((char *) buf) + i, count - i);
-               if (ret < 0) {
-                       if (errno == EINTR) {
-#ifdef BT_LOG_WRITE_CUR_LVL
-                               BT_LOG_WRITE_CUR_LVL(BT_LOG_DEBUG, log_level,
-                                       BT_LOG_TAG,
-                                       "read() call interrupted; retrying...");
-#endif
-                               /* retry operation */
-                               continue;
-                       } else {
-#ifdef BT_LOG_WRITE_ERRNO_CUR_LVL
-                               BT_LOG_WRITE_ERRNO_CUR_LVL(BT_LOG_ERROR,
-                                       log_level, BT_LOG_TAG,
-                                       "Error while reading", ": fd=%d", fd);
-#endif
-                               goto end;
-                       }
-               }
-               i += ret;
-               BT_ASSERT_DBG(i <= count);
-       } while (count - i > 0 && ret > 0);
-
-end:
-       if (ret >= 0) {
-               if (i == 0) {
-                       ret = -1;
-               } else {
-                       ret = i;
-               }
-       }
-
-       return ret;
-}
-
 static inline
 const char *bt_common_field_class_type_string(enum bt_field_class_type class_type)
 {
@@ -496,6 +436,16 @@ const char *bt_common_field_class_type_string(enum bt_field_class_type class_typ
                return "VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD";
        case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD:
                return "VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD";
+       case BT_FIELD_CLASS_TYPE_BLOB:
+               return "BT_FIELD_CLASS_TYPE_BLOB";
+       case BT_FIELD_CLASS_TYPE_STATIC_BLOB:
+               return "BT_FIELD_CLASS_TYPE_STATIC_BLOB";
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_BLOB:
+               return "BT_FIELD_CLASS_TYPE_DYNAMIC_BLOB";
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_BLOB_WITHOUT_LENGTH_FIELD:
+               return "BT_FIELD_CLASS_TYPE_DYNAMIC_BLOB_WITHOUT_LENGTH_FIELD";
+       case BT_FIELD_CLASS_TYPE_DYNAMIC_BLOB_WITH_LENGTH_FIELD:
+               return "BT_FIELD_CLASS_TYPE_DYNAMIC_BLOB_WITH_LENGTH_FIELD";
        case __BT_FIELD_CLASS_TYPE_BIG_VALUE:
                bt_common_abort ();
        }
@@ -521,7 +471,7 @@ const char *bt_common_field_class_integer_preferred_display_base_string(enum bt_
 }
 
 static inline
-const char *bt_common_scope_string(enum bt_field_path_scope scope)
+const char *bt_common_field_path_scope_string(enum bt_field_path_scope scope)
 {
        switch (scope) {
        case BT_FIELD_PATH_SCOPE_PACKET_CONTEXT:
@@ -537,6 +487,23 @@ const char *bt_common_scope_string(enum bt_field_path_scope scope)
        bt_common_abort();
 }
 
+static inline
+const char *bt_common_field_location_scope_string(enum bt_field_location_scope scope)
+{
+       switch (scope) {
+       case BT_FIELD_LOCATION_SCOPE_PACKET_CONTEXT:
+               return "PACKET_CONTEXT";
+       case BT_FIELD_LOCATION_SCOPE_EVENT_COMMON_CONTEXT:
+               return "EVENT_COMMON_CONTEXT";
+       case BT_FIELD_LOCATION_SCOPE_EVENT_SPECIFIC_CONTEXT:
+               return "EVENT_SPECIFIC_CONTEXT";
+       case BT_FIELD_LOCATION_SCOPE_EVENT_PAYLOAD:
+               return "EVENT_PAYLOAD";
+       }
+
+       bt_common_abort();
+}
+
 static inline
 const char *bt_common_event_class_log_level_string(
                enum bt_event_class_log_level level)
@@ -616,7 +583,7 @@ GString *bt_common_field_path_string(struct bt_field_path *path)
                goto end;
        }
 
-       g_string_append_printf(str, "[%s", bt_common_scope_string(
+       g_string_append_printf(str, "[%s", bt_common_field_path_scope_string(
                bt_field_path_get_root_scope(path)));
 
        for (i = 0; i < bt_field_path_get_item_count(path); i++) {
@@ -879,4 +846,4 @@ const char *bt_common_message_type_string(enum bt_message_type type)
 }
 #endif
 
-#endif /* BABELTRACE_COMMON_INTERNAL_H */
+#endif /* BABELTRACE_COMMON_COMMON_H */
This page took 0.024893 seconds and 4 git commands to generate.