summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2013-12-03 01:48:37 +0000
committermillert <millert@openbsd.org>2013-12-03 01:48:37 +0000
commitd99aa9e3f9212a7dba6aa09617fa958e5462d859 (patch)
treee2240068fc26451c6efdc9d78408410f0d40ad7f
parentstop using sys/syslimits.h directly, and use limits.h (diff)
downloadwireguard-openbsd-d99aa9e3f9212a7dba6aa09617fa958e5462d859.tar.xz
wireguard-openbsd-d99aa9e3f9212a7dba6aa09617fa958e5462d859.zip
Kill usage of timeb.h for upcoming removal of libcompat. OK deraadt@
-rw-r--r--usr.sbin/eeprom/eehandlers.c7
-rw-r--r--usr.sbin/eeprom/getdate.y74
2 files changed, 36 insertions, 45 deletions
diff --git a/usr.sbin/eeprom/eehandlers.c b/usr.sbin/eeprom/eehandlers.c
index 5940846df24..74df66c2fad 100644
--- a/usr.sbin/eeprom/eehandlers.c
+++ b/usr.sbin/eeprom/eehandlers.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eehandlers.c,v 1.16 2013/11/28 18:26:47 deraadt Exp $ */
+/* $OpenBSD: eehandlers.c,v 1.17 2013/12/03 01:48:37 millert Exp $ */
/* $NetBSD: eehandlers.c,v 1.2 1996/02/28 01:13:22 thorpej Exp $ */
/*-
@@ -55,8 +55,7 @@ extern int fix_checksum;
extern int cksumfail;
extern u_short writecount;
-struct timeb;
-extern time_t get_date(char *, struct timeb *);
+extern time_t get_date(char *);
static char err_str[BUFSIZE];
@@ -98,7 +97,7 @@ ee_hwupdate(struct keytabent *ktent, char *arg)
return;
}
} else
- if ((t = get_date(arg, NULL)) == (time_t)(-1))
+ if ((t = get_date(arg)) == (time_t)(-1))
BARF(ktent);
if (doio(ktent, (u_char *)&t, sizeof(t), IO_WRITE))
diff --git a/usr.sbin/eeprom/getdate.y b/usr.sbin/eeprom/getdate.y
index f2c3a7a302f..02f25a08918 100644
--- a/usr.sbin/eeprom/getdate.y
+++ b/usr.sbin/eeprom/getdate.y
@@ -1,5 +1,5 @@
%{
-/* $OpenBSD: getdate.y,v 1.8 2013/12/03 00:21:21 deraadt Exp $ */
+/* $OpenBSD: getdate.y,v 1.9 2013/12/03 01:48:37 millert Exp $ */
/*
** Originally written by Steven M. Bellovin <smb@research.att.com> while
@@ -801,57 +801,49 @@ difftm (struct tm *a, struct tm *b)
}
time_t
-get_date(char *p, struct timeb *now)
+get_date(char *p)
{
- struct tm *tm, gmt;
- struct timeb ftz;
+ struct tm *tm, *gmt, gmtbuf;
time_t Start;
time_t tod;
- time_t nowtime;
+ time_t now;
+ time_t timezone;
yyInput = p;
- if (now == NULL) {
- struct tm *gmt_ptr;
+ (void)time (&now);
- now = &ftz;
- (void)time (&nowtime);
-
- gmt_ptr = gmtime (&nowtime);
- if (gmt_ptr != NULL)
- {
- /* Make a copy, in case localtime modifies *tm (I think
- that comment now applies to *gmt_ptr, but I am too
- lazy to dig into how gmtime and locatime allocate the
- structures they return pointers to). */
- gmt = *gmt_ptr;
- }
+ gmt = gmtime (&now);
+ if (gmt != NULL)
+ {
+ /* Make a copy, in case localtime modifies *tm (I think
+ that comment now applies to *gmt, but I am too
+ lazy to dig into how gmtime and locatime allocate the
+ structures they return pointers to). */
+ gmtbuf = *gmt;
+ gmt = &gmtbuf;
+ }
- if (! (tm = localtime (&nowtime)))
- return -1;
+ if (! (tm = localtime (&now)))
+ return -1;
- if (gmt_ptr != NULL)
- ftz.timezone = difftm (&gmt, tm) / 60;
- else
- /* We are on a system like VMS, where the system clock is
- in local time and the system has no concept of timezones.
- Hopefully we can fake this out (for the case in which the
- user specifies no timezone) by just saying the timezone
- is zero. */
- ftz.timezone = 0;
-
- if(tm->tm_isdst)
- ftz.timezone += 60;
- }
+ if (gmt != NULL)
+ timezone = difftm (gmt, tm) / 60;
else
- {
- nowtime = now->time;
- }
+ /* We are on a system like VMS, where the system clock is
+ in local time and the system has no concept of timezones.
+ Hopefully we can fake this out (for the case in which the
+ user specifies no timezone) by just saying the timezone
+ is zero. */
+ timezone = 0;
+
+ if(tm->tm_isdst)
+ timezone += 60;
- tm = localtime(&nowtime);
+ tm = localtime(&now);
yyYear = tm->tm_year + 1900;
yyMonth = tm->tm_mon + 1;
yyDay = tm->tm_mday;
- yyTimezone = now->timezone;
+ yyTimezone = timezone;
yyDSTmode = DSTmaybe;
yyHour = 0;
yyMinutes = 0;
@@ -876,7 +868,7 @@ get_date(char *p, struct timeb *now)
return -1;
}
else {
- Start = nowtime;
+ Start = now;
if (!yyHaveRel)
Start -= ((tm->tm_hour * 60L + tm->tm_min) * 60L) + tm->tm_sec;
}
@@ -907,7 +899,7 @@ main(int ac, char *av[])
(void)printf("Enter date, or blank line to exit.\n\t> ");
(void)fflush(stdout);
while (gets(buff) && buff[0]) {
- d = get_date(buff, (struct timeb *)NULL);
+ d = get_date(buff);
if (d == -1)
(void)printf("Bad format - couldn't convert.\n");
else