1994-09-30 05:45:07 +00:00
|
|
|
/*
|
|
|
|
* tzone.c - get the timezone
|
|
|
|
*
|
|
|
|
* This is shared by bootpd and bootpef
|
2000-11-10 12:19:53 +00:00
|
|
|
*
|
|
|
|
* $FreeBSD$
|
1994-09-30 05:45:07 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#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 */
|
2000-11-10 12:19:53 +00:00
|
|
|
# include <time.h>
|
1994-09-30 05:45:07 +00:00
|
|
|
# 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
|
|
|
|
tzone_init()
|
|
|
|
{
|
|
|
|
#ifdef SVR4
|
|
|
|
/* XXX - Is this really SunOS specific? -gwr */
|
|
|
|
secondswest = timezone;
|
|
|
|
#else /* SVR4 */
|
2000-11-10 12:19:53 +00:00
|
|
|
struct tm *tm;
|
|
|
|
time_t now;
|
|
|
|
|
|
|
|
(void)time(&now);
|
|
|
|
if ((tm = localtime(&now)) == NULL) {
|
1994-09-30 05:45:07 +00:00
|
|
|
secondswest = 0; /* Assume GMT for lack of anything better */
|
2000-11-10 12:19:53 +00:00
|
|
|
report(LOG_ERR, "localtime() failed");
|
1994-09-30 05:45:07 +00:00
|
|
|
} else {
|
2000-11-10 12:19:53 +00:00
|
|
|
secondswest = -tm->tm_gmtoff;
|
1994-09-30 05:45:07 +00:00
|
|
|
}
|
|
|
|
#endif /* SVR4 */
|
|
|
|
}
|