1 /* 2 * tzone.c - get the timezone 3 * 4 * This is shared by bootpd and bootpef 5 * 6 * $FreeBSD: src/libexec/bootpd/tzone.c,v 1.1.1.1.14.1 2000/11/11 00:10:41 dirk Exp $ 7 * $DragonFly: src/libexec/bootpd/tzone.c,v 1.2 2003/06/17 04:27:07 dillon Exp $ 8 */ 9 10 #ifdef SVR4 11 /* XXX - Is this really SunOS specific? -gwr */ 12 /* This is in <time.h> but only visible if (__STDC__ == 1). */ 13 extern long timezone; 14 #else /* SVR4 */ 15 /* BSD or SunOS */ 16 # include <time.h> 17 # include <syslog.h> 18 #endif /* SVR4 */ 19 20 #include "bptypes.h" 21 #include "report.h" 22 #include "tzone.h" 23 24 /* This is what other modules use. */ 25 int32 secondswest; 26 27 /* 28 * Get our timezone offset so we can give it to clients if the 29 * configuration file doesn't specify one. 30 */ 31 void tzone_init(void)32tzone_init(void) 33 { 34 #ifdef SVR4 35 /* XXX - Is this really SunOS specific? -gwr */ 36 secondswest = timezone; 37 #else /* SVR4 */ 38 struct tm *tm; 39 time_t now; 40 41 (void)time(&now); 42 if ((tm = localtime(&now)) == NULL) { 43 secondswest = 0; /* Assume GMT for lack of anything better */ 44 report(LOG_ERR, "localtime() failed"); 45 } else { 46 secondswest = -tm->tm_gmtoff; 47 } 48 #endif /* SVR4 */ 49 } 50