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:  */
   6: 
   7: #ifndef lint
   8: static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
   9: static char SccsId[] = "@(#)@(#)pop_msg.c	2.1  2.1 3/18/91";
  10: #endif not lint
  11: 
  12: #include <stdio.h>
  13: #include <sys/types.h>
  14: #include <strings.h>
  15: #include <varargs.h>
  16: #include "popper.h"
  17: 
  18: /*
  19:  *  msg:    Send a formatted line to the POP client
  20:  */
  21: 
  22: pop_msg(va_alist)
  23: va_dcl
  24: {
  25:     POP             *   p;
  26:     int                 stat;               /*  POP status indicator */
  27:     char            *   format;             /*  Format string for the message */
  28:     va_list             ap;
  29:     register char   *   mp;
  30:     char                message[MAXLINELEN];
  31: 
  32:     va_start(ap);
  33:     p = va_arg(ap, POP *);
  34:     stat = va_arg(ap, int);
  35:     format = va_arg(ap, char *);
  36:     va_end(ap);
  37: 
  38:     /*  Point to the message buffer */
  39:     mp = message;
  40: 
  41:     /*  Format the POP status code at the beginning of the message */
  42:     if (stat == POP_SUCCESS)
  43:         (void)sprintf (mp,"%s ",POP_OK);
  44:     else
  45:         (void)sprintf (mp,"%s ",POP_ERR);
  46: 
  47:     /*  Point past the POP status indicator in the message message */
  48:     mp += strlen(mp);
  49: 
  50:     /*  Append the message (formatted, if necessary) */
  51:     if (format)
  52: #ifdef HAVE_VSPRINTF
  53:         vsprintf(mp,format,ap);
  54: #else
  55:         (void)sprintf(mp,format,((int *)ap)[0],((int *)ap)[1],((int *)ap)[2],
  56:                 ((int *)ap)[3],((int *)ap)[4]);
  57: #endif HAVE_VSPRINTF
  58: 
  59:     /*  Log the message if debugging is turned on */
  60: #ifdef DEBUG
  61:     if (p->debug && stat == POP_SUCCESS)
  62:         pop_log(p,POP_DEBUG,"%s",message);
  63: #endif DEBUG
  64: 
  65:     /*  Log the message if a failure occurred */
  66:     if (stat != POP_SUCCESS)
  67:         pop_log(p,POP_PRIORITY,"%s",message);
  68: 
  69:     /*  Append the <CR><LF> */
  70:     (void)strcat(message, "\r\n");
  71: 
  72:     /*  Send the message to the client */
  73:     (void)fputs(message,p->output);
  74:     (void)fflush(p->output);
  75: 
  76:     return(stat);
  77: }
Last modified: 1991-04-04
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2854
Valid CSS Valid XHTML 1.0 Strict