aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS4
-rw-r--r--checkalias.c12
-rw-r--r--daemon.c12
-rw-r--r--driver.c138
-rw-r--r--etrn.c20
-rw-r--r--fetchmail.c42
-rw-r--r--fetchmail.h26
-rw-r--r--getpass.c2
-rw-r--r--imap.c84
-rw-r--r--interface.c16
-rw-r--r--pop3.c16
-rw-r--r--report.c46
-rw-r--r--rfc822.c4
-rw-r--r--rpa.c128
-rw-r--r--sink.c38
-rw-r--r--smtp.c20
-rw-r--r--socket.c17
-rw-r--r--unmime.c1
-rw-r--r--xalloca.c2
-rw-r--r--xmalloc.c10
20 files changed, 310 insertions, 328 deletions
diff --git a/NEWS b/NEWS
index e36f15bf..d705e831 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,3 @@
- Known bugs
-
-* Progress messages go to stderr. Can we send them to stdout?
Release Notes:
@@ -8,6 +5,7 @@ fetchmail-4.7.5 ():
* Issue proper logout after running fetchmail -c
* Fix prefix problem with internationalized version.
* Attempted fix for Harry McGavran's VPATH bug.
+* Progress messages now go to stdout. Errors still go to stderr
There are 249 people on fetchmail-friends and 334 on fetchmail-announce.
diff --git a/checkalias.c b/checkalias.c
index 3c8a6e6b..9d2dfc46 100644
--- a/checkalias.c
+++ b/checkalias.c
@@ -137,15 +137,15 @@ int is_host_alias(const char *name, struct query *ctl)
else if (((he_st = gethostbyname(ctl->server.truename)) != (struct hostent *)NULL) && ctl->server.checkalias)
{
if (outlevel >= O_DEBUG)
- progress(0, 0, _("Checking if %s is really the same node as %s"),ctl->server.truename,name);
+ report(stdout, 0, _("Checking if %s is really the same node as %s"),ctl->server.truename,name);
if (is_ip_alias(ctl->server.truename,name) == TRUE)
{
if (outlevel >= O_DEBUG)
- progress(0, 0, _("Yes, their IP addresses match"));
+ report(stdout, 0, _("Yes, their IP addresses match"));
goto match;
}
if (outlevel >= O_DEBUG)
- progress(0, 0, _("No, their IP addresses don't match"));
+ report(stdout, 0, _("No, their IP addresses don't match"));
}
else
return(FALSE);
@@ -161,8 +161,8 @@ int is_host_alias(const char *name, struct query *ctl)
case TRY_AGAIN: /* temporary error on authoritative server */
default:
if (outlevel != O_SILENT)
- putchar('\n'); /* terminate the progress message */
- error(0, 0,
+ report_complete(stdout, 0, ""); /* terminate the progress message */
+ report(stderr, 0,
_("nameserver failure while looking for `%s' during poll of %s."),
name, ctl->server.pollname);
ctl->errcount++;
@@ -187,7 +187,7 @@ int is_host_alias(const char *name, struct query *ctl)
case NO_RECOVERY: /* non-recoverable name server error */
case TRY_AGAIN: /* temporary error on authoritative server */
default:
- error(0, -1,
+ report(stderr, -1,
_("nameserver failure while looking for `%s' during poll of %s."),
name, ctl->server.pollname);
ctl->errcount++;
diff --git a/daemon.c b/daemon.c
index e6e7b10b..75c39486 100644
--- a/daemon.c
+++ b/daemon.c
@@ -109,7 +109,7 @@ daemonize (const char *logfile, void (*termhook)(int))
group leader */
if ((childpid = fork()) < 0) {
- error(0, errno, "fork");
+ report(stderr, errno, "fork");
return(PS_IOERR);
}
else if (childpid > 0)
@@ -122,7 +122,7 @@ daemonize (const char *logfile, void (*termhook)(int))
#if defined(HAVE_SETSID) /* POSIX */
/* POSIX makes this soooo easy to do */
if (setsid() < 0) {
- error(0, errno, "setsid");
+ report(stderr, errno, "setsid");
return(PS_IOERR);
}
#elif defined(SIGTSTP) /* BSD */
@@ -144,7 +144,7 @@ daemonize (const char *logfile, void (*termhook)(int))
/* lose controlling tty */
signal(SIGHUP, SIG_IGN);
if ((childpid = fork()) < 0) {
- error(0, errno, "fork");
+ report(stderr, errno, "fork");
return(PS_IOERR);
}
else if (childpid > 0) {
@@ -168,7 +168,7 @@ nottyDetach:
/* Reopen stdin descriptor on /dev/null */
if ((fd = open("/dev/null", O_RDWR)) < 0) { /* stdin */
- error(0, errno, "open: /dev/null");
+ report(stderr, errno, "open: /dev/null");
return(PS_IOERR);
}
@@ -176,11 +176,11 @@ nottyDetach:
fd = open(logfile, O_CREAT|O_WRONLY|O_APPEND, 0666); /* stdout */
else
if (dup(fd) < 0) { /* stdout */
- error(0, errno, "dup");
+ report(stderr, errno, "dup");
return(PS_IOERR);
}
if (dup(fd) < 0) { /* stderr */
- error(0, errno, "dup");
+ report(stderr, errno, "dup");
return(PS_IOERR);
}
diff --git a/driver.c b/driver.c
index 7c0e1d63..44ae9821 100644
--- a/driver.c
+++ b/driver.c
@@ -132,7 +132,7 @@ static void map_name(const char *name, struct query *ctl, struct idlist **xmit_n
if (lname != (char *)NULL)
{
if (outlevel >= O_DEBUG)
- progress(0, 0, _("mapped %s to local %s"), name, lname);
+ report(stdout, 0, _("mapped %s to local %s"), name, lname);
save_str(xmit_names, lname, XMIT_ACCEPT);
accept_count++;
}
@@ -189,7 +189,7 @@ static void find_server_names(const char *hdr,
strcasecmp(rhs, idp->id) == 0)
{
if (outlevel >= O_DEBUG)
- progress(0, 0, _("passed through %s matching %s"),
+ report(stdout, 0, _("passed through %s matching %s"),
cp, idp->id);
save_str(xmit_names, cp, XMIT_ACCEPT);
accept_count++;
@@ -243,7 +243,7 @@ static char *parse_received(struct query *ctl, char *bufp)
* does this when the mail has a single recipient.
*/
if (outlevel >= O_DEBUG)
- progress(0, 0, _("analyzing Received line:\n%s"), bufp);
+ report(stdout, 0, _("analyzing Received line:\n%s"), bufp);
/* search for whitepace-surrounded "by" followed by xxxx.yyyy */
for (base = bufp; ; base = ok + 2)
@@ -281,13 +281,13 @@ static char *parse_received(struct query *ctl, char *bufp)
if (is_host_alias(rbuf, ctl))
{
if (outlevel >= O_DEBUG)
- progress(0, 0,
+ report(stdout, 0,
_("line accepted, %s is an alias of the mailserver"), rbuf);
}
else
{
if (outlevel >= O_DEBUG)
- progress(0, 0,
+ report(stdout, 0,
_("line rejected, %s is not an alias of the mailserver"),
rbuf);
return(NULL);
@@ -359,7 +359,7 @@ static char *parse_received(struct query *ctl, char *bufp)
if (!ok)
{
if (outlevel >= O_DEBUG)
- progress(0, 0, _("no Received address found"));
+ report(stdout, 0, _("no Received address found"));
return(NULL);
}
else
@@ -368,7 +368,7 @@ static char *parse_received(struct query *ctl, char *bufp)
char *lf = rbuf + strlen(rbuf)-1;
*lf = '\0';
if (outlevel >= O_DEBUG)
- progress(0, 0, _("found Received address `%s'"), rbuf+2);
+ report(stdout, 0, _("found Received address `%s'"), rbuf+2);
*lf = '\n';
}
return(rbuf);
@@ -499,7 +499,7 @@ static int readheaders(int sock,
sizeticker += linelen;
while (sizeticker >= SIZETICKER)
{
- progress_build(".");
+ report_build(stdout, ".");
sizeticker -= SIZETICKER;
}
}
@@ -731,7 +731,7 @@ static int readheaders(int sock,
if (!headers_ok)
{
if (outlevel > O_SILENT)
- progress(0,0,_("message delimiter found while scanning headers"));
+ report(stdout, 0,0,_("message delimiter found while scanning headers"));
}
/*
@@ -854,7 +854,7 @@ static int readheaders(int sock,
no_local_matches = TRUE;
save_str(&msgblk.recipients, run.postmaster, XMIT_ACCEPT);
if (outlevel >= O_DEBUG)
- progress(0, 0,
+ report(stdout, 0,
_("no local matches, forwarding to %s"),
run.postmaster);
}
@@ -869,7 +869,7 @@ static int readheaders(int sock,
if (ctl->errcount > olderrs) /* there were DNS errors above */
{
if (outlevel >= O_DEBUG)
- progress(0,0, _("forwarding and deletion suppressed due to DNS errors"));
+ report(stdout, 0,0, _("forwarding and deletion suppressed due to DNS errors"));
free(msgblk.headers);
free_str_list(&msgblk.recipients);
return(PS_TRANSIENT);
@@ -966,7 +966,7 @@ static int readheaders(int sock,
if (n == -1)
{
- progress(0, errno, _("writing RFC822 msgblk.headers"));
+ report(stdout, errno, _("writing RFC822 msgblk.headers"));
release_sink(ctl);
free(msgblk.headers);
free_str_list(&msgblk.recipients);
@@ -1074,7 +1074,7 @@ static int readbody(int sock, struct query *ctl, flag forward, int len)
while (sizeticker >= SIZETICKER)
{
if (!run.use_syslog && outlevel > O_SILENT)
- progress_build(".");
+ report_build(stdout, ".");
sizeticker -= SIZETICKER;
}
}
@@ -1122,7 +1122,7 @@ static int readbody(int sock, struct query *ctl, flag forward, int len)
if (n < 0)
{
- progress(0, errno, _("writing message text"));
+ report(stdout, errno, _("writing message text"));
release_sink(ctl);
return(PS_IOERR);
}
@@ -1165,7 +1165,7 @@ const char *canonical; /* server name */
"KPOPV0.1"));
if (rem != KSUCCESS)
{
- error(0, -1, _("kerberos error %s"), (krb_get_err_text (rem)));
+ report(stderr, -1, _("kerberos error %s"), (krb_get_err_text (rem)));
return (PS_AUTHFAIL);
}
return (0);
@@ -1191,19 +1191,19 @@ const char *canonical; /* server name */
krb5_auth_con_init(context, &auth_context);
if (retval = krb5_cc_default(context, &ccdef)) {
- error(0, 0, "krb5_cc_default: %s", error_message(retval));
+ report(stderr, 0, "krb5_cc_default: %s", error_message(retval));
return(PS_ERROR);
}
if (retval = krb5_cc_get_principal(context, ccdef, &client)) {
- error(0, 0, "krb5_cc_get_principal: %s", error_message(retval));
+ report(stderr, 0, "krb5_cc_get_principal: %s", error_message(retval));
return(PS_ERROR);
}
if (retval = krb5_sname_to_principal(context, canonical, "pop",
KRB5_NT_UNKNOWN,
&server)) {
- error(0, 0, "krb5_sname_to_principal: %s", error_message(retval));
+ report(stderr, 0, "krb5_sname_to_principal: %s", error_message(retval));
return(PS_ERROR);
}
@@ -1223,13 +1223,13 @@ const char *canonical; /* server name */
if (retval) {
if (err_ret && err_ret->text.length) {
- error(0, 0, _("krb5_sendauth: %s [server says '%*s'] "),
+ report(stderr, 0, _("krb5_sendauth: %s [server says '%*s'] "),
error_message(retval),
err_ret->text.length,
err_ret->text.data);
- krb5_free_error(context, err_ret);
+ krb5_free_report(stderr, context, err_ret);
} else
- error(0, 0, "krb5_sendauth: %s", error_message(retval));
+ report(stderr, 0, "krb5_sendauth: %s", error_message(retval));
return(PS_ERROR);
}
@@ -1353,7 +1353,7 @@ const struct method *proto; /* protocol method table */
#ifndef KERBEROS_V4
if (ctl->server.preauthenticate == A_KERBEROS_V4)
{
- error(0, -1, _("Kerberos V4 support not linked."));
+ report(stderr, -1, _("Kerberos V4 support not linked."));
return(PS_ERROR);
}
#endif /* KERBEROS_V4 */
@@ -1361,7 +1361,7 @@ const struct method *proto; /* protocol method table */
#ifndef KERBEROS_V5
if (ctl->server.preauthenticate == A_KERBEROS_V5)
{
- error(0, -1, _("Kerberos V5 support not linked."));
+ report(stderr, -1, _("Kerberos V5 support not linked."));
return(PS_ERROR);
}
#endif /* KERBEROS_V5 */
@@ -1371,13 +1371,13 @@ const struct method *proto; /* protocol method table */
{
/* check for unsupported options */
if (ctl->flush) {
- error(0, 0,
+ report(stderr, 0,
_("Option --flush is not supported with %s"),
proto->name);
return(PS_SYNTAX);
}
else if (ctl->fetchall) {
- error(0, 0,
+ report(stderr, 0,
_("Option --all is not supported with %s"),
proto->name);
return(PS_SYNTAX);
@@ -1385,7 +1385,7 @@ const struct method *proto; /* protocol method table */
}
if (!proto->getsizes && NUM_SPECIFIED(ctl->limit))
{
- error(0, 0,
+ report(stderr, 0,
_("Option --limit is not supported with %s"),
proto->name);
return(PS_SYNTAX);
@@ -1419,23 +1419,23 @@ const struct method *proto; /* protocol method table */
#endif /* HAVE_SIGPROCMASK */
if (phase == OPEN_WAIT)
- progress(0, 0,
+ report(stdout, 0,
_("timeout after %d seconds waiting to connect to server %s."),
ctl->server.timeout, ctl->server.pollname);
else if (phase == SERVER_WAIT)
- progress(0, 0,
+ report(stdout, 0,
_("timeout after %d seconds waiting for server %s."),
ctl->server.timeout, ctl->server.pollname);
else if (phase == FORWARDING_WAIT)
- progress(0, 0,
+ report(stdout, 0,
_("timeout after %d seconds waiting for %s."),
ctl->server.timeout,
ctl->mda ? "MDA" : "SMTP");
else if (phase == LISTENER_WAIT)
- progress(0, 0,
+ report(stdout, 0,
_("timeout after %d seconds waiting for listener to respond."));
else
- progress(0, 0, _("timeout after %d seconds."), ctl->server.timeout);
+ report(stdout, 0, _("timeout after %d seconds."), ctl->server.timeout);
release_sink(ctl);
if (ctl->smtp_socket != -1)
@@ -1485,7 +1485,7 @@ const struct method *proto; /* protocol method table */
/* execute pre-initialization command, if any */
if (ctl->preconnect && (ok = system(ctl->preconnect)))
{
- error(0, 0, _("pre-connection command failed with status %d"), ok);
+ report(stderr, 0, _("pre-connection command failed with status %d"), ok);
ok = PS_SYNTAX;
goto closeUp;
}
@@ -1510,7 +1510,7 @@ const struct method *proto; /* protocol method table */
int err_no = errno;
#ifdef HAVE_RES_SEARCH
if (err_no != 0 && h_errno != 0)
- error(0, 0, _("fetchmail: internal inconsistency"));
+ report(stderr, 0, _("fetchmail: internal inconsistency"));
#endif
/*
* Avoid generating a bogus error every poll cycle when we're
@@ -1520,26 +1520,26 @@ const struct method *proto; /* protocol method table */
if (err_no == EHOSTUNREACH && run.poll_interval)
goto ehostunreach;
- error_build(_("fetchmail: %s connection to %s failed"),
+ report_build(stderr, _("fetchmail: %s connection to %s failed"),
protocol->name, ctl->server.pollname);
#ifdef HAVE_RES_SEARCH
if (h_errno != 0)
{
if (h_errno == HOST_NOT_FOUND)
- error_complete(0, 0, _(": host is unknown"));
+ report_complete(stderr, 0, _(": host is unknown"));
else if (h_errno == NO_ADDRESS)
- error_complete(0, 0, _(": name is valid but has no IP address"));
+ report_complete(stderr, 0, _(": name is valid but has no IP address"));
else if (h_errno == NO_RECOVERY)
- error_complete(0, 0, _(": unrecoverable name server error"));
+ report_complete(stderr, 0, _(": unrecoverable name server error"));
else if (h_errno == TRY_AGAIN)
- error_complete(0, 0, _(": temporary name server error"));
+ report_complete(stderr, 0, _(": temporary name server error"));
else
- error_complete(0, 0, _(": unknown DNS error %d"), h_errno);
+ report_complete(stderr, 0, _(": unknown DNS error %d"), h_errno);
}
else
#endif /* HAVE_RES_SEARCH */
- error_complete(0, err_no, "");
+ report_complete(stderr, err_no, "");
ehostunreach:
#endif /* INET6 */
@@ -1590,14 +1590,14 @@ const struct method *proto; /* protocol method table */
if (ok != 0)
{
if (ok == PS_LOCKBUSY)
- error(0, -1, _("Lock-busy error on %s@%s"),
+ report(stderr, -1, _("Lock-busy error on %s@%s"),
ctl->remotename,
ctl->server.truename);
else
{
if (ok == PS_ERROR)
ok = PS_AUTHFAIL;
- error(0, -1, _("Authorization failure on %s@%s"),
+ report(stderr, -1, _("Authorization failure on %s@%s"),
ctl->remotename,
ctl->server.truename);
@@ -1640,9 +1640,9 @@ const struct method *proto; /* protocol method table */
if (outlevel >= O_DEBUG)
if (idp->id)
- progress(0, 0, _("selecting or re-polling folder %s"), idp->id);
+ report(stdout, 0, _("selecting or re-polling folder %s"), idp->id);
else
- progress(0, 0, _("selecting or re-polling default folder"));
+ report(stdout, 0, _("selecting or re-polling default folder"));
/* compute # of messages and number of new messages waiting */
ok = (protocol->getrange)(sock, ctl, idp->id, &count, &new, &bytes);
@@ -1658,28 +1658,28 @@ const struct method *proto; /* protocol method table */
ctl->remotename, ctl->server.truename);
if (outlevel > O_SILENT)
if (count == -1) /* only used for ETRN */
- progress(0, 0, _("Polling %s"), ctl->server.truename);
+ report(stdout, 0, _("Polling %s"), ctl->server.truename);
else if (count != 0)
{
if (new != -1 && (count - new) > 0)
- progress_build(_("%d %s (%d seen) for %s"),
+ report_build(stdout, _("%d %s (%d seen) for %s"),
count, count > 1 ? _("messages") :
_("message"),
count-new, buf);
else
- progress_build(_("%d %s for %s"),
+ report_build(stdout, _("%d %s for %s"),
count, count > 1 ? _("messages") :
_("message"), buf);
if (bytes == -1)
- progress_complete(0, 0, ".");
+ report_complete(stdout, 0, ".");
else
- progress_complete(0, 0, _(" (%d octets)."), bytes);
+ report_complete(stdout, 0, _(" (%d octets)."), bytes);
}
else
{
/* these are pointless in normal daemon mode */
if (pass == 1 && (run.poll_interval == 0 || outlevel >= O_VERBOSE))
- progress(0, 0, _("No mail for %s"), buf);
+ report(stdout, 0, _("No mail for %s"), buf);
}
/* very important, this is where we leave the do loop */
@@ -1779,7 +1779,7 @@ const struct method *proto; /* protocol method table */
if (msgsizes && msgsizes[num-1] == -1)
{
if (outlevel >= O_VERBOSE)
- progress(0, 0,
+ report(stdout, 0,
_("Skipping message %d, length -1"),
num - 1);
continue;
@@ -1790,7 +1790,7 @@ const struct method *proto; /* protocol method table */
{
if (outlevel > O_SILENT)
{
- progress_build(_("skipping message %d"), num);
+ report_build(stdout, _("skipping message %d"), num);
if (toolarge && !check_only)
{
char size[32];
@@ -1835,7 +1835,7 @@ const struct method *proto; /* protocol method table */
tmp->val.status.num = cnt;
}
- progress_build(_(" (oversized, %d octets)"),
+ report_build(stdout, _(" (oversized, %d octets)"),
msgsizes[num-1]);
}
}
@@ -1858,16 +1858,16 @@ const struct method *proto; /* protocol method table */
if (outlevel > O_SILENT)
{
- progress_build(_("reading message %d of %d"),
+ report_build(stdout, _("reading message %d of %d"),
num,count);
if (len > 0)
- progress_build(_(" (%d %soctets)"),
+ report_build(stdout, _(" (%d %soctets)"),
len, wholesize ? "" : _("header "));
if (outlevel >= O_VERBOSE)
- progress_complete(0, 0, "");
+ report_complete(stdout, 0, "");
else
- progress_build(" ");
+ report_build(stdout, " ");
}
/*
@@ -1908,7 +1908,7 @@ const struct method *proto; /* protocol method table */
if ((ok=(protocol->fetch_body)(sock,ctl,num,&len)))
goto cleanUp;
if (outlevel > O_SILENT && !wholesize)
- progress_build(_(" (%d body octets) "), len);
+ report_build(stdout, _(" (%d body octets) "), len);
}
}
@@ -1976,7 +1976,7 @@ const struct method *proto; /* protocol method table */
if (msgsizes && msglen != msgsizes[num-1])
{
if (outlevel >= O_DEBUG)
- progress(0, 0,
+ report(stdout, 0,
_("message %d was not the expected length (%d actual != %d expected)"),
num, msglen, msgsizes[num-1]);
}
@@ -2015,7 +2015,7 @@ const struct method *proto; /* protocol method table */
if (retained)
{
if (outlevel > O_SILENT)
- progress_complete(0, 0, _(" retained"));
+ report_complete(stdout, 0, _(" retained"));
}
else if (protocol->delete
&& !suppress_delete
@@ -2023,7 +2023,7 @@ const struct method *proto; /* protocol method table */
{
deletions++;
if (outlevel > O_SILENT)
- progress_complete(0, 0, _(" flushed"));
+ report_complete(stdout, 0, _(" flushed"));
ok = (protocol->delete)(sock, ctl, num);
if (ok != 0)
goto cleanUp;
@@ -2032,13 +2032,13 @@ const struct method *proto; /* protocol method table */
#endif /* POP3_ENABLE */
}
else if (outlevel > O_SILENT)
- progress_complete(0, 0, _(" not flushed"));
+ report_complete(stdout, 0, _(" not flushed"));
/* perhaps this as many as we're ready to handle */
if (NUM_NONZERO(ctl->fetchlimit)
&& ctl->fetchlimit <= fetches)
{
- progress(0, 0, _("fetchlimit reached; %d messages left on server"),
+ report(stdout, 0, _("fetchlimit reached; %d messages left on server"),
count - fetches);
goto no_error;
}
@@ -2109,19 +2109,19 @@ const struct method *proto; /* protocol method table */
msg = _("DNS lookup");
break;
case PS_UNDEFINED:
- error(0, 0, _("undefined"));
+ report(stderr, 0, _("undefined"));
break;
}
if (ok==PS_SOCKET || ok==PS_AUTHFAIL || ok==PS_SYNTAX
|| ok==PS_IOERR || ok==PS_ERROR || ok==PS_PROTOCOL
|| ok==PS_LOCKBUSY || ok==PS_SMTP)
- error(0,-1, _("%s error while fetching from %s"), msg, ctl->server.pollname);
+ report(stderr,-1, _("%s error while fetching from %s"), msg, ctl->server.pollname);
closeUp:
/* execute post-initialization command, if any */
if (ctl->postconnect && (ok = system(ctl->postconnect)))
{
- error(0, 0, _("post-connection command failed with status %d"), ok);
+ report(stderr, 0, _("post-connection command failed with status %d"), ok);
if (ok == PS_SUCCESS)
ok = PS_SYNTAX;
}
@@ -2178,7 +2178,7 @@ va_dcl
*cp = '\0';
}
buf[strlen(buf)-2] = '\0';
- progress(0, 0, "%s> %s", protocol->name, buf);
+ report(stdout, 0, "%s> %s", protocol->name, buf);
}
}
@@ -2206,7 +2206,7 @@ int size; /* length of buffer */
if (buf[strlen(buf)-1] == '\r')
buf[strlen(buf)-1] = '\0';
if (outlevel >= O_MONITOR)
- progress(0, 0, "%s< %s", protocol->name, buf);
+ report(stdout, 0, "%s< %s", protocol->name, buf);
phase = oldphase;
return(PS_SUCCESS);
}
@@ -2264,7 +2264,7 @@ va_dcl
*cp = '\0';
}
buf[strlen(buf)-1] = '\0';
- progress(0, 0, "%s> %s", protocol->name, buf);
+ report(stdout, 0, "%s> %s", protocol->name, buf);
}
/* we presume this does its own response echoing */
diff --git a/etrn.c b/etrn.c
index 2ead70d7..341bf768 100644
--- a/etrn.c
+++ b/etrn.c
@@ -39,13 +39,13 @@ static int etrn_getrange(int sock, struct query *ctl, const char *id,
if ((ok = SMTP_ehlo(sock, fetchmailhost, &opts)))
{
- error(0, 0, _("%s's SMTP listener does not support ESMTP"),
+ report(stderr, 0, _("%s's SMTP listener does not support ESMTP"),
ctl->server.pollname);
return(ok);
}
else if (!(opts & ESMTP_ETRN))
{
- error(0, 0, _("%s's SMTP listener does not support ETRN"),
+ report(stderr, 0, _("%s's SMTP listener does not support ETRN"),
ctl->server.pollname);
return(PS_PROTOCOL);
}
@@ -69,38 +69,38 @@ static int etrn_getrange(int sock, struct query *ctl, const char *id,
{
case 250: /* OK, queuing for node <x> started */
if (outlevel >= O_SILENT)
- progress(0, 0, _("Queuing for %s started"), qnp->id);
+ report(stdout, 0, _("Queuing for %s started"), qnp->id);
break;
case 251: /* OK, no messages waiting for node <x> */
if (outlevel >= O_SILENT)
- progress(0, 0, _("No messages waiting for %s"), qnp->id);
+ report(stdout, 0, _("No messages waiting for %s"), qnp->id);
return(PS_NOMAIL);
case 252: /* OK, pending messages for node <x> started */
case 253: /* OK, <n> pending messages for node <x> started */
if (outlevel >= O_SILENT)
- progress(0, 0, _("Pending messages for %s started"), qnp->id);
+ report(stdout, 0, _("Pending messages for %s started"), qnp->id);
break;
case 458: /* Unable to queue messages for node <x> */
- error(0, -1, _("Unable to queue messages for node %s"),qnp->id);
+ report(stderr, -1, _("Unable to queue messages for node %s"),qnp->id);
return(PS_PROTOCOL);
case 459: /* Node <x> not allowed: <reason> */
- error(0, -1, _("Node %s not allowed: %s"), qnp->id, buf);
+ report(stderr, -1, _("Node %s not allowed: %s"), qnp->id, buf);
return(PS_AUTHFAIL);
case 500: /* Syntax Error */
- error(0, -1, _("ETRN syntax error"));
+ report(stderr, -1, _("ETRN syntax error"));
return(PS_PROTOCOL);
case 501: /* Syntax Error in Parameters */
- error(0, -1, _("ETRN syntax error in parameters"));
+ report(stderr, -1, _("ETRN syntax error in parameters"));
return(PS_PROTOCOL);
default:
- error(0, -1, _("Unknown ETRN error %d"), atoi(buf));
+ report(stderr, -1, _("Unknown ETRN error %d"), atoi(buf));
return(PS_PROTOCOL);
}
}
diff --git a/fetchmail.c b/fetchmail.c
index 5636e803..6264b9f1 100644
--- a/fetchmail.c
+++ b/fetchmail.c
@@ -464,7 +464,7 @@ int main (int argc, char **argv)
{
if (!nodetach)
daemonize(run.logfile, termhook);
- progress( 0, 0, _("starting fetchmail %s daemon "), VERSION);
+ report(stdout, 0, 0, _("starting fetchmail %s daemon "), VERSION);
/*
* We'll set up a handler for these when we're sleeping,
@@ -525,7 +525,7 @@ int main (int argc, char **argv)
{
if (ctl->wedged)
{
- error(0, -1,
+ report(stderr, -1,
_("poll of %s skipped (failed authentication or too many timeouts)"),
ctl->server.pollname);
continue;
@@ -537,7 +537,7 @@ int main (int argc, char **argv)
if (ctl->server.poll_count++ % ctl->server.interval)
{
if (outlevel >= O_VERBOSE)
- progress(0, -1,
+ report(stdout, -1,
_("interval not reached, not querying %s"),
ctl->server.pollname);
continue;
@@ -565,13 +565,13 @@ int main (int argc, char **argv)
{
write_saved_lists(querylist, run.idfile);
if (outlevel >= O_DEBUG)
- progress(0, 0, _("saved UID List"));
+ report(stdout, 0, _("saved UID List"));
}
#endif /* POP3_ENABLE */
}
else if (!check_only &&
((querystatus!=PS_NOMAIL) || (outlevel==O_DEBUG)))
- progress(0, 0, _("Query status=%d"), querystatus);
+ report(stdout, 0, _("Query status=%d"), querystatus);
#if defined(linux) && !INET6
if (ctl->server.monitor)
@@ -628,12 +628,12 @@ int main (int argc, char **argv)
unwedged++;
if (!unwedged)
{
- error(0, -1, _("All connections are wedged. Exiting."));
+ report(stderr, -1, _("All connections are wedged. Exiting."));
exit(PS_AUTHFAIL);
}
if (outlevel >= O_VERBOSE)
- progress(0, -1, _("fetchmail: sleeping at %s"), rfc822timestamp());
+ report(stdout, -1, _("fetchmail: sleeping at %s"), rfc822timestamp());
/*
* With this simple hack, we make it possible for a foreground
@@ -728,9 +728,9 @@ int main (int argc, char **argv)
|| ((run.poll_interval && !getuid()) && lastsig == SIGHUP))
{
#ifdef SYS_SIGLIST_DECLARED
- progress(0, 0, _("awakened by %s"), sys_siglist[lastsig]);
+ report(stdout, 0, _("awakened by %s"), sys_siglist[lastsig]);
#else
- progress(0, 0, _("awakened by signal %d"), lastsig);
+ report(stdout, 0, _("awakened by signal %d"), lastsig);
#endif
/* received a wakeup - unwedge all servers in case */
/* the problem has been manually repaired */
@@ -745,13 +745,13 @@ int main (int argc, char **argv)
signal(SIGHUP, SIG_IGN);
if (outlevel >= O_VERBOSE)
- progress(0, -1, _("awakened at %s"), rfc822timestamp());
+ report(stdout, -1, _("awakened at %s"), rfc822timestamp());
}
} while
(run.poll_interval);
if (outlevel >= O_VERBOSE)
- progress(0, -1, _("normal termination, status %d"),
+ report(stdout, -1, _("normal termination, status %d"),
successes ? PS_SUCCESS : querystatus);
termhook(0);
@@ -1025,7 +1025,7 @@ static int load_params(int argc, char **argv, int optind)
free(ctl->server.via);
ctl->server.via = xstrdup(hes_p->po_host);
} else {
- error(0, errno, _("couldn't find HESIOD pobox for %s"),
+ report(stderr, errno, _("couldn't find HESIOD pobox for %s"),
ctl->remotename);
}
}
@@ -1050,7 +1050,7 @@ static int load_params(int argc, char **argv, int optind)
namerec = gethostbyname(ctl->server.queryname);
if (namerec == (struct hostent *)NULL)
{
- error(0, errno,
+ report(stderr, errno,
_("couldn't find canonical DNS name of %s"),
ctl->server.pollname);
exit(PS_DNS);
@@ -1167,7 +1167,7 @@ static void termhook(int sig)
*/
if (sig != 0)
- progress(0, 0, _("terminated with signal %d"), sig);
+ report(stdout, 0, _("terminated with signal %d"), sig);
else
/* terminate all SMTP connections cleanly */
for (ctl = querylist; ctl; ctl = ctl->next)
@@ -1227,7 +1227,7 @@ static int query_host(struct query *ctl)
time_t now;
time(&now);
- progress(0, -1, _("%s querying %s (protocol %s) at %s"),
+ report(stdout, -1, _("%s querying %s (protocol %s) at %s"),
VERSION,
ctl->server.pollname, showproto(ctl->server.protocol), ctime(&now));
}
@@ -1246,7 +1246,7 @@ static int query_host(struct query *ctl)
#ifdef POP2_ENABLE
return(doPOP2(ctl));
#else
- error(0, -1, _("POP2 support is not configured.\n"));
+ report(stderr, -1, _("POP2 support is not configured.\n"));
return(PS_PROTOCOL);
#endif /* POP2_ENABLE */
break;
@@ -1256,7 +1256,7 @@ static int query_host(struct query *ctl)
#ifdef POP3_ENABLE
return(doPOP3(ctl));
#else
- error(0, -1, _("POP3 support is not configured.\n"));
+ report(stderr, -1, _("POP3 support is not configured.\n"));
return(PS_PROTOCOL);
#endif /* POP3_ENABLE */
break;
@@ -1268,24 +1268,24 @@ static int query_host(struct query *ctl)
#ifdef IMAP_ENABLE
return(doIMAP(ctl));
#else
- error(0, -1, _("IMAP support is not configured.\n"));
+ report(stderr, -1, _("IMAP support is not configured.\n"));
return(PS_PROTOCOL);
#endif /* IMAP_ENABLE */
break;
case P_ETRN:
#ifndef ETRN_ENABLE
- error(0, -1, _("ETRN support is not configured.\n"));
+ report(stderr, -1, _("ETRN support is not configured.\n"));
return(PS_PROTOCOL);
#else
#ifdef HAVE_GETHOSTBYNAME
return(doETRN(ctl));
#else
- error(0, -1, _("Cannot support ETRN without gethostbyname(2).\n"));
+ report(stderr, -1, _("Cannot support ETRN without gethostbyname(2).\n"));
return(PS_PROTOCOL);
#endif /* HAVE_GETHOSTBYNAME */
#endif /* ETRN_ENABLE */
default:
- error(0, 0, _("unsupported protocol selected."));
+ report(stderr, 0, _("unsupported protocol selected."));
return(PS_PROTOCOL);
}
}
diff --git a/fetchmail.h b/fetchmail.h
index e1e04787..eb8bab8e 100644
--- a/fetchmail.h
+++ b/fetchmail.h
@@ -337,24 +337,18 @@ extern const char *fetchmailhost;
/* error.c: Error reporting */
#if defined(HAVE_STDARG_H)
-void error_init(int foreground);
-void error (int status, int errnum, const char *format, ...);
-void error_build (const char *format, ...);
-void error_complete (int status, int errnum, const char *format, ...);
-void error_at_line (int, int, const char *, unsigned int, const char *, ...);
+void report_init(FILE *fp, int foreground);
+void report (FILE *fp, int errnum, const char *format, ...);
+void report_build (FILE *fp, const char *format, ...);
+void report_complete (FILE *fp, int errnum, const char *format, ...);
+void report_at_line (FILE *fp, int, const char *, unsigned int, const char *, ...);
#else
-void error ();
-void error_build ();
-void error_complete ();
-void error_at_line ();
+void report ();
+void report_build ();
+void report_complete ();
+void report_at_line ();
#endif
-/* for now, send progress messages to stderr */
-#define progress error
-#define progress_build error_build
-#define progress_complete error_complete
-#define progress_at_line error_at_line
-
/* driver.c: transaction support */
void set_timeout(int);
#if defined(HAVE_STDARG_H)
@@ -455,7 +449,7 @@ char *xstrdup(const char *);
#pragma alloca
#endif
#endif
-#define xalloca(ptr, t, n) if (!(ptr = (t) alloca(n))) error(PS_UNDEFINED, 0, "alloca failed")
+#define xalloca(ptr, t, n) if (!(ptr = (t) alloca(n))) report(stderr, PS_UNDEFINED, 0, "alloca failed")
/* protocol driver and methods */
int do_protocol(struct query *, const struct method *);
diff --git a/getpass.c b/getpass.c
index dc6ea426..6c71ae9b 100644
--- a/getpass.c
+++ b/getpass.c
@@ -190,7 +190,7 @@ static void restore_tty_state(void)
static RETSIGTYPE sigint_handler(int signum)
{
restore_tty_state();
- error(1, 0, _("\nCaught signal... bailing out."));
+ report(stderr, 1, 0, _("\nCaught signal... bailing out."));
}
/* getpass.c ends here */
diff --git a/imap.c b/imap.c
index 8a0e310f..b085e35a 100644
--- a/imap.c
+++ b/imap.c
@@ -142,7 +142,7 @@ static int do_otp(int sock, struct query *ctl)
return rval;
if ((i = from64tobits(challenge, buffer)) < 0) {
- error(0, -1, _("Could not decode initial BASE64 challenge"));
+ report(stderr, -1, _("Could not decode initial BASE64 challenge"));
return PS_AUTHFAIL;
};
@@ -150,7 +150,7 @@ static int do_otp(int sock, struct query *ctl)
to64frombits(buffer, ctl->remotename, strlen(ctl->remotename));
if (outlevel >= O_MONITOR)
- progress(0, 0, "IMAP> %s", buffer);
+ report(stdout, 0, "IMAP> %s", buffer);
SockWrite(sock, buffer, strlen(buffer));
SockWrite(sock, "\r\n", 2);
@@ -158,7 +158,7 @@ static int do_otp(int sock, struct query *ctl)
return rval;
if ((i = from64tobits(challenge, buffer)) < 0) {
- error(0, -1, _("Could not decode OTP challenge"));
+ report(stderr, -1, _("Could not decode OTP challenge"));
return PS_AUTHFAIL;
};
@@ -177,7 +177,7 @@ static int do_otp(int sock, struct query *ctl)
to64frombits(buffer, response, strlen(response));
if (outlevel >= O_MONITOR)
- progress(0, 0, "IMAP> %s", buffer);
+ report(stdout, 0, "IMAP> %s", buffer);
SockWrite(sock, buffer, strlen(buffer));
SockWrite(sock, "\r\n", 2);
@@ -241,7 +241,7 @@ static int do_rfc1731(int sock, char *truename)
len = from64tobits(challenge1.cstr, buf1);
if (len < 0) {
- error(0, -1, _("could not decode initial BASE64 challenge"));
+ report(stderr, -1, _("could not decode initial BASE64 challenge"));
return PS_AUTHFAIL;
}
@@ -270,13 +270,13 @@ static int do_rfc1731(int sock, char *truename)
result = krb_mk_req(&authenticator, "imap", srvinst, srvrealm, 0);
if (result) {
- error(0, -1, "krb_mq_req: %s", krb_get_err_text(result));
+ report(stderr, -1, "krb_mq_req: %s", krb_get_err_text(result));
return PS_AUTHFAIL;
}
result = krb_get_cred("imap", srvinst, srvrealm, &credentials);
if (result) {
- error(0, -1, "krb_get_cred: %s", krb_get_err_text(result));
+ report(stderr, -1, "krb_get_cred: %s", krb_get_err_text(result));
return PS_AUTHFAIL;
}
@@ -286,18 +286,18 @@ static int do_rfc1731(int sock, char *truename)
result = krb_get_tf_fullname(TKT_FILE, tktuser, tktinst, tktrealm);
if (result) {
- error(0, -1, "krb_get_tf_fullname: %s", krb_get_err_text(result));
+ report(stderr, -1, "krb_get_tf_fullname: %s", krb_get_err_text(result));
return PS_AUTHFAIL;
}
if (strcmp(tktuser, user) != 0) {
- error(0, -1, _("principal %s in ticket does not match -u %s"), tktuser,
+ report(stderr, -1, _("principal %s in ticket does not match -u %s"), tktuser,
user);
return PS_AUTHFAIL;
}
if (tktinst[0]) {
- error(0, 0, _("non-null instance (%s) might cause strange behavior"),
+ report(stderr, 0, _("non-null instance (%s) might cause strange behavior"),
tktinst);
strcat(tktuser, ".");
strcat(tktuser, tktinst);
@@ -311,13 +311,13 @@ static int do_rfc1731(int sock, char *truename)
result = krb_mk_req(&authenticator, "imap", srvinst, srvrealm,
challenge1.cint);
if (result) {
- error(0, -1, "krb_mq_req: %s", krb_get_err_text(result));
+ report(stderr, -1, "krb_mq_req: %s", krb_get_err_text(result));
return PS_AUTHFAIL;
}
to64frombits(buf1, authenticator.dat, authenticator.length);
if (outlevel >= O_MONITOR) {
- progress(0, 0, "IMAP> %s", buf1);
+ report(stdout, 0, "IMAP> %s", buf1);
}
SockWrite(sock, buf1, strlen(buf1));
SockWrite(sock, "\r\n", 2);
@@ -363,14 +363,14 @@ static int do_rfc1731(int sock, char *truename)
len = from64tobits(buf2, buf1);
if (len < 0) {
- error(0, -1, _("could not decode BASE64 ready response"));
+ report(stderr, -1, _("could not decode BASE64 ready response"));
return PS_AUTHFAIL;
}
des_ecb_encrypt((des_cblock *)buf2, (des_cblock *)buf2, schedule, 0);
memcpy(challenge2.cstr, buf2, 4);
if (ntohl(challenge2.cint) != challenge1.cint + 1) {
- error(0, -1, _("challenge mismatch"));
+ report(stderr, -1, _("challenge mismatch"));
return PS_AUTHFAIL;
}
@@ -400,7 +400,7 @@ static int do_rfc1731(int sock, char *truename)
to64frombits(buf1, authenticator.dat, authenticator.length);
if (outlevel >= O_MONITOR) {
- progress(0, 0, "IMAP> %s", buf1);
+ report(stdout, 0, "IMAP> %s", buf1);
}
SockWrite(sock, buf1, strlen(buf1));
SockWrite(sock, "\r\n", 2);
@@ -443,13 +443,13 @@ static int do_gssauth(int sock, char *hostname, char *username)
maj_stat = gss_import_name(&min_stat, &request_buf, gss_nt_service_name,
&target_name);
if (maj_stat != GSS_S_COMPLETE) {
- error(0, -1, _("Couldn't get service name for [%s]"), buf1);
+ report(stderr, -1, _("Couldn't get service name for [%s]"), buf1);
return PS_AUTHFAIL;
}
else if (outlevel >= O_DEBUG) {
maj_stat = gss_display_name(&min_stat, target_name, &request_buf,
&mech_name);
- error(0, 0, _("Using service name [%s]"),request_buf.value);
+ report(stderr, 0, _("Using service name [%s]"),request_buf.value);
maj_stat = gss_release_buffer(&min_stat, &request_buf);
}
@@ -465,13 +465,13 @@ static int do_gssauth(int sock, char *hostname, char *username)
sec_token = GSS_C_NO_BUFFER;
context = GSS_C_NO_CONTEXT;
if (outlevel >= O_VERBOSE)
- progress(0,0,_("Sending credentials"));
+ report(stdout, 0,0,_("Sending credentials"));
do {
maj_stat = gss_init_sec_context(&min_stat, GSS_C_NO_CREDENTIAL,
&context, target_name, NULL, 0, 0, NULL, sec_token, NULL,
&send_token, &cflags, NULL);
if (maj_stat!=GSS_S_COMPLETE && maj_stat!=GSS_S_CONTINUE_NEEDED) {
- error(0, -1,_("Error exchanging credentials"));
+ report(stderr, -1,_("Error exchanging credentials"));
gss_release_name(&min_stat, &target_name);
/* wake up server and await NO response */
SockWrite(sock, "\r\n", 2);
@@ -484,7 +484,7 @@ static int do_gssauth(int sock, char *hostname, char *username)
SockWrite(sock, buf1, strlen(buf1));
SockWrite(sock, "\r\n", 2);
if (outlevel >= O_MONITOR)
- progress(0,0,"IMAP> %s", buf1);
+ report(stdout, 0,0,"IMAP> %s", buf1);
if (maj_stat == GSS_S_CONTINUE_NEEDED) {
if (result = gen_recv(sock, buf1, sizeof buf1)) {
gss_release_name(&min_stat, &target_name);
@@ -507,16 +507,16 @@ static int do_gssauth(int sock, char *hostname, char *username)
maj_stat = gss_unwrap(&min_stat, context, &request_buf, &send_token,
&cflags, &quality);
if (maj_stat != GSS_S_COMPLETE) {
- error(0,-1,_("Couldn't unwrap security level data"));
+ report(stderr, 0,-1,_("Couldn't unwrap security level data"));
gss_release_buffer(&min_stat, &send_token);
return PS_AUTHFAIL;
}
if (outlevel >= O_DEBUG)
- progress(0,0,_("Credential exchange complete"));
+ report(stdout, 0,0,_("Credential exchange complete"));
/* first octet is security levels supported. We want none, for now */
server_conf_flags = ((char *)send_token.value)[0];
if ( !(((char *)send_token.value)[0] & GSSAUTH_P_NONE) ) {
- error(0,-1,_("Server requires integrity and/or privacy"));
+ report(stderr, 0,-1,_("Server requires integrity and/or privacy"));
gss_release_buffer(&min_stat, &send_token);
return PS_AUTHFAIL;
}
@@ -525,11 +525,11 @@ static int do_gssauth(int sock, char *hostname, char *username)
/* we don't care about buffer size if we don't wrap data */
gss_release_buffer(&min_stat, &send_token);
if (outlevel >= O_DEBUG) {
- progress(0,0,_("Unwrapped security level flags: %s%s%s"),
+ report(stdout, 0,0,_("Unwrapped security level flags: %s%s%s"),
server_conf_flags & GSSAUTH_P_NONE ? "N" : "-",
server_conf_flags & GSSAUTH_P_INTEGRITY ? "I" : "-",
server_conf_flags & GSSAUTH_P_PRIVACY ? "C" : "-");
- progress(0,0,_("Maximum GSS token size is %ld"),buf_size);
+ report(stdout, 0,0,_("Maximum GSS token size is %ld"),buf_size);
}
/* now respond in kind (hack!!!) */
@@ -542,13 +542,13 @@ static int do_gssauth(int sock, char *hostname, char *username)
maj_stat = gss_wrap(&min_stat, context, 0, GSS_C_QOP_DEFAULT, &request_buf,
&cflags, &send_token);
if (maj_stat != GSS_S_COMPLETE) {
- error(0,-1,_("Error creating security level request"));
+ report(stderr, 0,-1,_("Error creating security level request"));
return PS_AUTHFAIL;
}
to64frombits(buf1, send_token.value, send_token.length);
if (outlevel >= O_DEBUG) {
- progress(0,0,_("Requesting authorisation as %s"), username);
- progress(0,0,"IMAP> %s",buf1);
+ report(stdout, 0,0,_("Requesting authorisation as %s"), username);
+ report(stdout, 0,0,"IMAP> %s",buf1);
}
SockWrite(sock, buf1, strlen(buf1));
SockWrite(sock, "\r\n", 2);
@@ -559,10 +559,10 @@ static int do_gssauth(int sock, char *hostname, char *username)
if (strstr(buf1, "OK")) {
/* flush security context */
if (outlevel >= O_DEBUG)
- progress(0, 0, _("Releasing GSS credentials"));
+ report(stdout, 0, _("Releasing GSS credentials"));
maj_stat = gss_delete_sec_context(&min_stat, &context, &send_token);
if (maj_stat != GSS_S_COMPLETE) {
- error(0, -1, _("Error releasing credentials"));
+ report(stderr, -1, _("Error releasing credentials"));
return PS_AUTHFAIL;
}
/* send_token may contain a notification to the server to flush
@@ -609,20 +609,20 @@ int imap_getauth(int sock, struct query *ctl, char *greeting)
{
imap_version = IMAP4rev1;
if (outlevel >= O_DEBUG)
- progress(0, 0, _("Protocol identified as IMAP4 rev 1"));
+ report(stdout, 0, _("Protocol identified as IMAP4 rev 1"));
}
else
{
imap_version = IMAP4;
if (outlevel >= O_DEBUG)
- progress(0, 0, _("Protocol identified as IMAP4 rev 0"));
+ report(stdout, 0, _("Protocol identified as IMAP4 rev 0"));
}
}
else if (ok == PS_ERROR)
{
imap_version = IMAP2;
if (outlevel >= O_DEBUG)
- progress(0, 0, _("Protocol identified as IMAP2 or IMAP2BIS"));
+ report(stdout, 0, _("Protocol identified as IMAP2 or IMAP2BIS"));
}
else
return(ok);
@@ -633,7 +633,7 @@ int imap_getauth(int sock, struct query *ctl, char *greeting)
if ((ctl->server.protocol == P_IMAP) && strstr(capabilities, "AUTH=X-OTP"))
{
if (outlevel >= O_DEBUG)
- progress(0, 0, _("OTP authentication is supported"));
+ report(stdout, 0, _("OTP authentication is supported"));
if (do_otp(sock, ctl) == PS_SUCCESS)
return(PS_SUCCESS);
};
@@ -645,13 +645,13 @@ int imap_getauth(int sock, struct query *ctl, char *greeting)
if (ctl->server.protocol == P_IMAP_GSS)
{
if (outlevel >= O_DEBUG)
- progress(0, 0, _("GSS authentication is supported"));
+ report(stdout, 0, _("GSS authentication is supported"));
return do_gssauth(sock, ctl->server.truename, ctl->remotename);
}
}
else if (ctl->server.protocol == P_IMAP_GSS)
{
- error(0,-1, _("Required GSS capability not supported by server"));
+ report(stderr, 0,-1, _("Required GSS capability not supported by server"));
return(PS_AUTHFAIL);
}
#endif /* GSSAPI */
@@ -660,14 +660,14 @@ int imap_getauth(int sock, struct query *ctl, char *greeting)
if (strstr(capabilities, "AUTH=KERBEROS_V4"))
{
if (outlevel >= O_DEBUG)
- progress(0, 0, _("KERBEROS_V4 authentication is supported"));
+ report(stdout, 0, _("KERBEROS_V4 authentication is supported"));
if (ctl->server.protocol == P_IMAP_K4)
{
if ((ok = do_rfc1731(sock, ctl->server.truename)))
{
if (outlevel >= O_MONITOR)
- progress(0, 0, "IMAP> *");
+ report(stdout, 0, "IMAP> *");
SockWrite(sock, "*\r\n", 3);
}
@@ -677,7 +677,7 @@ int imap_getauth(int sock, struct query *ctl, char *greeting)
}
else if (ctl->server.protocol == P_IMAP_K4)
{
- error(0,-1, _("Required KERBEROS_V4 capability not supported by server"));
+ report(stderr, 0,-1, _("Required KERBEROS_V4 capability not supported by server"));
return(PS_AUTHFAIL);
}
#endif /* KERBEROS_V4 */
@@ -685,7 +685,7 @@ int imap_getauth(int sock, struct query *ctl, char *greeting)
#ifdef __UNUSED__ /* The Cyrus IMAP4rev1 server chokes on this */
/* this handles either AUTH=LOGIN or AUTH-LOGIN */
if ((imap_version >= IMAP4rev1) && (!strstr(capabilities, "LOGIN"))) {
- error(0,-1, _("Required LOGIN capability not supported by server"));
+ report(stderr, 0,-1, _("Required LOGIN capability not supported by server"));
return PS_AUTHFAIL;
};
#endif /* __UNUSED__ */
@@ -739,7 +739,7 @@ static int imap_getrange(int sock,
count = -1;
if (ok || gen_transact(sock, "NOOP"))
{
- error(0, 0, _("re-poll failed"));
+ report(stderr, 0, _("re-poll failed"));
return(ok);
}
else if (count == -1) /* no EXISTS response to NOOP */
@@ -756,7 +756,7 @@ static int imap_getrange(int sock,
ok = gen_transact(sock, "EXAMINE %s", folder ? folder : "INBOX");
if (ok != 0)
{
- error(0, 0, _("mailbox selection failed"));
+ report(stderr, 0, _("mailbox selection failed"));
return(ok);
}
}
diff --git a/interface.c b/interface.c
index 140822d0..22c1a35b 100644
--- a/interface.c
+++ b/interface.c
@@ -168,7 +168,7 @@ void interface_parse(char *buf, struct hostdata *hp)
/* find and isolate just the IP address */
if (!(cp1 = strchr(buf, '/')))
- (void) error(PS_SYNTAX, 0, _("missing IP interface address"));
+ (void) report(stderr, PS_SYNTAX, 0, _("missing IP interface address"));
*cp1++ = '\000';
/* find and isolate just the netmask */
@@ -180,9 +180,9 @@ void interface_parse(char *buf, struct hostdata *hp)
/* convert IP address and netmask */
hp->interface_pair = (struct interface_pair_s *)xmalloc(sizeof(struct interface_pair_s));
if (!inet_aton(cp1, &hp->interface_pair->interface_address))
- (void) error(PS_SYNTAX, 0, _("invalid IP interface address"));
+ (void) report(stderr, PS_SYNTAX, 0, _("invalid IP interface address"));
if (!inet_aton(cp2, &hp->interface_pair->interface_mask))
- (void) error(PS_SYNTAX, 0, _("invalid IP interface mask"));
+ (void) report(stderr, PS_SYNTAX, 0, _("invalid IP interface mask"));
/* apply the mask now to the IP address (range) required */
hp->interface_pair->interface_address.s_addr &=
hp->interface_pair->interface_mask.s_addr;
@@ -218,7 +218,7 @@ void interface_note_activity(struct hostdata *hp)
}
#ifdef ACTIVITY_DEBUG
- (void) progress(0, 0, _("activity on %s -noted- as %d"),
+ (void) report(stdout, 0, _("activity on %s -noted- as %d"),
hp->monitor, hp->monitor_io);
#endif
}
@@ -232,7 +232,7 @@ int interface_approve(struct hostdata *hp)
if (hp->interface) {
/* get interface info */
if (!get_ifinfo(hp->interface, &ifinfo)) {
- (void) progress(0, 0, _("skipping poll of %s, %s down"),
+ (void) report(stdout, 0, _("skipping poll of %s, %s down"),
hp->pollname, hp->interface);
return(FALSE);
}
@@ -240,7 +240,7 @@ int interface_approve(struct hostdata *hp)
if ((ifinfo.addr.s_addr &
hp->interface_pair->interface_mask.s_addr) !=
hp->interface_pair->interface_address.s_addr) {
- (void) progress(0, 0,
+ (void) report(stdout, 0,
_("skipping poll of %s, %s IP address excluded"),
hp->pollname, hp->interface);
return(FALSE);
@@ -252,14 +252,14 @@ int interface_approve(struct hostdata *hp)
return(TRUE);
#ifdef ACTIVITY_DEBUG
- (void) progress(0, 0, _("activity on %s checked as %d"),
+ (void) report(stdout, 0, _("activity on %s checked as %d"),
hp->monitor, hp->monitor_io);
#endif
/* if monitoring, check link for activity if it is up */
if (get_ifinfo(hp->monitor, &ifinfo) &&
hp->monitor_io == ifinfo.rx_packets +
ifinfo.tx_packets) {
- (void) progress(0, 0, _("skipping poll of %s, %s inactive"),
+ (void) report(stdout, 0, _("skipping poll of %s, %s inactive"),
hp->pollname, hp->monitor);
return(FALSE);
}
diff --git a/pop3.c b/pop3.c
index 9b0de48d..4eb1aa07 100644
--- a/pop3.c
+++ b/pop3.c
@@ -92,7 +92,7 @@ int pop3_ok (int sock, char *argbuf)
else
ok = PS_AUTHFAIL;
if (*bufp)
- error(0,0,bufp);
+ report(stderr, 0,0,bufp);
}
else
ok = PS_PROTOCOL;
@@ -205,7 +205,7 @@ int pop3_getauth(int sock, struct query *ctl, char *greeting)
for (start = greeting; *start != 0 && *start != '<'; start++)
continue;
if (*start == 0) {
- error(0, -1, _("Required APOP timestamp not found in greeting"));
+ report(stderr, -1, _("Required APOP timestamp not found in greeting"));
return(PS_AUTHFAIL);
}
@@ -213,7 +213,7 @@ int pop3_getauth(int sock, struct query *ctl, char *greeting)
for (end = start; *end != 0 && *end != '>'; end++)
continue;
if (*end == 0 || end == start + 1) {
- error(0, -1, _("Timestamp syntax error in greeting"));
+ report(stderr, -1, _("Timestamp syntax error in greeting"));
return(PS_AUTHFAIL);
}
else
@@ -235,7 +235,7 @@ int pop3_getauth(int sock, struct query *ctl, char *greeting)
break;
default:
- error(0, 0, _("Undefined protocol request in POP3_auth"));
+ report(stderr, 0, _("Undefined protocol request in POP3_auth"));
ok = PS_ERROR;
}
@@ -243,7 +243,7 @@ int pop3_getauth(int sock, struct query *ctl, char *greeting)
{
/* maybe we detected a lock-busy condition? */
if (ok == PS_LOCKBUSY)
- error(0, 0, _("lock busy! Is another session active?"));
+ report(stderr, 0, _("lock busy! Is another session active?"));
return(ok);
}
@@ -351,7 +351,7 @@ pop3_slowuidl( int sock, struct query *ctl, int *countp, int *newp)
try_id--;
}
} else {
- error(0,0,_("Messages inserted into list on server. "
+ report(stderr, 0,0,_("Messages inserted into list on server. "
"Cannot handle this."));
return -1;
}
@@ -425,7 +425,7 @@ static int pop3_getrange(int sock,
{
if (sscanf(buf, "%d", &last) == 0)
{
- error(0, 0, _("protocol error"));
+ report(stderr, 0, _("protocol error"));
return(PS_ERROR);
}
*newp = (*countp - last);
@@ -438,7 +438,7 @@ static int pop3_getrange(int sock,
/* don't worry, yet! do it the slow way */
if((ok = pop3_slowuidl( sock, ctl, countp, newp))!=0)
{
- error(0, 0, _("protocol error while fetching UIDLs"));
+ report(stderr, 0, _("protocol error while fetching UIDLs"));
return(PS_ERROR);
}
}
diff --git a/report.c b/report.c
index 2e3d0b34..dea48801 100644
--- a/report.c
+++ b/report.c
@@ -77,9 +77,6 @@ static unsigned int use_syslog;
/* This variable is incremented each time `error' is called. */
unsigned int error_message_count;
-/* for now, send all error messages to stderr */
-#define errfp stderr
-
#ifdef _LIBC
/* In the GNU C library, there is a predefined variable for this. */
@@ -108,16 +105,14 @@ char *strerror (errnum)
/* Print the program name and error message MESSAGE, which is a printf-style
format string with optional args.
- If ERRNUM is nonzero, print its corresponding system error message.
- Exit with status STATUS if it is nonzero. */
+ If ERRNUM is nonzero, print its corresponding system error message. */
/* VARARGS */
void
#ifdef HAVE_STDARG_H
-error (int status, int errnum, const char *message, ...)
+report (FILE *errfp, int errnum, const char *message, ...)
#else
-error (status, errnum, message, va_alist)
- int status;
+report (FILE *errfp, errnum, message, va_alist)
int errnum;
const char *message;
va_dcl
@@ -131,7 +126,7 @@ error (status, errnum, message, va_alist)
if (partial_message_size_used != 0)
{
partial_message_size_used = 0;
- error (0, 0, _("%s (log message incomplete)"), partial_message);
+ report (errfp, 0, 0, _("%s (log message incomplete)"), partial_message);
}
#if defined(HAVE_SYSLOG)
@@ -142,7 +137,7 @@ error (status, errnum, message, va_alist)
#ifdef VA_START
VA_START (args, message);
#endif
- priority = status? LOG_ALERT : errnum? LOG_ERR : LOG_INFO;
+ priority = errnum ? LOG_ERR : LOG_INFO;
if (errnum > 0)
{
@@ -234,8 +229,6 @@ error (status, errnum, message, va_alist)
fflush (errfp);
}
++error_message_count;
- if (status)
- exit (status);
}
/*
@@ -279,9 +272,9 @@ void error_init(int mode)
void
#ifdef HAVE_STDARG_H
-error_build (const char *message, ...)
+report_build (FILE *errfp, const char *message, ...)
#else
-error_build (message, va_alist)
+report_build (FILE *errfp, message, va_alist)
const char *message;
va_dcl
#endif
@@ -331,7 +324,7 @@ error_build (message, va_alist)
if (partial_message_size_used >= partial_message_size)
{
partial_message_size_used = 0;
- error (PS_UNDEFINED, 0, _("partial error message buffer overflow"));
+ report (PS_UNDEFINED, 0, _("partial error message buffer overflow"));
}
#endif
va_end (args);
@@ -359,7 +352,7 @@ error_build (message, va_alist)
if ((partial_message_size_used = strlen (partial_message)) >= partial_message_size)
{
partial_message_size_used = 0;
- error (PS_UNDEFINED, 0, _("partial error message buffer overflow"));
+ report (PS_UNDEFINED, 0, _("partial error message buffer overflow"));
}
#endif
#endif
@@ -379,10 +372,9 @@ error_build (message, va_alist)
void
#ifdef HAVE_STDARG_H
-error_complete (int status, int errnum, const char *message, ...)
+report_complete (FILE *errfp, int errnum, const char *message, ...)
#else
-error_complete (status, errnum, message, va_alist)
- int status;
+report_complete (FILE *errfp, errnum, message, va_alist)
int errnum;
const char *message;
va_dcl
@@ -433,7 +425,7 @@ error_complete (status, errnum, message, va_alist)
if (partial_message_size_used >= partial_message_size)
{
partial_message_size_used = 0;
- error (PS_UNDEFINED, 0, _("partial error message buffer overflow"));
+ report (PS_UNDEFINED, 0, _("partial error message buffer overflow"));
}
#endif
va_end (args);
@@ -461,7 +453,7 @@ error_complete (status, errnum, message, va_alist)
if ((partial_message_size_used = strlen (partial_message)) >= partial_message_size)
{
partial_message_size_used = 0;
- error (PS_UNDEFINED, 0, _("partial error message buffer overflow"));
+ report (PS_UNDEFINED, 0, _("partial error message buffer overflow"));
}
#endif
#endif
@@ -480,12 +472,9 @@ error_complete (status, errnum, message, va_alist)
fflush (errfp);
++error_message_count;
-
- if (status)
- exit(status);
}
else
- error (status, errnum, "%s", partial_message);
+ report (errfp, errnum, "%s", partial_message);
}
/* Sometimes we want to have at most one error per line. This
@@ -494,11 +483,10 @@ int error_one_per_line;
void
#ifdef HAVE_STDARG_H
-error_at_line (int status, int errnum, const char *file_name,
+report_at_line (FILE *errfp, int errnum, const char *file_name,
unsigned int line_number, const char *message, ...)
#else
-error_at_line (status, errnum, file_name, line_number, message, va_alist)
- int status;
+report_at_line (FILE *errfp, errnum, file_name, line_number, message, va_alist)
int errnum;
const char *file_name;
unsigned int line_number;
@@ -557,6 +545,4 @@ error_at_line (status, errnum, file_name, line_number, message, va_alist)
fprintf (errfp, ": %s", strerror (errnum));
putc ('\n', errfp);
fflush (errfp);
- if (status)
- exit (status);
}
diff --git a/rfc822.c b/rfc822.c
index 06a2da0e..fe73b887 100644
--- a/rfc822.c
+++ b/rfc822.c
@@ -53,7 +53,7 @@ const char *host; /* server hostname */
#ifndef TESTMAIN
if (outlevel >= O_DEBUG)
- error_build("About to rewrite %s", buf);
+ report_build(stdout, "About to rewrite %s", buf);
/* make room to hack the address; buf must be malloced */
for (cp = buf; *cp; cp++)
@@ -178,7 +178,7 @@ const char *host; /* server hostname */
#ifndef TESTMAIN
if (outlevel >= O_DEBUG)
- error_complete(0, 0, "Rewritten version is %s", buf);
+ report_complete(stdout, 0, "Rewritten version is %s", buf);
#endif /* TESTMAIN */
return(buf);
}
diff --git a/rpa.c b/rpa.c
index f295e47d..1ecc2116 100644
--- a/rpa.c
+++ b/rpa.c
@@ -120,7 +120,7 @@ int POP3_auth_rpa (unsigned char *userid, unsigned char *passphrase, int socket)
SockPrintf(socket,"AUTH RPA\r\n");
if (outlevel >= O_MONITOR)
- progress(0, 0, "> AUTH RPA\n");
+ report(stdout, 0, "> AUTH RPA\n");
/* Create unicode user name in Nu. */
/* Create MD5 digest of user's passphrase in Pu */
@@ -134,7 +134,7 @@ int POP3_auth_rpa (unsigned char *userid, unsigned char *passphrase, int socket)
if ((ok = POP3_rpa_resp(buf,socket)) != 0)
{
if (outlevel > O_SILENT && outlevel < O_MONITOR)
- progress(0, 0, "%s\n",buf);
+ report(stdout, 0, "%s\n",buf);
return(ok);
}
@@ -156,17 +156,17 @@ int POP3_auth_rpa (unsigned char *userid, unsigned char *passphrase, int socket)
SockPrintf(socket,"%s\r\n",buf);
#endif
if (outlevel >= O_MONITOR)
- progress(0, 0, "> %s\n",buf);
+ report(stdout, 0, "> %s\n",buf);
if ((ok = POP3_rpa_resp(buf,socket)) != 0)
{
if (outlevel > O_SILENT && outlevel < O_MONITOR)
- progress(0, 0, "%s\n",buf);
+ report(stdout, 0, "%s\n",buf);
return(ok);
}
if ((rxlen = DecBase64(buf)) == 0)
{
if (outlevel > O_SILENT)
- error(0, 0, _("RPA token 2: Base64 decode error\n"));
+ report(stderr, 0, _("RPA token 2: Base64 decode error\n"));
return(PS_RPA);
}
bufp = buf;
@@ -177,35 +177,35 @@ int POP3_auth_rpa (unsigned char *userid, unsigned char *passphrase, int socket)
verh = *(bufp++); verl = *(bufp++);
if (outlevel >= O_DEBUG)
- progress(0, 0, _("Service chose RPA version %d.%d\n"),verh,verl);
+ report(stdout, 0, _("Service chose RPA version %d.%d\n"),verh,verl);
Csl = *(bufp++);
memcpy(Cs, bufp, Csl);
bufp += Csl;
if (outlevel >= O_DEBUG)
{
- progress(0, 0, _("Service challenge (l=%d):"),Csl);
+ report(stdout, 0, _("Service challenge (l=%d):"),Csl);
for (i=0; i<Csl; i++)
- progress_build("%02X ",Cs[i]);
- progress_complete(0, 0, "");
+ report_build(stdout, "%02X ",Cs[i]);
+ report_complete(stdout, 0, "");
}
memcpy(Ts, bufp, Tsl);
Ts[Tsl] = 0;
bufp += Tsl;
if (outlevel >= O_DEBUG)
- progress(0, 0, _("Service timestamp %s\n"),Ts);
+ report(stdout, 0, _("Service timestamp %s\n"),Ts);
rll = *(bufp++) << 8; rll = rll | *(bufp++);
if ((bufp-buf+rll) != rxlen)
{
if (outlevel > O_SILENT)
- error(0, 0, _("RPA token 2 length error\n"));
+ report(stderr, 0, _("RPA token 2 length error\n"));
return(PS_RPA);
}
if (outlevel >= O_DEBUG)
- progress(0, 0, _("Realm list: %s\n"),bufp);
+ report(stdout, 0, _("Realm list: %s\n"),bufp);
if (SetRealmService(bufp) != 0)
{
if (outlevel > O_SILENT)
- error(0, 0, _("RPA error in service@realm string\n"));
+ report(stderr, 0, _("RPA error in service@realm string\n"));
return(PS_RPA);
}
@@ -232,17 +232,17 @@ int POP3_auth_rpa (unsigned char *userid, unsigned char *passphrase, int socket)
SockPrintf(socket,"%s\r\n",buf);
#endif
if (outlevel >= O_MONITOR)
- progress(0, 0, "> %s\n",buf);
+ report(stdout, 0, "> %s\n",buf);
if ((ok = POP3_rpa_resp(buf,socket)) != 0)
{
if (outlevel > O_SILENT && outlevel < O_MONITOR)
- progress(0, 0, "%s\n",buf);
+ report(stdout, 0, "%s\n",buf);
return(ok);
}
if ((rxlen = DecBase64(buf)) == 0)
{
if (outlevel > O_SILENT)
- error(0, 0, _("RPA token 4: Base64 decode error\n"));
+ report(stderr, 0, _("RPA token 4: Base64 decode error\n"));
return(PS_RPA);
}
bufp = buf;
@@ -253,10 +253,10 @@ int POP3_auth_rpa (unsigned char *userid, unsigned char *passphrase, int socket)
aulin = *(bufp++);
if (outlevel >= O_DEBUG)
{
- progress(0, 0, _("User authentication (l=%d):"),aulin);
+ report(stdout, 0, _("User authentication (l=%d):"),aulin);
for (i=0; i<aulin; i++)
- progress_build("%02X ",bufp[i]);
- progress_complete(0, 0, "");
+ report_build(stdout, "%02X ",bufp[i]);
+ report_complete(stdout, 0, "");
}
if (aulin == Aul) memcpy(Au, bufp, Aul);
bufp += aulin;
@@ -267,46 +267,46 @@ int POP3_auth_rpa (unsigned char *userid, unsigned char *passphrase, int socket)
{
status = *(bufp++);
if (outlevel >= O_DEBUG)
- progress(0, 0, _("RPA status: %02X\n"),status);
+ report(stdout, 0, _("RPA status: %02X\n"),status);
}
else status = 0;
if ((bufp - buf) != rxlen)
{
if (outlevel > O_SILENT)
- error(0, 0, _("RPA token 4 length error\n"));
+ report(stderr, 0, _("RPA token 4 length error\n"));
return(PS_RPA);
}
if (status != 0)
{
if (outlevel > O_SILENT)
if (status < 4)
- error(0, 0, _("RPA rejects you: %s\n"),_(stdec[status]));
+ report(stderr, 0, _("RPA rejects you: %s\n"),_(stdec[status]));
else
- error(0, 0, _("RPA rejects you, reason unknown\n"));
+ report(stderr, 0, _("RPA rejects you, reason unknown\n"));
return(PS_AUTHFAIL);
}
if (Aul != aulin)
{
- error(0, 0, _("RPA User Authentication length error: %d\n"),aulin);
+ report(stderr, 0, _("RPA User Authentication length error: %d\n"),aulin);
return(PS_RPA);
}
if (Kusl != kuslin)
{
- error(0, 0, _("RPA Session key length error: %d\n"),kuslin);
+ report(stderr, 0, _("RPA Session key length error: %d\n"),kuslin);
return(PS_RPA);
}
if (CheckUserAuth() != 0)
{
if (outlevel > O_SILENT)
- error(0, 0, _("RPA _service_ auth fail. Spoof server?\n"));
+ report(stderr, 0, _("RPA _service_ auth fail. Spoof server?\n"));
return(PS_AUTHFAIL);
}
if (outlevel >= O_DEBUG)
{
- progress(0, 0, _("Session key established:"));
+ report(stdout, 0, _("Session key established:"));
for (i=0; i<Kusl; i++)
- progress_build("%02X ",Kus[i]);
- progress_complete(0, 0, "");
+ report_build(stdout, "%02X ",Kus[i]);
+ report_complete(stdout, 0, "");
}
/* Assemble Token 5 in buf and send (not in ver 2 though) */
@@ -324,17 +324,17 @@ int POP3_auth_rpa (unsigned char *userid, unsigned char *passphrase, int socket)
SockPrintf(socket,"%s\r\n",buf);
#endif
if (outlevel >= O_MONITOR)
- progress(0, 0, "> %s\n",buf);
+ report(stdout, 0, "> %s\n",buf);
if ((ok = POP3_rpa_resp(buf,socket)) != 0)
{
if (outlevel > O_SILENT && outlevel < O_MONITOR)
- progress(0, 0, "%s\n",buf);
+ report(stdout, 0, "%s\n",buf);
return(ok);
}
}
if (outlevel > O_SILENT)
- progress(0, 0, _("RPA authorisation complete\n"));
+ report(stdout, 0, _("RPA authorisation complete\n"));
return(PS_SUCCESS);
}
@@ -363,7 +363,7 @@ int socket;
int sockrc;
if (outlevel >= O_DEBUG)
- progress(0, 0, _("Get response\n"));
+ report(stdout, 0, _("Get response\n"));
#ifndef TESTMODE
sockrc = gen_recv(socket, buf, sizeof(buf));
#else
@@ -371,7 +371,7 @@ int socket;
if (linecount == 1) strcpy(buf,line1);
if (linecount == 2) strcpy(buf,line2);
if (linecount == 3) strcpy(buf,line3);
-/* progress(0, 0, "--> "); fflush(stderr); */
+/* report(stdout, 0, "--> "); fflush(stderr); */
/* scanf("%s",&buf) */
sockrc = PS_SUCCESS;
#endif
@@ -393,7 +393,7 @@ int socket;
else
ok = PS_SOCKET;
if (outlevel >= O_DEBUG)
- progress(0, 0, _("Get response return %d [%s]\n"), ok, buf);
+ report(stdout, 0, _("Get response return %d [%s]\n"), ok, buf);
buf[sockrc] = 0;
return(ok);
}
@@ -455,7 +455,7 @@ int rxlen;
save = *pptr;
if (**pptr != HDR)
{
- if (outlevel > O_SILENT) error(0, 0, _("Hdr not 60\n"));
+ if (outlevel > O_SILENT) report(stderr, 0, _("Hdr not 60\n"));
return(0);
}
(*pptr)++;
@@ -476,18 +476,18 @@ int rxlen;
if (len==0)
{
if (outlevel>O_SILENT)
- error(0, 0, _("Token length error\n"));
+ report(stderr, 0, _("Token length error\n"));
}
else if (((*pptr-save)+len) != rxlen)
{
if (outlevel>O_SILENT)
- error(0, 0, _("Token Length %d disagrees with rxlen %d\n"),len,rxlen);
+ report(stderr, 0, _("Token Length %d disagrees with rxlen %d\n"),len,rxlen);
len = 0;
}
else if (memcmp(*pptr,MECH,11))
{
if (outlevel > O_SILENT)
- error(0, 0, _("Mechanism field incorrect\n"));
+ report(stderr, 0, _("Mechanism field incorrect\n"));
len = 0;
}
else (*pptr) += 11; /* Skip mechanism field */
@@ -524,7 +524,7 @@ unsigned char *bufp;
else if ( ch=='+' ) new = 62;
else if ( ch=='/' ) new = 63;
else {
- error(0, 0, _("dec64 error at char %d: %x\n"), inp - bufp, ch);
+ report(stderr, 0, _("dec64 error at char %d: %x\n"), inp - bufp, ch);
return(0);
}
part=((part & 0x3F)*64) + new;
@@ -539,12 +539,12 @@ unsigned char *bufp;
}
if (outlevel >= O_MONITOR)
{
- progress(0, 0, _("Inbound binary data:\n"));
+ report(stdout, 0, _("Inbound binary data:\n"));
for (i=0; i<cnt; i++)
{
- progress_build("%02X ",bufp[i]);
+ report_build(stdout, "%02X ",bufp[i]);
if (((i % 16)==15) || (i==(cnt-1)))
- progress_complete(0, 0, "");
+ report_complete(stdout, 0, "");
}
}
return(cnt);
@@ -577,12 +577,12 @@ int len;
if (outlevel >= O_MONITOR)
{
- progress(0, 0, _("Outbound data:\n"));
+ report(stdout, 0, _("Outbound data:\n"));
for (i=0; i<len; i++)
{
- progress_build("%02X ",bufp[i]);
+ report_build(stdout, "%02X ",bufp[i]);
if (((i % 16)==15) || (i==(len-1)))
- progress_complete(0, 0, "");
+ report_complete(stdout, 0, "");
}
}
outp = bufp + (((len-1)/3)*4);
@@ -643,17 +643,17 @@ int conv;
if ( ((**pptr)!=delim) && ((**pptr)!=0) && ((*plen)==STRMAX) )
{
if (outlevel > O_SILENT)
- error(0, 0, _("RPA String too long\n"));
+ report(stderr, 0, _("RPA String too long\n"));
*plen = 0;
}
if (outlevel >= O_DEBUG)
{
- progress(0, 0, _("Unicode:"));
+ report(stdout, 0, _("Unicode:"));
for (i=0; i<(*plen); i++)
{
- progress_build("%02X ",buf[i]);
+ report_build(stdout, "%02X ",buf[i]);
if (((i % 16)==15) || (i==((*plen)-1)))
- progress_complete(0, 0, "");
+ report_complete(stdout, 0, "");
}
}
}
@@ -710,11 +710,11 @@ int len;
devrandom = fopen("/dev/urandom","rb");
if (devrandom == NULL && outlevel > O_SILENT)
{
- progress(0, 0, _("RPA Failed open of /dev/urandom. This shouldn't\n"));
- progress(0, 0, _(" prevent you logging in, but means you\n"));
- progress(0, 0, _(" cannot be sure you are talking to the\n"));
- progress(0, 0, _(" service that you think you are (replay\n"));
- progress(0, 0, _(" attacks by a dishonest service are possible.)\n"));
+ report(stdout, 0, _("RPA Failed open of /dev/urandom. This shouldn't\n"));
+ report(stdout, 0, _(" prevent you logging in, but means you\n"));
+ report(stdout, 0, _(" cannot be sure you are talking to the\n"));
+ report(stdout, 0, _(" service that you think you are (replay\n"));
+ report(stdout, 0, _(" attacks by a dishonest service are possible.)\n"));
}
for(i=0; i<len; i++)
@@ -725,12 +725,12 @@ int len;
if (outlevel >= O_DEBUG)
{
- progress(0, 0, _("User challenge:"));
+ report(stdout, 0, _("User challenge:"));
for (i=0; i<len; i++)
{
- progress_build("%02X ",buf[i]);
+ report_build(stdout, "%02X ",buf[i]);
if (((i % 16)==15) || (i==(len-1)))
- progress_complete(0, 0, "");
+ report_complete(stdout, 0, "");
}
}
}
@@ -883,12 +883,12 @@ unsigned char* out;
if (outlevel >= O_DEBUG)
{
- progress(0, 0, _("MD5 being applied to data block:\n"));
+ report(stdout, 0, _("MD5 being applied to data block:\n"));
for (i=0; i<len; i++)
{
- progress_build("%02X ",in[i]);
+ report_build(stdout, "%02X ",in[i]);
if (((i % 16)==15) || (i==(len-1)))
- progress_complete(0, 0, "");
+ report_complete(stdout, 0, "");
}
}
MD5Init( &md5context );
@@ -896,12 +896,12 @@ unsigned char* out;
MD5Final( out, &md5context );
if (outlevel >= O_DEBUG)
{
- progress(0, 0, _("MD5 result is: "));
+ report(stdout, 0, _("MD5 result is: "));
for (i=0; i<16; i++)
{
- progress_build("%02X ",out[i]);
+ report_build(stdout, "%02X ",out[i]);
}
- progress_complete(0, 0, "");
+ report_complete(stdout, 0, "");
}
}
#endif /* POP3_ENABLE && RPA_ENABLE */
diff --git a/sink.c b/sink.c
index fdf9a0e3..5790ebd4 100644
--- a/sink.c
+++ b/sink.c
@@ -162,7 +162,7 @@ static int smtp_open(struct query *ctl)
ctl->destaddr = ctl->smtpaddress ? ctl->smtpaddress : ( ctl->smtphost ? ctl->smtphost : "localhost");
if (outlevel >= O_DEBUG && ctl->smtp_socket != -1)
- progress(0, 0, _("forwarding to %s"), ctl->smtphost);
+ report(stdout, 0, _("forwarding to %s"), ctl->smtphost);
return(ctl->smtp_socket);
}
@@ -284,7 +284,7 @@ static int send_bouncemail(struct msgblk *msg, int userclass,
ts = rfc822timestamp();
if (outlevel >= O_VERBOSE)
- progress(0, 0, "SMTP: (bounce-message body)");
+ report(stdout, 0, "SMTP: (bounce-message body)");
/* bouncemail headers */
SockPrintf(sock, "Return-Path: <>");
@@ -367,7 +367,7 @@ static int send_bouncemail(struct msgblk *msg, int userclass,
return(TRUE);
}
-static int handle_smtp_error(struct query *ctl, struct msgblk *msg)
+static int handle_smtp_report(struct query *ctl, struct msgblk *msg)
/* handle SMTP errors based on the content of SMTP_response */
{
int smtperr = atoi(smtp_response);
@@ -413,7 +413,7 @@ static int handle_smtp_error(struct query *ctl, struct msgblk *msg)
* an error when the return code is less specific.
*/
if (smtperr >= 400)
- error(0, -1, _("%cMTP error: %s"),
+ report(stderr, -1, _("%cMTP error: %s"),
ctl->listener,
smtp_response);
@@ -516,7 +516,7 @@ int open_sink(struct query *ctl, struct msgblk *msg,
if (ferror(sinkfp))
{
- error(0, -1, _("BSMTP file open or preamble write failed"));
+ report(stderr, -1, _("BSMTP file open or preamble write failed"));
return(PS_BSMTP);
}
}
@@ -637,7 +637,7 @@ int open_sink(struct query *ctl, struct msgblk *msg,
if (outlevel >= O_DEBUG)
- progress(0, 0, _("about to deliver with: %s"), before);
+ report(stdout, 0, _("about to deliver with: %s"), before);
#ifdef HAVE_SETEUID
/*
@@ -660,7 +660,7 @@ int open_sink(struct query *ctl, struct msgblk *msg,
if (!sinkfp)
{
- error(0, 0, _("MDA open failed"));
+ report(stderr, 0, _("MDA open failed"));
return(PS_IOERR);
}
@@ -677,7 +677,7 @@ int open_sink(struct query *ctl, struct msgblk *msg,
/* build a connection to the SMTP listener */
if ((smtp_open(ctl) == -1))
{
- error(0, errno, _("%cMTP connect to %s failed"),
+ report(stderr, errno, _("%cMTP connect to %s failed"),
ctl->listener,
ctl->smtphost ? ctl->smtphost : "localhost");
return(PS_SMTP);
@@ -716,7 +716,7 @@ int open_sink(struct query *ctl, struct msgblk *msg,
*/
ap = (msg->return_path[0]) ? msg->return_path : user;
if (SMTP_from(ctl->smtp_socket, ap, options) != SM_OK)
- return(handle_smtp_error(ctl, msg));
+ return(handle_smtp_report(ctl, msg));
/*
* Now list the recipient addressees
@@ -755,7 +755,7 @@ int open_sink(struct query *ctl, struct msgblk *msg,
(*bad_addresses)++;
idp->val.status.mark = XMIT_RCPTBAD;
if (outlevel >= O_VERBOSE)
- error(0, 0,
+ report(stderr, 0,
_("%cMTP listener doesn't like recipient address `%s'"),
ctl->listener, addr);
}
@@ -786,13 +786,13 @@ int open_sink(struct query *ctl, struct msgblk *msg,
if (SMTP_rcpt(ctl->smtp_socket, addr) != SM_OK)
{
- error(0, 0, _("can't even send to %s!"), run.postmaster);
+ report(stderr, 0, _("can't even send to %s!"), run.postmaster);
SMTP_rset(ctl->smtp_socket); /* required by RFC1870 */
return(PS_SMTP);
}
if (outlevel >= O_VERBOSE)
- error(0, 0, _("no address matches; forwarding to %s."), run.postmaster);
+ report(stderr, 0, _("no address matches; forwarding to %s."), run.postmaster);
}
/*
@@ -800,7 +800,7 @@ int open_sink(struct query *ctl, struct msgblk *msg,
* Some listeners (like zmailer) may return antispam errors here.
*/
if (SMTP_data(ctl->smtp_socket) != SM_OK)
- return(handle_smtp_error(ctl, msg));
+ return(handle_smtp_report(ctl, msg));
}
/*
@@ -846,7 +846,7 @@ int close_sink(struct query *ctl, struct msgblk *msg, flag forward)
signal(SIGCHLD, sigchld);
if (rc)
{
- error(0, -1, _("MDA exited abnormally or returned nonzero status"));
+ report(stderr, -1, _("MDA exited abnormally or returned nonzero status"));
return(FALSE);
}
}
@@ -858,7 +858,7 @@ int close_sink(struct query *ctl, struct msgblk *msg, flag forward)
fclose(sinkfp);
if (ferror(sinkfp))
{
- error(0, -1, _("Message termination or close of BSMTP file failed"));
+ report(stderr, -1, _("Message termination or close of BSMTP file failed"));
return(FALSE);
}
}
@@ -867,11 +867,11 @@ int close_sink(struct query *ctl, struct msgblk *msg, flag forward)
/* write message terminator */
if (SMTP_eom(ctl->smtp_socket) != SM_OK)
{
- if (handle_smtp_error(ctl, msg) != PS_REFUSED)
+ if (handle_smtp_report(ctl, msg) != PS_REFUSED)
return(FALSE);
else
{
- error(0, -1, _("SMTP listener refused delivery"));
+ report(stderr, -1, _("SMTP listener refused delivery"));
return(TRUE);
}
}
@@ -899,9 +899,9 @@ int close_sink(struct query *ctl, struct msgblk *msg, flag forward)
* comply.
*/
if (atoi(smtp_response) == 503)
- error(0, -1, _("LMTP delivery error on EOM"));
+ report(stderr, -1, _("LMTP delivery error on EOM"));
else
- error(0, -1,
+ report(stderr, -1,
_("Unexpected non-503 response to LMTP EOM: %s"),
smtp_response);
diff --git a/smtp.c b/smtp.c
index 31a8a983..70af87d5 100644
--- a/smtp.c
+++ b/smtp.c
@@ -47,7 +47,7 @@ int SMTP_helo(int sock,const char *host)
SockPrintf(sock,"HELO %s\r\n", host);
if (outlevel >= O_MONITOR)
- progress(0, 0, "SMTP> HELO %s", host);
+ report(stdout, 0, "SMTP> HELO %s", host);
ok = SMTP_ok(sock);
return ok;
}
@@ -59,7 +59,7 @@ int SMTP_ehlo(int sock, const char *host, int *opt)
SockPrintf(sock,"%cHLO %s\r\n", (smtp_mode == 'S') ? 'E' : smtp_mode, host);
if (outlevel >= O_MONITOR)
- progress(0, 0, "%cMTP> %cHLO %s",
+ report(stdout, 0, "%cMTP> %cHLO %s",
smtp_mode, (smtp_mode == 'S') ? 'E' : smtp_mode, host);
*opt = 0;
@@ -75,7 +75,7 @@ int SMTP_ehlo(int sock, const char *host, int *opt)
return SM_ERROR;
smtp_response[n] = '\0';
if (outlevel >= O_MONITOR)
- progress(0, 0, "SMTP< %s", smtp_response);
+ report(stdout, 0, "SMTP< %s", smtp_response);
for (hp = extensions; hp->name; hp++)
if (!strncasecmp(hp->name, smtp_response+4, strlen(hp->name)))
*opt |= hp->value;
@@ -101,7 +101,7 @@ int SMTP_from(int sock, const char *from, const char *opts)
strcat(buf, opts);
SockPrintf(sock,"%s\r\n", buf);
if (outlevel >= O_MONITOR)
- progress(0, 0, "%cMTP> %s", smtp_mode, buf);
+ report(stdout, 0, "%cMTP> %s", smtp_mode, buf);
ok = SMTP_ok(sock);
return ok;
}
@@ -113,7 +113,7 @@ int SMTP_rcpt(int sock, const char *to)
SockPrintf(sock,"RCPT TO:<%s>\r\n", to);
if (outlevel >= O_MONITOR)
- progress(0, 0, "%cMTP> RCPT TO:<%s>", smtp_mode, to);
+ report(stdout, 0, "%cMTP> RCPT TO:<%s>", smtp_mode, to);
ok = SMTP_ok(sock);
return ok;
}
@@ -125,7 +125,7 @@ int SMTP_data(int sock)
SockPrintf(sock,"DATA\r\n");
if (outlevel >= O_MONITOR)
- progress(0, 0, "%cMTP> DATA", smtp_mode);
+ report(stdout, 0, "%cMTP> DATA", smtp_mode);
ok = SMTP_ok(sock);
return ok;
}
@@ -137,7 +137,7 @@ int SMTP_rset(int sock)
SockPrintf(sock,"RSET\r\n");
if (outlevel >= O_MONITOR)
- progress(0, 0, "%cMTP> RSET", smtp_mode);
+ report(stdout, 0, "%cMTP> RSET", smtp_mode);
ok = SMTP_ok(sock);
return ok;
}
@@ -149,7 +149,7 @@ int SMTP_quit(int sock)
SockPrintf(sock,"QUIT\r\n");
if (outlevel >= O_MONITOR)
- progress(0, 0, "%cMTP> QUIT", smtp_mode);
+ report(stdout, 0, "%cMTP> QUIT", smtp_mode);
ok = SMTP_ok(sock);
return ok;
}
@@ -161,7 +161,7 @@ int SMTP_eom(int sock)
SockPrintf(sock,".\r\n");
if (outlevel >= O_MONITOR)
- progress(0, 0, "%cMTP>. (EOM)", smtp_mode);
+ report(stdout, 0, "%cMTP>. (EOM)", smtp_mode);
/*
* When doing LMTP, must process many of these at the outer level.
@@ -189,7 +189,7 @@ int SMTP_ok(int sock)
return SM_ERROR;
smtp_response[n] = '\0';
if (outlevel >= O_MONITOR)
- progress(0, 0, "%cMTP< %s", smtp_mode, smtp_response);
+ report(stdout, 0, "%cMTP< %s", smtp_mode, smtp_response);
if ((smtp_response[0] == '1' || smtp_response[0] == '2' || smtp_response[0] == '3') && smtp_response[3] == ' ')
return SM_OK;
else if (smtp_response[3] != '-')
diff --git a/socket.c b/socket.c
index 75a08bd6..715367ea 100644
--- a/socket.c
+++ b/socket.c
@@ -52,14 +52,13 @@ static int handle_plugin(const char *host,
int fds[2];
if (socketpair(AF_UNIX,SOCK_STREAM,0,fds))
{
- error(0, 0, _("fetchmail: socketpair failed: %s(%d)"),strerror(errno),errno);
+ report(stderr, errno, _("fetchmail: socketpair failed"));
return -1;
}
switch (fork()) {
case -1:
/* error */
- error(0, 0, _("fetchmail: fork failed: %s(%d)"),
- strerror(errno), errno);
+ report(stderr, errno, _("fetchmail: fork failed"));
return -1;
break;
case 0: /* child */
@@ -67,17 +66,15 @@ static int handle_plugin(const char *host,
** detection */
(void) close(fds[1]);
if ( (dup2(fds[0],0) == -1) || (dup2(fds[0],1) == -1) ) {
- error(0, 0, _("fetchmail: dup2 failed: %s(%d)"),
- strerror(errno), errno);
+ report(stderr, errno, _("dup2 failed"));
exit(1);
}
/* fds[0] is now connected to 0 and 1; close it */
(void) close(fds[0]);
if (outlevel >= O_VERBOSE)
- error(0, 0, _("running %s %s %s"), plugin, host, service);
+ report(stderr, 0, _("running %s %s %s"), plugin, host, service);
execlp(plugin,plugin,host,service,0);
- error(0, 0, _("execl(%s) failed: %s (%d)"),
- plugin, strerror(errno), errno);
+ report(stderr, errno, _("execl(%s) failed"), plugin);
exit(0);
break;
default: /* parent */
@@ -109,7 +106,7 @@ int SockOpen(const char *host, const char *service, const char *options,
req.ai_socktype = SOCK_STREAM;
if (i = getaddrinfo(host, service, &req, &ai)) {
- error(0, 0, _("fetchmail: getaddrinfo(%s.%s): %s(%d)"), host, service, gai_strerror(i), i);
+ report(stderr, i, _("fetchmail: getaddrinfo(%s.%s)"), host,service);
return -1;
};
@@ -189,7 +186,7 @@ int SockOpen(const char *host, int clientPort, const char *options,
if(hp->h_length != 4 && hp->h_length != 8)
{
h_errno = errno = 0;
- error(0, 0, _("fetchmail: illegal address length received for host %s"),host);
+ report(stderr, 0, _("fetchmail: illegal address length received for host %s"),host);
return -1;
}
/*
diff --git a/unmime.c b/unmime.c
index 2f9bddb0..cedc6737 100644
--- a/unmime.c
+++ b/unmime.c
@@ -15,6 +15,7 @@
#include "config.h"
#include <string.h>
#include <stdlib.h>
+#include <stdio.h>
#include <ctype.h>
#include "fetchmail.h"
diff --git a/xalloca.c b/xalloca.c
index d5ed7abe..ce3285ee 100644
--- a/xalloca.c
+++ b/xalloca.c
@@ -40,7 +40,7 @@ int n;
p = (XALLOCATYPE *) alloca(n);
if (p == (XALLOCATYPE *) 0)
- error(PS_UNDEFINED, 0, "alloca failed");
+ report(stderr, PS_UNDEFINED, 0, "alloca failed");
return(p);
}
diff --git a/xmalloc.c b/xmalloc.c
index ed0b88e7..6d63cde8 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -28,7 +28,10 @@ xmalloc (int n)
p = (XMALLOCTYPE *) malloc(n);
if (p == (XMALLOCTYPE *) 0)
- error(PS_UNDEFINED, errno, _("malloc failed"));
+ {
+ report(stderr, errno, _("malloc failed"));
+ exit(PS_UNDEFINED);
+ }
return(p);
}
@@ -39,7 +42,10 @@ xrealloc (XMALLOCTYPE *p, int n)
return xmalloc (n);
p = (XMALLOCTYPE *) realloc(p, n);
if (p == (XMALLOCTYPE *) 0)
- error(PS_UNDEFINED, errno, _("realloc failed"));
+ {
+ report(stderr, errno, _("realloc failed"));
+ exit(PS_UNDEFINED);
+ }
return p;
}