mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
dirmngr: Make Assuan output of keyblocks easier readable
* dirmngr/server.c (data_line_cookie_write): Print shorter data lines in verbose mode.
This commit is contained in:
parent
3c35b46a32
commit
71b55c9455
@ -141,15 +141,45 @@ leave_cmd (assuan_context_t ctx, gpg_error_t err)
|
|||||||
/* A write handler used by es_fopencookie to write assuan data
|
/* A write handler used by es_fopencookie to write assuan data
|
||||||
lines. */
|
lines. */
|
||||||
static ssize_t
|
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;
|
assuan_context_t ctx = cookie;
|
||||||
|
const char *buffer = buffer_arg;
|
||||||
|
|
||||||
|
if (opt.verbose && buffer && size)
|
||||||
|
{
|
||||||
|
/* 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))
|
if (assuan_send_data (ctx, buffer, size))
|
||||||
{
|
{
|
||||||
gpg_err_set_errno (EIO);
|
gpg_err_set_errno (EIO);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user