2 * Copyright (c) 1989 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
8 __RCSID("$Heimdal: pop_msg.c 6984 1999-09-16 20:41:57Z assar $"
12 * msg: Send a formatted line to the POP client
16 pop_msg(POP
*p
, int stat
, char *format
, ...)
19 char message
[MAXLINELEN
];
24 /* Point to the message buffer */
27 /* Format the POP status code at the beginning of the message */
28 snprintf (mp
, sizeof(message
), "%s ",
29 (stat
== POP_SUCCESS
) ? POP_OK
: POP_ERR
);
31 /* Point past the POP status indicator in the message message */
34 /* Append the message (formatted, if necessary) */
36 vsnprintf (mp
, sizeof(message
) - strlen(message
),
39 /* Log the message if debugging is turned on */
41 if (p
->debug
&& stat
== POP_SUCCESS
)
42 pop_log(p
,POP_DEBUG
,"%s",message
);
45 /* Log the message if a failure occurred */
46 if (stat
!= POP_SUCCESS
)
47 pop_log(p
,POP_PRIORITY
,"%s",message
);
49 /* Append the <CR><LF> */
50 strlcat(message
, "\r\n", sizeof(message
));
52 /* Send the message to the client */
53 fputs(message
, p
->output
);