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