diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2004-11-10 19:57:47 +0000 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2004-11-10 19:57:47 +0000 |
commit | 2ed8dc12cd5ffbbff9cd25e928a720be3596f2af (patch) | |
tree | 994d80cb32bb77ad0f380f9254a7e3171d2ec051 | |
parent | 13c27199231cbc2cc83969ada741b95be1cca4d3 (diff) | |
download | fetchmail-2ed8dc12cd5ffbbff9cd25e928a720be3596f2af.tar.gz fetchmail-2ed8dc12cd5ffbbff9cd25e928a720be3596f2af.tar.bz2 fetchmail-2ed8dc12cd5ffbbff9cd25e928a720be3596f2af.zip |
Clean up the horrible HAVE_[V]SNPRINTF mess, use Trio on systems that lack
real snprintf or vsnprintf.
svn path=/trunk/; revision=3996
-rw-r--r-- | Makefile.am | 18 | ||||
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | configure.ac | 52 | ||||
-rw-r--r-- | cram.c | 4 | ||||
-rw-r--r-- | driver.c | 30 | ||||
-rw-r--r-- | fetchmail.h | 5 | ||||
-rw-r--r-- | imap.c | 6 | ||||
-rw-r--r-- | interface.c | 7 | ||||
-rw-r--r-- | ipv6-connect.c | 23 | ||||
-rw-r--r-- | report.c | 46 | ||||
-rw-r--r-- | sink.c | 59 | ||||
-rw-r--r-- | smtp.c | 34 | ||||
-rw-r--r-- | socket.c | 15 | ||||
-rw-r--r-- | transact.c | 73 |
14 files changed, 108 insertions, 269 deletions
diff --git a/Makefile.am b/Makefile.am index bbd82289..2dbea302 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,6 +25,19 @@ libfm_a_DEPENDENCIES= $(EXTRAOBJ) LDADD = libfm.a @LIBINTL@ $(LIBOBJS) DEPENDENCIES= libfm.a $(LIBOBJS) +check_PROGRAMS= + +if NEED_TRIO +noinst_LIBRARIES+= libtrio.a +libtrio_a_SOURCES= trio/triostr.c trio/trio.c trio/trionan.c \ + trio/trio.h trio/triop.h trio/triodef.h \ + trio/trionan.h trio/triostr.h +check_PROGRAMS+= regression +regression_SOURCES= trio/regression.c +LDADD += libtrio.a -lm +TESTS= regression +endif + fetchmail_SOURCES= fetchmail.h getopt.h \ i18n.h kerberos.h md5.h mx.h netrc.h ntlm.h \ smbbyteorder.h smbdes.h smbmd4.h smbencrypt.h smtp.h \ @@ -38,7 +51,7 @@ fetchmail_SOURCES= fetchmail.h getopt.h \ smbmd4.c smbutil.c ipv6-connect.c lock.c \ rcfile_l.l rcfile_y.y ucs/norm_charmap.c -check_PROGRAMS= rfc822 unmime netrc rfc2047e +check_PROGRAMS += rfc822 unmime netrc rfc2047e rfc2047e_CFLAGS= -DTEST @@ -64,7 +77,8 @@ DISTDOCS= FAQ FEATURES NOTES fetchmail-man.html fetchmail-FAQ.html \ # extra directories to ship distdirs = rh-config contrib beos -EXTRA_DIST= $(DISTDOCS) fetchmail.spec $(distdirs) ucs/README.svn +EXTRA_DIST= $(DISTDOCS) fetchmail.spec $(distdirs) ucs/README.svn \ + trio/CHANGES trio/README FAQ: fetchmail-FAQ.html AWK=$(AWK) $(SHELL) $(srcdir)/html2txt.sh $(srcdir)/fetchmail-FAQ.html >$@ || { rm -f $@ ; exit 1 ; } @@ -36,6 +36,11 @@ in succession, make sure that Common Name and fingerprint checking are only done once. Print all validation warnings/errors even if not in verbose mode. Patch by Brian Candler. +* Import Bjorn Reese and Daniel Stenberg's MIT-licensed Trio 1.10 from + http://daniel.haxx.se/projects/trio/ for systems that do not support + snprintf or vsnprintf. +* Clean up the horrible #ifdef HAVE_[V]SNPRINTF that made the code + unreadable. Use Trio where [v]snprintf is/are missing. Matthias Andree. fetchmail-6.2.5 (Wed Oct 15 18:39:22 EDT 2003), 23079 lines: diff --git a/configure.ac b/configure.ac index 445f5d95..6777b1b5 100644 --- a/configure.ac +++ b/configure.ac @@ -682,6 +682,58 @@ AC_SUBST(CPFLAGS) AC_SUBST(CEFLAGS) AC_SUBST(LDEFLAGS) +dnl ,------------------------------------------------------------------ +dnl Check if we need TRIO +needtrio=0 +if test "$FORCE_TRIO" = "yes" ; then + needtrio=1 + ac_cv_func_vsnprintf=no + ac_cv_func_snprintf=no +fi +if test "x$ac_cv_func_snprintf" != "xyes" ; then + AC_DEFINE(snprintf, trio_snprintf, + [Define to trio_snprintf if your system lacks snprintf]) + needtrio=1 +fi +if test "x$ac_cv_func_vsnprintf" != "xyes" ; then + AC_DEFINE(vsnprintf, trio_vsnprintf, + [Define to trio_vsnprintf if your system lacks vsnprintf]) + needtrio=1 +fi +AM_CONDITIONAL(NEED_TRIO, test "$needtrio" = 1) + +dnl TRIO IEEE compiler option for Alpha +dnl +if test "$needtrio" = 1 ; then + AC_MSG_CHECKING(for IEEE compilation options) + AC_CACHE_VAL(ac_cv_ieee_option, [ + AC_TRY_COMPILE(,[ + #if !(defined(__alpha) && (defined(__DECC) || defined(__DECCXX) || (defined(__osf__) && defined(__LANGUAGE_C__))) && (defined(VMS) || defined(__VMS))) + # error "Option needed" + #endif + ],ac_cv_ieee_option="/IEEE_MODE=UNDERFLOW_TO_ZERO/FLOAT=IEEE", + AC_TRY_COMPILE(,[ + #if !(defined(__alpha) && (defined(__DECC) || defined(__DECCXX) || (defined(__osf__) && defined(__LANGUAGE_C__))) && !(defined(VMS) || defined(__VMS)) && !defined(_CFE)) + # error "Option needed" + #endif + ],ac_cv_ieee_option="-ieee", + AC_TRY_COMPILE(,[ + #if !(defined(__alpha) && (defined(__GNUC__) && (defined(__osf__) || defined(__linux__)))) + # error "Option needed" + #endif + ],ac_cv_ieee_option="-mieee", + ac_cv_ieee_option="none" + ) + ) + ) + ]) + AC_MSG_RESULT($ac_cv_ieee_option) + if test $ac_cv_ieee_option != none; then + CFLAGS="${CFLAGS} ${ac_cv_ieee_option}" + fi +fi +dnl ----------------------------------------------------------------' + AC_CONFIG_FILES([Makefile m4/Makefile po/Makefile.in intl/Makefile]) AC_OUTPUT @@ -114,11 +114,7 @@ int do_cram_md5 (int sock, char *command, struct query *ctl, char *strip) msg_id, strlen (msg_id), response, sizeof (response)); -#ifdef HAVE_SNPRINTF snprintf (reply, sizeof(reply), -#else - sprintf(reply, -#endif "%s %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", ctl->remotename, response[0], response[1], response[2], response[3], @@ -378,12 +378,7 @@ static void mark_oversized(struct query *ctl, int num, int size) int cnt; /* convert size to string */ -#ifdef HAVE_SNPRINTF - snprintf(sizestr, sizeof(sizestr), -#else - sprintf(sizestr, -#endif /* HAVE_SNPRINTF */ - "%d", size); + snprintf(sizestr, sizeof(sizestr), "%d", size); /* build a list of skipped messages * val.id = size of msg (string cnvt) @@ -1085,16 +1080,8 @@ static int do_session( else if (h_errno == TRY_AGAIN) strcpy(errbuf, GT_("temporary name server error.")); else -#ifdef HAVE_SNPRINTF - snprintf -#else - sprintf -#endif /* HAVE_SNPRINTF */ - (errbuf, -#ifdef HAVE_SNPRINTF - sizeof(errbuf), -#endif - GT_("unknown DNS error %d."), h_errno); + snprintf (errbuf, sizeof(errbuf), + GT_("unknown DNS error %d."), h_errno); } else #endif /* HAVE_RES_SEARCH */ @@ -1352,20 +1339,11 @@ is restored.")); /* show user how many messages we downloaded */ if (idp->id) -#ifdef HAVE_SNPRINTF (void) snprintf(buf, sizeof(buf), -#else - (void) sprintf(buf, -#endif /* HAVE_SNPRINTF */ GT_("%s at %s (folder %s)"), ctl->remotename, ctl->server.pollname, idp->id); else -#ifdef HAVE_SNPRINTF - (void) snprintf(buf, sizeof(buf), -#else - (void) sprintf(buf, -#endif /* HAVE_SNPRINTF */ - GT_("%s at %s"), + (void) snprintf(buf, sizeof(buf), GT_("%s at %s"), ctl->remotename, ctl->server.pollname); if (outlevel > O_SILENT) { diff --git a/fetchmail.h b/fetchmail.h index afb976d2..9ce7942e 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -22,6 +22,11 @@ #include <stdio.h> +/* Import Trio if needed */ +#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) +# include "trio/trio.h" +#endif + /* We need this for strstr */ #if !defined(HAVE_STRSTR) && !defined(strstr) char *strstr(const char *, const char *); @@ -510,13 +510,7 @@ static int imap_getauth(int sock, struct query *ctl, char *greeting) imap_canonicalize(remotename, ctl->remotename, NAMELEN); imap_canonicalize(password, ctl->password, PASSWORDLEN); -#ifdef HAVE_SNPRINTF snprintf(shroud, sizeof (shroud), "\"%s\"", password); -#else - strcpy(shroud, "\""); - strcat(shroud, password); - strcat(shroud, "\""); -#endif ok = gen_transact(sock, "LOGIN \"%s\" \"%s\"", remotename, password); shroud[0] = '\0'; #ifdef SSL_ENABLE diff --git a/interface.c b/interface.c index a70e6104..4c9dde32 100644 --- a/interface.c +++ b/interface.c @@ -268,12 +268,7 @@ get_ifinfo(const char *ifname, ifinfo_t *ifinfo) { kvm_read(kvmfd, ifnet_addr, &ifnet, sizeof(ifnet)); kvm_read(kvmfd, (unsigned long) ifnet.if_name, tname, sizeof tname); -#ifdef HAVE_SNPRINTF - snprintf(tname, sizeof tname, -#else - sprintf(tname, -#endif - "%s%d", tname, ifnet.if_unit); + snprintf(tname, sizeof tname, "%s%d", tname, ifnet.if_unit); if (!strcmp(tname, iname)) { diff --git a/ipv6-connect.c b/ipv6-connect.c index 6064806c..6537984d 100644 --- a/ipv6-connect.c +++ b/ipv6-connect.c @@ -100,23 +100,15 @@ int inner_connect(struct addrinfo *ai, void *request, int requestlen, int (*tryi continue; if ((fd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) < 0) { -#ifdef HAVE_SNPRINTF - snprintf(errorbuf, sizeof(errorbuf), -#else - sprintf(errorbuf, -#endif - "socket: %s(%d)", strerror(errno), errno); + snprintf(errorbuf, sizeof(errorbuf), "socket: %s(%d)", + strerror(errno), errno); error_callback(myname, errorbuf); continue; }; if (connect(fd, ai->ai_addr, ai->ai_addrlen) < 0) { -#ifdef HAVE_SNPRINTF - snprintf(errorbuf, sizeof(errorbuf), -#else - sprintf(errorbuf, -#endif - "connect: %s(%d)", strerror(errno), errno); + snprintf(errorbuf, sizeof(errorbuf), "connect: %s(%d)", + strerror(errno), errno); error_callback(myname, errorbuf); close(fd); /* just after a connect; no reads or writes yet */ continue; @@ -128,12 +120,7 @@ int inner_connect(struct addrinfo *ai, void *request, int requestlen, int (*tryi if (pai) *pai = ai; } else { -#ifdef HAVE_SNPRINTF - snprintf(errorbuf, sizeof(errorbuf), -#else - sprintf(errorbuf, -#endif - "no connections result"); + snprintf(errorbuf, sizeof(errorbuf), "no connections result"); error_callback(myname, errorbuf); fd = -1; }; @@ -235,7 +235,6 @@ report_build (FILE *errfp, message, va_alist) #if defined(VA_START) VA_START (args, message); -#if defined(HAVE_VSNPRINTF) || defined(_LIBC) for ( ; ; ) { n = vsnprintf (partial_message + partial_message_size_used, @@ -251,20 +250,8 @@ report_build (FILE *errfp, message, va_alist) partial_message_size += 2048; partial_message = REALLOC (partial_message, partial_message_size); } -#else - vsprintf (partial_message + partial_message_size_used, message, args); - partial_message_size_used += strlen(partial_message+partial_message_size_used); - - /* Attempt to catch memory overwrites... */ - if (partial_message_size_used >= partial_message_size) - { - partial_message_size_used = 0; - report (stderr, GT_("partial error message buffer overflow")); - } -#endif va_end (args); #else -#if HAVE_SNPRINTF for ( ; ; ) { n = snprintf (partial_message + partial_message_size_used, @@ -280,16 +267,6 @@ report_build (FILE *errfp, message, va_alist) partial_message_size += 2048; partial_message = REALLOC (partial_message, partial_message_size); } -#else - sprintf (partial_message + partial_message_size_used, message, a1, a2, a3, a4, a5, a6, a7, a8); - - /* Attempt to catch memory overwrites... */ - if ((partial_message_size_used = strlen (partial_message)) >= partial_message_size) - { - partial_message_size_used = 0; - report (stderr, GT_("partial error message buffer overflow")); - } -#endif #endif if (use_stderr && partial_message_size_used != 0) @@ -335,7 +312,6 @@ report_complete (FILE *errfp, message, va_alist) #if defined(VA_START) VA_START (args, message); -#if defined(HAVE_VSNPRINTF) || defined(_LIBC) for ( ; ; ) { n = vsnprintf (partial_message + partial_message_size_used, @@ -351,20 +327,8 @@ report_complete (FILE *errfp, message, va_alist) partial_message_size += 2048; partial_message = REALLOC (partial_message, partial_message_size); } -#else - vsprintf (partial_message + partial_message_size_used, message, args); - partial_message_size_used += strlen(partial_message+partial_message_size_used); - - /* Attempt to catch memory overwrites... */ - if (partial_message_size_used >= partial_message_size) - { - partial_message_size_used = 0; - report (stderr, GT_("partial error message buffer overflow")); - } -#endif va_end (args); #else -#if HAVE_SNPRINTF for ( ; ; ) { n = snprintf (partial_message + partial_message_size_used, @@ -380,16 +344,6 @@ report_complete (FILE *errfp, message, va_alist) partial_message_size += 2048; partial_message = REALLOC (partial_message, partial_message_size); } -#else - sprintf (partial_message + partial_message_size_used, message, a1, a2, a3, a4, a5, a6, a7, a8); - - /* Attempt to catch memory overwrites... */ - if ((partial_message_size_used = strlen (partial_message)) >= partial_message_size) - { - partial_message_size_used = 0; - report (stderr, GT_("partial error message buffer overflow")); - } -#endif #endif /* Finally... print it. */ @@ -264,27 +264,15 @@ char *rcpt_address(struct query *ctl, const char *id, static char addr[HOSTLEN+USERNAMELEN+1]; if (strchr(id, '@')) { -#ifdef HAVE_SNPRINTF snprintf(addr, sizeof (addr), "%s", id); -#else - sprintf(addr, "%s", id); -#endif /* HAVE_SNPRINTF */ } else if (usesmtpname && ctl->smtpname) { -#ifdef HAVE_SNPRINTF snprintf(addr, sizeof (addr), "%s", ctl->smtpname); -#else - sprintf(addr, "%s", ctl->smtpname); -#endif /* HAVE_SNPRINTF */ } else { -#ifdef HAVE_SNPRINTF snprintf(addr, sizeof (addr), "%s@%s", id, ctl->destaddr); -#else - sprintf(addr, "%s@%s", id, ctl->destaddr); -#endif /* HAVE_SNPRINTF */ } return addr; } @@ -337,12 +325,7 @@ static int send_bouncemail(struct query *ctl, struct msgblk *msg, } /* our first duty is to keep the sacred foo counters turning... */ -#ifdef HAVE_SNPRINTF - snprintf(boundary, sizeof(boundary), -#else - sprintf(boundary, -#endif /* HAVE_SNPRINTF */ - "foo-mani-padme-hum-%d-%d-%ld", + snprintf(boundary, sizeof(boundary), "foo-mani-padme-hum-%d-%d-%ld", (int)getpid(), (int)getppid(), time((time_t *)NULL)); if (outlevel >= O_VERBOSE) @@ -524,11 +507,7 @@ static int handle_smtp_report(struct query *ctl, struct msgblk *msg) if (run.spambounce) { char rejmsg[160]; -#ifdef HAVE_SNPRINTF snprintf(rejmsg, sizeof(rejmsg), -#else - sprintf(rejmsg, -#endif /* HAVE_SNPRINTF */ "spam filter or virus scanner rejected message because:\r\n" "%s\r\n", responses[0]); @@ -900,20 +879,12 @@ static int open_smtp_sink(struct query *ctl, struct msgblk *msg, { if (is_dottedquad(ctl->server.truename)) { -#ifdef HAVE_SNPRINTF - snprintf(addr, sizeof(addr), -#else - sprintf(addr, -#endif /* HAVE_SNPRINTF */ - "%s@[%s]", ctl->remotename, ctl->server.truename); + snprintf(addr, sizeof(addr), "%s@[%s]", ctl->remotename, + ctl->server.truename); } else { -#ifdef HAVE_SNPRINTF snprintf(addr, sizeof(addr), -#else - sprintf(addr, -#endif /* HAVE_SNPRINTF */ "%s@%s", ctl->remotename, ctl->server.truename); } ap = addr; @@ -927,21 +898,13 @@ static int open_smtp_sink(struct query *ctl, struct msgblk *msg, { if (is_dottedquad(ctl->server.truename)) { -#ifdef HAVE_SNPRINTF - snprintf(addr, sizeof(addr), -#else - sprintf(addr, -#endif /* HAVE_SNPRINTF */ - "%s@[%s]", msg->return_path, ctl->server.truename); + snprintf(addr, sizeof(addr), "%s@[%s]", msg->return_path, + ctl->server.truename); } else { -#ifdef HAVE_SNPRINTF - snprintf(addr, sizeof(addr), -#else - sprintf(addr, -#endif /* HAVE_SNPRINTF */ - "%s@%s", msg->return_path, ctl->server.truename); + snprintf(addr, sizeof(addr), "%s@%s", + msg->return_path, ctl->server.truename); } ap = addr; } @@ -1573,18 +1536,10 @@ va_dcl #else va_start(ap); #endif -#ifdef HAVE_VSNPRINTF vsnprintf(buf, sizeof(buf), fmt, ap); -#else - vsprintf(buf, fmt, ap); -#endif va_end(ap); -#ifdef HAVE_SNPRINTF snprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), "\r\n"); -#else - strcat(buf, "\r\n"); -#endif /* HAVE_SNPRINTF */ /* guard against very long lines */ buf[MSGBUFSIZE+1] = '\r'; @@ -8,14 +8,15 @@ * For license terms, see the file COPYING in this directory. */ +#include "config.h" +#include "fetchmail.h" + #include <stdio.h> #include <unistd.h> #include <string.h> #include <signal.h> -#include "fetchmail.h" #include "socket.h" #include "smtp.h" -#include "config.h" #include "i18n.h" struct opt @@ -105,11 +106,7 @@ static void SMTP_auth(int sock, char *username, char *password, char *buf) report(stdout, GT_("Challenge decoded: %s\n"), b64buf); hmac_md5(password, strlen(password), b64buf, strlen(b64buf), digest, sizeof(digest)); -#ifdef HAVE_SNPRINTF snprintf(tmp, sizeof(tmp), -#else - sprintf(tmp, -#endif /* HAVE_SNPRINTF */ "%s %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", username, digest[0], digest[1], digest[2], digest[3], digest[4], digest[5], digest[6], digest[7], digest[8], @@ -124,12 +121,7 @@ static void SMTP_auth(int sock, char *username, char *password, char *buf) int len; if (outlevel >= O_MONITOR) report(stdout, GT_("ESMTP PLAIN Authentication...\n")); -#ifdef HAVE_SNPRINTF - snprintf(tmp, sizeof(tmp), -#else - sprintf(tmp, -#endif /* HAVE_SNPRINTF */ - "^%s^%s", username, password); + snprintf(tmp, sizeof(tmp), "^%s^%s", username, password); len = strlen(tmp); for (c = len - 1; c >= 0; c--) @@ -233,25 +225,11 @@ int SMTP_from(int sock, const char *from, const char *opts) char buf[MSGBUFSIZE]; if (from[0]=='<') -#ifdef HAVE_SNPRINTF - snprintf(buf, sizeof(buf), -#else - sprintf(buf, -#endif /* HAVE_SNPRINTF */ - "MAIL FROM:%s", from); + snprintf(buf, sizeof(buf), "MAIL FROM:%s", from); else -#ifdef HAVE_SNPRINTF - snprintf(buf, sizeof(buf), -#else - sprintf(buf, -#endif /* HAVE_SNPRINTF */ - "MAIL FROM:<%s>", from); + snprintf(buf, sizeof(buf), "MAIL FROM:<%s>", from); if (opts) -#ifdef HAVE_SNPRINTF snprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), "%s", opts); -#else - strcat(buf, opts); -#endif /* HAVE_SNPRINTF */ SockPrintf(sock,"%s\r\n", buf); if (outlevel >= O_MONITOR) report(stdout, "%cMTP> %s\n", smtp_mode, buf); @@ -351,12 +351,7 @@ int SockOpen(const char *host, int clientPort, const char *options, #ifdef HAVE_SOCKETPAIR if (plugin) { char buf[10]; -#ifdef HAVE_SNPRINTF - snprintf(buf, sizeof(buf), /* Yeah, paranoic. So what? :P */ -#else - sprintf(buf, -#endif /* HAVE_SNPRINTF */ - "%d",clientPort); + snprintf(buf, sizeof(buf), "%d", clientPort); return handle_plugin(host,buf,plugin); } #endif /* HAVE_SOCKETPAIR */ @@ -487,11 +482,7 @@ va_dcl { #else va_start(ap); #endif -#ifdef HAVE_VSNPRINTF vsnprintf(buf, sizeof(buf), format, ap); -#else - vsprintf(buf, format, ap); -#endif va_end(ap); return SockWrite(sock, buf, strlen(buf)); @@ -849,11 +840,7 @@ static int SSL_verify_callback( int ok_return, X509_STORE_CTX *ctx, int strict ) tp = text; te = text + sizeof(text); for (i = 0; i < dsz; i++) { -#ifdef HAVE_SNPRINTF esz = snprintf(tp, te - tp, i > 0 ? ":%02X" : "%02X", digest[i]); -#else - esz = sprintf(tp, i > 0 ? ":%02X" : "%02X", digest[i]); -#endif if (esz >= te - tp) { report(stderr, GT_("Digest text buffer too small!\n")); return (0); @@ -941,12 +941,10 @@ int readheaders(int sock, */ if (msgblk.headers == (char *)NULL) { -#ifdef HAVE_SNPRINTF snprintf(buf, sizeof(buf), -#else - sprintf(buf, -#endif /* HAVE_SNPRINTF */ - "From: FETCHMAIL-DAEMON\r\nTo: %s@%s\r\nSubject: Headerless mail from %s's mailbox on %s\r\n", + "From: FETCHMAIL-DAEMON\r\n" + "To: %s@%s\r\n" + "Subject: Headerless mail from %s's mailbox on %s\r\n", user, fetchmailhost, ctl->remotename, ctl->server.truename); msgblk.headers = xstrdup(buf); } @@ -1125,11 +1123,7 @@ int readheaders(int sock, { /* utter any per-message Received information we need here */ if (ctl->server.trueaddr) { -#ifdef HAVE_SNPRINTF snprintf(buf, sizeof(buf), -#else - sprintf(buf, -#endif /* HAVE_SNPRINTF */ "Received: from %s [%u.%u.%u.%u]\r\n", ctl->server.truename, (unsigned int)(unsigned char)ctl->server.trueaddr[0], @@ -1137,11 +1131,7 @@ int readheaders(int sock, (unsigned int)(unsigned char)ctl->server.trueaddr[2], (unsigned int)(unsigned char)ctl->server.trueaddr[3]); } else { -#ifdef HAVE_SNPRINTF snprintf(buf, sizeof(buf), -#else - sprintf(buf, -#endif /* HAVE_SNPRINTF */ "Received: from %s\r\n", ctl->server.truename); } n = stuffline(ctl, buf); @@ -1151,11 +1141,7 @@ int readheaders(int sock, * This header is technically invalid under RFC822. * POP3, IMAP, etc. are not legal mail-parameter values. */ -#ifdef HAVE_SNPRINTF snprintf(buf, sizeof(buf), -#else - sprintf(buf, -#endif /* HAVE_SNPRINTF */ "\tby %s with %s (fetchmail-%s", fetchmailhost, protocol->name, @@ -1166,23 +1152,14 @@ int readheaders(int sock, ctl->server.pollname, ctl->remotename); } -#ifdef HAVE_SNPRINTF snprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), ")\r\n"); -#else - strcat(buf, ")\r\n"); -#endif /* HAVE_SNPRINTF */ n = stuffline(ctl, buf); if (n != -1) { buf[0] = '\t'; if (good_addresses == 0) { -#ifdef HAVE_SNPRINTF - snprintf(buf+1, sizeof(buf)-1, -#else - sprintf(buf+1, -#endif /* HAVE_SNPRINTF */ - "for %s (by default); ", + snprintf(buf+1, sizeof(buf)-1, "for %s (by default); ", rcpt_address (ctl, run.postmaster, 0)); } else if (good_addresses == 1) @@ -1190,25 +1167,17 @@ int readheaders(int sock, for (idp = msgblk.recipients; idp; idp = idp->next) if (idp->val.status.mark == XMIT_ACCEPT) break; /* only report first address */ -#ifdef HAVE_SNPRINTF snprintf(buf+1, sizeof(buf)-1, -#else - sprintf(buf+1, -#endif /* HAVE_SNPRINTF */ "for %s", rcpt_address (ctl, idp->id, 1)); - sprintf(buf+strlen(buf), " (%s); ", + snprintf(buf+strlen(buf), sizeof(buf)-strlen(buf)-1, + " (%s); ", MULTIDROP(ctl) ? "multi-drop" : "single-drop"); } else buf[1] = '\0'; -#ifdef HAVE_SNPRINTF snprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), "%s\r\n", rfc822timestamp()); -#else - strcat(buf, rfc822timestamp()); - strcat(buf, "\r\n"); -#endif /* HAVE_SNPRINTF */ n = stuffline(ctl, buf); } } @@ -1246,11 +1215,7 @@ int readheaders(int sock, for (idp = msgblk.recipients; idp; idp = idp->next) if (idp->val.status.mark == XMIT_REJECT) break; -#ifdef HAVE_SNPRINTF snprintf(errhd+strlen(errhd), sizeof(errhd)-strlen(errhd), -#else - sprintf(errhd+strlen(errhd), -#endif /* HAVE_SNPRINTF */ GT_("recipient address %s didn't match any local name"), idp->id); } } @@ -1258,26 +1223,16 @@ int readheaders(int sock, if (has_nuls) { if (errhd[sizeof("X-Fetchmail-Warning: ")]) -#ifdef HAVE_SNPRINTF snprintf(errhd+strlen(errhd), sizeof(errhd)-strlen(errhd), "; "); snprintf(errhd+strlen(errhd), sizeof(errhd)-strlen(errhd), -#else - strcat(errhd, "; "); - strcat(errhd, -#endif /* HAVE_SNPRINTF */ GT_("message has embedded NULs")); } if (bad_addresses) { if (errhd[sizeof("X-Fetchmail-Warning: ")]) -#ifdef HAVE_SNPRINTF snprintf(errhd+strlen(errhd), sizeof(errhd)-strlen(errhd), "; "); snprintf(errhd+strlen(errhd), sizeof(errhd)-strlen(errhd), -#else - strcat(errhd, "; "); - strcat(errhd, -#endif /* HAVE_SNPRINTF */ GT_("SMTP listener rejected local recipient addresses: ")); errlen = strlen(errhd); for (idp = msgblk.recipients; idp; idp = idp->next) @@ -1466,18 +1421,10 @@ va_dcl #else va_start(ap); #endif -#ifdef HAVE_VSNPRINTF vsnprintf(buf + strlen(buf), sizeof(buf)-strlen(buf), fmt, ap); -#else - vsprintf(buf + strlen(buf), fmt, ap); -#endif va_end(ap); -#ifdef HAVE_SNPRINTF snprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), "\r\n"); -#else - strcat(buf, "\r\n"); -#endif /* HAVE_SNPRINTF */ SockWrite(sock, buf, strlen(buf)); if (outlevel >= O_MONITOR) @@ -1551,18 +1498,10 @@ va_dcl #else va_start(ap); #endif -#ifdef HAVE_VSNPRINTF vsnprintf(buf + strlen(buf), sizeof(buf)-strlen(buf), fmt, ap); -#else - vsprintf(buf + strlen(buf), fmt, ap); -#endif va_end(ap); -#ifdef HAVE_SNPRINTF snprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), "\r\n"); -#else - strcat(buf, "\r\n"); -#endif /* HAVE_SNPRINTF */ SockWrite(sock, buf, strlen(buf)); if (outlevel >= O_MONITOR) |