Commit | Line | Data |
---|---|---|
2f45b415 | 1 | #ifndef lint |
9ae19ea7 | 2 | static char sccsid[] = "@(#)uupoll.c 5.6 (Berkeley) %G%"; |
2f45b415 SL |
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 | * | |
9ae19ea7 | 11 | * Original Author: Tom Truscott (rti!trt) |
2f45b415 SL |
12 | */ |
13 | ||
14 | #include "uucp.h" | |
15 | ||
1a85e9d2 | 16 | int TransferSucceeded = 1; |
8762a029 | 17 | struct timeb Now; |
1a85e9d2 | 18 | |
2f45b415 | 19 | main(argc, argv) |
9ae19ea7 RA |
20 | int argc; |
21 | char **argv; | |
2f45b415 | 22 | { |
46b15d8a RC |
23 | char wrkpre[MAXFULLNAME]; |
24 | char file[MAXFULLNAME]; | |
08570df5 | 25 | char grade = 'A'; |
1a85e9d2 | 26 | int nocall = 0; |
9ae19ea7 RA |
27 | int c; |
28 | char *sysname; | |
29 | extern char *optarg; | |
30 | extern int optind; | |
46b15d8a | 31 | |
2f45b415 | 32 | if (argc < 2) { |
1a85e9d2 | 33 | fprintf(stderr, "usage: uupoll [-gX] [-n] system ...\n"); |
2f45b415 SL |
34 | cleanup(1); |
35 | } | |
36 | ||
9ae19ea7 RA |
37 | if (chdir(Spool) < 0) { |
38 | syslog(LOG_WARNING, "chdir(%s) failed: %m", Spool); | |
39 | cleanup(1); | |
40 | } | |
2f45b415 SL |
41 | strcpy(Progname, "uupoll"); |
42 | uucpname(Myname); | |
43 | ||
9ae19ea7 RA |
44 | while ((c = getopt(argc, argv, "g:n")) != EOF) |
45 | switch(c) { | |
46 | case 'g': | |
47 | grade = *optarg; | |
48 | break; | |
49 | case 'n': | |
50 | nocall++; | |
51 | break; | |
52 | case '?': | |
53 | default: | |
54 | fprintf(stderr, "unknown option %s\n", | |
55 | argv[optind-1]); | |
2f45b415 | 56 | } |
9ae19ea7 RA |
57 | |
58 | while(optind < argc) { | |
59 | sysname = argv[optind++]; | |
60 | if (strcmp(sysname, Myname) == SAME) { | |
61 | fprintf(stderr, "This *is* %s!\n", Myname); | |
1a85e9d2 RC |
62 | continue; |
63 | } | |
2f45b415 | 64 | |
9ae19ea7 RA |
65 | if (versys(&sysname)) { |
66 | fprintf(stderr, "%s: unknown system.\n", sysname); | |
2f45b415 SL |
67 | continue; |
68 | } | |
69 | /* Remove any STST file that might stop the poll */ | |
9ae19ea7 | 70 | sprintf(wrkpre, "%s/LCK..%.*s", LOCKDIR, MAXBASENAME, sysname); |
46b15d8a | 71 | if (access(wrkpre, 0) < 0) |
9ae19ea7 RA |
72 | rmstat(sysname); |
73 | sprintf(wrkpre, "%c.%.*s", CMDPRE, SYSNSIZE, sysname); | |
46b15d8a | 74 | if (!iswrk(file, "chk", Spool, wrkpre)) { |
08570df5 | 75 | sprintf(file, "%s/%c.%.*s%cPOLL", subdir(Spool, CMDPRE), |
9ae19ea7 | 76 | CMDPRE, SYSNSIZE, sysname, grade); |
46b15d8a RC |
77 | close(creat(file, 0666)); |
78 | } | |
2f45b415 | 79 | /* Attempt the call */ |
1a85e9d2 | 80 | if (!nocall) |
9ae19ea7 | 81 | xuucico(sysname); |
2f45b415 SL |
82 | } |
83 | cleanup(0); | |
84 | } | |
85 | ||
86 | cleanup(code) | |
87 | int code; | |
88 | { | |
89 | exit(code); | |
90 | } |