home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / mod.std.unix.v8 / text0028.txt < prev    next >
Encoding:
Internet Message Format  |  1987-06-30  |  1.1 KB

  1. From: gwyn@brl.arpa (VLD/VMB) (Douglas A. Gwyn)
  2. Date:     Mon, 3 Nov 86 10:37:13 EST
  3.  
  4. /*
  5.     newer -- test file modification dates
  6.  
  7.     last edit:    86/03/30    D A Gwyn
  8. */
  9. #ifndef lint
  10. static char    SCCS_ID[] = "@(#)newer.c    1.1";
  11. #endif
  12.  
  13. #include    <sys/types.h>
  14. #include    <sys/stat.h>
  15.  
  16. #define    EXIT    _exit            /* non-STDIO exit(), if available */
  17.  
  18. #define    STDERR    2            /* standard error file descriptor */
  19.  
  20. extern void    EXIT();
  21. extern int    stat(), write();
  22.  
  23. main( argc, argv )
  24.     int            argc;
  25.     char            *argv[];
  26.     {
  27.     static char        usage[] = "Usage: newer file1 file2\n";
  28.     static struct stat    file1;    /* file1 statistics */
  29.     static struct stat    file2;    /* file2 statistics */
  30.  
  31.     if ( argc != 3 )
  32.         {            /* wrong number of arguments */
  33.         (void)write( STDERR, usage, sizeof usage - 1 );
  34.         EXIT( 3 );
  35.         }
  36.  
  37.     if ( stat( argv[1], &file1 ) != 0 )
  38.         EXIT( 2 );        /* file1 doesn't exist */
  39.  
  40.     if ( stat( argv[2], &file2 ) != 0 )
  41.         EXIT( 0 );        /* file2 doesn't exist */
  42.  
  43. #ifdef lint
  44.     return file1.st_mtime < file2.st_mtime ? 1 : 0;
  45. #else
  46.     EXIT( file1.st_mtime < file2.st_mtime ? 1 : 0 );
  47. #endif
  48.     }
  49.  
  50. Volume-Number: Volume 8, Number 29
  51.  
  52.