dovecot-2.2: doveadm: Added doveadm_print_istream() for easily p...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Oct 23 03:39:36 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/5d3898cacf8b
changeset: 17988:5d3898cacf8b
user: Timo Sirainen <tss at iki.fi>
date: Thu Oct 23 06:37:30 2014 +0300
description:
doveadm: Added doveadm_print_istream() for easily printing istreams.
diffstat:
src/doveadm/doveadm-print.c | 21 +++++++++++++++++++++
src/doveadm/doveadm-print.h | 2 ++
2 files changed, 23 insertions(+), 0 deletions(-)
diffs (50 lines):
diff -r 43728039836c -r 5d3898cacf8b src/doveadm/doveadm-print.c
--- a/src/doveadm/doveadm-print.c Thu Oct 23 05:55:51 2014 +0300
+++ b/src/doveadm/doveadm-print.c Thu Oct 23 06:37:30 2014 +0300
@@ -2,6 +2,7 @@
#include "lib.h"
#include "array.h"
+#include "istream.h"
#include "doveadm-print-private.h"
#include <stdio.h>
@@ -101,6 +102,26 @@
}
}
+int doveadm_print_istream(struct istream *input)
+{
+ const unsigned char *data;
+ size_t size;
+ ssize_t ret;
+
+ while ((ret = i_stream_read_data(input, &data, &size, 0)) > 0) {
+ doveadm_print_stream(data, size);
+ i_stream_skip(input, size);
+ }
+ i_assert(ret == -1);
+ doveadm_print_stream("", 0);
+ if (input->stream_errno != 0) {
+ i_error("read(%s) failed: %s", i_stream_get_name(input),
+ i_stream_get_error(input));
+ return -1;
+ }
+ return 0;
+}
+
void doveadm_print_sticky(const char *key, const char *value)
{
struct doveadm_print_header_context *hdr;
diff -r 43728039836c -r 5d3898cacf8b src/doveadm/doveadm-print.h
--- a/src/doveadm/doveadm-print.h Thu Oct 23 05:55:51 2014 +0300
+++ b/src/doveadm/doveadm-print.h Thu Oct 23 06:37:30 2014 +0300
@@ -23,6 +23,8 @@
void doveadm_print_num(uintmax_t value);
/* Stream for same field continues until len=0 */
void doveadm_print_stream(const void *value, size_t size);
+/* Print the whole input stream. Returns 0 if ok, -1 if stream read() failed */
+int doveadm_print_istream(struct istream *input);
void doveadm_print_sticky(const char *key, const char *value);
void doveadm_print_flush(void);
void doveadm_print_unstick_headers(void);
More information about the dovecot-cvs
mailing list