add names of pop states, add some more debugging and use

fprintf(stderr) for all dbg stmts.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11875 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2003-03-18 18:21:28 +00:00
parent b88f38d522
commit db5235baa9

View File

@@ -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). * (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved. * 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, typedef enum { INIT = 0, GREET, USER, PASS, STAT, RETR, TOP,
DELE, XDELE, QUIT} pop_state; 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 PUSH_BUFSIZ 65536
#define STEP 16 #define STEP 16
@@ -267,7 +272,7 @@ doit(int s,
if (net_write (s, out_buf, out_len) != out_len) if (net_write (s, out_buf, out_len) != out_len)
err (1, "write"); err (1, "write");
if (verbose > 1) if (verbose > 1)
write (STDERR_FILENO, out_buf, out_len); fprintf (stderr, "%s", out_buf);
if (!do_from) if (!do_from)
write_state_init (&write_state, out_fd); write_state_init (&write_state, out_fd);
@@ -280,6 +285,13 @@ doit(int s,
if (s >= FD_SETSIZE) if (s >= FD_SETSIZE)
errx (1, "fd too large"); errx (1, "fd too large");
FD_SET(s,&readset); 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) if (((state == STAT || state == RETR || state == TOP)
&& asked_for < count) && asked_for < count)
|| (state == XDELE && !sent_xdele) || (state == XDELE && !sent_xdele)
@@ -331,7 +343,7 @@ doit(int s,
state = QUIT; state = QUIT;
net_write (s, "QUIT\r\n", 6); net_write (s, "QUIT\r\n", 6);
if (verbose > 1) if (verbose > 1)
net_write (STDERR_FILENO, "QUIT\r\n", 6); fprintf (stderr, "QUIT\r\n");
} }
} }
rem -= p - beg + 2; rem -= p - beg + 2;
@@ -354,7 +366,7 @@ doit(int s,
state = QUIT; state = QUIT;
net_write (s, "QUIT\r\n", 6); net_write (s, "QUIT\r\n", 6);
if (verbose > 1) if (verbose > 1)
net_write (STDERR_FILENO, "QUIT\r\n", 6); fprintf (stderr, "QUIT\r\n");
} else { } else {
if (forkp) { if (forkp) {
pid_t pid; pid_t pid;
@@ -401,14 +413,14 @@ doit(int s,
state = QUIT; state = QUIT;
net_write (s, "QUIT\r\n", 6); net_write (s, "QUIT\r\n", 6);
if (verbose > 1) if (verbose > 1)
net_write (STDERR_FILENO, "QUIT\r\n", 6); fprintf (stderr, "QUIT\r\n");
break; break;
} else if (state == DELE) { } else if (state == DELE) {
if (++deleted == count) { if (++deleted == count) {
state = QUIT; state = QUIT;
net_write (s, "QUIT\r\n", 6); net_write (s, "QUIT\r\n", 6);
if (verbose > 1) if (verbose > 1)
net_write (STDERR_FILENO, "QUIT\r\n", 6); fprintf (stderr, "QUIT\r\n", 6);
break; break;
} }
} else if (++state == STAT) { } else if (++state == STAT) {
@@ -428,7 +440,7 @@ doit(int s,
state = QUIT; state = QUIT;
net_write (s, "QUIT\r\n", 6); net_write (s, "QUIT\r\n", 6);
if (verbose > 1) if (verbose > 1)
net_write (STDERR_FILENO, "QUIT\r\n", 6); fprintf (stderr, "QUIT\r\n");
break; break;
} }
} }
@@ -471,7 +483,7 @@ doit(int s,
if (net_write (s, out_buf, out_len) != out_len) if (net_write (s, out_buf, out_len) != out_len)
err (1, "write"); err (1, "write");
if (verbose > 1) if (verbose > 1)
write (STDERR_FILENO, out_buf, out_len); fprintf (stderr, "%s", out_buf);
} }
} }
if (verbose) if (verbose)