diff --git a/appl/push/push.c b/appl/push/push.c index 18123c4a3..8796ac5fc 100644 --- a/appl/push/push.c +++ b/appl/push/push.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2001 Kungliga Tekniska Högskolan + * Copyright (c) 1997-2001, 2003 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -137,6 +137,11 @@ do_connect (const char *hostname, int port, int nodelay) typedef enum { INIT = 0, GREET, USER, PASS, STAT, RETR, TOP, DELE, XDELE, QUIT} pop_state; +static char *pop_state_string[] = { + "INIT", "GREET", "USER", "PASS", "STAT", "RETR", "TOP", + "DELE", "XDELE", "QUIT" +}; + #define PUSH_BUFSIZ 65536 #define STEP 16 @@ -267,7 +272,7 @@ doit(int s, if (net_write (s, out_buf, out_len) != out_len) err (1, "write"); if (verbose > 1) - write (STDERR_FILENO, out_buf, out_len); + fprintf (stderr, "%s", out_buf); if (!do_from) write_state_init (&write_state, out_fd); @@ -280,6 +285,13 @@ doit(int s, if (s >= FD_SETSIZE) errx (1, "fd too large"); FD_SET(s,&readset); + + if (verbose > 1) + fprintf (stderr, "state: %s count: %d asked_for: %d " + "retrieved: %d asked_deleted: %d\n", + pop_state_string[state], + count, asked_for, retrieved, asked_deleted); + if (((state == STAT || state == RETR || state == TOP) && asked_for < count) || (state == XDELE && !sent_xdele) @@ -331,7 +343,7 @@ doit(int s, state = QUIT; net_write (s, "QUIT\r\n", 6); if (verbose > 1) - net_write (STDERR_FILENO, "QUIT\r\n", 6); + fprintf (stderr, "QUIT\r\n"); } } rem -= p - beg + 2; @@ -354,7 +366,7 @@ doit(int s, state = QUIT; net_write (s, "QUIT\r\n", 6); if (verbose > 1) - net_write (STDERR_FILENO, "QUIT\r\n", 6); + fprintf (stderr, "QUIT\r\n"); } else { if (forkp) { pid_t pid; @@ -401,14 +413,14 @@ doit(int s, state = QUIT; net_write (s, "QUIT\r\n", 6); if (verbose > 1) - net_write (STDERR_FILENO, "QUIT\r\n", 6); + fprintf (stderr, "QUIT\r\n"); break; } else if (state == DELE) { if (++deleted == count) { state = QUIT; net_write (s, "QUIT\r\n", 6); if (verbose > 1) - net_write (STDERR_FILENO, "QUIT\r\n", 6); + fprintf (stderr, "QUIT\r\n", 6); break; } } else if (++state == STAT) { @@ -428,7 +440,7 @@ doit(int s, state = QUIT; net_write (s, "QUIT\r\n", 6); if (verbose > 1) - net_write (STDERR_FILENO, "QUIT\r\n", 6); + fprintf (stderr, "QUIT\r\n"); break; } } @@ -471,7 +483,7 @@ doit(int s, if (net_write (s, out_buf, out_len) != out_len) err (1, "write"); if (verbose > 1) - write (STDERR_FILENO, out_buf, out_len); + fprintf (stderr, "%s", out_buf); } } if (verbose)