Merge from vendor branch TNF:
[pkgsrc.git] / sysutils / apcupsd / patches / patch-ae
1 $NetBSD: $
2
3 --- apcserial.c.orig    Wed Apr  7 18:06:41 1999
4 +++ apcserial.c Fri Jan  7 18:54:39 2000
5 @@ -59,7 +59,9 @@
6  
7  #include <stdio.h>
8  #include <unistd.h>
9 +#ifndef __NetBSD__
10  #include <getopt.h>
11 +#endif /* __NetBSD__ */
12  #include <stdlib.h>
13  #include <stdarg.h>
14  #include <fcntl.h>
15 @@ -135,10 +137,10 @@
16         newtio.c_oflag = 0;                  /* Raw output */
17         newtio.c_lflag = 0;                  /* No local echo */
18  
19 -#ifdef __freebsd__
20 +#if defined(__freebsd__) || defined (__NetBSD__)
21         newtio.c_ispeed = DEFAULT_SPEED;     /* Set input speed */
22         newtio.c_ospeed = DEFAULT_SPEED;     /* Set output speed */
23 -#endif /* __freebsd__ */
24 +#endif /* __freebsd__  || __NetBSD__ */
25  
26         /* w.p. This makes a non.blocking read() with 5 sec. timeout */
27         newtio.c_cc[VMIN] = 0;
28 @@ -195,7 +197,6 @@
29  {
30         char response[32];                                         /* w.p. */
31         char a;
32 -       FILE *pwdf;
33         int errflag = 0;
34         response[0] = '\0';
35  
36 @@ -230,19 +231,6 @@
37                                 }
38                         }
39                 }
40 -               if ((((pwdf = fopen(PWRFAIL, "r" )) == NULL) &&
41 -                   (ups->mode.type != BK)) ||
42 -                   (((pwdf = fopen(PWRFAIL, "r" )) == NULL) &&
43 -                   (ups->LineUp != 0) && (ups->mode.type == BK))) {
44 -                       fprintf(stderr,
45 -                               "%s: Attempting to kill the power!\n" \
46 -                               "%s: Nice TRY but not TODAY!\n" \
47 -                               "%s: Shutdown not called first.\n" \
48 -                               "%s: Bug found by Tom Kunicki\n",
49 -                               ups->argvalue, ups->argvalue,
50 -                               ups->argvalue, ups->argvalue);
51 -                       terminate(0);
52 -               } else {
53                         errflag=0;                             /* w.p. */
54                         if ((ups->class.type == SHAREMASTER) ||
55                             (ups->class.type == SHARENETMASTER)) {
56 @@ -259,7 +247,6 @@
57                                         ups->argvalue);
58                                 sleep(15);
59                         }
60 -                       fclose(pwdf);
61  
62                         fprintf(stderr,
63                                 "%s: Attempting to kill the power!\n",
64 @@ -407,9 +394,7 @@
65                                 }
66                         }
67                         /* w.p. */
68 -                       sleep(10);
69                         terminate(0);
70 -               }
71         } else {
72                 if (ups->mode.type <= SHAREBASIC) {
73                         switch(ups->cable.type) {