home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume18 / upsd / patch01 / Patch01 < prev    next >
Encoding:
Text File  |  1991-04-11  |  3.2 KB  |  151 lines

  1. *** common.h.orig    Tue Apr  9 21:47:26 1991
  2. --- common.h    Tue Apr  9 21:47:36 1991
  3. ***************
  4. *** 17,22 ****
  5. --- 17,24 ----
  6.   #include <sys/signal.h>
  7.   #include <sys/stat.h>
  8.   
  9. + #include "version.h"
  10.   #define ERR        -1        /* error return value */
  11.   #define SH        "/bin/sh"    /* shell to exec shutdown command */
  12.   #define ROOT        "/"        /* root directory for chdir */
  13. *** funcs.c.orig    Tue Apr  9 21:47:26 1991
  14. --- funcs.c    Tue Apr  9 21:47:42 1991
  15. ***************
  16. *** 27,33 ****
  17.       if ((s = getenv(UPSLOG)) != NULL)
  18.           ups_log = s;
  19.       if ((s = getenv(UPSTIME)) != NULL)
  20. !         ups_time = atoi(s) * SECS_PER_MIN;
  21.   }
  22.   
  23.   /*
  24. --- 27,33 ----
  25.       if ((s = getenv(UPSLOG)) != NULL)
  26.           ups_log = s;
  27.       if ((s = getenv(UPSTIME)) != NULL)
  28. !         ups_time = atoi(s);
  29.   }
  30.   
  31.   /*
  32. ***************
  33. *** 42,52 ****
  34. --- 42,56 ----
  35.   {
  36.       int     c;
  37.   
  38. +     void    version();
  39.       void    usage();
  40.   
  41.       extern char *optarg;
  42.       extern int optind, opterr;
  43.   
  44. +     /* display program version */
  45. +     version(av[0]);
  46.       /* parse the command line */
  47.       while ((c = getopt(ac, av, "d:c:l:t:")) != EOF)
  48.           switch (c) {
  49. ***************
  50. *** 60,66 ****
  51.               ups_log = optarg;
  52.               break;
  53.           case 't':    /* time option */
  54. !             ups_time = atoi(optarg) * SECS_PER_MIN;
  55.               break;
  56.           case '\?':    /* illegal option */
  57.               usage(av[0]);
  58. --- 64,70 ----
  59.               ups_log = optarg;
  60.               break;
  61.           case 't':    /* time option */
  62. !             ups_time = atoi(optarg);
  63.               break;
  64.           case '\?':    /* illegal option */
  65.               usage(av[0]);
  66. ***************
  67. *** 158,164 ****
  68.           }
  69.           writelog(BATTERY_MSG);
  70.   
  71. !         alarm(ups_time);/* set the alarm clock */
  72.   
  73.           /* read blocks on UPS switch to online */
  74.           if (read(ups_fd, &c, 1) == ERR)
  75. --- 162,169 ----
  76.           }
  77.           writelog(BATTERY_MSG);
  78.   
  79. !         /* set the alarm clock */
  80. !         alarm(ups_time * SECS_PER_MIN);
  81.   
  82.           /* read blocks on UPS switch to online */
  83.           if (read(ups_fd, &c, 1) == ERR)
  84. ***************
  85. *** 258,263 ****
  86. --- 263,304 ----
  87.   }
  88.   
  89.   /*
  90. + **    b a s e n a m e
  91. + **
  92. + **    remove absolute path from filename
  93. + **
  94. + */
  95. + char   *
  96. + basename(s)
  97. + char   *s;
  98. + {
  99. +     register char *p;
  100. +     /* point to char after last '/' */
  101. +     if ((p = strrchr(s, '/')) != NULL)
  102. +         return (++p);
  103. +     return (s);
  104. + }
  105. + /*
  106. + **    v e r s i o n
  107. + **
  108. + **    display program version
  109. + */
  110. + void
  111. + version(s)
  112. + char   *s;
  113. + {
  114. +     char   *basename();
  115. +     /* display version if foreground */
  116. +     if (signal(SIGINT, SIG_IGN) != SIG_IGN)
  117. +         fprintf(stderr, "%s v%d.%d patchlevel %d\n", basename(s),
  118. +             RELEASE, REVISION, PATCHLEVEL);
  119. + }
  120. + /*
  121.   **    u s a g e
  122.   **
  123.   **    display program usage
  124. ***************
  125. *** 266,272 ****
  126.   usage(s)
  127.   char   *s;
  128.   {
  129. !     fprintf(stderr, "usage: %s [-d tty][-c cmd][-l log][-t min]\n", s);
  130.       fprintf(stderr, "\t-d tty\t\tpathname of UPS device\n");
  131.       fprintf(stderr, "\t-c cmd\t\tpathname of shutdown command\n");
  132.       fprintf(stderr, "\t-l log\t\tpathname of UPS log file\n");
  133. --- 307,316 ----
  134.   usage(s)
  135.   char   *s;
  136.   {
  137. !     char   *basename();
  138. !     fprintf(stderr, "usage: %s [-d tty][-c cmd][-l log][-t min][-v]\n",
  139. !         basename(s));
  140.       fprintf(stderr, "\t-d tty\t\tpathname of UPS device\n");
  141.       fprintf(stderr, "\t-c cmd\t\tpathname of shutdown command\n");
  142.       fprintf(stderr, "\t-l log\t\tpathname of UPS log file\n");
  143.