diff options
author | assar <assar@FreeBSD.org> | 2001-06-21 02:12:07 +0000 |
---|---|---|
committer | assar <assar@FreeBSD.org> | 2001-06-21 02:12:07 +0000 |
commit | 0c8fa354358381b3f1b92598e7f1b46f8cf744cc (patch) | |
tree | ed28ffb73cc0ae48a9892dab3f10b09bc36436d5 /crypto/heimdal/appl/popper/pop_msg.c | |
parent | 06c859ecf534f468a52f24a3eb14409d73a4907c (diff) | |
download | FreeBSD-src-0c8fa354358381b3f1b92598e7f1b46f8cf744cc.zip FreeBSD-src-0c8fa354358381b3f1b92598e7f1b46f8cf744cc.tar.gz |
import of heimdal 0.3f
Diffstat (limited to 'crypto/heimdal/appl/popper/pop_msg.c')
-rw-r--r-- | crypto/heimdal/appl/popper/pop_msg.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/crypto/heimdal/appl/popper/pop_msg.c b/crypto/heimdal/appl/popper/pop_msg.c new file mode 100644 index 0000000..12887a4 --- /dev/null +++ b/crypto/heimdal/appl/popper/pop_msg.c @@ -0,0 +1,57 @@ +/* + * 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: pop_msg.c,v 1.16 1999/09/16 20:38:50 assar Exp $"); + +/* + * 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 */ + snprintf (mp, sizeof(message), "%s ", + (stat == POP_SUCCESS) ? POP_OK : POP_ERR); + + /* Point past the POP status indicator in the message message */ + mp += strlen(mp); + + /* Append the message (formatted, if necessary) */ + if (format) + vsnprintf (mp, sizeof(message) - strlen(message), + 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> */ + strlcat(message, "\r\n", sizeof(message)); + + /* Send the message to the client */ + fputs(message, p->output); + fflush(p->output); + + va_end(ap); + return(stat); +} |