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