Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/mam/mamstate.c
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1989-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
* Glenn Fowler <[email protected]> *
18
* *
19
***********************************************************************/
20
#pragma prototyped
21
/*
22
* AT&T Bell Laboratories
23
* mamexec state support
24
*
25
* mamstate reference [ file ... | <files ]
26
*
27
* stdout is list of <file,delta> pairs where delta
28
* is diff between reference and file times
29
* non-existent files are not listed
30
*/
31
32
static const char id[] = "\n@(#)$Id: mamstate (AT&T Bell Laboratories) 1989-06-26 $\0\n";
33
34
#include <stdio.h>
35
#include <sys/types.h>
36
#include <sys/stat.h>
37
38
int
39
main(int argc, register char** argv)
40
{
41
register char* s;
42
char* id;
43
unsigned long ref;
44
struct stat st;
45
char buf[1024];
46
47
id = "mamstate";
48
if (!(s = *++argv))
49
{
50
fprintf(stderr, "%s: reference file argument expected\n", id);
51
return 1;
52
}
53
if (stat(s, &st))
54
{
55
fprintf(stderr, "%s: %s: cannot stat\n", id, s);
56
return 1;
57
}
58
ref = (unsigned long)st.st_mtime;
59
if (s = *++argv)
60
do
61
{
62
if (!stat(s, &st))
63
printf("%s %ld\n", s, (unsigned long)st.st_mtime - ref);
64
} while (s = *++argv);
65
else
66
while (s = fgets(buf, sizeof(buf), stdin))
67
if (!stat(s, &st))
68
printf("%s %ld\n", s, (unsigned long)st.st_mtime - ref);
69
return 0;
70
}
71
72