summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/sys/time.c14
-rw-r--r--include/cmsys.h1
-rw-r--r--mbbsd/announce.c5
-rw-r--r--mbbsd/bbs.c59
-rw-r--r--mbbsd/cal.c3
-rw-r--r--mbbsd/calendar.c2
-rw-r--r--mbbsd/chicken.c8
-rw-r--r--mbbsd/edit.c7
-rw-r--r--mbbsd/lovepaper.c7
-rw-r--r--mbbsd/mbbsd.c9
-rw-r--r--mbbsd/menu.c9
-rw-r--r--mbbsd/record.c20
-rw-r--r--mbbsd/stuff.c15
-rw-r--r--mbbsd/talk.c7
-rw-r--r--mbbsd/vote.c5
15 files changed, 86 insertions, 85 deletions
diff --git a/common/sys/time.c b/common/sys/time.c
index 7a3768c1..3031d445 100644
--- a/common/sys/time.c
+++ b/common/sys/time.c
@@ -79,6 +79,20 @@ Cdatedate(const time4_t * clock)
}
/**
+ * 5+1 bytes, "12/31\0"
+ */
+const char*
+Cdate_md(const time4_t * clock)
+{
+ time_t temp = (time_t)*clock;
+ struct tm mytm;
+
+ localtime_r(&temp, &mytm);
+ strftime(cdate_buffer, sizeof(cdate_buffer), "%m/%d", &mytm);
+ return cdate_buffer;
+}
+
+/**
* 11+1 bytes, "12/31 10:01\0"
*/
const char*
diff --git a/include/cmsys.h b/include/cmsys.h
index a50793fe..d783b67c 100644
--- a/include/cmsys.h
+++ b/include/cmsys.h
@@ -112,6 +112,7 @@ extern const char* Cdate(const time4_t *clock);
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);
diff --git a/mbbsd/announce.c b/mbbsd/announce.c
index 35e9ecc0..12875b51 100644
--- a/mbbsd/announce.c
+++ b/mbbsd/announce.c
@@ -200,9 +200,10 @@ a_loadname(menu_t * pm)
static void
a_timestamp(char *buf, const time4_t *time)
{
- struct tm *pt = localtime4(time);
+ struct tm pt;
- sprintf(buf, "%02d/%02d/%02d", pt->tm_mon + 1, pt->tm_mday, (pt->tm_year + 1900) % 100);
+ localtime4_r(time, &pt);
+ sprintf(buf, "%02d/%02d/%02d", pt.tm_mon + 1, pt.tm_mday, (pt.tm_year + 1900) % 100);
}
static int
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index e0add447..8b7ba24e 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -663,7 +663,6 @@ cancelpost(const fileheader_t *fh, int by_BM, char *newpath)
char genbuf[200];
char nick[STRLEN], fn1[PATHLEN];
int len = 42-strlen(currboard);
- struct tm *ptime = localtime4(&now);
if(!fh->filename[0]) return;
setbfile(fn1, currboard, fh->filename);
@@ -695,8 +694,8 @@ cancelpost(const fileheader_t *fh, int by_BM, char *newpath)
fclose(fout);
}
fclose(fin);
- log_filef(fn1, LOG_CREAT, "\n※ Deleted by: %s (%s) %d/%d",
- cuser.userid, fromhost, ptime->tm_mon + 1, ptime->tm_mday);
+ log_filef(fn1, LOG_CREAT, "\n※ Deleted by: %s (%s) %s",
+ cuser.userid, fromhost, Cdatelite(&now));
Rename(fn1, newpath);
setbdir(genbuf, brd);
append_record(genbuf, &postfile, sizeof(postfile));
@@ -1663,15 +1662,12 @@ edit_post(int ent, fileheader_t * fhdr, const char *direct)
if(src)
{
int c = 0;
- struct tm *ptime;
fprintf(fp, MSG_SEPERATOR "\n");
fprintf(fp, "以下為被修改過的最新內容: ");
- ptime = localtime4(&newmt);
fprintf(fp,
- " (%02d/%02d %02d:%02d)\n",
- ptime->tm_mon + 1, ptime->tm_mday,
- ptime->tm_hour, ptime->tm_min);
+ " (%s)\n",
+ Cdate_mdHM(&newmt));
fprintf(fp, MSG_SEPERATOR "\n");
while ((c = fgetc(src)) >= 0)
fputc(c, fp);
@@ -1919,7 +1915,6 @@ cross_post(int ent, fileheader_t * fhdr, const char *direct)
{
char buf[PATHLEN], tail[STRLEN];
char bname[STRLEN] = "";
- struct tm *ptime = localtime4(&now);
int maxlength = 51 +2 - 6;
int bid = getbnum(xboard);
@@ -1936,15 +1931,13 @@ cross_post(int ent, fileheader_t * fhdr, const char *direct)
#ifdef GUESTRECOMMEND
snprintf(tail, sizeof(tail),
- "%15s %02d/%02d",
- FROMHOST,
- ptime->tm_mon + 1, ptime->tm_mday);
+ "%15s %s",
+ FROMHOST, Cdate_md(&now));
#else
maxlength += (15 - 6);
snprintf(tail, sizeof(tail),
- " %02d/%02d %02d:%02d",
- ptime->tm_mon + 1, ptime->tm_mday,
- ptime->tm_hour, ptime->tm_min);
+ " %s",
+ Cdate_mdHM(&now));
#endif
snprintf(buf, sizeof(buf),
// ANSI_COLOR(32) <- system will add green
@@ -2534,8 +2527,7 @@ do_add_recommend(const char *direct, fileheader_t *fhdr,
}
static int
-do_bid(int ent, fileheader_t * fhdr, const boardheader_t *bp,
- const char *direct, const struct tm *ptime)
+do_bid(int ent, fileheader_t * fhdr, const boardheader_t *bp, const char *direct)
{
char genbuf[200], fpath[PATHLEN],say[30],*money;
bid_t bidinfo;
@@ -2610,9 +2602,9 @@ do_bid(int ent, fileheader_t * fhdr, const boardheader_t *bp,
ANSI_COLOR(1;31) "→ "
ANSI_COLOR(33) "賣方%s提早結標"
ANSI_RESET "%*s"
- "標%15s %02d/%02d\n",
+ "標%15s %s\n",
cuser.userid, (int)(45 - strlen(cuser.userid) - strlen(money)),
- " ", fromhost, ptime->tm_mon + 1, ptime->tm_mday);
+ " ", fromhost, Cdate_md(&now));
do_add_recommend(direct, fhdr, ent, genbuf, 0);
bidinfo.enddate = now;
substitute_record(fpath, &bidinfo, sizeof(bidinfo), 1);
@@ -2647,12 +2639,11 @@ do_bid(int ent, fileheader_t * fhdr, const boardheader_t *bp,
snprintf(genbuf, sizeof(genbuf),
ANSI_COLOR(1;31) "→ " ANSI_COLOR(33) "%s" ANSI_RESET ANSI_COLOR(33) ":%s" ANSI_RESET "%*s"
- "%s%-15d標%15s %02d/%02d\n",
+ "%s%-15d標%15s %s\n",
cuser.userid, say,
(int)(31 - strlen(cuser.userid) - strlen(say)), " ",
money,
- next, fromhost,
- ptime->tm_mon + 1, ptime->tm_mday);
+ next, fromhost, Cdate_md(&now));
do_add_recommend(direct, fhdr, ent, genbuf, 0);
if( next > bidinfo.usermax ){
bidinfo.usermax = mymax;
@@ -2668,11 +2659,11 @@ do_bid(int ent, fileheader_t * fhdr, const boardheader_t *bp,
snprintf(genbuf, sizeof(genbuf),
ANSI_COLOR(1;31) "→ " ANSI_COLOR(33) "自動競標%s勝出" ANSI_RESET
- ANSI_COLOR(33) ANSI_RESET "%*s%s%-15d標 %02d/%02d\n",
+ ANSI_COLOR(33) ANSI_RESET "%*s%s%-15d標 %s\n",
cuser.userid,
(int)(20 - strlen(cuser.userid)), " ", money,
bidinfo.high,
- ptime->tm_mon + 1, ptime->tm_mday);
+ Cdate_md(&now));
do_add_recommend(direct, fhdr, ent, genbuf, 0);
}
else {
@@ -2682,11 +2673,11 @@ do_bid(int ent, fileheader_t * fhdr, const boardheader_t *bp,
bidinfo.high=bidinfo.usermax; /*這邊怪怪的*/
snprintf(genbuf, sizeof(genbuf),
ANSI_COLOR(1;31) "→ " ANSI_COLOR(33) "自動競標%s勝出"
- ANSI_RESET ANSI_COLOR(33) ANSI_RESET "%*s%s%-15d標 %02d/%02d\n",
+ ANSI_RESET ANSI_COLOR(33) ANSI_RESET "%*s%s%-15d標 %s\n",
bidinfo.userid,
(int)(20 - strlen(bidinfo.userid)), " ", money,
bidinfo.high,
- ptime->tm_mon + 1, ptime->tm_mday);
+ Cdate_md(&now));
do_add_recommend(direct, fhdr, ent, genbuf, 0);
}
substitute_record(fpath, &bidinfo, sizeof(bidinfo), 1);
@@ -2697,7 +2688,6 @@ do_bid(int ent, fileheader_t * fhdr, const boardheader_t *bp,
int
recommend(int ent, fileheader_t * fhdr, const char *direct)
{
- struct tm *ptime = localtime4(&now);
char buf[PATHLEN], msg[STRLEN];
const char *myid = cuser.userid;
char aligncmt = 0;
@@ -2760,7 +2750,7 @@ recommend(int ent, fileheader_t * fhdr, const char *direct)
#endif
if( fhdr->filemode & FILE_BID){
- return do_bid(ent, fhdr, bp, direct, ptime);
+ return do_bid(ent, fhdr, bp, direct);
}
#ifndef DEBUG
@@ -3008,21 +2998,16 @@ recommend(int ent, fileheader_t * fhdr, const char *direct)
/* build tail first. */
char tail[STRLEN];
- // sync time again because ptime may be changed during
- // getdata().
- ptime = localtime4(&now);
if(logIP)
{
snprintf(tail, sizeof(tail),
- "%15s %02d/%02d %02d:%02d",
+ "%15s %s",
FROMHOST,
- ptime->tm_mon+1, ptime->tm_mday,
- ptime->tm_hour, ptime->tm_min);
+ Cdate_mdHM(&now));
} else {
snprintf(tail, sizeof(tail),
- " %02d/%02d %02d:%02d",
- ptime->tm_mon+1, ptime->tm_mday,
- ptime->tm_hour, ptime->tm_min);
+ " %s",
+ Cdate_mdHM(&now));
}
#ifdef OLDRECOMMEND
diff --git a/mbbsd/cal.c b/mbbsd/cal.c
index c0160ffd..d0233bc5 100644
--- a/mbbsd/cal.c
+++ b/mbbsd/cal.c
@@ -497,8 +497,9 @@ int
resolve_over18_user(const userec_t *u)
{
/* get local time */
- struct tm ptime = *localtime4(&now);
+ struct tm ptime;
+ localtime4_r(&now, &ptime);
// 照實歲計算,沒生日的當作未滿 18
if (u->year < 1 || u->month < 1)
return 0;
diff --git a/mbbsd/calendar.c b/mbbsd/calendar.c
index ba290aa2..db3f4f43 100644
--- a/mbbsd/calendar.c
+++ b/mbbsd/calendar.c
@@ -313,7 +313,7 @@ calendar(void)
event_t *head = NULL, *e = NULL;
/* initialize date */
- memcpy(&snow, localtime4(&now), sizeof(struct tm));
+ localtime4_r(&now, &snow);
today = Days(snow.tm_year + 1900, snow.tm_mon + 1, snow.tm_mday);
y = snow.tm_year + 1900, m = snow.tm_mon + 1;
diff --git a/mbbsd/chicken.c b/mbbsd/chicken.c
index 053b09a0..d689d5f0 100644
--- a/mbbsd/chicken.c
+++ b/mbbsd/chicken.c
@@ -261,9 +261,9 @@ new_chicken(void)
static void
show_chicken_stat(const chicken_t * thechicken, int age)
{
- struct tm *ptime;
+ struct tm ptime;
- ptime = localtime4(&thechicken->birthday);
+ localtime4_r(&thechicken->birthday, &ptime);
prints(" Name :" ANSI_COLOR(33) "%s" ANSI_RESET " (" ANSI_COLOR(32) "%s" ANSI_RESET ")%*s生日 "
":" ANSI_COLOR(31) "%02d" ANSI_RESET "年" ANSI_COLOR(31) "%2d" ANSI_RESET "月" ANSI_COLOR(31) "%2d" ANSI_RESET "日 "
"(" ANSI_COLOR(32) "%s %d歲" ANSI_RESET ")\n"
@@ -278,8 +278,8 @@ show_chicken_stat(const chicken_t * thechicken, int age)
ANSI_RESET " \n",
thechicken->name, chicken_type[(int)thechicken->type],
strlen(thechicken->name) >= 15 ? 0 : (int)(15 - strlen(thechicken->name)), "",
- ptime->tm_year % 100, ptime->tm_mon + 1, ptime->tm_mday,
- cage[age > 16 ? 16 : age], age, thechicken->hp, thechicken->hp_max,
+ ptime.tm_year % 100, ptime.tm_mon + 1, ptime.tm_mday,
+ cage[age > 16 ? 16 : age], age, thechicken->hp, thechicken->hp_max,
thechicken->mm, thechicken->mm_max,
thechicken->attack, thechicken->run, thechicken->book,
thechicken->happy, thechicken->satis, thechicken->tiredstrong,
diff --git a/mbbsd/edit.c b/mbbsd/edit.c
index b0c806ac..495b4381 100644
--- a/mbbsd/edit.c
+++ b/mbbsd/edit.c
@@ -1669,7 +1669,6 @@ static void upload_file(void);
static int
write_file(const char *fpath, int saveheader, int *islocal, char *mytitle, int upload, int chtitle)
{
- struct tm *ptime;
FILE *fp = NULL;
textline_t *p, *v;
char ans[TTLEN], *msg;
@@ -1831,13 +1830,11 @@ write_file(const char *fpath, int saveheader, int *islocal, char *mytitle, int u
if(strcmp(currboard, BN_SYSOP) == 0)
#endif
{
- ptime = localtime4(&now);
fprintf(fp,
- "※ 編輯: %-15s 來自: %-20s (%02d/%02d %02d:%02d)\n",
+ "※ 編輯: %-15s 來自: %-20s (%s)\n",
cuser.userid,
FROMHOST,
- ptime->tm_mon + 1, ptime->tm_mday,
- ptime->tm_hour, ptime->tm_min);
+ Cdate_mdHM(&now));
}
}
diff --git a/mbbsd/lovepaper.c b/mbbsd/lovepaper.c
index 50c643bb..3003cdb2 100644
--- a/mbbsd/lovepaper.c
+++ b/mbbsd/lovepaper.c
@@ -9,13 +9,14 @@ x_love(void)
char receiver[61], path[STRLEN] = "home/";
int x, y = 0, tline = 0, poem = 0;
FILE *fp, *fpo;
- struct tm *gtime;
+ struct tm gtime;
fileheader_t mhdr;
setutmpmode(LOVE);
- gtime = localtime4(&now);
+
+ localtime4_r(&now, &gtime);
snprintf(buf1, sizeof(buf1), "%c/%s/love%d%d",
- cuser.userid[0], cuser.userid, gtime->tm_sec, gtime->tm_min);
+ cuser.userid[0], cuser.userid, gtime.tm_sec, gtime.tm_min);
strcat(path, buf1);
move(1, 0);
clrtobot();
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index c0ba2881..c599c524 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -89,10 +89,11 @@ start_daemon(void)
* children, once per connection --- and it does add up.
*/
time_t dummy = time(NULL);
- struct tm *dummy_time = localtime(&dummy);
+ struct tm dummy_time;
char buf[32];
- strftime(buf, sizeof(buf), "%d/%b/%Y:%H:%M:%S", dummy_time);
+ localtime_r(&dummy, &dummy_time);
+ strftime(buf, sizeof(buf), "%d/%b/%Y:%H:%M:%S", &dummy_time);
#ifndef NO_FORK
if ((n = fork())) {
@@ -1136,7 +1137,7 @@ user_login(void)
* 否則可藉機 race condition 達到 multi-login */
/* get local time */
- ptime = *localtime4(&now);
+ localtime4_r(&now, &ptime);
/* 初始化: random number 增加user跟時間的差異 */
mysrand();
@@ -1165,7 +1166,7 @@ user_login(void)
/* 初始化 uinfo、flag、mode */
setup_utmp(LOGIN);
enter_uflag = cuser.uflag;
- lasttime = *localtime4(&cuser.lastlogin);
+ localtime4_r(&cuser.lastlogin, &lasttime);
redrawwin();
/* mask fromhost a.b.c.d to a.b.c.* */
diff --git a/mbbsd/menu.c b/mbbsd/menu.c
index 18a0d344..aa6a73e3 100644
--- a/mbbsd/menu.c
+++ b/mbbsd/menu.c
@@ -212,19 +212,20 @@ static void
show_status(void)
{
int i;
- struct tm *ptime = localtime4(&now);
+ struct tm ptime;
char *myweek = "天一二三四五六";
const char *msgs[] = {"關閉", "打開", "拔掉", "防水", "好友"};
- i = ptime->tm_wday << 1;
+ localtime4_r(&now, &ptime);
+ i = ptime.tm_wday << 1;
move(b_lines, 0);
vbarf(ANSI_COLOR(34;46) "[%d/%d 星期%c%c %d:%02d]"
ANSI_COLOR(1;33;45) "%-14s"
ANSI_COLOR(30;47) " 線上" ANSI_COLOR(31)
"%d" ANSI_COLOR(30) "人, 我是" ANSI_COLOR(31) "%s"
ANSI_COLOR(30) "\t[扣機]" ANSI_COLOR(31) "%s ",
- ptime->tm_mon + 1, ptime->tm_mday, myweek[i], myweek[i + 1],
- ptime->tm_hour, ptime->tm_min, currutmp->birth ?
+ ptime.tm_mon + 1, ptime.tm_mday, myweek[i], myweek[i + 1],
+ ptime.tm_hour, ptime.tm_min, currutmp->birth ?
"生日要請客唷" : SHM->today_is,
SHM->UTMPnumber, cuser.userid,
msgs[currutmp->pager]);
diff --git a/mbbsd/record.c b/mbbsd/record.c
index a5263e0e..1839a7d1 100644
--- a/mbbsd/record.c
+++ b/mbbsd/record.c
@@ -485,8 +485,8 @@ stampfile_u(char *fpath, fileheader_t * fh)
// stampfile: will clear fileheader
{
register char *ip = fpath;
- time4_t dtime = COMMON_TIME;
- struct tm *ptime;
+ time4_t dtime = COMMON_TIME;
+ struct tm ptime;
#ifdef _BBS_UTIL_C_
int fp = 0; //Ptt: don't need to check
// for utils, the time may be the same between several runs, by scw
@@ -508,9 +508,9 @@ stampfile_u(char *fpath, fileheader_t * fh)
close(fp);
#endif
strlcpy(fh->filename, ip, sizeof(fh->filename));
- ptime = localtime4(&dtime);
+ localtime4_r(&dtime, &ptime);
snprintf(fh->date, sizeof(fh->date),
- "%2d/%02d", ptime->tm_mon + 1, ptime->tm_mday);
+ "%2d/%02d", ptime.tm_mon + 1, ptime.tm_mday);
return 0;
}
@@ -526,7 +526,7 @@ stampdir(char *fpath, fileheader_t * fh)
{
register char *ip = fpath;
time4_t dtime = COMMON_TIME;
- struct tm *ptime;
+ struct tm ptime;
if (access(fpath, X_OK | R_OK | W_OK))
mkdir(fpath, 0755);
@@ -538,9 +538,9 @@ stampdir(char *fpath, fileheader_t * fh)
} while (mkdir(fpath, 0755) == -1);
memset(fh, 0, sizeof(fileheader_t));
strlcpy(fh->filename, ip, sizeof(fh->filename));
- ptime = localtime4(&dtime);
+ localtime4_r(&dtime, &ptime);
snprintf(fh->date, sizeof(fh->date),
- "%2d/%02d", ptime->tm_mon + 1, ptime->tm_mday);
+ "%2d/%02d", ptime.tm_mon + 1, ptime.tm_mday);
}
void
@@ -548,7 +548,7 @@ stamplink(char *fpath, fileheader_t * fh)
{
register char *ip = fpath;
time4_t dtime = COMMON_TIME;
- struct tm *ptime;
+ struct tm ptime;
if (access(fpath, X_OK | R_OK | W_OK))
mkdir(fpath, 0755);
@@ -560,9 +560,9 @@ stamplink(char *fpath, fileheader_t * fh)
} while (symlink("temp", fpath) == -1);
memset(fh, 0, sizeof(fileheader_t));
strlcpy(fh->filename, ip, sizeof(fh->filename));
- ptime = localtime4(&dtime);
+ localtime4_r(&dtime, &ptime);
snprintf(fh->date, sizeof(fh->date),
- "%2d/%02d", ptime->tm_mon + 1, ptime->tm_mday);
+ "%2d/%02d", ptime.tm_mon + 1, ptime.tm_mday);
}
int
diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c
index 2498fdbe..f67779a5 100644
--- a/mbbsd/stuff.c
+++ b/mbbsd/stuff.c
@@ -116,11 +116,12 @@ gettime(int line, time4_t dt, const char*head)
{
char yn[7];
int i;
- struct tm *ptime = localtime4(&dt), endtime;
+ struct tm ptime, endtime;
time_t t;
- memcpy(&endtime, ptime, sizeof(struct tm));
- snprintf(yn, sizeof(yn), "%4d", ptime->tm_year + 1900);
+ localtime4_r(&dt, &ptime);
+ endtime = ptime;
+ snprintf(yn, sizeof(yn), "%4d", ptime.tm_year + 1900);
move(line, 0); outs(head);
i=strlen(head);
do {
@@ -129,19 +130,19 @@ gettime(int line, time4_t dt, const char*head)
// unsigned: limited on (..., 1970)
// let's restrict inside the boundary.
} while ((endtime.tm_year = atoi(yn) - 1900) < 70 || endtime.tm_year > 135);
- snprintf(yn, sizeof(yn), "%d", ptime->tm_mon + 1);
+ snprintf(yn, sizeof(yn), "%d", ptime.tm_mon + 1);
do {
getdata_buf(line, i+15, "月:", yn, 3, NUMECHO);
} while ((endtime.tm_mon = atoi(yn) - 1) < 0 || endtime.tm_mon > 11);
- snprintf(yn, sizeof(yn), "%d", ptime->tm_mday);
+ snprintf(yn, sizeof(yn), "%d", ptime.tm_mday);
do {
getdata_buf(line, i+24, "日:", yn, 3, NUMECHO);
} while ((endtime.tm_mday = atoi(yn)) < 1 || endtime.tm_mday > 31);
- snprintf(yn, sizeof(yn), "%d", ptime->tm_hour);
+ snprintf(yn, sizeof(yn), "%d", ptime.tm_hour);
do {
getdata_buf(line, i+33, "時(0-23):", yn, 3, NUMECHO);
} while ((endtime.tm_hour = atoi(yn)) < 0 || endtime.tm_hour > 23);
- snprintf(yn, sizeof(yn), "%d", ptime->tm_min);
+ snprintf(yn, sizeof(yn), "%d", ptime.tm_min);
do {
getdata_buf(line, i+42, "分(0-59):", yn, 3, NUMECHO);
} while ((endtime.tm_min = atoi(yn)) < 0 || endtime.tm_min > 59);
diff --git a/mbbsd/talk.c b/mbbsd/talk.c
index 5786eca6..5812bc29 100644
--- a/mbbsd/talk.c
+++ b/mbbsd/talk.c
@@ -1350,11 +1350,9 @@ do_talk(int fd)
int i, datac, ch;
int im_leaving = 0;
FILE *log, *flog;
- struct tm *ptime;
char genbuf[200], fpath[100];
STATINC(STAT_DOTALK);
- ptime = localtime4(&now);
setuserfile(fpath, "talk_XXXXXX");
flog = fdopen(mkstemp(fpath), "w");
@@ -1363,9 +1361,8 @@ do_talk(int fd)
setuserfile(genbuf, fn_talklog);
if ((log = fopen(genbuf, "w")))
- fprintf(log, "[%d/%d %d:%02d] & %s\n",
- ptime->tm_mon + 1, ptime->tm_mday, ptime->tm_hour,
- ptime->tm_min, save_page_requestor);
+ fprintf(log, "[%s] & %s\n",
+ Cdate_mdHM(&now),save_page_requestor);
setutmpmode(TALK);
ch = 58 - strlen(save_page_requestor);
diff --git a/mbbsd/vote.c b/mbbsd/vote.c
index e27279dd..79a02246 100644
--- a/mbbsd/vote.c
+++ b/mbbsd/vote.c
@@ -144,10 +144,11 @@ vote_report(const char *bname, const char *fname, char *fpath)
strlcpy(header.owner, "[馬路探子]", sizeof(header.owner));
snprintf(header.title, sizeof(header.title), "[%s] 看板 選情報導", bname);
{
- register struct tm *ptime = localtime4(&dtime);
+ struct tm ptime;
+ localtime4_r(&dtime, &ptime);
snprintf(header.date, sizeof(header.date),
- "%2d/%02d", ptime->tm_mon + 1, ptime->tm_mday);
+ "%2d/%02d", ptime.tm_mon + 1, ptime.tm_mday);
}
strlcpy(header.filename, ip, sizeof(header.filename));