Home | History | Annotate | Line # | Download | only in common
      1  1.5    wiz /*	$NetBSD: tzone.c,v 1.5 2002/07/14 00:26:18 wiz Exp $	*/
      2  1.4  lukem 
      3  1.4  lukem #include <sys/cdefs.h>
      4  1.4  lukem #ifndef lint
      5  1.5    wiz __RCSID("$NetBSD: tzone.c,v 1.5 2002/07/14 00:26:18 wiz Exp $");
      6  1.4  lukem #endif
      7  1.3  perry 
      8  1.1    gwr /*
      9  1.1    gwr  * tzone.c - get the timezone
     10  1.1    gwr  *
     11  1.1    gwr  * This is shared by bootpd and bootpef
     12  1.1    gwr  */
     13  1.1    gwr 
     14  1.2    cgd #include <sys/types.h>
     15  1.2    cgd 
     16  1.1    gwr #ifdef	SVR4
     17  1.1    gwr /* XXX - Is this really SunOS specific? -gwr */
     18  1.1    gwr /* This is in <time.h> but only visible if (__STDC__ == 1). */
     19  1.1    gwr extern long timezone;
     20  1.1    gwr #else /* SVR4 */
     21  1.1    gwr /* BSD or SunOS */
     22  1.1    gwr # include <sys/time.h>
     23  1.1    gwr # include <syslog.h>
     24  1.1    gwr #endif /* SVR4 */
     25  1.1    gwr 
     26  1.1    gwr #include "bptypes.h"
     27  1.1    gwr #include "report.h"
     28  1.1    gwr #include "tzone.h"
     29  1.1    gwr 
     30  1.1    gwr /* This is what other modules use. */
     31  1.1    gwr int32 secondswest;
     32  1.1    gwr 
     33  1.1    gwr /*
     34  1.1    gwr  * Get our timezone offset so we can give it to clients if the
     35  1.1    gwr  * configuration file doesn't specify one.
     36  1.1    gwr  */
     37  1.1    gwr void
     38  1.5    wiz tzone_init(void)
     39  1.1    gwr {
     40  1.1    gwr #ifdef	SVR4
     41  1.1    gwr 	/* XXX - Is this really SunOS specific? -gwr */
     42  1.1    gwr 	secondswest = timezone;
     43  1.1    gwr #else /* SVR4 */
     44  1.1    gwr 	struct timezone tzp;		/* Time zone offset for clients */
     45  1.1    gwr 	struct timeval tp;			/* Time (extra baggage) */
     46  1.1    gwr 	if (gettimeofday(&tp, &tzp) < 0) {
     47  1.1    gwr 		secondswest = 0;		/* Assume GMT for lack of anything better */
     48  1.1    gwr 		report(LOG_ERR, "gettimeofday: %s", get_errmsg());
     49  1.1    gwr 	} else {
     50  1.1    gwr 		secondswest = 60L * tzp.tz_minuteswest;	/* Convert to seconds */
     51  1.1    gwr 	}
     52  1.1    gwr #endif /* SVR4 */
     53  1.1    gwr }
     54