aboutsummaryrefslogtreecommitdiffstats
path: root/driver.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1996-11-05 00:07:53 +0000
committerEric S. Raymond <esr@thyrsus.com>1996-11-05 00:07:53 +0000
commitb7f1c1eb3391a54ff7faed69da40a96799553bfd (patch)
tree69867ac144f2d3c5c4b44dbbe5677f1675ddcb0b /driver.c
parent9b699b1aebb24f4f42b0c8b89a497339fc1e1499 (diff)
downloadfetchmail-b7f1c1eb3391a54ff7faed69da40a96799553bfd.tar.gz
fetchmail-b7f1c1eb3391a54ff7faed69da40a96799553bfd.tar.bz2
fetchmail-b7f1c1eb3391a54ff7faed69da40a96799553bfd.zip
Better error reporting.
svn path=/trunk/; revision=486
Diffstat (limited to 'driver.c')
-rw-r--r--driver.c47
1 files changed, 38 insertions, 9 deletions
diff --git a/driver.c b/driver.c
index 46b2a153..4d127d23 100644
--- a/driver.c
+++ b/driver.c
@@ -570,7 +570,7 @@ struct query *ctl; /* query control record */
oldlen = strlen(bufp);
headers = malloc(oldlen + 1);
if (headers == NULL)
- return(PS_IOERR);
+ return(PS_SYNTAX);
(void) strcpy(headers, bufp);
bufp = headers;
}
@@ -593,7 +593,7 @@ struct query *ctl; /* query control record */
newlen = oldlen + strlen(bufp);
headers = realloc(headers, newlen + 1);
if (headers == NULL)
- return(PS_IOERR);
+ return(PS_SYNTAX);
strcpy(headers + oldlen, bufp);
bufp = headers + oldlen;
oldlen = newlen;
@@ -726,10 +726,8 @@ struct query *ctl; /* query control record */
/* replace all LFs with CR-LF before sending to the SMTP server */
if (!ctl->mda[0])
{
- char *newheaders = malloc(1 + oldlen * 2);
+ char *newheaders = xmalloc(1 + oldlen * 2);
- if (newheaders == NULL)
- return(PS_IOERR);
oldlen = strcrlf(newheaders, headers, oldlen);
free(headers);
headers = newheaders;
@@ -761,10 +759,8 @@ struct query *ctl; /* query control record */
/* replace all LFs with CR-LF in the line */
if (!ctl->mda[0])
{
- char *newbufp = malloc(1 + strlen(bufp) * 2);
+ char *newbufp = xmalloc(1 + strlen(bufp) * 2);
- if (newbufp == NULL)
- return(PS_IOERR);
strcrlf(newbufp, bufp, strlen(bufp));
bufp = newbufp;
}
@@ -902,9 +898,12 @@ const struct method *proto; /* protocol method table */
vtalarm(mytimeout = ctl->timeout);
if (setjmp(restart) == 1)
+ {
fprintf(stderr,
"fetchmail: timeout after %d seconds waiting for %s.\n",
ctl->timeout, ctl->servername);
+ ok = PS_ERROR;
+ }
else
{
char buf [POPBUFSIZE+1];
@@ -1091,9 +1090,39 @@ const struct method *proto; /* protocol method table */
}
}
- signal(SIGVTALRM, sigsave);
+ switch (ok)
+ {
+ case PS_SOCKET:
+ fputs("fetchmail: socket", stderr);
+ break;
+ case PS_AUTHFAIL:
+ fputs("fetchmail: authorization", stderr);
+ break;
+ case PS_SYNTAX:
+ fputs("fetchmail: missing or bad RFC822 header", stderr);
+ break;
+ case PS_IOERR:
+ fputs("fetchmail: MDA", stderr);
+ break;
+ case PS_ERROR:
+ fputs("fetchmail: client/server synchronization", stderr);
+ break;
+ case PS_PROTOCOL:
+ fputs("fetchmail: client/server protocol", stderr);
+ break;
+ case PS_SMTP:
+ fputs("fetchmail: SMTP transaction", stderr);
+ break;
+ case PS_UNDEFINED:
+ fputs("fetchmail: undefined", stderr);
+ break;
+ }
+ if (ok==PS_SOCKET || ok==PS_AUTHFAIL || ok==PS_SYNTAX || ok==PS_IOERR
+ || ok==PS_ERROR || ok==PS_PROTOCOL || ok==PS_SMTP)
+ fprintf(stderr, "error while talking to %s\n", ctl->servername);
closeUp:
+ signal(SIGVTALRM, sigsave);
return(ok);
}