kdc: pass down the delegated_proxy_principal to the verify_pac() function
[heimdal.git] / appl / popper / pop_msg.c
bloba197a41db705ace3ca13a61ce4d42d5aa9dd8bfe
1 /*
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.
5 */
7 #include <popper.h>
8 RCSID("$Id$");
11 * msg: Send a formatted line to the POP client
14 int
15 pop_msg(POP *p, int stat, const char *format, ...)
17 char *mp;
18 char message[MAXLINELEN];
19 va_list ap;
21 va_start(ap, format);
23 /* Point to the message buffer */
24 mp = message;
26 /* Format the POP status code at the beginning of the message */
27 snprintf (mp, sizeof(message), "%s ",
28 (stat == POP_SUCCESS) ? POP_OK : POP_ERR);
30 /* Point past the POP status indicator in the message message */
31 mp += strlen(mp);
33 /* Append the message (formatted, if necessary) */
34 if (format)
35 vsnprintf (mp, sizeof(message) - strlen(message),
36 format, ap);
38 /* Log the message if debugging is turned on */
39 #ifdef DEBUG
40 if (p->debug && stat == POP_SUCCESS)
41 pop_log(p,POP_DEBUG,"%s",message);
42 #endif /* DEBUG */
44 /* Log the message if a failure occurred */
45 if (stat != POP_SUCCESS)
46 pop_log(p,POP_PRIORITY,"%s",message);
48 /* Append the <CR><LF> */
49 strlcat(message, "\r\n", sizeof(message));
51 /* Send the message to the client */
52 fputs(message, p->output);
53 fflush(p->output);
55 va_end(ap);
56 return(stat);