I've been meaning to do this for a while. Add an underscore to the

time_to_xxx() and xxx_to_time() functions.  e.g. _time_to_xxx()
instead of time_to_xxx(), to make it more obvious that these are
stopgap functions & placemarkers and not meant to create a defacto
standard.  They will eventually be replaced when a real standard
comes out of committee.
This commit is contained in:
Matthew Dillon 2002-01-19 23:20:02 +00:00
parent 819a142080
commit 170ac683f2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=89572
15 changed files with 58 additions and 58 deletions

View file

@ -136,14 +136,14 @@ size_t strftime __P((char *, size_t, const char *, const struct tm *));
time_t time __P((time_t *));
#ifndef _ANSI_SOURCE
time_t time32_to_time __P((__int32_t t32));
__int32_t time_to_time32 __P((time_t t));
time_t time64_to_time __P((__int64_t t64));
__int64_t time_to_time64 __P((time_t t));
long time_to_long __P((time_t t));
time_t long_to_time __P((long tlong));
int time_to_int __P((time_t t));
time_t int_to_time __P((int tint));
time_t _time32_to_time __P((__int32_t t32));
__int32_t _time_to_time32 __P((time_t t));
time_t _time64_to_time __P((__int64_t t64));
__int64_t _time_to_time64 __P((time_t t));
long _time_to_long __P((time_t t));
time_t _long_to_time __P((long tlong));
int _time_to_int __P((time_t t));
time_t _int_to_time __P((int tint));
#endif /* not ANSI */
#ifndef _ANSI_SOURCE

View file

@ -21,7 +21,7 @@
* implement the 50-year rule to handle post-2038 conversions.
*/
time_t
time32_to_time(__int32_t t32)
_time32_to_time(__int32_t t32)
{
return((time_t)t32);
}
@ -32,7 +32,7 @@ time32_to_time(__int32_t t32)
* converted back to a temporally local 64 bit time_t using time32_to_time.
*/
__int32_t
time_to_time32(time_t t)
_time_to_time32(time_t t)
{
return((__int32_t)t);
}
@ -43,7 +43,7 @@ time_to_time32(time_t t)
* past 2038.
*/
time_t
time64_to_time(__int64_t t64)
_time64_to_time(__int64_t t64)
{
return((time_t)t64);
}
@ -53,7 +53,7 @@ time64_to_time(__int64_t t64)
* as 32 bits we simply sign-extend and do not support times past 2038.
*/
__int64_t
time_to_time64(time_t t)
_time_to_time64(time_t t)
{
return((__int64_t)t);
}
@ -63,18 +63,18 @@ time_to_time64(time_t t)
* may not require using the 50-year rule.
*/
long
time_to_long(time_t t)
_time_to_long(time_t t)
{
if (sizeof(long) == sizeof(__int64_t))
return(time_to_time64(t));
return(_time_to_time64(t));
return((long)t);
}
time_t
long_to_time(long tlong)
_long_to_time(long tlong)
{
if (sizeof(long) == sizeof(__int32_t))
return(time32_to_time(tlong));
return(_time32_to_time(tlong));
return((time_t)tlong);
}
@ -83,18 +83,18 @@ long_to_time(long tlong)
* may not require using the 50-year rule.
*/
int
time_to_int(time_t t)
_time_to_int(time_t t)
{
if (sizeof(int) == sizeof(__int64_t))
return(time_to_time64(t));
return(_time_to_time64(t));
return((int)t);
}
time_t
int_to_time(int tint)
_int_to_time(int tint)
{
if (sizeof(int) == sizeof(__int32_t))
return(time32_to_time(tint));
return(_time32_to_time(tint));
return((time_t)tint);
}

View file

@ -155,9 +155,9 @@ getdumptime()
continue;
if (ddp->dd_level >= level)
continue;
if (ddp->dd_ddate <= time32_to_time(spcl.c_ddate))
if (ddp->dd_ddate <= _time32_to_time(spcl.c_ddate))
continue;
spcl.c_ddate = time_to_time32(ddp->dd_ddate);
spcl.c_ddate = _time_to_time32(ddp->dd_ddate);
lastlevel = ddp->dd_level;
}
}
@ -205,7 +205,7 @@ putdumptime()
found:
(void) strncpy(dtwalk->dd_name, fname, sizeof (dtwalk->dd_name));
dtwalk->dd_level = level;
dtwalk->dd_ddate = time32_to_time(spcl.c_date);
dtwalk->dd_ddate = _time32_to_time(spcl.c_date);
ITITERATE(i, dtwalk) {
dumprecout(df, dtwalk);
@ -218,7 +218,7 @@ putdumptime()
if (spcl.c_date == 0) {
tmsg = "the epoch\n";
} else {
time_t t = time32_to_time(spcl.c_date);
time_t t = _time32_to_time(spcl.c_date);
tmsg = ctime(&t);
}
msg("level %c dump on %s", level, tmsg);

View file

@ -103,7 +103,7 @@ main(argc, argv)
char *tmsg;
time_t t;
spcl.c_date = time_to_time32(time(NULL));
spcl.c_date = _time_to_time32(time(NULL));
tsize = 0; /* Default later, based on 'c' option for cart tapes */
if ((tape = getenv("TAPE")) == NULL)
@ -312,14 +312,14 @@ main(argc, argv)
if (spcl.c_date == 0) {
tmsg = "the epoch\n";
} else {
time_t t = time32_to_time(spcl.c_date);
time_t t = _time32_to_time(spcl.c_date);
tmsg = ctime(&t);
}
msg("Date of this level %c dump: %s", level, tmsg);
if (spcl.c_ddate == 0) {
tmsg = "the epoch\n";
} else {
time_t t = time32_to_time(spcl.c_ddate);
time_t t = _time32_to_time(spcl.c_ddate);
tmsg = ctime(&t);
}
msg("Date of last level %c dump: %s", lastlevel, tmsg);

View file

@ -207,7 +207,7 @@ show_ip6fw(struct ip6_fw *chain)
if (chain->timestamp)
{
char timestr[30];
time_t t = long_to_time(chain->timestamp);
time_t t = _long_to_time(chain->timestamp);
strcpy(timestr, ctime(&t));
*strchr(timestr, '\n') = '\0';

View file

@ -202,7 +202,7 @@ show_ipfw(struct ip_fw *chain)
if (do_time) {
if (chain->timestamp) {
char timestr[30];
time_t t = long_to_time(chain->timestamp);
time_t t = _long_to_time(chain->timestamp);
strcpy(timestr, ctime(&t));
*strchr(timestr, '\n') = '\0';

View file

@ -232,8 +232,8 @@ setup()
}
if (vflag || command == 't')
printdumpinfo();
dumptime = time32_to_time(spcl.c_ddate);
dumpdate = time32_to_time(spcl.c_date);
dumptime = _time32_to_time(spcl.c_ddate);
dumpdate = _time32_to_time(spcl.c_date);
if (stat(".", &stbuf) < 0) {
fprintf(stderr, "cannot stat .: %s\n", strerror(errno));
done(1);
@ -404,9 +404,9 @@ getvol(nextvol)
volno = 0;
goto again;
}
if (time32_to_time(tmpbuf.c_date) != dumpdate ||
time32_to_time(tmpbuf.c_ddate) != dumptime) {
time_t t = time32_to_time(tmpbuf.c_date);
if (_time32_to_time(tmpbuf.c_date) != dumpdate ||
_time32_to_time(tmpbuf.c_ddate) != dumptime) {
time_t t = _time32_to_time(tmpbuf.c_date);
fprintf(stderr, "Wrong dump date\n\tgot: %s", ctime(&t));
fprintf(stderr, "\twanted: %s", ctime(&dumpdate));
volno = 0;
@ -510,9 +510,9 @@ void
printdumpinfo()
{
time_t t;
t = time32_to_time(spcl.c_date);
t = _time32_to_time(spcl.c_date);
fprintf(stdout, "Dump date: %s", ctime(&t));
t = time32_to_time(spcl.c_ddate);
t = _time32_to_time(spcl.c_ddate);
fprintf(stdout, "Dumped from: %s",
(spcl.c_ddate == 0) ? "the epoch\n" : ctime(&t));
if (spcl.c_host[0] == '\0')
@ -1231,7 +1231,7 @@ findinode(header)
if (header->c_magic != NFS_MAGIC) {
skipcnt++;
while (gethead(header) == FAIL ||
time32_to_time(header->c_date) != dumpdate)
_time32_to_time(header->c_date) != dumpdate)
skipcnt++;
}
switch (header->c_type) {
@ -1244,7 +1244,7 @@ findinode(header)
if (header->c_addr[i])
readtape(buf);
while (gethead(header) == FAIL ||
time32_to_time(header->c_date) != dumpdate)
_time32_to_time(header->c_date) != dumpdate)
skipcnt++;
break;

View file

@ -211,7 +211,7 @@ wtmp()
bl = (stb.st_size + sizeof(buf) - 1) / sizeof(buf);
(void)time(&t);
buf[0].ut_time = time_to_int(t);
buf[0].ut_time = _time_to_int(t);
(void)signal(SIGINT, onintr);
(void)signal(SIGQUIT, onintr);
@ -248,7 +248,7 @@ wtmp()
* unless flagged for
*/
if (!snaptime && want(bp)) {
t = int_to_time(bp->ut_time);
t = _int_to_time(bp->ut_time);
tm = localtime(&t);
(void) strftime(ct, sizeof(ct),
d_first ? "%a %e %b %R" :
@ -272,7 +272,7 @@ wtmp()
if ((bp->ut_line[0] == '{' || bp->ut_line[0] == '|')
&& !bp->ut_line[1]) {
if (want(bp) && !snaptime) {
t = int_to_time(bp->ut_time);
t = _int_to_time(bp->ut_time);
tm = localtime(&t);
(void) strftime(ct, sizeof(ct),
d_first ? "%a %e %b %R" :
@ -320,7 +320,7 @@ wtmp()
bp->ut_line[3] = '\0';
else if (!strncmp(bp->ut_line, "uucp", sizeof("uucp") - 1))
bp->ut_line[4] = '\0';
t = int_to_time(bp->ut_time);
t = _int_to_time(bp->ut_time);
tm = localtime(&t);
(void) strftime(ct, sizeof(ct),
d_first ? "%a %e %b %R" :
@ -366,7 +366,7 @@ wtmp()
tt->logout = bp->ut_time;
}
}
t = int_to_time(buf[0].ut_time);
t = _int_to_time(buf[0].ut_time);
tm = localtime(&t);
(void) strftime(ct, sizeof(ct), "\nwtmp begins %+\n", tm);
printf("%s", ct);
@ -566,7 +566,7 @@ onintr(signo)
{
char ct[80];
struct tm *tm;
time_t t = int_to_time(buf[0].ut_time);
time_t t = _int_to_time(buf[0].ut_time);
tm = localtime(&t);
(void) strftime(ct, sizeof(ct),

View file

@ -115,7 +115,7 @@ rusers_reply(caddr_t replyp, struct sockaddr_in *raddrp)
printf("%-*s ", HOST_WIDTH, host);
for (x = 0; x < up->utmpidlearr_len; x++) {
time_t t = int_to_time(up->utmpidlearr_val[x].ui_utmp.ut_time);
time_t t = _int_to_time(up->utmpidlearr_val[x].ui_utmp.ut_time);
strncpy(date, &(ctime(&t)[4]), sizeof(date) - 1);
idle = up->utmpidlearr_val[x].ui_idle;

View file

@ -162,7 +162,7 @@ main(argc, argv)
mp = myutmp;
for (i = 0; i < nusers; i++) {
char buf[BUFSIZ], cbuf[80];
time_t t = int_to_time(mp->myutmp.out_time);
time_t t = _int_to_time(mp->myutmp.out_time);
strftime(cbuf, sizeof(cbuf),
d_first ? "%e %b %R" : "%b %e %R",

View file

@ -473,7 +473,7 @@ ac(fp)
if (!FirstTime)
FirstTime = usr.ut_time;
if (Flags & AC_D) {
time_t t = int_to_time(usr.ut_time);
time_t t = _int_to_time(usr.ut_time);
ltm = localtime(&t);
if (day >= 0 && day != ltm->tm_yday) {
day = ltm->tm_yday;
@ -525,7 +525,7 @@ ac(fp)
(void)strcpy(usr.ut_line, "~");
if (Flags & AC_D) {
time_t t = int_to_time(usr.ut_time);
time_t t = _int_to_time(usr.ut_time);
ltm = localtime(&t);
if (day >= 0 && day != ltm->tm_yday) {
/*

View file

@ -116,7 +116,7 @@ output(p, l)
struct passwd *p;
struct lastlog *l;
{
time_t t = int_to_time(l->ll_time);
time_t t = _int_to_time(l->ll_time);
printf("%-*.*s %-*.*s %-*.*s %s",
UT_NAMESIZE, UT_NAMESIZE, p->pw_name,
UT_LINESIZE, UT_LINESIZE, l->ll_line,

View file

@ -327,7 +327,7 @@ main(argc, argv)
}
#endif
(void) time(&t);
wd.wd_recvtime = time_to_int(t);
wd.wd_recvtime = _time_to_int(t);
(void) write(whod, (char *)&wd, cc);
if (fstat(whod, &st) < 0 || st.st_size > cc)
ftruncate(whod, cc);
@ -464,7 +464,7 @@ onalrm(signo)
for (i = 0; i < 3; i++)
mywd.wd_loadav[i] = htonl((u_long)(avenrun[i] * 100));
cc = (char *)we - (char *)&mywd;
mywd.wd_sendtime = htonl(time_to_time32(time(NULL)));
mywd.wd_sendtime = htonl(_time_to_time32(time(NULL)));
mywd.wd_vers = WHODVERSION;
mywd.wd_type = WHODTYPE_STATUS;
if (multicast_mode == SCOPED_MULTICAST) {
@ -514,7 +514,7 @@ getboottime(signo)
syslog(LOG_ERR, "cannot get boottime: %m");
exit(1);
}
mywd.wd_boottime = htonl(time_to_time32(tm.tv_sec));
mywd.wd_boottime = htonl(_time_to_time32(tm.tv_sec));
}
void
@ -702,7 +702,7 @@ Sendto(s, buf, cc, flags, to, tolen)
ntohl(w->wd_loadav[2]) / 100.0);
cc -= WHDRSIZE;
for (we = w->wd_we, cc /= sizeof(struct whoent); cc > 0; cc--, we++) {
time_t t = time32_to_time(ntohl(we->we_utmp.out_time));
time_t t = _time32_to_time(ntohl(we->we_utmp.out_time));
printf("%-8.8s %s:%s %.12s",
we->we_utmp.out_name,
w->wd_hostname, we->we_utmp.out_line,

View file

@ -195,7 +195,7 @@ long local_time_zone(long timestamp)
struct timeval now;
struct timezone tz;
long localzone;
time_t t = long_to_time(timestamp);
time_t t = _long_to_time(timestamp);
if (gettimeofday(&now, &tz) < 0)
err(1, "gettimeofday");
@ -215,7 +215,7 @@ long local_time_zone(long timestamp)
struct timeval
parse_time(char *time_string, struct timeval base_time)
{
time_t tt = long_to_time(base_time.tv_sec);
time_t tt = _long_to_time(base_time.tv_sec);
struct tm *bt = localtime(&tt);
struct tm t;
struct timeval result;
@ -574,14 +574,14 @@ timestamp_to_string(struct timeval *timestamp)
break;
case TIMESTAMP_READABLE:
tt = long_to_time(timestamp->tv_sec);
tt = _long_to_time(timestamp->tv_sec);
t = localtime(&tt);
strcpy( buf, asctime( t ) );
buf[24] = '\0'; /* nuke final newline */
break;
case TIMESTAMP_PARSEABLE:
tt = long_to_time(timestamp->tv_sec);
tt = _long_to_time(timestamp->tv_sec);
t = localtime(&tt);
if (t->tm_year >= 100)
t->tm_year += 1900;

View file

@ -88,7 +88,7 @@ char **argv;
r = yp_order(domainname, inmap, &order);
if (r != 0)
errx(1, "no such map %s. Reason: %s", inmap, yperr_string(r));
t = int_to_time(order);
t = _int_to_time(order);
printf("Map %s has order number %d. %s", inmap, order, ctime(&t));
r = yp_master(domainname, inmap, &master);
if (r != 0)