home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume7 / bsnews1.1 / checknews.c next >
C/C++ Source or Header  |  1989-08-05  |  707b  |  31 lines

  1. /*
  2.  * checknews.c - checks for bootstrap news
  3.  * copyright 1989 Ronald Florence (ron@mlfarm, 7/30/89)
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <sys/types.h>
  8. #include <sys/stat.h>
  9.  
  10. #ifndef Newsspool
  11. #define Newsspool  "/usr/spool/news/bsnews"
  12. #endif
  13. #define bye(s)       puts(s), exit(1)
  14.  
  15. main()
  16. {
  17.   struct stat nt, lt;
  18.   char newsmarker[80], *getenv();
  19.  
  20.   if (!strcpy(newsmarker, getenv("HOME")))
  21.     bye("checknews: cannot find $HOME.");
  22.   strcat(newsmarker, "/.lastnews");
  23.   if (stat(newsmarker, <) == -1)
  24.     lt.st_mtime = 0;
  25.   if (stat(Newsspool, &nt) == -1)
  26.     bye("checknews: cannot find Newsspool.");
  27.   puts(nt.st_mtime < lt.st_mtime ? "No news is good news.":\
  28.        "New news has arrived.");
  29.   exit(0);
  30. }
  31.