148617Sbostic /*-
2*62401Sbostic * Copyright (c) 1986, 1991, 1993
3*62401Sbostic * The Regents of the University of California. All rights reserved.
448617Sbostic *
548617Sbostic * %sccs.include.redist.c%
648617Sbostic */
748617Sbostic
813689Ssam #ifndef lint
9*62401Sbostic static char copyright[] =
10*62401Sbostic "@(#) Copyright (c) 1986, 1991, 1993\n\
11*62401Sbostic The Regents of the University of California. All rights reserved.\n";
1248617Sbostic #endif /* not lint */
1313689Ssam
1448617Sbostic #ifndef lint
15*62401Sbostic static char sccsid[] = "@(#)uupoll.c 8.1 (Berkeley) 06/06/93";
1648617Sbostic #endif /* not lint */
1748617Sbostic
1813689Ssam /*
1913689Ssam * Poll named system(s).
2013689Ssam *
2113689Ssam * The poll occurs even if recent attempts have failed,
2213689Ssam * but not if L.sys prohibits the call (e.g. wrong time of day).
2313689Ssam *
2433963Srick * Original Author: Tom Truscott (rti!trt)
2513689Ssam */
2613689Ssam
2713689Ssam #include "uucp.h"
2813689Ssam
2918625Sralph int TransferSucceeded = 1;
3025144Sbloom struct timeb Now;
3118625Sralph
main(argc,argv)3213689Ssam main(argc, argv)
3333963Srick int argc;
3433963Srick char **argv;
3513689Ssam {
3617844Sralph char wrkpre[MAXFULLNAME];
3717844Sralph char file[MAXFULLNAME];
3823688Sbloom char grade = 'A';
3918625Sralph int nocall = 0;
4033963Srick int c;
4133963Srick char *sysname;
4233963Srick extern char *optarg;
4333963Srick extern int optind;
4417844Sralph
4513689Ssam if (argc < 2) {
4618625Sralph fprintf(stderr, "usage: uupoll [-gX] [-n] system ...\n");
4713689Ssam cleanup(1);
4813689Ssam }
4913689Ssam
5033963Srick if (chdir(Spool) < 0) {
5133963Srick syslog(LOG_WARNING, "chdir(%s) failed: %m", Spool);
5233963Srick cleanup(1);
5333963Srick }
5413689Ssam strcpy(Progname, "uupoll");
5513689Ssam uucpname(Myname);
5613689Ssam
5733963Srick while ((c = getopt(argc, argv, "g:n")) != EOF)
5833963Srick switch(c) {
5933963Srick case 'g':
6033963Srick grade = *optarg;
6133963Srick break;
6233963Srick case 'n':
6333963Srick nocall++;
6433963Srick break;
6533963Srick case '?':
6633963Srick default:
6733963Srick fprintf(stderr, "unknown option %s\n",
6833963Srick argv[optind-1]);
6933963Srick }
7033963Srick
7133963Srick while(optind < argc) {
7233963Srick sysname = argv[optind++];
7333963Srick if (strcmp(sysname, Myname) == SAME) {
7413689Ssam fprintf(stderr, "This *is* %s!\n", Myname);
7513689Ssam continue;
7613689Ssam }
7713689Ssam
7833963Srick if (versys(&sysname)) {
7933963Srick fprintf(stderr, "%s: unknown system.\n", sysname);
8013689Ssam continue;
8113689Ssam }
8213689Ssam /* Remove any STST file that might stop the poll */
8333963Srick sprintf(wrkpre, "%s/LCK..%.*s", LOCKDIR, MAXBASENAME, sysname);
8417844Sralph if (access(wrkpre, 0) < 0)
8533963Srick rmstat(sysname);
8633963Srick sprintf(wrkpre, "%c.%.*s", CMDPRE, SYSNSIZE, sysname);
8717844Sralph if (!iswrk(file, "chk", Spool, wrkpre)) {
8823688Sbloom sprintf(file, "%s/%c.%.*s%cPOLL", subdir(Spool, CMDPRE),
8933963Srick CMDPRE, SYSNSIZE, sysname, grade);
9017844Sralph close(creat(file, 0666));
9117844Sralph }
9213689Ssam /* Attempt the call */
9318625Sralph if (!nocall)
9433963Srick xuucico(sysname);
9513689Ssam }
9613689Ssam cleanup(0);
9713689Ssam }
9813689Ssam
cleanup(code)9913689Ssam cleanup(code)
10013689Ssam int code;
10113689Ssam {
10213689Ssam exit(code);
10313689Ssam }
104