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