diff options
Diffstat (limited to 'libexec/bootpd/tzone.c')
-rw-r--r-- | libexec/bootpd/tzone.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/libexec/bootpd/tzone.c b/libexec/bootpd/tzone.c new file mode 100644 index 000000000000..d0c20a389c06 --- /dev/null +++ b/libexec/bootpd/tzone.c @@ -0,0 +1,46 @@ +/* + * tzone.c - get the timezone + * + * This is shared by bootpd and bootpef + */ + +#ifdef SVR4 +/* XXX - Is this really SunOS specific? -gwr */ +/* This is in <time.h> but only visible if (__STDC__ == 1). */ +extern long timezone; +#else /* SVR4 */ +/* BSD or SunOS */ +# include <time.h> +# include <syslog.h> +#endif /* SVR4 */ + +#include "bptypes.h" +#include "report.h" +#include "tzone.h" + +/* This is what other modules use. */ +int32 secondswest; + +/* + * Get our timezone offset so we can give it to clients if the + * configuration file doesn't specify one. + */ +void +tzone_init() +{ +#ifdef SVR4 + /* XXX - Is this really SunOS specific? -gwr */ + secondswest = timezone; +#else /* SVR4 */ + struct tm *tm; + time_t now; + + (void)time(&now); + if ((tm = localtime(&now)) == NULL) { + secondswest = 0; /* Assume GMT for lack of anything better */ + report(LOG_ERR, "localtime() failed"); + } else { + secondswest = -tm->tm_gmtoff; + } +#endif /* SVR4 */ +} |