From 9084d9602e8725a6fb832d4396c12ddd7bb2b7c7 Mon Sep 17 00:00:00 2001 From: in2 Date: Mon, 24 Jan 2005 14:06:48 +0000 Subject: use time4_t(uint32_t) instead of time_t for x86-64 arch. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2426 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/stuff.c | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) (limited to 'mbbsd/stuff.c') diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c index d3c6c9b0..569bddc0 100644 --- a/mbbsd/stuff.c +++ b/mbbsd/stuff.c @@ -299,7 +299,7 @@ dashs(char *fname) * ¶Ç¦^ fname ªº mtime * @param fname */ -time_t +time4_t dasht(char *fname) { struct stat st; @@ -468,12 +468,12 @@ ipstr2int(char *ip) } #ifndef _BBS_UTIL_C_ /* getdata_buf */ -time_t -gettime(int line, time_t dt, char*head) +time4_t +gettime(int line, time4_t dt, char*head) { char yn[7]; int i; - struct tm *ptime = localtime(&dt), endtime; + struct tm *ptime = localtime4(&dt), endtime; memcpy(&endtime, ptime, sizeof(struct tm)); snprintf(yn, sizeof(yn), "%4d", ptime->tm_year + 1900); @@ -499,30 +499,33 @@ gettime(int line, time_t dt, char*head) #endif char * -Cdate(time_t * clock) +Cdate(time4_t *clock) { static char foo[32]; - struct tm *mytm = localtime(clock); + time_t temp = (time_t)*clock; + struct tm *mytm = localtime(&temp); strftime(foo, 32, "%m/%d/%Y %T %a", mytm); return foo; } char * -Cdatelite(time_t * clock) +Cdatelite(time4_t *clock) { static char foo[32]; - struct tm *mytm = localtime(clock); + time_t temp = (time_t)*clock; + struct tm *mytm = localtime(&temp); strftime(foo, 32, "%m/%d/%Y %T", mytm); return foo; } char * -Cdatedate(time_t * clock) +Cdatedate(time4_t * clock) { static char foo[32]; - struct tm *mytm = localtime(clock); + time_t temp = (time_t)*clock; + struct tm *mytm = localtime(&temp); strftime(foo, 32, "%m/%d/%Y", mytm); return foo; @@ -935,6 +938,24 @@ int qsort_intcompar(const void *a, const void *b) return *(int *)a - *(int *)b; } +struct tm *localtime4(time4_t *t) +{ + if( t == NULL ) + return localtime(NULL); + else { + time_t temp = (time_t)*t; + return localtime(&temp); + } +} + +time4_t time4(time4_t *ptr) +{ + if( ptr == NULL ) + return time(NULL); + else + return *ptr = (time4_t)time(NULL); +} + #ifdef OUTTACACHE #include int tobind(int port) -- cgit v1.2.3