From 5229f34d0f1d7bf689894f042d0bd9be4ceff7eb Mon Sep 17 00:00:00 2001 From: Eric Allman Date: Tue, 17 Nov 1992 01:52:20 -0800 Subject: [PATCH] make it use varargs/stdarg and vsprintf SCCS-vsn: usr.sbin/sendmail/src/usersmtp.c 5.25 SCCS-vsn: usr.sbin/sendmail/src/main.c 5.60 SCCS-vsn: usr.sbin/sendmail/src/conf.h 5.30 SCCS-vsn: usr.sbin/sendmail/src/err.c 5.16 SCCS-vsn: usr.sbin/sendmail/src/version.c 5.126 SCCS-vsn: usr.sbin/sendmail/src/conf.c 5.46 --- usr/src/usr.sbin/sendmail/src/conf.c | 12 ++++-- usr/src/usr.sbin/sendmail/src/conf.h | 28 ++++++++++++- usr/src/usr.sbin/sendmail/src/err.c | 50 ++++++++++++++++-------- usr/src/usr.sbin/sendmail/src/main.c | 7 +--- usr/src/usr.sbin/sendmail/src/usersmtp.c | 13 ++++-- usr/src/usr.sbin/sendmail/src/version.c | 4 +- 6 files changed, 82 insertions(+), 32 deletions(-) diff --git a/usr/src/usr.sbin/sendmail/src/conf.c b/usr/src/usr.sbin/sendmail/src/conf.c index 6c7773370d..fc8e08d645 100644 --- a/usr/src/usr.sbin/sendmail/src/conf.c +++ b/usr/src/usr.sbin/sendmail/src/conf.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)conf.c 5.45 (Berkeley) %G%"; +static char sccsid[] = "@(#)conf.c 5.46 (Berkeley) %G%"; #endif /* not lint */ # include @@ -684,15 +684,17 @@ refuseconnections() */ /*VARARGS1*/ -setproctitle(fmt, a, b, c) +setproctitle(fmt VA_ARG_FORMAL) char *fmt; + VA_ARG_DECL { # ifdef SETPROCTITLE register char *p; register int i; + char buf[MAXLINE]; + VA_LOCAL_DECL extern char **Argv; extern char *LastArgv; - char buf[MAXLINE]; p = buf; @@ -701,7 +703,9 @@ setproctitle(fmt, a, b, c) p += strlen(p); /* print the argument string */ - (void) sprintf(p, fmt, a, b, c); + VA_START(fmt); + (void) vsprintf(p, fmt, ap); + VA_END; i = strlen(buf); if (i > LastArgv - Argv[0] - 2) diff --git a/usr/src/usr.sbin/sendmail/src/conf.h b/usr/src/usr.sbin/sendmail/src/conf.h index b7a8bf1c1b..ebdadb9fb4 100644 --- a/usr/src/usr.sbin/sendmail/src/conf.h +++ b/usr/src/usr.sbin/sendmail/src/conf.h @@ -5,7 +5,7 @@ * * %sccs.include.redist.c% * - * @(#)conf.h 5.29 (Berkeley) %G% + * @(#)conf.h 5.30 (Berkeley) %G% */ /* @@ -83,3 +83,29 @@ # ifndef EX_CONFIG # define EX_CONFIG 78 /* configuration error */ # endif + +/* +** Arrange to use either varargs or stdargs +*/ + +# ifdef __STDC__ + +# include + +# define VA_ARG_FORMAL +# define VA_ARG_DECL +# define VA_LOCAL_DECL va_list ap; +# define VA_START(f) va_start(ap, f) +# define VA_END va_end(ap) + +# else + +# include + +# define VA_ARG_FORMAL ,va_alist +# define VA_ARG_DECL va_dcl +# define VA_LOCAL_DECL va_list ap; +# define VA_START(f) va_start(ap) +# define VA_END va_end(ap) + +# endif diff --git a/usr/src/usr.sbin/sendmail/src/err.c b/usr/src/usr.sbin/sendmail/src/err.c index 348292c5c9..edec9373d9 100644 --- a/usr/src/usr.sbin/sendmail/src/err.c +++ b/usr/src/usr.sbin/sendmail/src/err.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)err.c 5.15 (Berkeley) %G%"; +static char sccsid[] = "@(#)err.c 5.16 (Berkeley) %G%"; #endif /* not lint */ # include "sendmail.h" @@ -42,11 +42,13 @@ char MsgBuf[BUFSIZ*2]; /* text of most recent message */ static void fmtmsg(); /*VARARGS1*/ -syserr(fmt, a, b, c, d, e) +syserr(fmt VA_ARG_FORMAL) char *fmt; + VA_ARG_DECL { register char *p; int olderrno = errno; + VA_LOCAL_DECL extern char Arpa_PSyserr[]; extern char Arpa_TSyserr[]; @@ -55,7 +57,9 @@ syserr(fmt, a, b, c, d, e) p = Arpa_PSyserr; else p = Arpa_TSyserr; - fmtmsg(MsgBuf, (char *) NULL, p, olderrno, fmt, a, b, c, d, e); + VA_START(fmt); + fmtmsg(MsgBuf, (char *) NULL, p, olderrno, fmt, ap); + VA_END; puterrmsg(MsgBuf); /* determine exit status if not already set */ @@ -94,9 +98,11 @@ syserr(fmt, a, b, c, d, e) */ /*VARARGS1*/ -usrerr(fmt, a, b, c, d, e) +usrerr(fmt VA_ARG_FORMAL) char *fmt; + VA_ARG_DECL { + VA_LOCAL_DECL extern char SuprErrs; extern char Arpa_Usrerr[]; extern int errno; @@ -104,7 +110,9 @@ usrerr(fmt, a, b, c, d, e) if (SuprErrs) return; - fmtmsg(MsgBuf, CurEnv->e_to, Arpa_Usrerr, errno, fmt, a, b, c, d, e); + VA_START(fmt); + fmtmsg(MsgBuf, CurEnv->e_to, Arpa_Usrerr, errno, fmt, ap); + VA_END; puterrmsg(MsgBuf); # ifdef LOG @@ -134,12 +142,17 @@ usrerr(fmt, a, b, c, d, e) */ /*VARARGS2*/ -message(num, msg, a, b, c, d, e) - register char *num; - register char *msg; +message(num, msg VA_ARG_FORMAL) + char *num; + char *msg; + VA_ARG_DECL { + VA_LOCAL_DECL + errno = 0; - fmtmsg(MsgBuf, CurEnv->e_to, num, 0, msg, a, b, c, d, e); + VA_START(msg); + fmtmsg(MsgBuf, CurEnv->e_to, num, 0, msg, ap); + VA_END; putmsg(MsgBuf, FALSE); } /* @@ -161,12 +174,17 @@ message(num, msg, a, b, c, d, e) */ /*VARARGS2*/ -nmessage(num, msg, a, b, c, d, e) - register char *num; - register char *msg; +nmessage(num, msg VA_ARG_FORMAL) + char *num; + char *msg; + VA_ARG_DECL { + VA_LOCAL_DECL + errno = 0; - fmtmsg(MsgBuf, (char *) NULL, num, 0, msg, a, b, c, d, e); + VA_START(msg); + fmtmsg(MsgBuf, (char *) NULL, num, 0, msg, ap); + VA_END; putmsg(MsgBuf, FALSE); } /* @@ -247,14 +265,14 @@ puterrmsg(msg) ** none. */ -/*VARARGS5*/ static void -fmtmsg(eb, to, num, eno, fmt, a, b, c, d, e) +fmtmsg(eb, to, num, eno, fmt, ap) register char *eb; char *to; char *num; int eno; char *fmt; + va_list ap; { char del; @@ -287,7 +305,7 @@ fmtmsg(eb, to, num, eno, fmt, a, b, c, d, e) } /* output the message */ - (void) sprintf(eb, fmt, a, b, c, d, e); + (void) vsprintf(eb, fmt, ap); while (*eb != '\0') *eb++ &= 0177; diff --git a/usr/src/usr.sbin/sendmail/src/main.c b/usr/src/usr.sbin/sendmail/src/main.c index 247dc29076..2179b78a65 100644 --- a/usr/src/usr.sbin/sendmail/src/main.c +++ b/usr/src/usr.sbin/sendmail/src/main.c @@ -13,7 +13,7 @@ char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)main.c 5.59 (Berkeley) %G%"; +static char sccsid[] = "@(#)main.c 5.60 (Berkeley) %G%"; #endif /* not lint */ #define _DEFINE @@ -1178,9 +1178,7 @@ disconnect(fulldrop) /* drop our controlling TTY completely if possible */ if (fulldrop) { -#if BSD > 43 - daemon(1, 1); -#else + (void) setsid(); #ifdef TIOCNOTTY fd = open("/dev/tty", 2); if (fd >= 0) @@ -1190,7 +1188,6 @@ disconnect(fulldrop) } (void) setpgrp(0, 0); #endif /* TIOCNOTTY */ -#endif /* BSD */ errno = 0; } diff --git a/usr/src/usr.sbin/sendmail/src/usersmtp.c b/usr/src/usr.sbin/sendmail/src/usersmtp.c index 5a542a71f0..99c4560684 100644 --- a/usr/src/usr.sbin/sendmail/src/usersmtp.c +++ b/usr/src/usr.sbin/sendmail/src/usersmtp.c @@ -10,9 +10,9 @@ #ifndef lint #ifdef SMTP -static char sccsid[] = "@(#)usersmtp.c 5.24 (Berkeley) %G% (with SMTP)"; +static char sccsid[] = "@(#)usersmtp.c 5.25 (Berkeley) %G% (with SMTP)"; #else -static char sccsid[] = "@(#)usersmtp.c 5.24 (Berkeley) %G% (without SMTP)"; +static char sccsid[] = "@(#)usersmtp.c 5.25 (Berkeley) %G% (without SMTP)"; #endif #endif /* not lint */ @@ -532,12 +532,17 @@ reply(m, mci, e) */ /*VARARGS1*/ -smtpmessage(f, m, mci, a, b, c) +smtpmessage(f, m, mci VA_ARG_FORMAL) char *f; MAILER *m; MCI *mci; + VA_ARG_DECL { - (void) sprintf(SmtpMsgBuffer, f, a, b, c); + VA_LOCAL_DECL + + VA_START(f); + (void) vsprintf(SmtpMsgBuffer, f, ap); + VA_END; if (tTd(18, 1) || (Verbose && !HoldErrs)) nmessage(Arpa_Info, ">>> %s", SmtpMsgBuffer); if (mci->mci_out != NULL) diff --git a/usr/src/usr.sbin/sendmail/src/version.c b/usr/src/usr.sbin/sendmail/src/version.c index e347c45269..ccda74013e 100644 --- a/usr/src/usr.sbin/sendmail/src/version.c +++ b/usr/src/usr.sbin/sendmail/src/version.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)version.c 5.125 (Berkeley) %G%"; +static char sccsid[] = "@(#)version.c 5.126 (Berkeley) %G%"; #endif /* not lint */ -char Version[] = "5.125"; +char Version[] = "5.126"; -- 2.20.1