|
|
1.1 root 1: /* /sccs/src/cmd/uucp/s.uuname.c
2: uuname.c 1.1 8/30/84 17:38:10
3: */
4: #include "uucp.h"
5: VERSION(@(#)uuname.c 1.1);
6:
7: /*
8: * returns a list of all remote systems.
9: * option:
10: * -l -> returns only the local system name.
11: */
12: main(argc,argv, envp)
13: int argc;
14: char **argv, **envp;
15: {
16: FILE *np;
17: register short lflg = 0;
18: char s[BUFSIZ], prev[BUFSIZ], name[BUFSIZ];
19: #ifdef MANYSYS
20: int nsys = 0;
21: FILE *sysopen();
22: #endif
23:
24: while (*(++argv) && *argv[0] == '-')
25: switch(argv[0][1]) {
26: case 'l':
27: lflg++;
28: break;
29: default:
30: (void) fprintf(stderr, "usage: uuname [-l]\n");
31: exit(1);
32: }
33:
34: if (lflg) {
35: uucpname(name);
36:
37: /* initialize to null string */
38: (void) printf("%s",name);
39: (void) printf("\n");
40: exit(0);
41: }
42: #ifndef MANYSYS
43: if ((np=fopen(SYSFILE, "r")) == NULL) {
44: (void) fprintf(stderr, "File \" %s \" is protected\n", SYSFILE);
45: exit(1);
46: }
47: #else
48: sysrewind();
49: while ((np = sysopen("r")) != NULL) {
50: nsys++;
51: #endif
52: while (fgets(s, BUFSIZ, np) != NULL) {
53: if((s[0] == '#') || (s[0] == ' ') || (s[0] == '\t') ||
54: (s[0] == '\n'))
55: continue;
56: (void) sscanf(s, "%s", name);
57: if (EQUALS(name, prev))
58: continue;
59: (void) printf("%s", name);
60: (void) printf("\n");
61: (void) strcpy(prev, name);
62: }
63: #ifdef MANYSYS
64: }
65: if (nsys == 0) {
66: fprintf(stderr, "cannot open any System files\n");
67: exit(1);
68: }
69: #endif
70: exit(0);
71: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.