Files
heimdal/appl/popper/pop_msg.c
Assar Westerlund 5b731d7b1d Always use vsprintf
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1094 ec53bebd-3082-4978-b11e-865c3cabbd6b
1996-12-14 20:53:29 +00:00

59 lines
1.4 KiB
C

/*
* Copyright (c) 1989 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#include <popper.h>
RCSID("$Id$");
/*
* msg: Send a formatted line to the POP client
*/
int
pop_msg(POP *p, int stat, char *format, ...)
{
char *mp;
char message[MAXLINELEN];
va_list ap;
va_start(ap, format);
/* Point to the message buffer */
mp = message;
/* Format the POP status code at the beginning of the message */
if (stat == POP_SUCCESS)
sprintf (mp,"%s ",POP_OK);
else
sprintf (mp,"%s ",POP_ERR);
/* Point past the POP status indicator in the message message */
mp += strlen(mp);
/* Append the message (formatted, if necessary) */
if (format)
vsprintf(mp,format,ap);
/* Log the message if debugging is turned on */
#ifdef DEBUG
if (p->debug && stat == POP_SUCCESS)
pop_log(p,POP_DEBUG,"%s",message);
#endif /* DEBUG */
/* Log the message if a failure occurred */
if (stat != POP_SUCCESS)
pop_log(p,POP_PRIORITY,"%s",message);
/* Append the <CR><LF> */
strcat(message, "\r\n");
/* Send the message to the client */
fputs(message,p->output);
fflush(p->output);
va_end(ap);
return(stat);
}