diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-01-24 22:06:48 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-01-24 22:06:48 +0800 |
commit | 9084d9602e8725a6fb832d4396c12ddd7bb2b7c7 (patch) | |
tree | 78d04dab42a50e73845c8e31eb877001fb8379cd /mbbsd | |
parent | f6324fdcb56a70815842cc39cb1826ce6b82148c (diff) | |
download | pttbbs-9084d9602e8725a6fb832d4396c12ddd7bb2b7c7.tar pttbbs-9084d9602e8725a6fb832d4396c12ddd7bb2b7c7.tar.gz pttbbs-9084d9602e8725a6fb832d4396c12ddd7bb2b7c7.tar.bz2 pttbbs-9084d9602e8725a6fb832d4396c12ddd7bb2b7c7.tar.lz pttbbs-9084d9602e8725a6fb832d4396c12ddd7bb2b7c7.tar.xz pttbbs-9084d9602e8725a6fb832d4396c12ddd7bb2b7c7.tar.zst pttbbs-9084d9602e8725a6fb832d4396c12ddd7bb2b7c7.zip |
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
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/admin.c | 6 | ||||
-rw-r--r-- | mbbsd/announce.c | 6 | ||||
-rw-r--r-- | mbbsd/bbs.c | 20 | ||||
-rw-r--r-- | mbbsd/board.c | 4 | ||||
-rw-r--r-- | mbbsd/brc.c | 56 | ||||
-rw-r--r-- | mbbsd/cache.c | 4 | ||||
-rw-r--r-- | mbbsd/cal.c | 8 | ||||
-rw-r--r-- | mbbsd/calendar.c | 2 | ||||
-rw-r--r-- | mbbsd/chicken.c | 12 | ||||
-rw-r--r-- | mbbsd/dice.c | 2 | ||||
-rw-r--r-- | mbbsd/edit.c | 8 | ||||
-rw-r--r-- | mbbsd/fav.c | 6 | ||||
-rw-r--r-- | mbbsd/go.c | 8 | ||||
-rw-r--r-- | mbbsd/io.c | 2 | ||||
-rw-r--r-- | mbbsd/kaede.c | 4 | ||||
-rw-r--r-- | mbbsd/lovepaper.c | 2 | ||||
-rw-r--r-- | mbbsd/mail.c | 2 | ||||
-rw-r--r-- | mbbsd/mbbsd.c | 12 | ||||
-rw-r--r-- | mbbsd/menu.c | 2 | ||||
-rw-r--r-- | mbbsd/merge.c | 26 | ||||
-rw-r--r-- | mbbsd/read.c | 2 | ||||
-rw-r--r-- | mbbsd/record.c | 14 | ||||
-rw-r--r-- | mbbsd/register.c | 8 | ||||
-rw-r--r-- | mbbsd/stuff.c | 41 | ||||
-rw-r--r-- | mbbsd/syspost.c | 11 | ||||
-rw-r--r-- | mbbsd/talk.c | 13 | ||||
-rw-r--r-- | mbbsd/user.c | 12 | ||||
-rw-r--r-- | mbbsd/var.c | 12 | ||||
-rw-r--r-- | mbbsd/vote.c | 34 | ||||
-rw-r--r-- | mbbsd/voteboard.c | 15 | ||||
-rw-r--r-- | mbbsd/xyz.c | 2 |
31 files changed, 192 insertions, 164 deletions
diff --git a/mbbsd/admin.c b/mbbsd/admin.c index 54cf243d..a8bccb03 100644 --- a/mbbsd/admin.c +++ b/mbbsd/admin.c @@ -1345,7 +1345,7 @@ cat_register() } static void -give_id_money(char *user_id, int money, FILE * log_fp, char *mail_title, time_t t) +give_id_money(char *user_id, int money, FILE * log_fp, char *mail_title, time4_t t) { char tt[TTLEN + 1] = {0}; @@ -1355,7 +1355,7 @@ give_id_money(char *user_id, int money, FILE * log_fp, char *mail_title, time_t prints("id:%s money:%d 不對吧!!", user_id, money); pressanykey(); } else { - fprintf(log_fp, "%d %s %d", (int)t, user_id, money); + fprintf(log_fp, "%d %s %d", t, user_id, money); snprintf(tt, sizeof(tt), "%s : %d ptt 幣", mail_title, money); mail_id(user_id, tt, "etc/givemoney.why", "[PTT 銀行]"); } @@ -1367,7 +1367,7 @@ give_money() FILE *fp, *fp2; char *ptr, *id, *mn; char buf[200] = "", tt[TTLEN + 1] = ""; - struct tm *pt = localtime(&now); + struct tm *pt = localtime4(&now); int to_all = 0, money = 0; getdata(0, 0, "指定使用者(S) 全站使用者(A) 取消(Q)?[S]", buf, sizeof(buf), LCECHO); diff --git a/mbbsd/announce.c b/mbbsd/announce.c index 2ac04137..aad29a92 100644 --- a/mbbsd/announce.c +++ b/mbbsd/announce.c @@ -36,9 +36,9 @@ a_loadname(menu_t * pm) } static void -a_timestamp(char *buf, time_t * time) +a_timestamp(char *buf, time4_t *time) { - struct tm *pt = localtime(time); + struct tm *pt = localtime4(time); sprintf(buf, "%02d/%02d/%02d", pt->tm_mon + 1, pt->tm_mday, (pt->tm_year + 1900) % 100); } @@ -50,7 +50,7 @@ a_showmenu(menu_t * pm) int n; fileheader_t *item; char buf[PATHLEN]; - time_t dtime; + time4_t dtime; showtitle("精華文章", pm->mtitle); prints(" \033[1;36m編號 標 題%56s\033[0m", diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index 361738e3..1381e06b 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -35,7 +35,7 @@ anticrosspost(void) { log_file("etc/illegal_money", LOG_CREAT | LOG_VF, "\033[1;33;46m%s \033[37;45mcross post 文章 \033[37m %s\033[m\n", - cuser.userid, ctime(&now)); + cuser.userid, Cdate(&now)); post_violatelaw(cuser.userid, "Ptt系統警察", "Cross-post", "罰單處份"); cuser.userlevel |= PERM_VIOLATELAW; @@ -107,7 +107,7 @@ save_violatelaw(void) * void make_blist() { CreateNameList(); apply_boards(g_board_names); } */ -static time_t *board_note_time; +static time4_t *board_note_time; void set_board(void) @@ -425,9 +425,9 @@ do_unanonymous_post(char *fpath) */ #ifdef NO_WATER_POST #ifndef DEBUG -static time_t last_post_time = 0; +static time4_t last_post_time = 0; #endif -static time_t water_counts = 0; +static time4_t water_counts = 0; #endif void @@ -1665,12 +1665,12 @@ do_bid(int ent, fileheader_t * fhdr, boardheader_t *bp, static int recommend(int ent, fileheader_t * fhdr, char *direct) { - struct tm *ptime = localtime(&now); + struct tm *ptime = localtime4(&now); char buf[200], path[200], *ctype[3] = {"37m推","31m噓","31m→"}; - int type = 0; + int type = 0; boardheader_t *bp; - static time_t lastrecommend = 0; + static time4_t lastrecommend = 0; bp = getbcache(currbid); if( bp->brdattr & BRD_NORECOMMEND ){ @@ -2638,7 +2638,7 @@ Read(void) int stat0 = currstat, tmpbid = currutmp->brc_id; char buf[40]; #ifdef LOG_BOARD - time_t usetime = now; + time4_t usetime = now; #endif if ( !currboard[0] ) @@ -2687,12 +2687,12 @@ ReadSelect(void) #ifdef LOG_BOARD static void -log_board(char *mode, time_t usetime) +log_board(char *mode, time4_t usetime) { if (usetime > 30) { log_file(FN_USEBOARD, LOG_CREAT | LOG_VF, "USE %-20.20s Stay: %5ld (%s) %s\n", - mode, usetime, cuser.userid, ctime(&now)); + mode, usetime, cuser.userid, Cdate(&now)); } } #endif diff --git a/mbbsd/board.c b/mbbsd/board.c index a94716a0..dba735f2 100644 --- a/mbbsd/board.c +++ b/mbbsd/board.c @@ -114,8 +114,8 @@ static int check_newpost(boardstat_t * ptr) { /* Ptt 改 */ int tbrc_num; - time_t ftime; - time_t *tbrc_list; + time4_t ftime; + time4_t *tbrc_list; ptr->myattr &= ~NBRD_UNREAD; if (B_BH(ptr)->brdattr & (BRD_GROUPBOARD | BRD_SYMBOLIC)) diff --git a/mbbsd/brc.c b/mbbsd/brc.c index 33a5f5cd..b1c6ee76 100644 --- a/mbbsd/brc.c +++ b/mbbsd/brc.c @@ -26,15 +26,15 @@ typedef unsigned short brcnbrd_t; * brc_num 1 byte, binary integer * brc_list brc_num * sizeof(int) bytes, brc_num binary integer(s) */ -static time_t brc_expire_time; +static time4_t brc_expire_time; /* Will be set to the time one year before login. All the files created * before then will be recognized read. */ -static int brc_changed = 0; +static int brc_changed = 0; /* The below two will be filled by read_brc_buf() and brc_update() */ -static char *brc_buf = NULL; -static int brc_size; -static int brc_alloc; +static char *brc_buf = NULL; +static int brc_size; +static int brc_alloc; static char * const fn_oldboardrc = ".boardrc"; static char * const fn_brc = ".brc2"; @@ -42,7 +42,8 @@ static char * const fn_brc = ".brc2"; #if 0 /* unused after brc2 */ static char * -brc_getrecord(char *ptr, char *endp, brcbid_t *bid, brcnbrd_t *pnum, time_t *list) +brc_getrecord(char *ptr, char *endp, brcbid_t *bid, + brcnbrd_t *pnum, time4_t *list) { brcnbrd_t num; char *tmp; @@ -53,9 +54,9 @@ brc_getrecord(char *ptr, char *endp, brcbid_t *bid, brcnbrd_t *pnum, time_t *lis ptr += sizeof(brcbid_t); num = *(brcnbrd_t*)ptr; /* brc_num */ ptr += sizeof(brcnbrd_t); - tmp = ptr + num * sizeof(time_t); /* end of this record */ + tmp = ptr + num * sizeof(time4_t); /* end of this record */ if (tmp <= endp){ - memcpy(list, ptr, num * sizeof(time_t)); /* brc_list */ + memcpy(list, ptr, num * sizeof(time4_t)); /* brc_list */ if (num > BRC_MAXNUM) num = BRC_MAXNUM; *pnum = num; @@ -80,7 +81,7 @@ brc_findrecord_in(char *begin, char *endp, brcbid_t bid, brcnbrd_t *num) tbid = *(brcbid_t*)tmpp; tmpp += sizeof(brcbid_t); *num = *(brcnbrd_t*)tmpp; - tmpp += sizeof(brcnbrd_t) + *num * sizeof(time_t); /* end of record */ + tmpp += sizeof(brcnbrd_t) + *num * sizeof(time4_t); /* end of record */ if ( tmpp > endp ){ /* dangling, ignore the trailing data */ @@ -96,7 +97,7 @@ brc_findrecord_in(char *begin, char *endp, brcbid_t bid, brcnbrd_t *num) return 0; } -time_t * +time4_t * brc_find_record(int bid, int *num) { char *p; @@ -104,13 +105,14 @@ brc_find_record(int bid, int *num) p = brc_findrecord_in(brc_buf, brc_buf + brc_size, bid, &tnum); *num = tnum; if (p) - return (time_t*)(p + sizeof(brcbid_t) + sizeof(brcnbrd_t)); + return (time4_t*)(p + sizeof(brcbid_t) + sizeof(brcnbrd_t)); *num = 0; return 0; } static char * -brc_putrecord(char *ptr, char *endp, brcbid_t bid, brcnbrd_t num, const time_t *list) +brc_putrecord(char *ptr, char *endp, brcbid_t bid, + brcnbrd_t num, const time4_t *list) { char * tmp; if (num > 0 && list[0] > brc_expire_time && @@ -124,9 +126,9 @@ brc_putrecord(char *ptr, char *endp, brcbid_t bid, brcnbrd_t num, const time_t * ptr += sizeof(brcbid_t); *(brcnbrd_t*)ptr = num; /* write in brc_num */ ptr += sizeof(brcnbrd_t); - tmp = ptr + num * sizeof(time_t); + tmp = ptr + num * sizeof(time4_t); if (tmp <= endp) - memcpy(ptr, list, num * sizeof(time_t)); /* write in brc_list */ + memcpy(ptr, list, num * sizeof(time4_t)); /* write in brc_list */ ptr = tmp; } return ptr; @@ -180,7 +182,7 @@ brc_get_buf(int size){ } static inline void -brc_insert_record(brcbid_t bid, brcnbrd_t num, time_t* list) +brc_insert_record(brcbid_t bid, brcnbrd_t num, time4_t* list) { char *ptr; int new_size, end_size; @@ -197,7 +199,7 @@ brc_insert_record(brcbid_t bid, brcnbrd_t num, time_t* list) /* put on the beginning */ if (num){ new_size = sizeof(brcbid_t) + sizeof(brcnbrd_t) - + num * sizeof(time_t); + + num * sizeof(time4_t); brc_size += new_size; if (brc_size > brc_alloc && !brc_enlarge_buf()) brc_size = BRC_MAXSIZE; @@ -208,13 +210,13 @@ brc_insert_record(brcbid_t bid, brcnbrd_t num, time_t* list) } else { /* ptr points to the old current brc list. * tmpp is the end of it (exclusive). */ - int len = sizeof(brcbid_t) + sizeof(brcnbrd_t) + tnum * sizeof(time_t); + int len = sizeof(brcbid_t) + sizeof(brcnbrd_t) + tnum * sizeof(time4_t); char *tmpp = ptr + len; end_size = brc_buf + brc_size - tmpp; if (num) { int sindex = ptr - brc_buf; - new_size = sizeof(brcbid_t) + sizeof(brcnbrd_t) - + num * sizeof(time_t); + new_size = (sizeof(brcbid_t) + sizeof(brcnbrd_t) + + num * sizeof(time4_t)); brc_size += new_size - len; if (brc_size > brc_alloc) { if (brc_enlarge_buf()) { @@ -279,8 +281,8 @@ read_old_brc(int fd) break; brc_size += sizeof(brcbid_t) + sizeof(brcnbrd_t) - + sizeof(time_t) * num; - ptr += sizeof(time_t) * num; + + sizeof(time4_t) * num; + ptr += sizeof(time4_t) * num; } } @@ -336,14 +338,14 @@ brc_initialize(){ } int -brc_read_record(int bid, int *num, time_t *list){ +brc_read_record(int bid, int *num, time4_t *list){ char *ptr; brcnbrd_t tnum; ptr = brc_findrecord_in(brc_buf, brc_buf + brc_size, bid, &tnum); *num = tnum; if ( ptr ){ memcpy(list, ptr + sizeof(brcbid_t) + sizeof(brcnbrd_t), - *num * sizeof(time_t)); + *num * sizeof(time4_t)); return *num; } list[0] = *num = 1; @@ -370,7 +372,7 @@ brc_initial_board(const char *boardname) } void -brc_trunc(int bid, time_t ftime){ +brc_trunc(int bid, time4_t ftime){ brc_insert_record(bid, 1, &ftime); if ( bid == currbid ){ brc_num = 1; @@ -383,7 +385,7 @@ void brc_addlist(const char *fname) { int n, i; - time_t ftime; + time4_t ftime; if (!cuser.userlevel) return; @@ -417,7 +419,7 @@ brc_addlist(const char *fname) } int -brc_unread_time(time_t ftime, int bnum, const time_t *blist) +brc_unread_time(time4_t ftime, int bnum, const time4_t *blist) { int n; @@ -436,7 +438,7 @@ brc_unread_time(time_t ftime, int bnum, const time_t *blist) } int -brc_unread(const char *fname, int bnum, const time_t *blist) +brc_unread(const char *fname, int bnum, const time4_t *blist) { int ftime, n; diff --git a/mbbsd/cache.c b/mbbsd/cache.c index 1823b370..f4996ffb 100644 --- a/mbbsd/cache.c +++ b/mbbsd/cache.c @@ -560,7 +560,7 @@ reload_bcache(void) sizeof(boardheader_t); close(fd); } - memset(SHM->lastposttime, 0, MAX_BOARD * sizeof(time_t)); + memset(SHM->lastposttime, 0, MAX_BOARD * sizeof(time4_t)); memset(SHM->total, 0, MAX_BOARD * sizeof(int)); /* 等所有 boards 資料更新後再設定 uptime */ SHM->Buptime = SHM->Btouchtime; @@ -678,7 +678,7 @@ setbtotal(int bid) if (num > 0) { lseek(fd, (off_t) (num - 1) * sizeof(fileheader_t), SEEK_SET); if (read(fd, genbuf, FNLEN) >= 0) { - SHM->lastposttime[bid - 1] = (time_t) atoi(&genbuf[2]); + SHM->lastposttime[bid - 1] = (time4_t) atoi(&genbuf[2]); } } else SHM->lastposttime[bid - 1] = 0; diff --git a/mbbsd/cal.c b/mbbsd/cal.c index 08289ef9..b2b877d8 100644 --- a/mbbsd/cal.c +++ b/mbbsd/cal.c @@ -329,8 +329,8 @@ mail_redenvelop(char *from, char *to, int money, char mode) "時間: %s\n" "\033[1;33m親愛的 %s :\n\n\033[m" "\033[1;31m 我包給你一個 %d 元的大紅包喔 ^_^\n\n" - " 禮輕情意重,請笑納...... ^_^\033[m\n" - ,from, ctime(&now), to, money); + " 禮輕情意重,請笑納...... ^_^\033[m\n", + from, Cdate(&now), to, money); fclose(fp); snprintf(fhdr.title, sizeof(fhdr.title), "招財進寶"); strlcpy(fhdr.owner, from, sizeof(fhdr.owner)); @@ -376,7 +376,7 @@ p_give() deumoney(searchuser(id), money - tax); demoney(-money); log_file(FN_MONEY, LOG_CREAT | LOG_VF, "%s\t給%s\t%d\t%s", - cuser.userid, id, money - tax, ctime(&now)); + cuser.userid, id, money - tax, Cdate(&now)); #ifdef PLAY_ANGEL getuser(id); if (!strcmp(xuser.myangel, cuser.userid)){ @@ -416,7 +416,7 @@ p_sysinfo(void) #else MAX_ACTIVE, #endif - compile_time, ctime(&start_time)); + compile_time, Cdate(&start_time)); if (HAS_PERM(PERM_SYSOP)) { struct rusage ru; getrusage(RUSAGE_SELF, &ru); diff --git a/mbbsd/calendar.c b/mbbsd/calendar.c index 7928f8a2..372dcc9a 100644 --- a/mbbsd/calendar.c +++ b/mbbsd/calendar.c @@ -268,7 +268,7 @@ calendar() event_t *head = NULL, *e = NULL; /* initialize date */ - memcpy(&snow, localtime(&now), sizeof(struct tm)); + memcpy(&snow, localtime4(&now), sizeof(struct tm)); 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 c1b3cf20..6881a9dc 100644 --- a/mbbsd/chicken.c +++ b/mbbsd/chicken.c @@ -137,7 +137,7 @@ new_chicken() log_file(CHICKENLOG, LOG_CREAT | LOG_VF, "\033[31m%s \033[m養了一隻叫\033[33m %s \033[m的 " "\033[32m%s\033[m 於 %s\n", cuser.userid, - mychicken->name, chicken_type[(int)mychicken->type], ctime(&now)); + mychicken->name, chicken_type[(int)mychicken->type], Cdate(&now)); mychicken->lastvisit = mychicken->birthday = mychicken->cbirth = now; mychicken->food = 0; mychicken->weight = time_change[(int)mychicken->type][WEIGHT] / 3; @@ -162,7 +162,7 @@ show_chicken_stat(chicken_t * thechicken) { struct tm *ptime; - ptime = localtime(&thechicken->birthday); + ptime = localtime4(&thechicken->birthday); prints(" Name :\033[33m%s\033[m (\033[32m%s\033[m)%*s生日 " ":\033[31m%02d\033[m年\033[31m%2d\033[m月\033[31m%2d\033[m日 " "(\033[32m%s %d歲\033[m)\n" @@ -431,7 +431,7 @@ ch_kill() log_file(CHICKENLOG, LOG_CREAT | LOG_VF, "\033[31m%s \033[m把 \033[33m%s\033[m\033[32m %s " "\033[m宰了 於 %s\n", cuser.userid, mychicken->name, - chicken_type[(int)mychicken->type], ctime(&now)); + chicken_type[(int)mychicken->type], Cdate(&now)); mychicken->name[0] = 0; } } @@ -489,7 +489,7 @@ ch_sell() "\033[31m%s\033[m 把 \033[33m%s\033[m " "\033[32m%s\033[m 用 \033[36m%d\033[m 賣了 於 %s\n", cuser.userid, mychicken->name, - chicken_type[(int)mychicken->type], money, ctime(&now)); + chicken_type[(int)mychicken->type], money, Cdate(&now)); mychicken->lastvisit = mychicken->name[0] = 0; passwd_update(usernum, &cuser); more(CHICKEN_PIC "/sell", YEA); @@ -645,7 +645,7 @@ deadtype(chicken_t * thechicken) log_file(CHICKENLOG, LOG_CREAT | LOG_VF, "\033[31m%s\033[m 所疼愛的\033[33m %s\033[32m %s " "\033[m掛了 於 %s\n", cuser.userid, thechicken->name, - chicken_type[(int)thechicken->type], ctime(&now)); + chicken_type[(int)thechicken->type], Cdate(&now)); mychicken->name[0] = 0; passwd_update(usernum, &cuser); } @@ -703,7 +703,7 @@ ch_changename() "\033[31m%s\033[m 把疼愛的\033[33m %s\033[32m %s " "\033[m改名為\033[33m %s\033[m 於 %s\n", cuser.userid, mychicken->name, - chicken_type[(int)mychicken->type], newname, ctime(&now)); + chicken_type[(int)mychicken->type], newname, Cdate(&now)); } } diff --git a/mbbsd/dice.c b/mbbsd/dice.c index b385a60f..b6283731 100644 --- a/mbbsd/dice.c +++ b/mbbsd/dice.c @@ -80,6 +80,7 @@ IsNum(char *a, int n) return 1; } +#if 0 static int IsSNum(char *a) { @@ -90,6 +91,7 @@ IsSNum(char *a) return 0; return 1; } +#endif static void show_data(void) diff --git a/mbbsd/edit.c b/mbbsd/edit.c index 76bd9c83..09cd5591 100644 --- a/mbbsd/edit.c +++ b/mbbsd/edit.c @@ -948,7 +948,7 @@ write_header(FILE * fp, int ifuseanony) // FIXME unused char author[IDLEN + 1]; char board[IDLEN + 1]; char title[66]; - time_t date; /* last post's date */ + time4_t date; /* last post's date */ int number; /* post number */ } postlog; @@ -1012,7 +1012,7 @@ write_header(FILE * fp, int ifuseanony) // FIXME unused } save_title[72] = '\0'; - fprintf(fp, "標題: %s\n時間: %s\n", save_title, ctime(&now)); + fprintf(fp, "標題: %s\n時間: %s\n", save_title, Cdate(&now)); } void @@ -1201,7 +1201,7 @@ write_file(char *fpath, int saveheader, int *islocal) && strcmp(currboard, "SYSOP") == 0 #endif ) { - ptime = localtime(&now); + ptime = localtime4(&now); fprintf(fp, "※ 編輯: %-15s 來自: %-20s (%02d/%02d %02d:%02d)\n", cuser.userid, fromhost, @@ -1775,7 +1775,7 @@ vedit(char *fpath, int saveheader, int *islocal) int destuid0 = currutmp->destuid; int money = 0; int interval = 0; - time_t th = now; + time4_t th = now; int count = 0, tin = 0; textline_t *oldcurrline; diff --git a/mbbsd/fav.c b/mbbsd/fav.c index b2a267df..71780d65 100644 --- a/mbbsd/fav.c +++ b/mbbsd/fav.c @@ -662,7 +662,7 @@ char getbrdattr(short bid) return fb->attr; } -time_t getbrdtime(short bid) +time4_t getbrdtime(short bid) { fav_type_t *fb = getboard(bid); if (!fb) @@ -670,7 +670,7 @@ time_t getbrdtime(short bid) return cast_board(fb)->lastvisit; } -void setbrdtime(short bid, time_t t) +void setbrdtime(short bid, time4_t t) { fav_type_t *fb = getboard(bid); if (fb) @@ -1084,7 +1084,7 @@ void subscribe_newfav(void) typedef struct { short bid; char attr; - time_t lastvisit; + time4_t lastvisit; } fav3_board_t; typedef struct { @@ -661,8 +661,8 @@ gochess(int fd) { Horder_t mv; userinfo_t *my = currutmp; - time_t mtime, htime, btime; - int i, j, ch = 0, passflag, endflag, totalgo, timeflag, is_view; + time4_t mtime, htime, btime; + int i, j, ch = 0, passflag, endflag, totalgo, timeflag, is_view; unsigned char mhand, hhand; int scr_need_redraw = 1; @@ -840,13 +840,13 @@ gochess(int fd) char buf[128]; int n; //move(5, 46); - n = sprintf(buf, "\033[6;47H%s 方時間:%02ld:%02ld ", + n = sprintf(buf, "\033[6;47H%s 方時間:%02d:%02d ", bw_chess[me - 1], mtime / 60, mtime % 60); if (mhand <= 25) n += sprintf(buf + n, "%2d 手", 25 - mhand); output(buf, n); //move(6, 46); - n = sprintf(buf, "\033[7;47H%s 方時間:%02ld:%02ld ", + n = sprintf(buf, "\033[7;47H%s 方時間:%02d:%02d ", bw_chess[he - 1], htime / 60, htime % 60); if (hhand <= 25) n += sprintf(buf + n, "%2d 手", 25 - hhand); @@ -120,7 +120,7 @@ static int dogetch() { int len; - static time_t lastact; + static time4_t lastact; if (ibufsize <= icurrchar) { if (flushf) diff --git a/mbbsd/kaede.c b/mbbsd/kaede.c index 8df76a75..61a6505f 100644 --- a/mbbsd/kaede.c +++ b/mbbsd/kaede.c @@ -105,11 +105,11 @@ Link(char *src, char *dst) } char * -my_ctime(const time_t * t, char *ans, int len) +my_ctime(const time4_t * t, char *ans, int len) { struct tm *tp; - tp = localtime(t); + tp = localtime4((time4_t*)t); 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); diff --git a/mbbsd/lovepaper.c b/mbbsd/lovepaper.c index 4a2a1a18..b93fefbd 100644 --- a/mbbsd/lovepaper.c +++ b/mbbsd/lovepaper.c @@ -13,7 +13,7 @@ x_love() fileheader_t mhdr; setutmpmode(LOVE); - gtime = localtime(&now); + gtime = localtime4(&now); snprintf(buf1, sizeof(buf1), "%c/%s/love%d%d", cuser.userid[0], cuser.userid, gtime->tm_sec, gtime->tm_min); strcat(path, buf1); diff --git a/mbbsd/mail.c b/mbbsd/mail.c index 1f3e7f76..6244ddd3 100644 --- a/mbbsd/mail.c +++ b/mbbsd/mail.c @@ -1494,7 +1494,7 @@ int bsmtp(char *fpath, char *title, char *rcpt, int method) { char buf[80], *ptr; - time_t chrono; + time4_t chrono; MailQueue mqueue; /* check if the mail is a inner mail */ diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 1237a8db..a616da9e 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -217,7 +217,7 @@ talk_request(int sig) bell(); if (currutmp->msgcount) { char timebuf[100]; - time_t now = time(0); + time4_t now = time(0); move(0, 0); clrtoeol(); @@ -263,13 +263,11 @@ show_call_in(int save, int which) if (save) { char genbuf[200]; - time_t now; if (!fp_writelog) { sethomefile(genbuf, cuser.userid, fn_writelog); fp_writelog = fopen(genbuf, "a"); } if (fp_writelog) { - time(&now); fprintf(fp_writelog, "%s [%s]\n", buf, Cdatelite(&now)); } } @@ -878,12 +876,10 @@ user_login() { char i; struct tm *ptime, *tmp; - time_t now; int a, ifbirth; /* get local time */ - time(&now); - ptime = localtime(&now); + ptime = localtime4(&now); /* 初始化: random number 增加user跟時間的差異 */ mysrand(); @@ -932,7 +928,7 @@ user_login() enter_uflag = cuser.uflag; currutmp->birth = ifbirth; - tmp = localtime(&(cuser.lastlogin)); + tmp = localtime4(&(cuser.lastlogin)); if ((a = SHM->UTMPnumber) > SHM->max_user) { SHM->max_user = a; SHM->max_time = now; @@ -1458,7 +1454,7 @@ static int check_ban_and_load(int fd) { FILE *fp; - static time_t chkload_time = 0; + static time4_t chkload_time = 0; static int overload = 0; /* overload or banned, update every 1 * sec */ static int banned = 0; diff --git a/mbbsd/menu.c b/mbbsd/menu.c index 975656e3..092c497f 100644 --- a/mbbsd/menu.c +++ b/mbbsd/menu.c @@ -79,7 +79,7 @@ static void show_status(void) { int i; - struct tm *ptime = localtime(&now); + struct tm *ptime = localtime4(&now); char mystatus[160]; char *myweek = "天一二三四五六"; const char *msgs[] = {"關閉", "打開", "拔掉", "防水", "好友"}; diff --git a/mbbsd/merge.c b/mbbsd/merge.c index 7694f4a6..678e5fe6 100644 --- a/mbbsd/merge.c +++ b/mbbsd/merge.c @@ -12,7 +12,7 @@ m_sob() int count=0, i, isimported=0, corrected; FILE *fp; sobuserec man; - time_t d; + time4_t d; clear(); move(1,0); @@ -112,26 +112,32 @@ m_sob() cuser.userlevel |= PERM_MAILLIMIT; } - if(cuser.firstlogin > man.firstlogin) d = man.firstlogin; - else d = cuser.firstlogin; + if (cuser.firstlogin > man.firstlogin) + d = man.firstlogin; + else + d = cuser.firstlogin; cuser.firstlogin = d; - if(cuser.numlogins < man.numlogins) i = man.numlogins; - else i = cuser.numlogins; + if (cuser.numlogins < man.numlogins) + i = man.numlogins; + else + i = cuser.numlogins; sprintf(buf, "沙灘進站次數 %d 此帳號 %d 將取 %d \n", man.numlogins, cuser.numlogins, i); strcat(msg,buf); cuser.numlogins = i; - if(cuser.numposts < man.numposts ) i = man.numposts; - else i = cuser.numposts; + if (cuser.numposts < man.numposts ) + i = man.numposts; + else + i = cuser.numposts; sprintf(buf, "沙灘文章次數 %d 此帳號 %d 將取 %d\n", man.numposts,cuser.numposts,i); strcat(msg,buf); cuser.numposts = i; outs(msg); - while(search_ulistn(usernum,2)) + while (search_ulistn(usernum,2)) {vmsg("請將重覆上站其他線關閉! 再繼續");} passwd_update(usernum, &cuser); } @@ -144,13 +150,13 @@ m_sob() chdir(BBSHOME); if (getans("是否匯入個人信箱? (Y/n)")!='n') - { + { sethomedir(buf, cuser.userid); sprintf(genbuf, "sob/home/%c/%s/.DIR", userid[0], userid); merge_dir(buf, genbuf, 1); strcat(msg, "匯入個人信箱\n"); - } + } if(getans("是否匯入個人信箱精華區(個人作品集)? (會覆蓋\現有設定) (y/N)")=='y') { fileheader_t fh; diff --git a/mbbsd/read.c b/mbbsd/read.c index 17c39abc..c127d4b0 100644 --- a/mbbsd/read.c +++ b/mbbsd/read.c @@ -28,7 +28,7 @@ UnTagger(int locus) } int -Tagger(time_t chrono, int recno, int mode) +Tagger(time4_t chrono, int recno, int mode) { int head, tail, posi = 0, comp; diff --git a/mbbsd/record.c b/mbbsd/record.c index 7a5d9c53..05773ef7 100644 --- a/mbbsd/record.c +++ b/mbbsd/record.c @@ -211,7 +211,7 @@ static int force_open(char *fname) { int fd; - time_t expire; + time4_t expire; expire = now - 3600; /* lock 存在超過一個小時就是有問題! */ @@ -464,7 +464,7 @@ int stampfile(char *fpath, fileheader_t * fh) { register char *ip = fpath; - time_t dtime = COMMON_TIME; + time4_t dtime = COMMON_TIME; struct tm *ptime; #ifdef _BBS_UTIL_C_ int fp = 0; //Ptt: don't need to check @@ -488,7 +488,7 @@ stampfile(char *fpath, fileheader_t * fh) #endif memset(fh, 0, sizeof(fileheader_t)); strlcpy(fh->filename, ip, sizeof(fh->filename)); - ptime = localtime(&dtime); + ptime = localtime4(&dtime); snprintf(fh->date, sizeof(fh->date), "%2d/%02d", ptime->tm_mon + 1, ptime->tm_mday); return 0; @@ -498,7 +498,7 @@ void stampdir(char *fpath, fileheader_t * fh) { register char *ip = fpath; - time_t dtime = COMMON_TIME; + time4_t dtime = COMMON_TIME; struct tm *ptime; if (access(fpath, X_OK | R_OK | W_OK)) @@ -511,7 +511,7 @@ 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 = localtime(&dtime); + ptime = localtime4(&dtime); snprintf(fh->date, sizeof(fh->date), "%2d/%02d", ptime->tm_mon + 1, ptime->tm_mday); } @@ -520,7 +520,7 @@ void stamplink(char *fpath, fileheader_t * fh) { register char *ip = fpath; - time_t dtime = COMMON_TIME; + time4_t dtime = COMMON_TIME; struct tm *ptime; if (access(fpath, X_OK | R_OK | W_OK)) @@ -533,7 +533,7 @@ 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 = localtime(&dtime); + ptime = localtime4(&dtime); snprintf(fh->date, sizeof(fh->date), "%2d/%02d", ptime->tm_mon + 1, ptime->tm_mday); } diff --git a/mbbsd/register.c b/mbbsd/register.c index 19a3796b..c3f736c5 100644 --- a/mbbsd/register.c +++ b/mbbsd/register.c @@ -79,7 +79,7 @@ bad_user_id(char *userid) /* (b) is the object to be compared */ /* -------------------------------- */ static int -compute_user_value(userec_t * urec, time_t clock) +compute_user_value(userec_t * urec, time4_t clock) { int value; @@ -111,8 +111,8 @@ check_and_expire_account(int uid, userec_t * urec) int val; if ((val = compute_user_value(urec, now)) < 0) { snprintf(genbuf, sizeof(genbuf), "#%d %-12s %15.15s %d %d %d", - uid, urec->userid, ctime(&(urec->lastlogin)) + 4, - urec->numlogins, urec->numposts, val); + uid, urec->userid, Cdate(&(urec->lastlogin)) + 4, + urec->numlogins, urec->numposts, val); if (val > -1 * 60 * 24 * 365) { log_usies("CLEAN", genbuf); snprintf(genbuf, sizeof(genbuf), "home/%c/%s", urec->userid[0], @@ -138,7 +138,7 @@ int getnewuserid() { char genbuf[50]; - char *fn_fresh = ".fresh"; + char *fn_fresh = ".fresh"; userec_t utmp; time_t clock; struct stat st; 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 <err.h> int tobind(int port) diff --git a/mbbsd/syspost.c b/mbbsd/syspost.c index 100e067f..34804f1b 100644 --- a/mbbsd/syspost.c +++ b/mbbsd/syspost.c @@ -18,7 +18,7 @@ post_msg(char *bname, char *title, char *msg, char *author) return -1; fprintf(fp, "作者: %s 看板: %s\n標題: %s \n", author, bname, title); - fprintf(fp, "時間: %s\n", ctime(&now)); + fprintf(fp, "時間: %s\n", Cdate(&now)); /* 文章的內容 */ fputs(msg, fp); @@ -69,7 +69,7 @@ post_change_perm(int oldperm, int newperm, char *sysopid, char *userid) fprintf(fp, "作者: [系統安全局] 看板: Security\n" "標題: [公安報告] 站長修改權限報告\n" - "時間: %s\n", ctime(&now)); + "時間: %s\n", Cdate(&now)); for (i = 5; i < NUMPERMS; i++) { if (((oldperm >> i) & 1) != ((newperm >> i) & 1)) { fprintf(fp, " 站長\033[1;32m%s%s%s%s\033[m的權限\n", @@ -114,7 +114,7 @@ post_violatelaw(char *crime, char *police, char *reason, char *result) "時間: %s\n" "\033[1;32m%s\033[m判決:\n \033[1;32m%s\033[m" "因\033[1;35m%s\033[m行為,\n違反本站站規,處以\033[1;35m%s\033[m,特此公告", - crime, ctime(&now), police, crime, reason, result); + crime, Cdate(&now), police, crime, reason, result); fclose(fp); snprintf(fhdr.title, sizeof(fhdr.title), "[報告] %-20s 違法判決報告", crime); @@ -131,7 +131,7 @@ post_violatelaw(char *crime, char *police, char *reason, char *result) "時間: %s\n" "\033[1;32m%s\033[m判決:\n \033[1;32m%s\033[m" "因\033[1;35m%s\033[m行為,\n違反本站站規,處以\033[1;35m%s\033[m,特此公告", - crime, ctime(&now), police, crime, reason, result); + crime, Cdate(&now), police, crime, reason, result); fclose(fp); snprintf(fhdr.title, sizeof(fhdr.title), "[報告] %s:%-*s 判決", crime, @@ -159,7 +159,6 @@ give_money_post(char *userid, int money) { FILE *fp; fileheader_t fhdr; - time_t now = time(0); char genbuf[200]; strlcpy(genbuf, "boards/S/Security", sizeof(genbuf)); @@ -168,7 +167,7 @@ give_money_post(char *userid, int money) return; fprintf(fp, "作者: [系統安全局] 看板: Security\n" "標題: [公安報告] 站長%s使用紅包機報告\n" - "時間: %s\n", cuser.userid, ctime(&now)); + "時間: %s\n", cuser.userid, Cdate(&now)); clrtobot(); clear(); fprintf(fp, "\n 站長\033[1;32m%s\033[m給\033[1;33m%s %d 元\033[m", diff --git a/mbbsd/talk.c b/mbbsd/talk.c index 8637f77c..ae5db603 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -643,7 +643,7 @@ my_write(pid_t pid, char *prompt, char *id, int flag, userinfo_t * puin) currutmp->chatid[0] = 3; currstat = DBACK; - ptime = localtime(&now); + ptime = localtime4(&now); if (flag == WATERBALL_GENERAL #ifdef PLAY_ANGEL @@ -1112,7 +1112,7 @@ do_talk(int fd) struct tm *ptime; char genbuf[200], fpath[100]; - ptime = localtime(&now); + ptime = localtime4(&now); setuserfile(fpath, "talk_XXXXXX"); flog = fdopen(mkstemp(fpath), "w"); @@ -1630,7 +1630,7 @@ friend_descript(userinfo_t * uentp, char *desc_buf, int desc_buflen) /* XXX 為什麼 diff 是 time_t */ static char * -descript(int show_mode, userinfo_t * uentp, time_t diff) +descript(int show_mode, userinfo_t * uentp, time4_t diff) { static char description[30]; switch (show_mode) { @@ -2084,7 +2084,7 @@ userlist(void) char skippickup = 0, redraw, redrawall; int page, offset, pickup_way, ch, leave, fri_stat; int nfriend, myfriend, friendme, bfriend, badfriend, i; - time_t lastupdate; + time4_t lastupdate; nPickups = b_lines - 3; currpickup = (pickup_t *)malloc(sizeof(pickup_t) * nPickups); @@ -2561,8 +2561,9 @@ userlist(void) } else { deumoney(uentp->uid, ch - give_tax(ch)); log_file(FN_MONEY, LOG_CREAT | LOG_VF, - "%s\t給%s\t%d\t%s\n", cuser.userid, - uentp->userid, ch, ctime(&currutmp->lastact)); + "%s\t給%s\t%d\t%s\n", cuser.userid, + uentp->userid, ch, + Cdate(&currutmp->lastact)); mail_redenvelop(cuser.userid, uentp->userid, ch - give_tax(ch), 'Y'); vmsg(" 嗯..還剩下 %d 錢..", demoney(-ch)); diff --git a/mbbsd/user.c b/mbbsd/user.c index f5ddac6f..7123d057 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -102,9 +102,9 @@ user_display(userec_t * u, int real) prints(" 小 天 使: %s\n", u->myangel[0] ? u->myangel : "無"); #endif - prints(" 註冊日期: %s", ctime(&u->firstlogin)); - prints(" 前次光臨: %s", ctime(&u->lastlogin)); - prints(" 前次點歌: %s", ctime(&u->lastsong)); + prints(" 註冊日期: %s", Cdate(&u->firstlogin)); + prints(" 前次光臨: %s", Cdate(&u->lastlogin)); + prints(" 前次點歌: %s", Cdate(&u->lastsong)); prints(" 上站文章: %d 次 / %d 篇\n", u->numlogins, u->numposts); @@ -183,7 +183,7 @@ mail_violatelaw(char *crime, char *police, char *reason, char *result) "\033[1;32m%s\033[m判決:\n \033[1;32m%s\033[m" "因\033[1;35m%s\033[m行為,\n違反本站站規,處以\033[1;35m%s\033[m,特此通知" "\n請到 PttLaw 查詢相關法規資訊,並到 Play-Pay-ViolateLaw 繳交罰單", - ctime(&now), police, crime, reason, result); + Cdate(&now), police, crime, reason, result); fclose(fp); strcpy(fhdr.title, "[報告] 違法判決報告"); strcpy(fhdr.owner, "[Ptt法院]"); @@ -744,7 +744,7 @@ uinfo_query(userec_t * u, int real, int unum) "時間: %s\n" " 站長\033[1;32m%s\033[m把\033[1;32m%s\033[m" "的錢從\033[1;35m%d\033[m改成\033[1;35m%d\033[m", - ctime(&now), cuser.userid, x.userid, money, x.money); + Cdate(&now), cuser.userid, x.userid, money, x.money); clrtobot(); clear(); @@ -1165,7 +1165,7 @@ toregister(char *email, char *genbuf, char *phone, char *career, REGFORM2: if (strcasecmp(email, "x") == 0) { /* 手動認證 */ if ((fn = fopen(fn_register, "a"))) { - fprintf(fn, "num: %d, %s", usernum, ctime(&now)); + fprintf(fn, "num: %d, %s\n", usernum, Cdate(&now)); fprintf(fn, "uid: %s\n", cuser.userid); fprintf(fn, "ident: %s\n", ident); fprintf(fn, "name: %s\n", rname); diff --git a/mbbsd/var.c b/mbbsd/var.c index 6ee9f2ff..cb422966 100644 --- a/mbbsd/var.c +++ b/mbbsd/var.c @@ -93,9 +93,9 @@ char currBM[IDLEN * 3 + 10]; const char reset_color[4] = "\033[m"; char margs[64] = "\0"; /* main argv list */ pid_t currpid; /* current process ID */ -time_t login_start_time; -time_t start_time; -time_t paste_time; +time4_t login_start_time; +time4_t start_time; +time4_t paste_time; userec_t cuser; /* current user structure */ userec_t xuser; /* lookup user structure */ crosspost_t postrecord; /* anti cross post */ @@ -332,7 +332,7 @@ int scrollrevlen = 2; int automargins = 1; /* io.c */ -time_t now; +time4_t now; int KEY_ESC_arg; int watermode = -1; int wmofo = NOTREPLYING; @@ -366,7 +366,7 @@ int class_bid = 0; /* brc.c */ int brc_num; -time_t brc_list[BRC_MAXNUM]; +time4_t brc_list[BRC_MAXNUM]; /* read.c */ int TagNum; /* tag's number */ @@ -379,7 +379,7 @@ char currdirect[64]; char save_title[STRLEN]; /* bbs.c */ -time_t board_visit_time; +time4_t board_visit_time; char real_name[IDLEN + 1]; char local_article; diff --git a/mbbsd/vote.c b/mbbsd/vote.c index 493858b1..5dd74229 100644 --- a/mbbsd/vote.c +++ b/mbbsd/vote.c @@ -169,7 +169,7 @@ static void vote_report(char *bname, char *fname, char *fpath) { register char *ip; - time_t dtime; + time4_t dtime; int fd, bid; fileheader_t header; @@ -181,7 +181,7 @@ vote_report(char *bname, char *fname, char *fpath) dtime = now; for (;;) { - sprintf(ip, "M.%ld.A", ++dtime); + sprintf(ip, "M.%d.A", (int)++dtime); fd = open(fpath, O_CREAT | O_EXCL | O_WRONLY, 0644); if (fd >= 0) break; @@ -198,7 +198,7 @@ vote_report(char *bname, char *fname, char *fpath) strlcpy(header.owner, "[馬路探子]", sizeof(header.owner)); snprintf(header.title, sizeof(header.title), "[%s] 看板 選情報導", bname); { - register struct tm *ptime = localtime(&dtime); + register struct tm *ptime = localtime4(&dtime); snprintf(header.date, sizeof(header.date), "%2d/%02d", ptime->tm_mon + 1, ptime->tm_mday); @@ -231,7 +231,7 @@ b_result_one(vote_buffer_t *vbuf, boardheader_t * fh, int ind, int *total) char b_control[64]; char b_newresults[64]; char b_report[64]; - time_t closetime; + time4_t closetime; fh->bvote--; @@ -252,7 +252,7 @@ b_result_one(vote_buffer_t *vbuf, boardheader_t * fh, int ind, int *total) cfp = convert_to_newversion(cfp, buf, b_control); #endif assert(cfp); - fscanf(cfp, "%hd,%hd\n%lu\n", &item_num, &junk, &closetime); + fscanf(cfp, "%hd,%hd\n%d\n", &item_num, &junk, &closetime); fclose(cfp); // prevent death caused by a bug, it should be remove later. @@ -288,7 +288,7 @@ b_result_one(vote_buffer_t *vbuf, boardheader_t * fh, int ind, int *total) fclose(xfp); } fprintf(tfp, "%s\n◆ 投票中止於: %s\n\n◆ 票選題目描述:\n\n", - msg_seperator, ctime(&closetime)); + msg_seperator, Cdate(&closetime)); fh->vtime = now; setbfile(buf, bname, vbuf->desc); @@ -346,7 +346,7 @@ static void b_result(vote_buffer_t *vbuf, boardheader_t * fh) { FILE *cfp; - time_t closetime; + time4_t closetime; int i, total; char buf[STRLEN]; char temp[STRLEN]; @@ -359,7 +359,7 @@ b_result(vote_buffer_t *vbuf, boardheader_t * fh) if (!cfp) continue; fgets(temp, sizeof(temp), cfp); - fscanf(cfp, "%lu\n", &closetime); + fscanf(cfp, "%d\n", &closetime); fclose(cfp); if (closetime < now) b_result_one(vbuf, fh, i, &total); @@ -405,7 +405,7 @@ b_closepolls() } if ((cfp = fopen(fn_vote_polling, "w")) == NULL) return 0; - fprintf(cfp, "%lu\n%s\n", now, ctime(&now)); + fprintf(cfp, "%d\n%s\n", now, Cdate(&now)); fclose(cfp); #endif @@ -441,7 +441,7 @@ vote_view(vote_buffer_t *vbuf, char *bname, int vote_index) char buf[STRLEN], genbuf[STRLEN], inbuf[STRLEN]; short item_num, i; int num = 0, pos, *counts, total; - time_t closetime; + time4_t closetime; snprintf(vbuf->ballots, sizeof(vbuf->ballots),"%s%d", STR_bv_ballots, vote_index); snprintf(vbuf->control, sizeof(vbuf->control), "%s%d", STR_bv_control, vote_index); @@ -471,12 +471,12 @@ vote_view(vote_buffer_t *vbuf, char *bname, int vote_index) fp = convert_to_newversion(fp, buf, genbuf); #endif assert(fp); - fscanf(fp, "%hd,%hd\n%lu\n", &item_num, &i, &closetime); + fscanf(fp, "%hd,%hd\n%d\n", &item_num, &i, &closetime); counts = (int *)malloc(item_num * sizeof(int)); prints("\n◆ 預知投票紀事: 每人最多可投 %d 票,目前共有 %d 票,\n" "本次投票將結束於 %s", atoi(inbuf), (int)(num / sizeof(short)), - ctime(&closetime)); + Cdate(&closetime)); /* Thor: 開放 票數 預知 */ setbfile(buf, bname, vbuf->flags); @@ -597,7 +597,7 @@ vote_maintain(char *bname) FILE *fp = NULL; char inbuf[STRLEN], buf[STRLEN]; int num = 0, aborted, pos, x, i; - time_t closetime; + time4_t closetime; boardheader_t *fhp; char genbuf[4]; vote_buffer_t vbuf; @@ -717,7 +717,7 @@ vote_maintain(char *bname) setbfile(buf, bname, vbuf.control); fp = fopen(buf, "w"); assert(fp); - fprintf(fp, "000,000\n%lu\n", closetime); + fprintf(fp, "000,000\n%d\n", closetime); outs("\n請依序輸入選項, 按 ENTER 完成設定"); num = 0; @@ -803,7 +803,7 @@ user_vote_one(vote_buffer_t *vbuf, char *bname, int ind) short pos = 0, i = 0, count, tickets, fd; short curr_page, item_num, max_page; char inbuf[80], choices[31], vote[4], *chosen; - time_t closetime; + time4_t closetime; snprintf(vbuf->ballots, sizeof(vbuf->ballots), "%s%d", STR_bv_ballots, ind); snprintf(vbuf->control, sizeof(vbuf->control), "%s%d", STR_bv_control, ind); @@ -848,7 +848,7 @@ user_vote_one(vote_buffer_t *vbuf, char *bname, int ind) cfp = convert_to_newversion(cfp, buf, inbuf); #endif assert(cfp); - fscanf(cfp, "%hd,%hd\n%lu\n", &item_num, &tickets, &closetime); + fscanf(cfp, "%hd,%hd\n%d\n", &item_num, &tickets, &closetime); chosen = (char *)malloc(item_num); memset(chosen, 0, item_num); memset(choices, 0, sizeof(choices)); @@ -857,7 +857,7 @@ user_vote_one(vote_buffer_t *vbuf, char *bname, int ind) prints("投票方式:確定好您的選擇後,輸入其代碼(A, B, C...)即可。\n" "此次投票你可以投 %1hd 票。按 0 取消投票, 1 完成投票, > 下一頁, < 上一頁\n" "此次投票將結束於:%s \n", - tickets, ctime(&closetime)); + tickets, Cdate(&closetime)); #define REDO_DRAW 1 #define REDO_SCAN 2 diff --git a/mbbsd/voteboard.c b/mbbsd/voteboard.c index 8fba9b9e..21dcc721 100644 --- a/mbbsd/voteboard.c +++ b/mbbsd/voteboard.c @@ -15,7 +15,7 @@ do_voteboardreply(fileheader_t * fhdr) fileheader_t votefile; int yes=0, no=0, len; int fd; - time_t endtime=0; + time4_t endtime=0; clear(); @@ -55,7 +55,7 @@ do_voteboardreply(fileheader_t * fhdr) if (!strncmp(genbuf, "連署結束時間", 12)) { ptr = strchr(genbuf, '('); assert(ptr); - sscanf(ptr + 1, "%ld", &endtime); + sscanf(ptr + 1, "%d", &endtime); if (endtime < now) { vmsg("連署時間已過"); fclose(fi); @@ -110,7 +110,7 @@ do_voteboardreply(fileheader_t * fhdr) } if (!endtime) { now += 14 * 24 * 60 * 60; - fprintf(fo, "連署結束時間: (%ld)%s", now, ctime(&now)); + fprintf(fo, "連署結束時間: (%d)%s\n", now, Cdate(&now)); now -= 14 * 24 * 60 * 60; } fputs(genbuf, fo); @@ -319,9 +319,10 @@ do_voteboard(int type) return FULLUPDATE; strcat(genbuf, "連署結束時間: "); now += 14 * 24 * 60 * 60; - snprintf(topic, sizeof(topic), "(%ld)", now); + snprintf(topic, sizeof(topic), "(%d)", now); strcat(genbuf, topic); - strcat(genbuf, ctime(&now)); + strcat(genbuf, Cdate(&now)); + strcat(genbuf, "\n"); now -= 14 * 24 * 60 * 60; strcat(genbuf, "----------支持----------\n"); strcat(genbuf, "----------反對----------\n"); @@ -333,10 +334,10 @@ do_voteboard(int type) outs("開檔失敗,請稍候重來一次"); return FULLUPDATE; } - fprintf(fp, "%s%s %s%s\n%s%s\n%s%s", "作者: ", cuser.userid, + fprintf(fp, "%s%s %s%s\n%s%s\n%s%s\n", "作者: ", cuser.userid, "看板: ", currboard, "標題: ", title, - "時間: ", ctime(&now)); + "時間: ", Cdate(&now)); fprintf(fp, "%s\n", genbuf); fclose(fp); strlcpy(votefile.owner, cuser.userid, sizeof(votefile.owner)); diff --git a/mbbsd/xyz.c b/mbbsd/xyz.c index 3cbeee41..b757392d 100644 --- a/mbbsd/xyz.c +++ b/mbbsd/xyz.c @@ -172,7 +172,7 @@ note() FILE *fp, *foo; typedef struct notedata_t { - time_t date; + time4_t date; char userid[IDLEN + 1]; char username[19]; char buf[3][80]; |