*** common.h.orig Tue Apr 9 21:47:26 1991 --- common.h Tue Apr 9 21:47:36 1991 *************** *** 17,22 **** --- 17,24 ---- #include #include + #include "version.h" + #define ERR -1 /* error return value */ #define SH "/bin/sh" /* shell to exec shutdown command */ #define ROOT "/" /* root directory for chdir */ *** funcs.c.orig Tue Apr 9 21:47:26 1991 --- funcs.c Tue Apr 9 21:47:42 1991 *************** *** 27,33 **** if ((s = getenv(UPSLOG)) != NULL) ups_log = s; if ((s = getenv(UPSTIME)) != NULL) ! ups_time = atoi(s) * SECS_PER_MIN; } /* --- 27,33 ---- if ((s = getenv(UPSLOG)) != NULL) ups_log = s; if ((s = getenv(UPSTIME)) != NULL) ! ups_time = atoi(s); } /* *************** *** 42,52 **** --- 42,56 ---- { int c; + void version(); void usage(); extern char *optarg; extern int optind, opterr; + /* display program version */ + version(av[0]); + /* parse the command line */ while ((c = getopt(ac, av, "d:c:l:t:")) != EOF) switch (c) { *************** *** 60,66 **** ups_log = optarg; break; case 't': /* time option */ ! ups_time = atoi(optarg) * SECS_PER_MIN; break; case '\?': /* illegal option */ usage(av[0]); --- 64,70 ---- ups_log = optarg; break; case 't': /* time option */ ! ups_time = atoi(optarg); break; case '\?': /* illegal option */ usage(av[0]); *************** *** 158,164 **** } writelog(BATTERY_MSG); ! alarm(ups_time);/* set the alarm clock */ /* read blocks on UPS switch to online */ if (read(ups_fd, &c, 1) == ERR) --- 162,169 ---- } writelog(BATTERY_MSG); ! /* set the alarm clock */ ! alarm(ups_time * SECS_PER_MIN); /* read blocks on UPS switch to online */ if (read(ups_fd, &c, 1) == ERR) *************** *** 258,263 **** --- 263,304 ---- } /* + ** b a s e n a m e + ** + ** remove absolute path from filename + ** + */ + char * + basename(s) + char *s; + { + register char *p; + + /* point to char after last '/' */ + if ((p = strrchr(s, '/')) != NULL) + return (++p); + + return (s); + } + + /* + ** v e r s i o n + ** + ** display program version + */ + void + version(s) + char *s; + { + char *basename(); + + /* display version if foreground */ + if (signal(SIGINT, SIG_IGN) != SIG_IGN) + fprintf(stderr, "%s v%d.%d patchlevel %d\n", basename(s), + RELEASE, REVISION, PATCHLEVEL); + } + + /* ** u s a g e ** ** display program usage *************** *** 266,272 **** usage(s) char *s; { ! fprintf(stderr, "usage: %s [-d tty][-c cmd][-l log][-t min]\n", s); fprintf(stderr, "\t-d tty\t\tpathname of UPS device\n"); fprintf(stderr, "\t-c cmd\t\tpathname of shutdown command\n"); fprintf(stderr, "\t-l log\t\tpathname of UPS log file\n"); --- 307,316 ---- usage(s) char *s; { ! char *basename(); ! ! fprintf(stderr, "usage: %s [-d tty][-c cmd][-l log][-t min][-v]\n", ! basename(s)); fprintf(stderr, "\t-d tty\t\tpathname of UPS device\n"); fprintf(stderr, "\t-c cmd\t\tpathname of shutdown command\n"); fprintf(stderr, "\t-l log\t\tpathname of UPS log file\n");