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
This commit is contained in:
Björn Groenvall
1995-10-02 21:57:14 +00:00
parent e6b8c96c72
commit 3a5e257b78
2 changed files with 52 additions and 12 deletions

View File

@@ -11,7 +11,11 @@ static char SccsId[] = "@(#)@(#)pop_log.c 2.1 2.1 3/18/91";
#include <stdio.h>
#include <sys/types.h>
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#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);
}

View File

@@ -12,29 +12,41 @@ static char SccsId[] = "@(#)@(#)pop_msg.c 2.1 2.1 3/18/91";
#include <stdio.h>
#include <sys/types.h>
#include <strings.h>
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#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);
}