xref: /original-bsd/usr.bin/uucp/uupoll/uupoll.c (revision 30d60fbe)
1 #ifndef lint
2 static char sccsid[] = "@(#)uupoll.c	5.5 (Berkeley) 10/09/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 struct timeb Now;
19 
20 main(argc, argv)
21 register int argc;
22 register char **argv;
23 {
24 	int ret;
25 	char wrkpre[MAXFULLNAME];
26 	char file[MAXFULLNAME];
27 	char grade = 'A';
28 	int nocall = 0;
29 
30 	if (argc < 2) {
31 		fprintf(stderr, "usage: uupoll [-gX] [-n] system ...\n");
32 		cleanup(1);
33 	}
34 
35 	ret = chdir(Spool);
36 	ASSERT(ret >= 0, "CHDIR FAILED", Spool, ret);
37 	strcpy(Progname, "uupoll");
38 	uucpname(Myname);
39 
40 	for (--argc, ++argv; argc > 0; --argc, ++argv) {
41 		if (strcmp(argv[0], Myname) == SAME) {
42 			fprintf(stderr, "This *is* %s!\n", Myname);
43 			continue;
44 		}
45 		if (strncmp(argv[0],"-g",2) == SAME) {
46 			grade = argv[0][2];
47 			continue;
48 		}
49 		if (strcmp(argv[0],"-n") == SAME) {
50 			nocall++;
51 			continue;
52 		}
53 
54 		if (versys(&argv[0])) {
55 			fprintf(stderr, "%s: unknown system.\n", argv[0]);
56 			continue;
57 		}
58 		/* Remove any STST file that might stop the poll */
59 		sprintf(wrkpre, "%s/LCK..%.*s", LOCKDIR, MAXBASENAME, argv[0]);
60 		if (access(wrkpre, 0) < 0)
61 			rmstat(argv[0]);
62 		sprintf(wrkpre, "%c.%.*s", CMDPRE, SYSNSIZE, argv[0]);
63 		if (!iswrk(file, "chk", Spool, wrkpre)) {
64 			sprintf(file, "%s/%c.%.*s%cPOLL", subdir(Spool, CMDPRE),
65 				CMDPRE, SYSNSIZE, argv[0], grade);
66 			close(creat(file, 0666));
67 		}
68 		/* Attempt the call */
69 		if (!nocall)
70 			xuucico(argv[0]);
71 	}
72 	cleanup(0);
73 }
74 
75 cleanup(code)
76 int code;
77 {
78 	exit(code);
79 }
80