|
|
1.1 root 1: static char *sccsid ="@(#)biff.c 4.1 (Berkeley) 10/18/80";
2: /*
3: * biff
4: */
5:
6: #include <sys/types.h>
7: #include <stat.h>
8: #include <stdio.h>
9:
10: char *ttyname();
11:
12: main(argc, argv)
13: int argc;
14: char **argv;
15: {
16: char *cp = ttyname(2);
17: struct stat stb;
18:
19: argc--, argv++;
20: if (cp == 0)
21: fprintf(stderr, "Where are you?\n"), exit(1);
22: if (stat(cp, &stb) < 0)
23: perror(cp), exit(1);
24: if (argc == 0) {
25: printf("is %s\n", stb.st_mode&0100 ? "y" : "n");
26: exit((stb.st_mode&0100) ? 0 : 1);
27: }
28: switch (argv[0][0]) {
29:
30: case 'y':
31: if (chmod(cp, stb.st_mode|0100) < 0)
32: perror(cp);
33: break;
34:
35: case 'n':
36: if (chmod(cp, stb.st_mode&~0100) < 0)
37: perror(cp);
38: break;
39:
40: default:
41: fprintf(stderr, "usage: biff [y] [n]\n");
42: }
43: exit((stb.st_mode&0100) ? 0 : 1);
44: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.