public-domain implementation of V8 "newer"
Moderator, John Quarterman
std-unix at ut-sally.UUCP
Tue Nov 4 11:34:23 AEST 1986
From: gwyn at brl.arpa (VLD/VMB) (Douglas A. Gwyn)
Date: Mon, 3 Nov 86 10:37:13 EST
/*
newer -- test file modification dates
last edit: 86/03/30 D A Gwyn
*/
#ifndef lint
static char SCCS_ID[] = "@(#)newer.c 1.1";
#endif
#include <sys/types.h>
#include <sys/stat.h>
#define EXIT _exit /* non-STDIO exit(), if available */
#define STDERR 2 /* standard error file descriptor */
extern void EXIT();
extern int stat(), write();
main( argc, argv )
int argc;
char *argv[];
{
static char usage[] = "Usage: newer file1 file2\n";
static struct stat file1; /* file1 statistics */
static struct stat file2; /* file2 statistics */
if ( argc != 3 )
{ /* wrong number of arguments */
(void)write( STDERR, usage, sizeof usage - 1 );
EXIT( 3 );
}
if ( stat( argv[1], &file1 ) != 0 )
EXIT( 2 ); /* file1 doesn't exist */
if ( stat( argv[2], &file2 ) != 0 )
EXIT( 0 ); /* file2 doesn't exist */
#ifdef lint
return file1.st_mtime < file2.st_mtime ? 1 : 0;
#else
EXIT( file1.st_mtime < file2.st_mtime ? 1 : 0 );
#endif
}
Volume-Number: Volume 8, Number 29
More information about the Mod.std.unix
mailing list