Browse Source

tweak debug output for IMAP literals

- short literals are now printed even with only -Dn.
  this ensures that we see all parts of, for example, LIST responses.
  we use xprintf() for that, so we don't mess up the -Dn output in case
  the literal contains something unexpected (we don't care with -DN).
- omitted bytes are now indicated.
- missing trailing newlines are now "pretty-printed".
- long literals are now printed in chunks as we receive them. this
  makes the output messier, but it's necessary for an upcoming change,
  and, on the upside, we'll get better indication when the transfer
  gets stuck in the middle of a message.
wip/maildir-path-under-inbox
Oswald Buddenhagen 3 years ago
parent
commit
f748bd45df
  1. 30
      src/drv_imap.c

30
src/drv_imap.c

@ -356,10 +356,14 @@ send_imap_cmd( imap_store_t *ctx, imap_cmd_t *cmd )
iov[2].len = 2; iov[2].len = 2;
iov[2].takeOwn = KeepOwn; iov[2].takeOwn = KeepOwn;
if (litplus) { if (litplus) {
if (DFlags & DEBUG_NET) {
if (DFlags & DEBUG_NET_ALL) { if (DFlags & DEBUG_NET_ALL) {
printf( "%s>>>>>>>>>\n", ctx->label ); printf( "%s>>>>>>>>>\n", ctx->label );
fwrite( cmd->param.data, cmd->param.data_len, 1, stdout ); fwrite( cmd->param.data, cmd->param.data_len, 1, stdout );
printf( "%s>>>>>>>>>\n", ctx->label ); printf( "%s>>>>>>>>>\n", ctx->label );
} else {
printf( "%s>>>>> (%u bytes omitted)\n", ctx->label, cmd->param.data_len );
}
fflush( stdout ); fflush( stdout );
} }
iov[3].buf = cmd->param.data; iov[3].buf = cmd->param.data;
@ -788,18 +792,24 @@ parse_imap_list( imap_store_t *ctx, char **sp, parse_list_state_t *sts )
sts->err = "unexpected EOF"; sts->err = "unexpected EOF";
goto bail; goto bail;
} }
memcpy( s, p, n ); if (DFlags & DEBUG_NET) {
bytes -= n; if (cur->len < 64) {
if (bytes > 0) xprintf( "%s%.*!s\n", ctx->label, (int)n, p );
goto postpone; } else if (DFlags & DEBUG_NET_ALL) {
if (DFlags & DEBUG_NET_ALL) {
printf( "%s=========\n", ctx->label ); printf( "%s=========\n", ctx->label );
fwrite( cur->val, cur->len, 1, stdout ); fwrite( p, n, 1, stdout );
if (p[n - 1] != '\n')
fputs( "\n(no-nl) ", stdout );
printf( "%s=========\n", ctx->label ); printf( "%s=========\n", ctx->label );
} else {
printf( "%s=== (%u bytes omitted)\n", ctx->label, n );
}
fflush( stdout ); fflush( stdout );
} }
memcpy( s, p, n );
bytes -= n;
if (bytes > 0)
goto postpone;
getline: getline:
if (!(s = socket_read_line( &ctx->conn ))) if (!(s = socket_read_line( &ctx->conn )))
goto postpone; goto postpone;
@ -1614,10 +1624,14 @@ imap_socket_read( void *aux )
if (cmdp->param.data) { if (cmdp->param.data) {
if (cmdp->param.to_trash) if (cmdp->param.to_trash)
ctx->trashnc = TrashKnown; /* Can't get NO [TRYCREATE] any more. */ ctx->trashnc = TrashKnown; /* Can't get NO [TRYCREATE] any more. */
if (DFlags & DEBUG_NET) {
if (DFlags & DEBUG_NET_ALL) { if (DFlags & DEBUG_NET_ALL) {
printf( "%s>>>>>>>>>\n", ctx->label ); printf( "%s>>>>>>>>>\n", ctx->label );
fwrite( cmdp->param.data, cmdp->param.data_len, 1, stdout ); fwrite( cmdp->param.data, cmdp->param.data_len, 1, stdout );
printf( "%s>>>>>>>>>\n", ctx->label ); printf( "%s>>>>>>>>>\n", ctx->label );
} else {
printf( "%s>>>>> (%u bytes omitted)\n", ctx->label, cmdp->param.data_len );
}
fflush( stdout ); fflush( stdout );
} }
iov[0].buf = cmdp->param.data; iov[0].buf = cmdp->param.data;

Loading…
Cancel
Save