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:
@@ -11,7 +11,11 @@ static char SccsId[] = "@(#)@(#)pop_log.c 2.1 2.1 3/18/91";
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#if __STDC__
|
||||||
|
#include <stdarg.h>
|
||||||
|
#else
|
||||||
#include <varargs.h>
|
#include <varargs.h>
|
||||||
|
#endif
|
||||||
#include "popper.h"
|
#include "popper.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -20,10 +24,18 @@ static char SccsId[] = "@(#)@(#)pop_log.c 2.1 2.1 3/18/91";
|
|||||||
|
|
||||||
static char msgbuf[MAXLINELEN];
|
static char msgbuf[MAXLINELEN];
|
||||||
|
|
||||||
|
int
|
||||||
|
#ifdef __STDC__
|
||||||
|
pop_log(POP *p, int stat, char *format, ...)
|
||||||
|
#else
|
||||||
pop_log(va_alist)
|
pop_log(va_alist)
|
||||||
va_dcl
|
va_dcl
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
#ifdef __STDC__
|
||||||
|
va_start(ap, format);
|
||||||
|
#else
|
||||||
POP * p;
|
POP * p;
|
||||||
int stat;
|
int stat;
|
||||||
char * format;
|
char * format;
|
||||||
@@ -32,14 +44,21 @@ va_dcl
|
|||||||
p = va_arg(ap,POP *);
|
p = va_arg(ap,POP *);
|
||||||
stat = va_arg(ap,int);
|
stat = va_arg(ap,int);
|
||||||
format = va_arg(ap,char *);
|
format = va_arg(ap,char *);
|
||||||
va_end(ap);
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_VSPRINTF
|
#ifdef HAVE_VSPRINTF
|
||||||
vsprintf(msgbuf,format,ap);
|
vsprintf(msgbuf,format,ap);
|
||||||
#else
|
#else
|
||||||
(void)sprintf (msgbuf,format,((int *)ap)[0],((int *)ap)[1],((int *)ap)[2],
|
{
|
||||||
((int *)ap)[3],((int *)ap)[4],((int *)ap)[5]);
|
int a0 = va_arg(ap, int);
|
||||||
#endif HAVE_VSPRINTF
|
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) {
|
if (p->debug && p->trace) {
|
||||||
(void)fprintf(p->trace,"%s\n",msgbuf);
|
(void)fprintf(p->trace,"%s\n",msgbuf);
|
||||||
@@ -48,6 +67,7 @@ va_dcl
|
|||||||
else {
|
else {
|
||||||
syslog (stat,"%s",msgbuf);
|
syslog (stat,"%s",msgbuf);
|
||||||
}
|
}
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
return(stat);
|
return(stat);
|
||||||
}
|
}
|
||||||
|
@@ -12,29 +12,41 @@ static char SccsId[] = "@(#)@(#)pop_msg.c 2.1 2.1 3/18/91";
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
#if __STDC__
|
||||||
|
#include <stdarg.h>
|
||||||
|
#else
|
||||||
#include <varargs.h>
|
#include <varargs.h>
|
||||||
|
#endif
|
||||||
#include "popper.h"
|
#include "popper.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* msg: Send a formatted line to the POP client
|
* 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)
|
pop_msg(va_alist)
|
||||||
va_dcl
|
va_dcl
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
register char * mp;
|
||||||
|
char message[MAXLINELEN];
|
||||||
|
va_list ap;
|
||||||
|
#ifdef __STDC__
|
||||||
|
va_start(ap, format);
|
||||||
|
#else
|
||||||
POP * p;
|
POP * p;
|
||||||
int stat; /* POP status indicator */
|
int stat; /* POP status indicator */
|
||||||
char * format; /* Format string for the message */
|
char * format; /* Format string for the message */
|
||||||
va_list ap;
|
|
||||||
register char * mp;
|
|
||||||
char message[MAXLINELEN];
|
|
||||||
|
|
||||||
va_start(ap);
|
va_start(ap);
|
||||||
p = va_arg(ap, POP *);
|
p = va_arg(ap, POP *);
|
||||||
stat = va_arg(ap, int);
|
stat = va_arg(ap, int);
|
||||||
format = va_arg(ap, char *);
|
format = va_arg(ap, char *);
|
||||||
va_end(ap);
|
#endif
|
||||||
|
|
||||||
/* Point to the message buffer */
|
/* Point to the message buffer */
|
||||||
mp = message;
|
mp = message;
|
||||||
|
|
||||||
@@ -52,9 +64,16 @@ va_dcl
|
|||||||
#ifdef HAVE_VSPRINTF
|
#ifdef HAVE_VSPRINTF
|
||||||
vsprintf(mp,format,ap);
|
vsprintf(mp,format,ap);
|
||||||
#else
|
#else
|
||||||
(void)sprintf(mp,format,((int *)ap)[0],((int *)ap)[1],((int *)ap)[2],
|
{
|
||||||
((int *)ap)[3],((int *)ap)[4]);
|
int a0 = va_arg(ap, int);
|
||||||
#endif HAVE_VSPRINTF
|
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 */
|
/* Log the message if debugging is turned on */
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@@ -73,5 +92,6 @@ va_dcl
|
|||||||
(void)fputs(message,p->output);
|
(void)fputs(message,p->output);
|
||||||
(void)fflush(p->output);
|
(void)fflush(p->output);
|
||||||
|
|
||||||
|
va_end(ap);
|
||||||
return(stat);
|
return(stat);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user