dovecot-2.1: doveadm: table formatter supports now writing by st...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Dec 8 10:48:30 EET 2012
details: http://hg.dovecot.org/dovecot-2.1/rev/c1e47738e7c3
changeset: 14841:c1e47738e7c3
user: Timo Sirainen <tss at iki.fi>
date: Sat Dec 08 10:48:23 2012 +0200
description:
doveadm: table formatter supports now writing by streaming.
This fixes it to work with doveadm server, which sometimes may use
streaming.
diffstat:
src/doveadm/doveadm-print-table.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diffs (56 lines):
diff -r f74f1b14975d -r c1e47738e7c3 src/doveadm/doveadm-print-table.c
--- a/src/doveadm/doveadm-print-table.c Sat Dec 08 10:43:21 2012 +0200
+++ b/src/doveadm/doveadm-print-table.c Sat Dec 08 10:48:23 2012 +0200
@@ -2,6 +2,7 @@
#include "lib.h"
#include "array.h"
+#include "str.h"
#include "doveadm-print-private.h"
#include <stdio.h>
@@ -24,6 +25,7 @@
pool_t pool;
ARRAY_DEFINE(headers, struct doveadm_print_table_header);
ARRAY_TYPE(const_string) buffered_values;
+ string_t *stream;
unsigned int hdr_idx;
unsigned int columns;
@@ -179,10 +181,17 @@
}
static void
-doveadm_print_table_print_stream(const unsigned char *value ATTR_UNUSED,
- size_t size ATTR_UNUSED)
+doveadm_print_table_print_stream(const unsigned char *value, size_t size)
{
- i_fatal("table formatter doesn't support multi-line values");
+ if (memchr(value, '\n', size) != NULL)
+ i_fatal("table formatter doesn't support multi-line values");
+
+ if (size != 0)
+ str_append_n(ctx->stream, value, size);
+ else {
+ doveadm_print_table_print(str_c(ctx->stream));
+ str_truncate(ctx->stream, 0);
+ }
}
static void doveadm_print_table_flush(void)
@@ -199,6 +208,7 @@
pool = pool_alloconly_create("doveadm print table", 2048);
ctx = p_new(pool, struct doveadm_print_table_context, 1);
ctx->pool = pool;
+ ctx->stream = str_new(default_pool, 128);
p_array_init(&ctx->headers, pool, 16);
i_array_init(&ctx->buffered_values, 64);
ctx->columns = DEFAULT_COLUMNS;
@@ -211,6 +221,7 @@
static void doveadm_print_table_deinit(void)
{
+ str_free(&ctx->stream);
array_free(&ctx->buffered_values);
pool_unref(&ctx->pool);
ctx = NULL;
More information about the dovecot-cvs
mailing list