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