|
|
1.1 root 1: #include <ctype.h>
2: #include <stdio.h>
3: #include <sys/types.h>
4: #include <sys/stat.h>
5: #include <libc.h>
6:
7: int mflag, aflag;
8: extern int errno;
9: extern char *sys_errlist[];
10: extern long timec();
11:
12: main(argc, argv)
13: char **argv;
14: {
15: char s[50];
16: int bad = 0;
17: long date;
18: struct stat statb;
19: time_t timeb[2];
20: while(argv[1][0] == '-') {
21: while(*(++argv[1])) {
22: switch(argv[1][0]) {
23: case 'm':
24: case 'u':
25: mflag++;
26: break;
27: case 'a':
28: aflag++;
29: break;
30: }
31: }
32: argc--;
33: argv++;
34: }
35: if(mflag==0 && aflag==0)
36: mflag = aflag = 1;
37: strcpy(s, argv[1]);
38: strcat(s, " ");
39: while(argc>2 && (isdigit(*argv[2])||*argv[2]=='-')) {
40: strcat(s, argv[2]);
41: strcat(s, " ");
42: argc--;
43: argv++;
44: }
45: date = timec(s);
46: for( ; argc>2; argc--,argv++) {
47: if(stat(argv[2],&statb) < 0) {
48: fprintf(stderr,"chdate: %s: %s\n",
49: argv[2],sys_errlist[errno]);
50: bad++;
51: continue;
52: }
53: timeb[0] = statb.st_atime;
54: timeb[1] = statb.st_mtime;
55: if(aflag)
56: timeb[0] = date;
57: if(mflag)
58: timeb[1] = date;
59: if(utime(argv[2],timeb) < 0) {
60: fprintf(stderr,"chdate: %s: %s\n",
61: argv[2],sys_errlist[errno]);
62: bad++;
63: }
64: }
65: return bad;
66: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.