1 /*********************************************************************** 2 * * 3 * This software is part of the ast package * 4 * Copyright (c) 1982-2011 AT&T Intellectual Property * 5 * and is licensed under the * 6 * Eclipse Public License, Version 1.0 * 7 * by AT&T Intellectual Property * 8 * * 9 * A copy of the License is available at * 10 * http://www.eclipse.org/org/documents/epl-v10.html * 11 * (with md5 checksum b35adb5213ca9657e911e9befb180842) * 12 * * 13 * Information and Software Systems Research * 14 * AT&T Research * 15 * Florham Park NJ * 16 * * 17 * David Korn <dgk@research.att.com> * 18 * * 19 ***********************************************************************/ 20 /* 21 * AT&T Bell Laboratories 22 * make abstract machine file state support 23 * 24 * mamstate reference [ file ... | <files ] 25 * 26 * stdout is list of <file,delta> pairs where delta 27 * is diff between reference and file times 28 * non-existent files are not listed 29 */ 30 31 #if !lint 32 static char id[] = "\n@(#)$Id: mamstate (AT&T Bell Laboratories) 1989-06-26 $\0\n"; 33 #endif 34 35 #include <stdio.h> 36 #include <sys/types.h> 37 #include <sys/stat.h> 38 39 main(argc, argv) 40 int argc; 41 register char** argv; 42 { 43 register char* s; 44 register int c; 45 long ref; 46 struct stat st; 47 char buf[1024]; 48 49 if (!(s = *++argv) || stat(s, &st)) 50 { 51 fprintf(stderr, "Usage: mamstate reference [ file ... | <files ]\n"); 52 exit(1); 53 } 54 ref = (long)st.st_mtime; 55 if (s = *++argv) do 56 { 57 if (!stat(s, &st)) 58 printf("%s %ld\n", s, (long)st.st_mtime - ref); 59 } while (s = *++argv); 60 else do 61 { 62 s = buf; 63 while ((c = getchar()) != EOF && c != ' ' && c != '\n') 64 if (s < buf + sizeof(buf) - 1) *s++ = c; 65 if (s > buf) 66 { 67 *s = 0; 68 if (!stat(buf, &st)) 69 printf("%s %ld\n", buf, (long)st.st_mtime - ref); 70 } 71 } while (c != EOF); 72 exit(0); 73 } 74