13229Spst/* 23229Spst * tzone.c - get the timezone 33229Spst * 43229Spst * This is shared by bootpd and bootpef 568561Sdirk * 668561Sdirk * $FreeBSD: releng/10.3/libexec/bootpd/tzone.c 68561 2000-11-10 12:19:53Z dirk $ 73229Spst */ 83229Spst 93229Spst#ifdef SVR4 103229Spst/* XXX - Is this really SunOS specific? -gwr */ 113229Spst/* This is in <time.h> but only visible if (__STDC__ == 1). */ 123229Spstextern long timezone; 133229Spst#else /* SVR4 */ 143229Spst/* BSD or SunOS */ 1568561Sdirk# include <time.h> 163229Spst# include <syslog.h> 173229Spst#endif /* SVR4 */ 183229Spst 193229Spst#include "bptypes.h" 203229Spst#include "report.h" 213229Spst#include "tzone.h" 223229Spst 233229Spst/* This is what other modules use. */ 243229Spstint32 secondswest; 253229Spst 263229Spst/* 273229Spst * Get our timezone offset so we can give it to clients if the 283229Spst * configuration file doesn't specify one. 293229Spst */ 303229Spstvoid 313229Spsttzone_init() 323229Spst{ 333229Spst#ifdef SVR4 343229Spst /* XXX - Is this really SunOS specific? -gwr */ 353229Spst secondswest = timezone; 363229Spst#else /* SVR4 */ 3768561Sdirk struct tm *tm; 3868561Sdirk time_t now; 3968561Sdirk 4068561Sdirk (void)time(&now); 4168561Sdirk if ((tm = localtime(&now)) == NULL) { 423229Spst secondswest = 0; /* Assume GMT for lack of anything better */ 4368561Sdirk report(LOG_ERR, "localtime() failed"); 443229Spst } else { 4568561Sdirk secondswest = -tm->tm_gmtoff; 463229Spst } 473229Spst#endif /* SVR4 */ 483229Spst} 49