diff options
author | Werner Koch <wk@gnupg.org> | 2014-03-11 14:27:58 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2014-03-11 16:30:36 +0100 |
commit | 71b55c945542e695161ddbd783f87c5f534012a5 (patch) | |
tree | 511c409c6a4afdf9a6dbbbcdb663b046e3b3de03 /dirmngr | |
parent | dirmngr: Fix HKP host selection code. (diff) | |
download | gnupg2-71b55c945542e695161ddbd783f87c5f534012a5.tar.xz gnupg2-71b55c945542e695161ddbd783f87c5f534012a5.zip |
dirmngr: Make Assuan output of keyblocks easier readable
* dirmngr/server.c (data_line_cookie_write): Print shorter data lines
in verbose mode.
Diffstat (limited to 'dirmngr')
-rw-r--r-- | dirmngr/server.c | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/dirmngr/server.c b/dirmngr/server.c index 9a0244195..d2682eaaa 100644 --- a/dirmngr/server.c +++ b/dirmngr/server.c @@ -141,14 +141,44 @@ leave_cmd (assuan_context_t ctx, gpg_error_t err) /* A write handler used by es_fopencookie to write assuan data lines. */ static ssize_t -data_line_cookie_write (void *cookie, const void *buffer, size_t size) +data_line_cookie_write (void *cookie, const void *buffer_arg, size_t size) { assuan_context_t ctx = cookie; + const char *buffer = buffer_arg; - if (assuan_send_data (ctx, buffer, size)) + if (opt.verbose && buffer && size) { - gpg_err_set_errno (EIO); - return -1; + /* Ease reading of output by sending a physical line at each LF. */ + const char *p; + size_t n, nbytes; + + nbytes = size; + do + { + p = memchr (buffer, '\n', nbytes); + n = p ? (p - buffer) + 1 : nbytes; + if (assuan_send_data (ctx, buffer, n)) + { + gpg_err_set_errno (EIO); + return -1; + } + buffer += n; + nbytes -= n; + if (nbytes && assuan_send_data (ctx, NULL, 0)) /* Flush line. */ + { + gpg_err_set_errno (EIO); + return -1; + } + } + while (nbytes); + } + else + { + if (assuan_send_data (ctx, buffer, size)) + { + gpg_err_set_errno (EIO); + return -1; + } } return size; |