home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2286 / mail.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-28  |  912 b   |  54 lines

  1. /*
  2.  * Copyright 1989, 1990, John F. Haugh II
  3.  * All rights reserved.
  4.  *
  5.  * Use, duplication, and disclosure prohibited without
  6.  * the express written permission of the author.
  7.  */
  8.  
  9. #include <sys/types.h>
  10. #include <sys/stat.h>
  11. #ifndef    BSD
  12. #include <string.h>
  13. #include <memory.h>
  14. #else
  15. #include <strings.h>
  16. #define    strchr    index
  17. #define    strrchr    rindex
  18. #endif
  19. #include "config.h"
  20.  
  21. #ifndef    lint
  22. static    char    _sccsid[] = "@(#)mail.c    2.2    19:23:56    7/29/90";
  23. #endif
  24.  
  25. extern    char    mail[];
  26.  
  27. #ifdef    HUSHLOGIN
  28. extern    int    hushed;
  29. #endif
  30.  
  31. #ifdef    MAILCHECK
  32. void    mailcheck ()
  33. {
  34.     struct    stat    statbuf;
  35.     char    *mailbox;
  36.  
  37. #ifdef    HUSHLOGIN
  38.     if (hushed)
  39.         return;
  40. #endif
  41.     if (mailbox = strchr (mail, '='))
  42.         mailbox++;
  43.     else
  44.         return;
  45.  
  46.     if (stat (mailbox, &statbuf) == -1 || statbuf.st_size == 0)
  47.         puts ("No mail.");
  48.     else if (statbuf.st_atime > statbuf.st_mtime)
  49.         puts ("You have mail.");
  50.     else
  51.         puts ("You have new mail.");
  52. }
  53. #endif
  54.