diff options
-rw-r--r-- | common/sys/time.c | 21 | ||||
-rw-r--r-- | include/cmsys.h | 4 | ||||
-rw-r--r-- | mbbsd/mbbsd.c | 4 |
3 files changed, 11 insertions, 18 deletions
diff --git a/common/sys/time.c b/common/sys/time.c index 3031d445..5cf20dc1 100644 --- a/common/sys/time.c +++ b/common/sys/time.c @@ -115,6 +115,14 @@ ctime4(const time4_t *clock) return ctime(&temp); } +char * +ctime4_r(const time4_t *t, char *buf) +{ + time_t temp = (time_t)*t; + + return ctime_r(&temp, buf); +} + // XXX TODO change this to localtime_r style someday. struct tm *localtime4(const time4_t *t) { @@ -148,16 +156,3 @@ time4_t time4(time4_t *ptr) return *ptr = (time4_t)time(NULL); } #endif - -const char* -my_ctime(const time4_t * t, char *ans, int len) -{ - time_t temp = (time_t)*clock; - struct tm tp; - - localtime_r(&temp, &tp); - snprintf(ans, len, - "%02d/%02d/%02d %02d:%02d:%02d", (tp.tm_year % 100), - tp.tm_mon + 1, tp.tm_mday, tp.tm_hour, tp.tm_min, tp.tm_sec); - return ans; -} diff --git a/include/cmsys.h b/include/cmsys.h index 7dfd6e02..da03e192 100644 --- a/include/cmsys.h +++ b/include/cmsys.h @@ -113,19 +113,19 @@ extern const char* Cdatelite(const time4_t *clock); extern const char* Cdatedate(const time4_t * clock); extern const char * Cdate_mdHM(const time4_t * clock); extern const char * Cdate_md(const time4_t * clock); -extern const char* my_ctime(const time4_t * t, char *ans, int len); -extern struct tm localtime4r(const time4_t *t); #ifdef TIMET64 struct tm* localtime4(const time4_t *); struct tm* localtime4_r(const time4_t *, struct tm *); time4_t time4(time4_t *); char* ctime4(const time4_t *); + char* ctime4_r(const time4_t *, char *); #else #define localtime4_r(a,b) localtime_r(a,b) #define localtime4(a) localtime(a) #define time4(a) time(a) #define ctime4(a) ctime(a) + #define ctime4_r(a) ctime_r(a) #endif extern int log_filef(const char *fn, int flag, const char *fmt,...) GCC_CHECK_FORMAT(3,4); diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 3793ef96..0b72cae7 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -343,13 +343,11 @@ talk_request(int sig) bell(); bell(); if (currutmp->msgcount) { - char timebuf[100]; - syncnow(); move(0, 0); clrtoeol(); prints(ANSI_COLOR(33;41) "★%s" ANSI_COLOR(34;47) " [%s] %s " ANSI_COLOR(0) "", - SHM->uinfo[currutmp->destuip].userid, my_ctime(&now,timebuf,sizeof(timebuf)), + SHM->uinfo[currutmp->destuip].userid, Cdatelite(&now), (currutmp->sig == 2) ? "重要消息廣播!(請Ctrl-U,l查看熱訊記錄)" : "呼叫、呼叫,聽到請回答"); refresh(); |