home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Other / upsd / ups_folder / patch01.old < prev    next >
Encoding:
Internet Message Format  |  1991-05-01  |  7.4 KB

  1. From: art@pilikia.pegasus.com (Authur W. Neilson III)
  2. Newsgroups: comp.sources.misc
  3. Subject: v18i011:  upsd - UPS monitor daemon, Patch01
  4. Message-ID: <1991Apr10.210522.17715@sparky.IMD.Sterling.COM>
  5. Date: 10 Apr 91 21:05:22 GMT
  6. Approved: kent@sparky.imd.sterling.com
  7. X-Checksum-Snefru: faa96f3c bd55a342 98dd8fc8 029c035f
  8.  
  9. Submitted-by: Authur W. Neilson III <art@pilikia.pegasus.com>
  10. Posting-number: Volume 18, Issue 11
  11. Archive-name: upsd/patch01
  12. Patch-To: upsd: Volume 18, Issue 5
  13.  
  14. This is an update to the UPS monitor daemon. This patch fixes a
  15. problem with the alarm setting. Version contol information has
  16. also been added to upsd in this patch.
  17.  
  18. -----8<----- cut here -----8<----- cut here -----8<----- cut here -----8<-----
  19. #! /bin/sh
  20. # This is a shell archive.  Remove anything before this line, then unpack
  21. # it by saving it into a file and typing "sh file".  To overwrite existing
  22. # files, type "sh file -c".  You can also feed this as standard input via
  23. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  24. # will see the following message at the end:
  25. #        "End of shell archive."
  26. # Contents:  HISTORY MANIFEST Patch01 version.h
  27. # Wrapped by root@pilikia on Tue Apr  9 22:03:27 1991
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'HISTORY' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'HISTORY'\"
  31. else
  32. echo shar: Extracting \"'HISTORY'\" \(304 characters\)
  33. sed "s/^X//" >'HISTORY' <<'END_OF_FILE'
  34. XRELEASE HISTORY
  35. X
  36. XDate      Release  Patch  Description
  37. X-------------------------------------------------------------------------------
  38. X03/30/91  1.0      0      Initial release to net
  39. X04/09/91  1.0      1      Fixed stupidity with ups_time alarm setting and
  40. X                          added version stuff
  41. END_OF_FILE
  42. if test 304 -ne `wc -c <'HISTORY'`; then
  43.     echo shar: \"'HISTORY'\" unpacked with wrong size!
  44. fi
  45. # end of 'HISTORY'
  46. fi
  47. echo shar: Extracting \"'MANIFEST'\" \(530 characters\)
  48. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  49. X   File Name        Archive #    Description
  50. X-----------------------------------------------------------
  51. X HISTORY                    1    Program revision history
  52. X MANIFEST                   1    This shipping list
  53. X Makefile                   1    Upsd makefile    
  54. X README                     1    Documentation
  55. X common.h                   1    Common program header
  56. X funcs.c                    1    Functions 
  57. X main.c                     1    Main program
  58. X ups                        1    Init.d startup script
  59. X version.h                  1    Version control header
  60. END_OF_FILE
  61. if test 530 -ne `wc -c <'MANIFEST'`; then
  62.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  63. fi
  64. # end of 'MANIFEST'
  65. if test -f 'Patch01' -a "${1}" != "-c" ; then 
  66.   echo shar: Will not clobber existing file \"'Patch01'\"
  67. else
  68. echo shar: Extracting \"'Patch01'\" \(3233 characters\)
  69. sed "s/^X//" >'Patch01' <<'END_OF_FILE'
  70. X*** common.h.orig    Tue Apr  9 21:47:26 1991
  71. X--- common.h    Tue Apr  9 21:47:36 1991
  72. X***************
  73. X*** 17,22 ****
  74. X--- 17,24 ----
  75. X  #include <sys/signal.h>
  76. X  #include <sys/stat.h>
  77. X  
  78. X+ #include "version.h"
  79. X+ 
  80. X  #define ERR        -1        /* error return value */
  81. X  #define SH        "/bin/sh"    /* shell to exec shutdown command */
  82. X  #define ROOT        "/"        /* root directory for chdir */
  83. X*** funcs.c.orig    Tue Apr  9 21:47:26 1991
  84. X--- funcs.c    Tue Apr  9 21:47:42 1991
  85. X***************
  86. X*** 27,33 ****
  87. X      if ((s = getenv(UPSLOG)) != NULL)
  88. X          ups_log = s;
  89. X      if ((s = getenv(UPSTIME)) != NULL)
  90. X!         ups_time = atoi(s) * SECS_PER_MIN;
  91. X  }
  92. X  
  93. X  /*
  94. X--- 27,33 ----
  95. X      if ((s = getenv(UPSLOG)) != NULL)
  96. X          ups_log = s;
  97. X      if ((s = getenv(UPSTIME)) != NULL)
  98. X!         ups_time = atoi(s);
  99. X  }
  100. X  
  101. X  /*
  102. X***************
  103. X*** 42,52 ****
  104. X--- 42,56 ----
  105. X  {
  106. X      int     c;
  107. X  
  108. X+     void    version();
  109. X      void    usage();
  110. X  
  111. X      extern char *optarg;
  112. X      extern int optind, opterr;
  113. X  
  114. X+     /* display program version */
  115. X+     version(av[0]);
  116. X+ 
  117. X      /* parse the command line */
  118. X      while ((c = getopt(ac, av, "d:c:l:t:")) != EOF)
  119. X          switch (c) {
  120. X***************
  121. X*** 60,66 ****
  122. X              ups_log = optarg;
  123. X              break;
  124. X          case 't':    /* time option */
  125. X!             ups_time = atoi(optarg) * SECS_PER_MIN;
  126. X              break;
  127. X          case '\?':    /* illegal option */
  128. X              usage(av[0]);
  129. X--- 64,70 ----
  130. X              ups_log = optarg;
  131. X              break;
  132. X          case 't':    /* time option */
  133. X!             ups_time = atoi(optarg);
  134. X              break;
  135. X          case '\?':    /* illegal option */
  136. X              usage(av[0]);
  137. X***************
  138. X*** 158,164 ****
  139. X          }
  140. X          writelog(BATTERY_MSG);
  141. X  
  142. X!         alarm(ups_time);/* set the alarm clock */
  143. X  
  144. X          /* read blocks on UPS switch to online */
  145. X          if (read(ups_fd, &c, 1) == ERR)
  146. X--- 162,169 ----
  147. X          }
  148. X          writelog(BATTERY_MSG);
  149. X  
  150. X!         /* set the alarm clock */
  151. X!         alarm(ups_time * SECS_PER_MIN);
  152. X  
  153. X          /* read blocks on UPS switch to online */
  154. X          if (read(ups_fd, &c, 1) == ERR)
  155. X***************
  156. X*** 258,263 ****
  157. X--- 263,304 ----
  158. X  }
  159. X  
  160. X  /*
  161. X+ **    b a s e n a m e
  162. X+ **
  163. X+ **    remove absolute path from filename
  164. X+ **
  165. X+ */
  166. X+ char   *
  167. X+ basename(s)
  168. X+ char   *s;
  169. X+ {
  170. X+     register char *p;
  171. X+ 
  172. X+     /* point to char after last '/' */
  173. X+     if ((p = strrchr(s, '/')) != NULL)
  174. X+         return (++p);
  175. X+ 
  176. X+     return (s);
  177. X+ }
  178. X+ 
  179. X+ /*
  180. X+ **    v e r s i o n
  181. X+ **
  182. X+ **    display program version
  183. X+ */
  184. X+ void
  185. X+ version(s)
  186. X+ char   *s;
  187. X+ {
  188. X+     char   *basename();
  189. X+ 
  190. X+     /* display version if foreground */
  191. X+     if (signal(SIGINT, SIG_IGN) != SIG_IGN)
  192. X+         fprintf(stderr, "%s v%d.%d patchlevel %d\n", basename(s),
  193. X+             RELEASE, REVISION, PATCHLEVEL);
  194. X+ }
  195. X+ 
  196. X+ /*
  197. X  **    u s a g e
  198. X  **
  199. X  **    display program usage
  200. X***************
  201. X*** 266,272 ****
  202. X  usage(s)
  203. X  char   *s;
  204. X  {
  205. X!     fprintf(stderr, "usage: %s [-d tty][-c cmd][-l log][-t min]\n", s);
  206. X      fprintf(stderr, "\t-d tty\t\tpathname of UPS device\n");
  207. X      fprintf(stderr, "\t-c cmd\t\tpathname of shutdown command\n");
  208. X      fprintf(stderr, "\t-l log\t\tpathname of UPS log file\n");
  209. X--- 307,316 ----
  210. X  usage(s)
  211. X  char   *s;
  212. X  {
  213. X!     char   *basename();
  214. X! 
  215. X!     fprintf(stderr, "usage: %s [-d tty][-c cmd][-l log][-t min][-v]\n",
  216. X!         basename(s));
  217. X      fprintf(stderr, "\t-d tty\t\tpathname of UPS device\n");
  218. X      fprintf(stderr, "\t-c cmd\t\tpathname of shutdown command\n");
  219. X      fprintf(stderr, "\t-l log\t\tpathname of UPS log file\n");
  220. END_OF_FILE
  221. if test 3233 -ne `wc -c <'Patch01'`; then
  222.     echo shar: \"'Patch01'\" unpacked with wrong size!
  223. fi
  224. # end of 'Patch01'
  225. fi
  226. if test -f 'version.h' -a "${1}" != "-c" ; then 
  227.   echo shar: Will not clobber existing file \"'version.h'\"
  228. else
  229. echo shar: Extracting \"'version.h'\" \(234 characters\)
  230. sed "s/^X//" >'version.h' <<'END_OF_FILE'
  231. X/*
  232. X**    v e r s i o n . h
  233. X**
  234. X**    version header for version control
  235. X**
  236. X**    Arthur W. Neilson III
  237. X**    art@pilikia.pegasus.com
  238. X**    Tue Apr  9 1991
  239. X*/
  240. X
  241. X#define RELEASE_DATE    "03/30/91"
  242. X#define RELEASE        1
  243. X#define REVISION    0
  244. X#define PATCHLEVEL    1
  245. END_OF_FILE
  246. if test 234 -ne `wc -c <'version.h'`; then
  247.     echo shar: \"'version.h'\" unpacked with wrong size!
  248. fi
  249. # end of 'version.h'
  250. fi
  251. echo shar: End of shell archive.
  252. exit 0
  253. -----8<----- cut here -----8<----- cut here -----8<----- cut here -----8<-----
  254.  
  255. -- 
  256. Arthur W. Neilson III        | INET: art@pilikia.pegasus.com
  257. Bank of Hawaii Tech Support    | UUCP: uunet!ucsd!nosc!pilikia!art
  258.  
  259. exit 0 # Just in case...
  260. -- 
  261. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  262. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  263. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  264. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  265.