xref: /original-bsd/usr.bin/uucp/uupoll/uupoll.c (revision c374ae69)
1 #ifndef lint
2 static char sccsid[] = "@(#)uupoll.c	5.3 (Berkeley) 04/10/85";
3 #endif
4 
5 /*
6  * Poll named system(s).
7  *
8  * The poll occurs even if recent attempts have failed,
9  * but not if L.sys prohibits the call (e.g. wrong time of day).
10  *
11  * AUTHOR
12  *	Tom Truscott (rti!trt)
13  */
14 
15 #include "uucp.h"
16 
17 int TransferSucceeded = 1;
18 
19 main(argc, argv)
20 register int argc;
21 register char **argv;
22 {
23 	int ret;
24 	char wrkpre[MAXFULLNAME];
25 	char file[MAXFULLNAME];
26 	char grade = 'z';
27 	int nocall = 0;
28 
29 	if (argc < 2) {
30 		fprintf(stderr, "usage: uupoll [-gX] [-n] system ...\n");
31 		cleanup(1);
32 	}
33 
34 	ret = chdir(Spool);
35 	ASSERT(ret >= 0, "CHDIR FAILED", Spool, ret);
36 	strcpy(Progname, "uupoll");
37 	uucpname(Myname);
38 
39 	for (--argc, ++argv; argc > 0; --argc, ++argv) {
40 		if (strcmp(argv[0], Myname) == SAME) {
41 			fprintf(stderr, "This *is* %s!\n", Myname);
42 			continue;
43 		}
44 		if (strncmp(argv[0],"-g",2) == SAME) {
45 			grade = argv[0][2];
46 			continue;
47 		}
48 		if (strcmp(argv[0],"-n") == SAME) {
49 			nocall++;
50 			continue;
51 		}
52 
53 		if (versys(&argv[0])) {
54 			fprintf(stderr, "%s: unknown system.\n", argv[0]);
55 			continue;
56 		}
57 		/* Remove any STST file that might stop the poll */
58 		sprintf(wrkpre, "%s/LCK..%.7s", LOCKDIR, argv[0]);
59 		if (access(wrkpre, 0) < 0)
60 			rmstat(argv[0]);
61 		sprintf(wrkpre, "%c.%.7s", CMDPRE, argv[0]);
62 		if (!iswrk(file, "chk", Spool, wrkpre)) {
63 			sprintf(file, "%s/%c.%.7s%cPOLL", subdir(Spool, CMDPRE),
64 				CMDPRE, argv[0], grade);
65 			close(creat(file, 0666));
66 		}
67 		/* Attempt the call */
68 		if (!nocall)
69 			xuucico(argv[0]);
70 	}
71 	cleanup(0);
72 }
73 
74 cleanup(code)
75 int code;
76 {
77 	exit(code);
78 }
79