+
+/** 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;
+};
+
+/**
+ * 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, ...) (\
+{ \
+ int _ret; \
+ if ((b)->flags & PBF_SIZE_PREFIX) { \
+ _ret = para_printf((b), "%02x:" f, n, ## __VA_ARGS__); \
+ } else { \
+ _ret = para_printf((b), "%s: " f, status_item_list[(n)], \
+ ## __VA_ARGS__); \
+ } \
+ _ret; \
+} \
+)
+