From 1c7ab650bf7acfdd94ee386c84dccc8d5cb157b6 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 26 Sep 2000 08:06:45 +0000 Subject: [PATCH] Bug fixes and internationalization improvements. svn path=/trunk/; revision=2967 --- NEWS | 4 ++++ driver.c | 22 ++++++++++++-------- fetchmail.c | 56 ++++++++++++++++++++++++++++++++++----------------- fetchmailconf | 6 ++++++ imap.c | 10 ++++----- rfc822.c | 5 +++-- sink.c | 14 ++++++------- socket.c | 6 +++--- uid.c | 24 ++++++++++++---------- 9 files changed, 91 insertions(+), 56 deletions(-) diff --git a/NEWS b/NEWS index ea9116bc..c6b9bd8d 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,10 @@ (The `lines' figures total .c, .h, .l, and .y files under version control.) +* Added skip size reporting as suggested by Franck Pommereau. +* Don't terminate on failed DNS lookup of host, go to next entry. +* Danish localizationb support, courtesy of Byrial Jensen. + fetchmail-5.5.2 (Thu Sep 7 23:00:24 EDT 2000), 19243 lines: * Horst Von Brand's security and specfile patches. diff --git a/driver.c b/driver.c index 5828b184..c9ac0d23 100644 --- a/driver.c +++ b/driver.c @@ -1420,7 +1420,6 @@ static void send_size_warnings(struct query *ctl) int msg_to_send = FALSE; struct idlist *head=NULL, *current=NULL; int max_warning_poll_count; -#define OVERHD "Subject: Fetchmail oversized-messages warning.\r\n\r\nThe following oversized messages remain on the mail server %s:" head = ctl->skipped; if (!head) @@ -1440,7 +1439,11 @@ static void send_size_warnings(struct query *ctl) */ if (open_warning_by_mail(ctl, (struct msgblk *)NULL)) return; - stuff_warning(ctl, OVERHD, ctl->server.pollname); + stuff_warning(ctl, + _("Subject: Fetchmail oversized-messages warning.\r\n" + "\r\n" + "The following oversized messages remain on the mail server %s:"), + ctl->server.pollname); if (run.poll_interval == 0) max_warning_poll_count = 0; @@ -1466,7 +1469,6 @@ static void send_size_warnings(struct query *ctl) } close_warning_by_mail(ctl, (struct msgblk *)NULL); -#undef OVERHD } static int do_session(ctl, proto, maxfetch) @@ -1677,11 +1679,13 @@ const int maxfetch; /* maximum number of messages to fetch */ /* warn the system administrator */ if (open_warning_by_mail(ctl, (struct msgblk *)NULL) == 0) { -#define OPENFAIL "Subject: Fetchmail unreachable-server warning.\r\n\r\nFetchmail could not reach the mail server %s:" - stuff_warning(ctl, OPENFAIL, ctl->server.pollname); + stuff_warning(ctl, + _("Subject: Fetchmail unreachable-server warning.\r\n" + "\r\n" + "Fetchmail could not reach the mail server %s:") + ctl->server.pollname); stuff_warning(ctl, errbuf, ctl->server.pollname); close_warning_by_mail(ctl, (struct msgblk *)NULL); -#undef OPENFAIL } #endif } @@ -1700,7 +1704,7 @@ const int maxfetch; /* maximum number of messages to fetch */ verification. We may want to make this configurable */ if (ctl->use_ssl && SSLOpen(mailserver_socket,ctl->sslkey,ctl->sslcert,realhost) == -1) { - report(stderr, "SSL connection failed.\n"); + report(stderr, _("SSL connection failed.\n")); goto closeUp; } #endif @@ -1968,7 +1972,9 @@ const int maxfetch; /* maximum number of messages to fetch */ { if (outlevel > O_SILENT) { - report_build(stdout, _("skipping message %d"), num); + report_build(stdout, + _("skipping message %d (%d octets)"), + num, msgsizes[num-1]); if (toolarge && !check_only) { char size[32]; diff --git a/fetchmail.c b/fetchmail.c index 6c392f4a..3e41d1d9 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -123,6 +123,24 @@ static void dropprivs(void) } #endif +#if defined(HAVE_SETLOCALE) && defined(ENABLE_NLS) && defined(HAVE_STRFTIME) +#include +#include +static char *timestamp (void) +{ + time_t now; + static char buf[60]; + + time (&now); + setlocale (LC_TIME, ""); + strftime (buf, sizeof (buf), "%c", localtime(&now)); + setlocale (LC_TIME, "C"); + return (buf); +} +#else +#define timestamp rfc822timestamp +#endif + int main(int argc, char **argv) { int st, bkgd = FALSE; @@ -153,7 +171,7 @@ int main(int argc, char **argv) { int i; - report(stdout, "fetchmail: invoked with"); + report(stdout, _("fetchmail: invoked with")); for (i = 0; i < argc; i++) report(stdout, " %s", argv[i]); report(stdout, "\n"); @@ -665,33 +683,33 @@ int main(int argc, char **argv) switch(querystatus) { case PS_SUCCESS: - report(stdout,"Query status=0 (SUCCESS)\n");break; + report(stdout,_("Query status=0 (SUCCESS)\n"));break; case PS_NOMAIL: - report(stdout,"Query status=1 (NOMAIL)\n"); break; + report(stdout,_("Query status=1 (NOMAIL)\n")); break; case PS_SOCKET: - report(stdout,"Query status=2 (SOCKET)\n"); break; + report(stdout,_("Query status=2 (SOCKET)\n")); break; case PS_AUTHFAIL: - report(stdout,"Query status=3 (AUTHFAIL)\n");break; + report(stdout,_("Query status=3 (AUTHFAIL)\n"));break; case PS_PROTOCOL: - report(stdout,"Query status=4 (PROTOCOL)\n");break; + report(stdout,_("Query status=4 (PROTOCOL)\n"));break; case PS_SYNTAX: - report(stdout,"Query status=5 (SYNTAX)\n"); break; + report(stdout,_("Query status=5 (SYNTAX)\n")); break; case PS_IOERR: - report(stdout,"Query status=6 (IOERR)\n"); break; + report(stdout,_("Query status=6 (IOERR)\n")); break; case PS_ERROR: - report(stdout,"Query status=7 (ERROR)\n"); break; + report(stdout,_("Query status=7 (ERROR)\n")); break; case PS_EXCLUDE: - report(stdout,"Query status=8 (EXCLUDE)\n"); break; + report(stdout,_("Query status=8 (EXCLUDE)\n")); break; case PS_LOCKBUSY: - report(stdout,"Query status=9 (LOCKBUSY)\n");break; + report(stdout,_("Query status=9 (LOCKBUSY)\n"));break; case PS_SMTP: - report(stdout,"Query status=10 (SMTP)\n"); break; + report(stdout,_("Query status=10 (SMTP)\n")); break; case PS_DNS: - report(stdout,"Query status=11 (DNS)\n"); break; + report(stdout,_("Query status=11 (DNS)\n")); break; case PS_BSMTP: - report(stdout,"Query status=12 (BSMTP)\n"); break; + report(stdout,_("Query status=12 (BSMTP)\n")); break; case PS_MAXFETCH: - report(stdout,"Query status=13 (MAXFETCH)\n");break; + report(stdout,_("Query status=13 (MAXFETCH)\n"));break; default: report(stdout,_("Query status=%d\n"),querystatus); break; @@ -746,7 +764,7 @@ int main(int argc, char **argv) if (outlevel >= O_VERBOSE) report(stdout, - _("fetchmail: sleeping at %s\n"), rfc822timestamp()); + _("fetchmail: sleeping at %s\n"), timestamp()); /* * OK, now pause util it's time for the next poll cycle. @@ -768,7 +786,7 @@ int main(int argc, char **argv) } if (outlevel >= O_VERBOSE) - report(stdout, _("awakened at %s\n"), rfc822timestamp()); + report(stdout, _("awakened at %s\n"), timestamp()); } } while (run.poll_interval); @@ -1150,7 +1168,7 @@ static int load_params(int argc, char **argv, int optind) report(stderr, _("couldn't find canonical DNS name of %s\n"), ctl->server.pollname); - exit(PS_DNS); + ctl->active = FALSE; } else ctl->server.truename=xstrdup((char *)namerec->h_name); @@ -1382,7 +1400,7 @@ static int query_host(struct query *ctl) VERSION, ctl->server.pollname, showproto(ctl->server.protocol), - rfc822timestamp()); + timestamp()); } switch (ctl->server.protocol) { case P_AUTO: diff --git a/fetchmailconf b/fetchmailconf index 07f2c167..15ccc2fb 100755 --- a/fetchmailconf +++ b/fetchmailconf @@ -1170,6 +1170,12 @@ isn't a SunOS 4.1.4 machine; cucipop tickles a bug in SunOS realloc() under that version, and doesn't cope with the result gracefully. Newer SunOS and Solaris machines run cucipop OK. +""" + if string.find(greetline, "David POP3 Server") > 0: + warnings = warnings + """ +This POP3 serrver is badly broken. You should get rid of it -- and the +brain-dead NT operating system it rode in on. + """ # The greeting line on the server known to be buggy is: # +OK POP3 server ready (running FTGate V2, 2, 1, 0 Jun 21 1999 09:55:01) diff --git a/imap.c b/imap.c index 0654bdeb..ea44e5a0 100644 --- a/imap.c +++ b/imap.c @@ -786,7 +786,7 @@ static int do_cram_md5 (int sock, struct query *ctl) msg_id[sizeof (msg_id)-1] = 0; } if (outlevel >= O_DEBUG) { - report (stdout, "decoded as %s\n", msg_id); + report (stdout, _("decoded as %s\n"), msg_id); } /* The client makes note of the data and then responds with a string @@ -813,7 +813,7 @@ static int do_cram_md5 (int sock, struct query *ctl) response[12], response[13], response[14], response[15]); if (outlevel >= O_DEBUG) { - report (stdout, "replying with %s\n", reply); + report (stdout, _("replying with %s\n"), reply); } to64frombits (buf1, reply, strlen (reply)); @@ -913,7 +913,7 @@ int imap_getauth(int sock, struct query *ctl, char *greeting) { do_idle = TRUE; if (outlevel >= O_VERBOSE) - report(stdout, "will idle after poll\n"); + report(stdout, _("will idle after poll\n")); } #if OPIE_ENABLE @@ -1090,7 +1090,7 @@ static int imap_getrange(int sock, count = 0; } if (outlevel >= O_DEBUG) - report(stdout, "%d messages waiting after re-poll\n", count); + report(stdout, _("%d messages waiting after re-poll\n"), count); } else { @@ -1103,7 +1103,7 @@ static int imap_getrange(int sock, return(ok); } else if (outlevel >= O_DEBUG) - report(stdout, "%d messages waiting after first poll\n", count); + report(stdout, _("%d messages waiting after first poll\n"), count); /* no messages? then we may need to idle until we get some */ if (count == 0 && do_idle) diff --git a/rfc822.c b/rfc822.c index de6008bf..5315f1b6 100644 --- a/rfc822.c +++ b/rfc822.c @@ -14,6 +14,7 @@ #include "config.h" #include "fetchmail.h" +#include "i18n.h" #define HEADER_END(p) ((p)[0] == '\n' && ((p)[1] != ' ' && (p)[1] != '\t')) @@ -53,7 +54,7 @@ const unsigned char *host; /* server hostname */ #ifndef TESTMAIN if (outlevel >= O_DEBUG) - report_build(stdout, "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++) @@ -180,7 +181,7 @@ const unsigned char *host; /* server hostname */ #ifndef TESTMAIN if (outlevel >= O_DEBUG) - report_complete(stdout, "Rewritten version is %s\n", buf); + report_complete(stdout, _("Rewritten version is %s\n"), buf); #endif /* TESTMAIN */ return(buf); } diff --git a/sink.c b/sink.c index 519fc2bd..45db08b6 100644 --- a/sink.c +++ b/sink.c @@ -264,7 +264,7 @@ static int send_bouncemail(struct query *ctl, struct msgblk *msg, /* bounce back an error report a la RFC 1892 */ { char daemon_name[18 + HOSTLEN] = "FETCHMAIL-DAEMON@"; - char boundary[BUFSIZ], *ts, *bounce_to; + char boundary[BUFSIZ], *bounce_to; int sock; /* don't bounce in reply to undeliverable bounces */ @@ -291,13 +291,11 @@ static int send_bouncemail(struct query *ctl, struct msgblk *msg, "foo-mani-padme-hum-%d-%d-%ld", (int)getpid(), (int)getppid(), time((time_t *)NULL)); - ts = rfc822timestamp(); - if (outlevel >= O_VERBOSE) - report(stdout, "SMTP: (bounce-message body)\n"); + report(stdout, _("SMTP: (bounce-message body)\n")); else /* this will usually go to sylog... */ - report(stderr, "mail from %s bounced to %s\n", + report(stderr, _("mail from %s bounced to %s\n"), daemon_name, bounce_to); /* bouncemail headers */ @@ -335,7 +333,7 @@ static int send_bouncemail(struct query *ctl, struct msgblk *msg, /* Minimum RFC1894 compliance + Diagnostic-Code field */ SockPrintf(sock, "\r\n"); SockPrintf(sock, "Final-Recipient: rfc822; %s\r\n", idp->id); - SockPrintf(sock, "Last-Attempt-Date: %s\r\n", ts); + SockPrintf(sock, "Last-Attempt-Date: %s\r\n", rfc822timestamp()); SockPrintf(sock, "Action: failed\r\n"); if (nerrors == 1) @@ -392,7 +390,7 @@ static int handle_smtp_report(struct query *ctl, struct msgblk *msg) SMTP_rset(ctl->smtp_socket); /* stay on the safe site */ if (outlevel >= O_DEBUG) - report(stdout, "Saved error is still %d\n", smtperr); + report(stdout, _("Saved error is still %d\n"), smtperr); /* * Note: send_bouncemail message strings are not made subject @@ -1113,7 +1111,7 @@ va_dcl void close_warning_by_mail(struct query *ctl, struct msgblk *msg) /* sign and send mailed warnings */ { - stuff_warning(ctl, "--\r\n\t\t\t\tThe Fetchmail Daemon\r\n"); + stuff_warning(ctl, _("--\r\n\t\t\t\tThe Fetchmail Daemon\r\n")); close_sink(ctl, msg, TRUE); } diff --git a/socket.c b/socket.c index 735b4388..fd8e246e 100644 --- a/socket.c +++ b/socket.c @@ -661,15 +661,15 @@ int SSL_verify_callback( int ok_return, X509_STORE_CTX *ctx ) switch (ctx->error) { case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: X509_NAME_oneline(X509_get_issuer_name(ctx->current_cert), buf, 256); - report(stdout, "unknown issuer= %s", buf); + report(stdout, _("unknown issuer= %s"), buf); break; case X509_V_ERR_CERT_NOT_YET_VALID: case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: - report(stderr, "Server Certificate not yet valid"); + report(stderr, _("Server Certificate not yet valid")); break; case X509_V_ERR_CERT_HAS_EXPIRED: case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: - report(stderr, "Server Certificate expired"); + report(stderr, _("Server Certificate expired")); break; } /* We are not requiring or validating server or issuer id's as yet */ diff --git a/uid.c b/uid.c index 33e01293..8163761b 100644 --- a/uid.c +++ b/uid.c @@ -19,6 +19,7 @@ #endif #include "fetchmail.h" +#include "i18n.h" /* * Machinery for handling UID lists live here. This is mainly to support @@ -93,7 +94,7 @@ void initialize_saved_lists(struct query *hostlist, const char *idfile) if (lstat(idfile, &statbuf) < 0) { if (errno == ENOTDIR) { - report(stderr, "lstat: %s: %s\n", idfile, strerror(errno)); + report(stderr, _("lstat: %s: %s\n"), idfile, strerror(errno)); exit(PS_IOERR); } } @@ -194,22 +195,23 @@ void initialize_saved_lists(struct query *hostlist, const char *idfile) for (ctl = hostlist; ctl; ctl = ctl->next) if (ctl->server.uidl) { - report_build(stdout, "Old UID list from %s:",ctl->server.pollname); + report_build(stdout, _("Old UID list from %s:"), + ctl->server.pollname); for (idp = ctl->oldsaved; idp; idp = idp->next) report_build(stdout, " %s", idp->id); if (!idp) - report_build(stdout, " "); + report_build(stdout, _(" ")); report_complete(stdout, "\n"); uidlcount++; } if (uidlcount) { - report_build(stdout, "Scratch list of UIDs:"); + report_build(stdout, _("Scratch list of UIDs:")); for (idp = scratchlist; idp; idp = idp->next) report_build(stdout, " %s", idp->id); if (!idp) - report_build(stdout, " "); + report_build(stdout, _(" ")); report_complete(stdout, "\n"); } } @@ -432,11 +434,11 @@ void uid_swap_lists(struct query *ctl) { struct idlist *idp; - report_build(stdout, "New UID list from %s:", ctl->server.pollname); + report_build(stdout, _("New UID list from %s:"), ctl->server.pollname); for (idp = ctl->newsaved; idp; idp = idp->next) report_build(stdout, " %s = %d", idp->id, idp->val.status.mark); if (!idp) - report_build(stdout, " "); + report_build(stdout, _(" ")); report_complete(stdout, "\n"); } @@ -449,14 +451,14 @@ void uid_swap_lists(struct query *ctl) { /* old state of mailbox may now be irrelevant */ if (outlevel >= O_DEBUG) - report(stdout, "swapping UID lists\n"); + report(stdout, _("swapping UID lists\n")); free_str_list(&ctl->oldsaved); free_str_list(&scratchlist); ctl->oldsaved = ctl->newsaved; ctl->newsaved = (struct idlist *) NULL; } else if (outlevel >= O_DEBUG) - report(stdout, "not swapping UID lists, no UIDs seen this query\n"); + report(stdout, _("not swapping UID lists, no UIDs seen this query\n")); } void write_saved_lists(struct query *hostlist, const char *idfile) @@ -480,13 +482,13 @@ void write_saved_lists(struct query *hostlist, const char *idfile) if (!idcount && !scratchlist) { if (outlevel >= O_DEBUG) - report(stdout, "Deleting fetchids file.\n"); + report(stdout, _("Deleting fetchids file.\n")); unlink(idfile); } else { if (outlevel >= O_DEBUG) - report(stdout, "Writing fetchids file.\n"); + report(stdout, _("Writing fetchids file.\n")); if ((tmpfp = fopen(idfile, "w")) != (FILE *)NULL) { for (ctl = hostlist; ctl; ctl = ctl->next) { for (idp = ctl->oldsaved; idp; idp = idp->next) -- 2.43.2