NetBSD/usr.sbin/bootp/common/tzone.c

54 lines
1.2 KiB
C
Raw Normal View History

2002-07-14 03:56:39 +04:00
/* $NetBSD: tzone.c,v 1.5 2002/07/14 00:26:18 wiz Exp $ */
1998-03-14 07:39:53 +03:00
#include <sys/cdefs.h>
#ifndef lint
2002-07-14 03:56:39 +04:00
__RCSID("$NetBSD: tzone.c,v 1.5 2002/07/14 00:26:18 wiz Exp $");
1998-03-14 07:39:53 +03:00
#endif
1998-01-09 11:03:16 +03:00
/*
* tzone.c - get the timezone
*
* This is shared by bootpd and bootpef
*/
1994-12-23 19:52:30 +03:00
#include <sys/types.h>
#ifdef SVR4
/* XXX - Is this really SunOS specific? -gwr */
/* This is in <time.h> but only visible if (__STDC__ == 1). */
extern long timezone;
#else /* SVR4 */
/* BSD or SunOS */
# include <sys/time.h>
# include <syslog.h>
#endif /* SVR4 */
#include "bptypes.h"
#include "report.h"
#include "tzone.h"
/* This is what other modules use. */
int32 secondswest;
/*
* Get our timezone offset so we can give it to clients if the
* configuration file doesn't specify one.
*/
void
2002-07-14 03:56:39 +04:00
tzone_init(void)
{
#ifdef SVR4
/* XXX - Is this really SunOS specific? -gwr */
secondswest = timezone;
#else /* SVR4 */
struct timezone tzp; /* Time zone offset for clients */
struct timeval tp; /* Time (extra baggage) */
if (gettimeofday(&tp, &tzp) < 0) {
secondswest = 0; /* Assume GMT for lack of anything better */
report(LOG_ERR, "gettimeofday: %s", get_errmsg());
} else {
secondswest = 60L * tzp.tz_minuteswest; /* Convert to seconds */
}
#endif /* SVR4 */
}