xref: /csrg-svn/usr.bin/uucp/uupoll/uupoll.c (revision 17844)
1 #ifndef lint
2 static char sccsid[] = "@(#)uupoll.c	5.2 (Berkeley) 01/22/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 main(argc, argv)
18 register int argc;
19 register char **argv;
20 {
21 	int ret;
22 	char wrkpre[MAXFULLNAME];
23 	char file[MAXFULLNAME];
24 
25 	if (argc < 2) {
26 		fprintf(stderr, "usage: uupoll system ...\n");
27 		cleanup(1);
28 	}
29 
30 	ret = chdir(Spool);
31 	ASSERT(ret >= 0, "CHDIR FAILED", Spool, ret);
32 	strcpy(Progname, "uupoll");
33 	uucpname(Myname);
34 
35 	for (--argc, ++argv; argc > 0; --argc, ++argv) {
36 		if (strcmp(argv[0], Myname) == SAME) {
37 			fprintf(stderr, "This *is* %s!\n", Myname);
38 			continue;
39 		}
40 
41 		if (versys(argv[0])) {
42 			fprintf(stderr, "%s: unknown system.\n", argv[0]);
43 			continue;
44 		}
45 		/* Remove any STST file that might stop the poll */
46 		sprintf(wrkpre, "LCK..%.7s", argv[0]);
47 		if (access(wrkpre, 0) < 0)
48 			rmstat(argv[0]);
49 		sprintf(wrkpre, "%c.%.7s", CMDPRE, argv[0]);
50 		if (!iswrk(file, "chk", Spool, wrkpre)) {
51 			sprintf(file, "%s/%c.%.7szPOLL", subdir(Spool, CMDPRE),
52 				CMDPRE, argv[0]);
53 			close(creat(file, 0666));
54 		}
55 		/* Attempt the call */
56 		xuucico(argv[0]);
57 	}
58 	cleanup(0);
59 }
60 
61 cleanup(code)
62 int code;
63 {
64 	exit(code);
65 }
66