tzone.c revision 3229
1/*
2 * tzone.c - get the timezone
3 *
4 * This is shared by bootpd and bootpef
5 */
6
7#ifdef	SVR4
8/* XXX - Is this really SunOS specific? -gwr */
9/* This is in <time.h> but only visible if (__STDC__ == 1). */
10extern long timezone;
11#else /* SVR4 */
12/* BSD or SunOS */
13# include <sys/time.h>
14# include <syslog.h>
15#endif /* SVR4 */
16
17#include "bptypes.h"
18#include "report.h"
19#include "tzone.h"
20
21/* This is what other modules use. */
22int32 secondswest;
23
24/*
25 * Get our timezone offset so we can give it to clients if the
26 * configuration file doesn't specify one.
27 */
28void
29tzone_init()
30{
31#ifdef	SVR4
32	/* XXX - Is this really SunOS specific? -gwr */
33	secondswest = timezone;
34#else /* SVR4 */
35	struct timezone tzp;		/* Time zone offset for clients */
36	struct timeval tp;			/* Time (extra baggage) */
37	if (gettimeofday(&tp, &tzp) < 0) {
38		secondswest = 0;		/* Assume GMT for lack of anything better */
39		report(LOG_ERR, "gettimeofday: %s", get_errmsg());
40	} else {
41		secondswest = 60L * tzp.tz_minuteswest;	/* Convert to seconds */
42	}
43#endif /* SVR4 */
44}
45