+/** \file string.h exported symbols from string.c */
+
+/** Flags that change how content is printed into the buffer. */
+enum para_buffer_flags {
+ /** Prefix each buffer with its length. */
+ PBF_SIZE_PREFIX = 1,
+};
+
+/** A string buffer used for para_printf(). */
+struct para_buffer {
+ /** The buffer. May be \p NULL. */
+ char *buf;
+ /** The size of \a buf. */
+ size_t size;
+ /** The maximal size this buffer may grow. Zero means unlimited. */
+ size_t max_size;
+ /** \sa para_buffer_flags. */
+ unsigned flags;
+ /** The next para_printf() will write at this offset. */
+ size_t offset;
+ /**
+ * If an attempt to print into this buffer is made that would need to
+ * grow \a buf to a size larger than \a max_size, then this function is
+ * called.
+ */
+ int (*max_size_handler)(char *buf, size_t size, void *private_data);
+ /** Passed to max_size_handler(). */
+ void *private_data;
+};
+
+/**
+ * Controls the behavior of for_each_line().
+ *
+ * \sa for_each_line().
+ */
+enum for_each_line_flags {
+ /** Activate read-only mode. */
+ FELF_READ_ONLY = 1 << 0,
+ /** Don't call line handler for the first input line. */
+ FELF_DISCARD_FIRST = 1 << 1,
+};
+
+/** Used for \ref for_each_line(). */
+typedef int line_handler_t(char *, void *);
+int for_each_line(unsigned flags, char *buf, size_t size,
+ line_handler_t *line_handler, void *private_data);
+
+/**
+ * Write the contents of a status item to a para_buffer.
+ *
+ * \param b The para_buffer.
+ * \param n The number of the status item.
+ * \param f A format string.
+ *
+ * \return The return value of the underlying call to para_printf().
+ */
+#define WRITE_STATUS_ITEM(b, n, f, ...) (\
+{ \
+ if ((b)->flags & PBF_SIZE_PREFIX) { \
+ para_printf((b), "%02x:" f, (unsigned)n, ## __VA_ARGS__); \
+ } else { \
+ para_printf((b), "%s: " f, status_item_list[(n)], \
+ ## __VA_ARGS__); \
+ } \
+} \
+)