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