home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3349 / mail.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-17  |  998 b   |  49 lines

  1. /*
  2.  * Copyright 1989, 1990, John F. Haugh II
  3.  * All rights reserved.
  4.  *
  5.  * Permission is granted to copy and create derivative works for any
  6.  * non-commercial purpose, provided this copyright notice is preserved
  7.  * in all copies of source code, or included in human readable form
  8.  * and conspicuously displayed on all copies of object code or
  9.  * distribution media.
  10.  */
  11.  
  12. #include <sys/types.h>
  13. #include <sys/stat.h>
  14.  
  15. #ifndef    BSD
  16. #include <string.h>
  17. #include <memory.h>
  18. #else
  19. #include <strings.h>
  20. #define    strchr    index
  21. #define    strrchr    rindex
  22. #endif
  23.  
  24. #include "config.h"
  25. #ifdef    MAILCHECK
  26.  
  27. #ifndef    lint
  28. static    char    sccsid[] = "@(#)mail.c    3.2    13:28:27    12/19/90";
  29. #endif
  30.  
  31. extern    char    *getenv();
  32.  
  33. void    mailcheck ()
  34. {
  35.     struct    stat    statbuf;
  36.     char    *mailbox;
  37.  
  38.     if (! (mailbox = getenv ("MAIL")))
  39.         return;
  40.  
  41.     if (stat (mailbox, &statbuf) == -1 || statbuf.st_size == 0)
  42.         puts ("No mail.");
  43.     else if (statbuf.st_atime > statbuf.st_mtime)
  44.         puts ("You have mail.");
  45.     else
  46.         puts ("You have new mail.");
  47. }
  48. #endif
  49.