Add bt_common_fold()
[babeltrace.git] / src / common / common.h
index 809c2e5063556a3ec500d60694794a9bf8264ce4..0f2736f00642782a3588b7675b94e7c97e136342 100644 (file)
@@ -331,6 +331,23 @@ size_t bt_common_get_page_size(int log_level);
 BT_HIDDEN
 void bt_common_sep_digits(char *str, unsigned int digits_per_group, char sep);
 
+/*
+ * This is similar to what the command `fold --spaces` does: it wraps
+ * the input lines of `str`, breaking at spaces, and indenting each line
+ * with `indent` spaces so that each line fits the total length
+ * `total_length`.
+ *
+ * If an original line in `str` contains a word which is >= the content
+ * length (`total_length - indent`), then the corresponding folded line
+ * is also larger than the content length. In other words, breaking at
+ * spaces is a best effort, but it might not be possible.
+ *
+ * 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);
+
 /*
  * Wraps read() function to handle EINTR and partial reads.
  * On success, it returns `count` received as parameter. On error, it returns a
This page took 0.023486 seconds and 4 git commands to generate.