Initial import from FreeBSD RELENG_4:
[games.git] / libexec / bootpd / tzone.c
1 /*
2  * tzone.c - get the timezone
3  *
4  * This is shared by bootpd and bootpef
5  *
6  * $FreeBSD: src/libexec/bootpd/tzone.c,v 1.1.1.1.14.1 2000/11/11 00:10:41 dirk Exp $
7  */
8
9 #ifdef  SVR4
10 /* XXX - Is this really SunOS specific? -gwr */
11 /* This is in <time.h> but only visible if (__STDC__ == 1). */
12 extern long timezone;
13 #else /* SVR4 */
14 /* BSD or SunOS */
15 # include <time.h>
16 # include <syslog.h>
17 #endif /* SVR4 */
18
19 #include "bptypes.h"
20 #include "report.h"
21 #include "tzone.h"
22
23 /* This is what other modules use. */
24 int32 secondswest;
25
26 /*
27  * Get our timezone offset so we can give it to clients if the
28  * configuration file doesn't specify one.
29  */
30 void
31 tzone_init()
32 {
33 #ifdef  SVR4
34         /* XXX - Is this really SunOS specific? -gwr */
35         secondswest = timezone;
36 #else /* SVR4 */
37         struct tm *tm;
38         time_t now;
39
40         (void)time(&now);
41         if ((tm = localtime(&now)) == NULL) {
42                 secondswest = 0;                /* Assume GMT for lack of anything better */
43                 report(LOG_ERR, "localtime() failed");
44         } else {
45                 secondswest = -tm->tm_gmtoff;
46         }
47 #endif /* SVR4 */
48 }