- improve console output

This commit is contained in:
Oswald Buddenhagen 2002-12-28 03:58:01 +00:00
parent d850150719
commit 095e3ec92c
2 changed files with 18 additions and 27 deletions

View File

@ -284,6 +284,10 @@ buffer_gets (buffer_t * b, char **s)
{ {
b->buf[b->offset] = 0; /* terminate the string */ b->buf[b->offset] = 0; /* terminate the string */
b->offset += 2; /* next line */ b->offset += 2; /* next line */
if (Verbose) {
puts (*s);
fflush (stdout);
}
return 0; return 0;
} }
} }
@ -425,8 +429,10 @@ imap_exec (imap_t * imap, const char *fmt, ...)
va_end (ap); va_end (ap);
snprintf (buf, sizeof (buf), "%d %s\r\n", ++Tag, tmp); snprintf (buf, sizeof (buf), "%d %s\r\n", ++Tag, tmp);
if (Verbose) if (Verbose) {
printf (">>> %s", buf); printf (">>> %s", buf);
fflush (stdout);
}
n = socket_write (imap->sock, buf, strlen (buf)); n = socket_write (imap->sock, buf, strlen (buf));
if (n <= 0) if (n <= 0)
{ {
@ -439,8 +445,6 @@ imap_exec (imap_t * imap, const char *fmt, ...)
next: next:
if (buffer_gets (imap->buf, &cmd)) if (buffer_gets (imap->buf, &cmd))
return -1; return -1;
if (Verbose)
puts (cmd);
arg = next_arg (&cmd); arg = next_arg (&cmd);
if (*arg == '*') if (*arg == '*')
@ -550,21 +554,23 @@ imap_exec (imap_t * imap, const char *fmt, ...)
} }
resp = cram (cmd, imap->box->user, imap->box->pass); resp = cram (cmd, imap->box->user, imap->box->pass);
if (Verbose) {
printf (">+> %s\n", resp);
fflush (stdout);
}
n = socket_write (imap->sock, resp, strlen (resp)); n = socket_write (imap->sock, resp, strlen (resp));
free (resp);
if (n <= 0) if (n <= 0)
{ {
socket_perror ("write", imap->sock, n); socket_perror ("write", imap->sock, n);
return -1; return -1;
} }
if (Verbose)
puts (resp);
n = socket_write (imap->sock, "\r\n", 2); n = socket_write (imap->sock, "\r\n", 2);
if (n <= 0) if (n <= 0)
{ {
socket_perror ("write", imap->sock, n); socket_perror ("write", imap->sock, n);
return -1; return -1;
} }
free (resp);
imap->cram = 0; imap->cram = 0;
} }
#endif #endif
@ -677,8 +683,6 @@ imap_connect (config_t * cfg)
fprintf (stderr, "IMAP error: no greeting response\n"); fprintf (stderr, "IMAP error: no greeting response\n");
goto bail; goto bail;
} }
if (Verbose)
puts (rsp);
arg = next_arg (&rsp); arg = next_arg (&rsp);
if (!arg || *arg != '*' || (arg = next_arg (&rsp)) == NULL) if (!arg || *arg != '*' || (arg = next_arg (&rsp)) == NULL)
{ {
@ -981,6 +985,10 @@ send_server (Socket_t * sock, const char *fmt, ...)
va_end (ap); va_end (ap);
snprintf (cmd, sizeof (cmd), "%d %s\r\n", ++Tag, buf); snprintf (cmd, sizeof (cmd), "%d %s\r\n", ++Tag, buf);
if (Verbose) {
printf (">>> %s", cmd);
fflush (stdout);
}
n = socket_write (sock, cmd, strlen (cmd)); n = socket_write (sock, cmd, strlen (cmd));
if (n <= 0) if (n <= 0)
{ {
@ -988,9 +996,6 @@ send_server (Socket_t * sock, const char *fmt, ...)
return -1; return -1;
} }
if (Verbose)
fputs (cmd, stdout);
return 0; return 0;
} }
@ -1009,10 +1014,6 @@ imap_fetch_message (imap_t * imap, unsigned int uid, int fd)
{ {
if (buffer_gets (imap->buf, &cmd)) if (buffer_gets (imap->buf, &cmd))
return -1; return -1;
if (Verbose)
puts (cmd);
if (*cmd == '*') if (*cmd == '*')
{ {
/* need to figure out how long the message is /* need to figure out how long the message is
@ -1094,8 +1095,6 @@ imap_fetch_message (imap_t * imap, unsigned int uid, int fd)
} }
buffer_gets (imap->buf, &cmd); buffer_gets (imap->buf, &cmd);
if (Verbose)
puts (cmd); /* last part of line */
} }
else else
{ {
@ -1224,8 +1223,6 @@ imap_append_message (imap_t * imap, int fd, message_t * msg)
if (buffer_gets (imap->buf, &s)) if (buffer_gets (imap->buf, &s))
goto bail; goto bail;
if (Verbose)
puts (s);
if (*s != '+') if (*s != '+')
{ {
@ -1267,9 +1264,6 @@ imap_append_message (imap_t * imap, int fd, message_t * msg)
if (buffer_gets (imap->buf, &s)) if (buffer_gets (imap->buf, &s))
return -1; return -1;
if (Verbose)
puts (s);
arg = next_arg (&s); arg = next_arg (&s);
if (*arg == '*') if (*arg == '*')
{ {
@ -1325,9 +1319,6 @@ imap_append_message (imap_t * imap, int fd, message_t * msg)
if (buffer_gets (imap->buf, &s)) if (buffer_gets (imap->buf, &s))
return -1; return -1;
if (Verbose)
puts (s);
arg = next_arg (&s); arg = next_arg (&s);
if (*arg == '*') if (*arg == '*')
{ {

View File

@ -257,7 +257,7 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags,
if (upload) if (upload)
info (" %d messages.\n", upload); info (" %d messages.\n", upload);
info ("Fetching new messages"); info ("Fetching new messages...");
fflush (stdout); fflush (stdout);
if (max_msgs == 0) if (max_msgs == 0)