From 3a5e257b7851e66774374b9f5466d3746b772ab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Groenvall?= Date: Mon, 2 Oct 1995 21:57:14 +0000 Subject: [PATCH] Use stdarg instead of varargs. The code is still broken though, you'll realize that on a machine with 64 bit pointers and 32 bit int:s and no vsprintf, let's hope there will be no such beasts. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@136 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/popper/pop_log.c | 28 ++++++++++++++++++++++++---- appl/popper/pop_msg.c | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 52 insertions(+), 12 deletions(-) diff --git a/appl/popper/pop_log.c b/appl/popper/pop_log.c index f8fcfb259..b1d9da0f0 100644 --- a/appl/popper/pop_log.c +++ b/appl/popper/pop_log.c @@ -11,7 +11,11 @@ static char SccsId[] = "@(#)@(#)pop_log.c 2.1 2.1 3/18/91"; #include #include +#if __STDC__ +#include +#else #include +#endif #include "popper.h" /* @@ -20,10 +24,18 @@ static char SccsId[] = "@(#)@(#)pop_log.c 2.1 2.1 3/18/91"; static char msgbuf[MAXLINELEN]; +int +#ifdef __STDC__ +pop_log(POP *p, int stat, char *format, ...) +#else pop_log(va_alist) va_dcl +#endif { va_list ap; +#ifdef __STDC__ + va_start(ap, format); +#else POP * p; int stat; char * format; @@ -32,14 +44,21 @@ va_dcl p = va_arg(ap,POP *); stat = va_arg(ap,int); format = va_arg(ap,char *); - va_end(ap); +#endif #ifdef HAVE_VSPRINTF vsprintf(msgbuf,format,ap); #else - (void)sprintf (msgbuf,format,((int *)ap)[0],((int *)ap)[1],((int *)ap)[2], - ((int *)ap)[3],((int *)ap)[4],((int *)ap)[5]); -#endif HAVE_VSPRINTF + { + int a0 = va_arg(ap, int); + int a1 = va_arg(ap, int); + int a2 = va_arg(ap, int); + int a3 = va_arg(ap, int); + int a4 = va_arg(ap, int); + int a5 = va_arg(ap, int); + (void)sprintf(msgbuf, format, a0, a1, a2, a3, a4, a5, 0, 4711); + } +#endif /* HAVE_VSPRINTF */ if (p->debug && p->trace) { (void)fprintf(p->trace,"%s\n",msgbuf); @@ -48,6 +67,7 @@ va_dcl else { syslog (stat,"%s",msgbuf); } + va_end(ap); return(stat); } diff --git a/appl/popper/pop_msg.c b/appl/popper/pop_msg.c index 083ae8098..08d133698 100644 --- a/appl/popper/pop_msg.c +++ b/appl/popper/pop_msg.c @@ -12,29 +12,41 @@ static char SccsId[] = "@(#)@(#)pop_msg.c 2.1 2.1 3/18/91"; #include #include #include +#if __STDC__ +#include +#else #include +#endif #include "popper.h" /* * msg: Send a formatted line to the POP client */ +int +#ifdef __STDC__ +pop_msg(POP *p, int stat, char *format, ...) +#else pop_msg(va_alist) va_dcl +#endif { + register char * mp; + char message[MAXLINELEN]; + va_list ap; +#ifdef __STDC__ + va_start(ap, format); +#else POP * p; int stat; /* POP status indicator */ char * format; /* Format string for the message */ - va_list ap; - register char * mp; - char message[MAXLINELEN]; va_start(ap); p = va_arg(ap, POP *); stat = va_arg(ap, int); format = va_arg(ap, char *); - va_end(ap); - +#endif + /* Point to the message buffer */ mp = message; @@ -52,9 +64,16 @@ va_dcl #ifdef HAVE_VSPRINTF vsprintf(mp,format,ap); #else - (void)sprintf(mp,format,((int *)ap)[0],((int *)ap)[1],((int *)ap)[2], - ((int *)ap)[3],((int *)ap)[4]); -#endif HAVE_VSPRINTF + { + int a0 = va_arg(ap, int); + int a1 = va_arg(ap, int); + int a2 = va_arg(ap, int); + int a3 = va_arg(ap, int); + int a4 = va_arg(ap, int); + int a5 = va_arg(ap, int); + (void)sprintf(mp, format, a0, a1, a2, a3, a4, a5, 0, 4711); + } +#endif /* HAVE_VSPRINTF */ /* Log the message if debugging is turned on */ #ifdef DEBUG @@ -73,5 +92,6 @@ va_dcl (void)fputs(message,p->output); (void)fflush(p->output); + va_end(ap); return(stat); }