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