home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / TELECOM / tass.lzh / mail.c < prev    next >
Text File  |  1993-01-24  |  1KB  |  56 lines

  1.  
  2. #include       <stdio.h>
  3. #ifndef                OSK
  4. #include       <sys/types.h>
  5. #include       <sys/stat.h>
  6. #else          /* OSK */
  7. #include       <types.h>
  8. #include       <stat.h>
  9. typedef long   off_t;
  10. #endif         /* OSK */
  11. #include       "tass.h"
  12.  
  13. char *mailbox_name = NULL;
  14. off_t mailbox_size;
  15.  
  16.  
  17. /*
  18.  *  Record size of mailbox so we can detect if new mail has arrived
  19.  */
  20.  
  21. mail_setup() {
  22.        struct stat buf;
  23.        extern char *getenv();
  24.  
  25.        if (do_mail_check) {
  26.                if (mailbox_name == NULL)
  27.                        mailbox_name = getenv("MAIL");
  28.  
  29.                if (mailbox_name == NULL)
  30.                        mailbox_size = 0;
  31.                else {
  32.                        if (stat(mailbox_name, &buf) >= 0)
  33.                                mailbox_size = buf.st_size;
  34.                        else
  35.                                mailbox_size = 0;
  36.                }
  37.        }
  38. }
  39.  
  40.  
  41. /*
  42.  *  Return TRUE if new mail has arrived
  43.  */
  44.  
  45. mail_check() {
  46.        struct stat buf;
  47.  
  48.        if (mailbox_name != NULL
  49.        &&  stat(mailbox_name, &buf) >= 0
  50.        &&  mailbox_size < buf.st_size)
  51.                return TRUE;
  52.  
  53.        return FALSE;
  54. }
  55.  
  56.