summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-01-24 22:06:48 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-01-24 22:06:48 +0800
commit9084d9602e8725a6fb832d4396c12ddd7bb2b7c7 (patch)
tree78d04dab42a50e73845c8e31eb877001fb8379cd
parentf6324fdcb56a70815842cc39cb1826ce6b82148c (diff)
downloadpttbbs-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
-rw-r--r--include/bbs.h1
-rw-r--r--include/proto.h30
-rw-r--r--include/pttstruct.h70
-rw-r--r--mbbsd/admin.c6
-rw-r--r--mbbsd/announce.c6
-rw-r--r--mbbsd/bbs.c20
-rw-r--r--mbbsd/board.c4
-rw-r--r--mbbsd/brc.c56
-rw-r--r--mbbsd/cache.c4
-rw-r--r--mbbsd/cal.c8
-rw-r--r--mbbsd/calendar.c2
-rw-r--r--mbbsd/chicken.c12
-rw-r--r--mbbsd/dice.c2
-rw-r--r--mbbsd/edit.c8
-rw-r--r--mbbsd/fav.c6
-rw-r--r--mbbsd/go.c8
-rw-r--r--mbbsd/io.c2
-rw-r--r--mbbsd/kaede.c4
-rw-r--r--mbbsd/lovepaper.c2
-rw-r--r--mbbsd/mail.c2
-rw-r--r--mbbsd/mbbsd.c12
-rw-r--r--mbbsd/menu.c2
-rw-r--r--mbbsd/merge.c26
-rw-r--r--mbbsd/read.c2
-rw-r--r--mbbsd/record.c14
-rw-r--r--mbbsd/register.c8
-rw-r--r--mbbsd/stuff.c41
-rw-r--r--mbbsd/syspost.c11
-rw-r--r--mbbsd/talk.c13
-rw-r--r--mbbsd/user.c12
-rw-r--r--mbbsd/var.c12
-rw-r--r--mbbsd/vote.c34
-rw-r--r--mbbsd/voteboard.c15
-rw-r--r--mbbsd/xyz.c2
-rw-r--r--util/account.c12
-rw-r--r--util/angel.c6
-rw-r--r--util/buildir.c4
-rw-r--r--util/checkdir.c1
-rw-r--r--util/chkhbf.c1
-rw-r--r--util/countalldice.c6
-rw-r--r--util/descrypt.c9
-rw-r--r--util/indexuser.c2
-rw-r--r--util/initbbs.c11
-rw-r--r--util/merge_board.c10
-rw-r--r--util/merge_passwd.c10
-rw-r--r--util/openticket.c2
-rw-r--r--util/passwdconverter.c6
-rw-r--r--util/poststat.c8
-rw-r--r--util/r2014convert.c2
-rw-r--r--util/reaper.c7
-rw-r--r--util/shmctl.c6
-rw-r--r--util/shmsweep.c9
-rw-r--r--util/showboard.c10
-rw-r--r--util/toplazyBM.c2
-rw-r--r--util/uhash_loader.c29
-rw-r--r--util/userlist.c12
-rw-r--r--util/xchatd.c19
-rw-r--r--util/yearsold.c4
58 files changed, 305 insertions, 340 deletions
diff --git a/include/bbs.h b/include/bbs.h
index 3a2f0cb9..654bb83c 100644
--- a/include/bbs.h
+++ b/include/bbs.h
@@ -37,6 +37,7 @@
#include <sys/sem.h>
#include <sys/msg.h>
+typedef uint32_t time4_t;
/* our header */
#include "config.h"
diff --git a/include/proto.h b/include/proto.h
index 66cd63ea..acc01f55 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -85,13 +85,13 @@ void sigfree(int);
/* brc */
int brc_initialize(void);
void brc_finalize(void);
-int brc_unread(const char *fname, int bnum, const time_t *blist);
-int brc_unread_time(time_t ftime, int bnum, const time_t *blist);
+int brc_unread(const char *fname, int bnum, const time4_t *blist);
+int brc_unread_time(time4_t ftime, int bnum, const time4_t *blist);
int brc_initial_board(const char *boardname);
void brc_update(void);
-int brc_read_record(int bid, int *num, time_t *list);
-time_t * brc_find_record(int bid, int *num);
-void brc_trunc(int bid, time_t ftime);
+int brc_read_record(int bid, int *num, time4_t *list);
+time4_t * brc_find_record(int bid, int *num);
+void brc_trunc(int bid, time4_t ftime);
void brc_addlist(const char* fname);
/* cache */
@@ -216,8 +216,8 @@ fav_type_t *getadmtag(short bid);
fav_type_t *getboard(short bid);
fav_type_t *getfolder(short fid);
char getbrdattr(short bid);
-time_t getbrdtime(short bid);
-void setbrdtime(short bid, time_t t);
+time4_t getbrdtime(short bid);
+void setbrdtime(short bid, time4_t t);
int fav_getid(fav_type_t *ft);
void fav_tag(short id, char type, char bool);
void move_in_current_folder(int from, int to);
@@ -301,7 +301,7 @@ int Rename(char* src, char* dst);
int Copy(char *src, char *dst);
int Link(char* src, char* dst);
char *Ptt_prints(char *str, int mode);
-char *my_ctime(const time_t *t, char *ans, int len);
+char *my_ctime(const time4_t *t, char *ans, int len);
/* lovepaper */
int x_love(void);
@@ -434,7 +434,7 @@ int main_railway(void);
void i_read(int cmdmode, char *direct, void (*dotitle)(), void (*doentry)(), const onekey_t *rcmdlist, int bidcache);
void fixkeep(char *s, int first);
keeploc_t *getkeep(char *s, int def_topline, int def_cursline);
-int Tagger(time_t chrono, int recno, int mode);
+int Tagger(time4_t chrono, int recno, int mode);
void EnumTagFhdr(fileheader_t *fhdr, char *direct, int locus);
void UnTagger (int locus);
/* record */
@@ -510,7 +510,7 @@ void screen_restore(int len, screenline_t *bp, void *buf);
int vmsg_lines(int lines, const char *msg);
int log_user(const char *fmt, ...) GCC_CHECK_FORMAT(1,2);
unsigned int ipstr2int(char *ip);
-time_t gettime(int line, time_t dt, char* head);
+time4_t gettime(int line, time4_t dt, char* head);
void setcalfile(char *buf, char *userid);
void stand_title(char *title);
char getans(const char *fmt,...) GCC_CHECK_FORMAT(1,2);
@@ -523,7 +523,7 @@ void setbpath(char *buf, const char *boardname);
int dashf(char *fname);
void sethomepath(char *buf, const char *userid);
void sethomedir(char *buf, const char *userid);
-char *Cdate(time_t *clock);
+char *Cdate(time4_t *clock);
void sethomefile(char *buf, const char *userid, const char *fname);
int log_file(char *fn, int flag, const char *fmt,...);
void str_lower(char *t, char *s);
@@ -532,7 +532,7 @@ int cursor_key(int row, int column);
int search_num(int ch, int max);
void setuserfile(char *buf, const char *fname);
int is_BM(char *list);
-time_t dasht(char *fname);
+time4_t dasht(char *fname);
int dashd(char *fname);
int invalid_pname(char *str);
void setbdir(char *buf, const char *boardname);
@@ -546,13 +546,13 @@ void show_help(char * const helptext[]);
void show_helpfile(const char * helpfile);
int copy_file(char *src, char *dst);
int belong(char *filelist, char *key);
-char *Cdatedate(time_t *clock);
+char *Cdatedate(time4_t *clock);
void sethomeman(char *buf, const char *userid);
off_t dashs(char *fname);
void cursor_clear(int row, int column);
void cursor_show(int row, int column);
void printdash(char *mesg);
-char *Cdatelite(time_t *clock);
+char *Cdatelite(time4_t *clock);
int valid_ident(char *ident);
int userid_is_BM(char *userid, char *list);
int is_uBM(char *list, char *id);
@@ -574,6 +574,8 @@ int towrite(int fd, void *buf, int len);
#ifdef PLAY_ANGEL
void pressanykey_or_callangel(void);
#endif
+struct tm *localtime4(time4_t *);
+time4_t time4(time4_t *);
/* syspost */
int post_msg(char* bname, char* title, char *msg, char* author);
diff --git a/include/pttstruct.h b/include/pttstruct.h
index bbc277dc..b8b714a9 100644
--- a/include/pttstruct.h
+++ b/include/pttstruct.h
@@ -8,16 +8,16 @@
/* 競標資訊 */
#define SALE_COMMENTED 0x1
typedef struct bid_t {
- int high;
- int buyitnow;
- int usermax;
- int increment;
- char userid[IDLEN + 1];
- time_t enddate;
- char payby; /* 1 cash 2 check or mail 4 wire 8 credit 16 postoffice */
- char flag;
- char pad[2];
- int shipping;
+ int high;
+ int buyitnow;
+ int usermax;
+ int increment;
+ char userid[IDLEN + 1];
+ time4_t enddate;
+ char payby; /* 1 cash 2 check or mail 4 wire 8 credit 16 postoffice */
+ char flag;
+ char pad[2];
+ int shipping;
}bid_t;
/* 小雞的資料 */
@@ -25,8 +25,8 @@ typedef struct chicken_t {
char name[20];
char type; /* 物種 */
unsigned char tech[16]; /* 技能 */
- time_t birthday; /* 生日 */
- time_t lastvisit; /* 上次照顧時間 */
+ time4_t birthday; /* 生日 */
+ time4_t lastvisit; /* 上次照顧時間 */
int oo; /* 補品 */
int food; /* 食物 */
int medicine; /* 藥品 */
@@ -44,7 +44,7 @@ typedef struct chicken_t {
int hp_max; /* 滿血量 */
int mm; /* 法力 */
int mm_max; /* 滿法力 */
- time_t cbirth; /* 實際計算用的生日 */
+ time4_t cbirth; /* 實際計算用的生日 */
int pad[2]; /* 留著以後用 */
} chicken_t;
@@ -66,8 +66,8 @@ typedef struct userec_t {
unsigned int userlevel;
unsigned int numlogins;
unsigned int numposts;
- time_t firstlogin;
- time_t lastlogin;
+ time4_t firstlogin;
+ time4_t lastlogin;
char lasthost[16];
int money;
char remoteuser[3]; /* 保留 目前沒用到的 */
@@ -84,7 +84,7 @@ typedef struct userec_t {
unsigned char invisible;
unsigned int exmailbox;
chicken_t mychicken;
- time_t lastsong;
+ time4_t lastsong;
unsigned int loginview;
unsigned char channel; /* 動態看板 (unused?) */
unsigned short vl_count; /* ViolateLaw counter */
@@ -168,12 +168,12 @@ typedef struct boardheader_t {
unsigned char vote_limit_posts; /* 連署 : 文章篇數下限 */
unsigned char vote_limit_logins; /* 連署 : 登入次數下限 */
char pad[1]; /* 沒用到的 */
- time_t bupdate; /* note update time */
+ time4_t bupdate; /* note update time */
unsigned char post_limit_posts; /* 發表文章 : 文章篇數下限 */
unsigned char post_limit_logins; /* 發表文章 : 登入次數下限 */
char pad2[1]; /* 沒用到的 */
unsigned char bvote; /* 正舉辦 Vote 數 */
- time_t vtime; /* Vote close time */
+ time4_t vtime; /* Vote close time */
unsigned int level; /* 可以看此板的權限 */
int unused; /* 還沒用到 */
int gid; /* 看板所屬的類別 ID */
@@ -183,7 +183,7 @@ typedef struct boardheader_t {
int childcount; /* 有多少個child */
int nuser; /* 多少人在這板 */
int postexpire; /* postexpire */
- time_t endgamble;
+ time4_t endgamble;
char posttype[33];
char posttype_f;
char pad3[50];
@@ -358,7 +358,7 @@ typedef struct userinfo_t {
char msgcount;
msgque_t msgs[MAX_MSGS];
unsigned int withme;
- time_t lastact; /* 上次使用者動的時間 */
+ time4_t lastact; /* 上次使用者動的時間 */
unsigned int brc_id;
unsigned char lockmode; /* 不准 multi_login 玩的東西 */
char turn; /* for gomo */
@@ -386,7 +386,7 @@ typedef struct userinfo_t {
char color;
char mind[4];
#ifdef NOKILLWATERBALL
- time_t wbtime;
+ time4_t wbtime;
#endif
} userinfo_t;
@@ -457,7 +457,7 @@ typedef struct {
/* 第一維double buffer 由currsorted指向目前使用的
第二維sort type */
int currsorted;
- time_t UTMPuptime;
+ time4_t UTMPuptime;
int UTMPnumber;
char UTMPneedsort;
char UTMPbusystate;
@@ -470,16 +470,16 @@ typedef struct {
unsigned char nHOTs;
int HBcache[HOTBOARDCACHE];
#endif
- time_t busystate_b[MAX_BOARD];
+ time4_t busystate_b[MAX_BOARD];
int total[MAX_BOARD];
unsigned char n_bottom[MAX_BOARD]; /* number of bottom */
int hbfl[MAX_BOARD][MAX_FRIEND + 1];
- time_t lastposttime[MAX_BOARD];
- time_t Buptime;
- time_t Btouchtime;
+ time4_t lastposttime[MAX_BOARD];
+ time4_t Buptime;
+ time4_t Btouchtime;
int Bnumber;
int Bbusystate;
- time_t close_vote_time;
+ time4_t close_vote_time;
/* pttcache */
char notes[MAX_MOVIE][200*11];
@@ -489,8 +489,8 @@ typedef struct {
msgque_t loginmsg; /* 進站水球 */
int max_film;
int max_history;
- time_t Puptime;
- time_t Ptouchtime;
+ time4_t Puptime;
+ time4_t Ptouchtime;
int Pbusystate;
int GLOBALVAR[10]; /* mbbsd間的 global variable
@@ -503,7 +503,7 @@ typedef struct {
int toomanyusers; /* 超過人數上限不給進的個數 */
int noonlineuser; /* 站上使用者不高亮度顯示 */
#ifdef OUTTA_TIMER
- time_t now;
+ time4_t now;
#endif
int nWelcomes;
} e;
@@ -516,9 +516,9 @@ typedef struct {
int home_num;
int max_user;
- time_t max_time;
- time_t Fuptime;
- time_t Ftouchtime;
+ time4_t max_time;
+ time4_t Fuptime;
+ time4_t Ftouchtime;
int Fbusystate;
#ifdef I18N
@@ -567,7 +567,7 @@ typedef struct commands_t {
typedef struct MailQueue {
char filepath[FNLEN];
char subject[STRLEN];
- time_t mailtime;
+ time4_t mailtime;
char sender[IDLEN + 1];
char username[24];
char rcpt[50];
@@ -579,7 +579,7 @@ enum {MQ_TEXT, MQ_UUENCODE, MQ_JUSTIFY};
typedef struct
{
- time_t chrono;
+ time4_t chrono;
int recno;
} TagItem;
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 {
diff --git a/mbbsd/go.c b/mbbsd/go.c
index e4918076..203e983a 100644
--- a/mbbsd/go.c
+++ b/mbbsd/go.c
@@ -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);
diff --git a/mbbsd/io.c b/mbbsd/io.c
index 3ad264b9..690b7351 100644
--- a/mbbsd/io.c
+++ b/mbbsd/io.c
@@ -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];
diff --git a/util/account.c b/util/account.c
index 1c9ce127..c15411b8 100644
--- a/util/account.c
+++ b/util/account.c
@@ -98,14 +98,14 @@ main(int argc, char **argv)
char buf[256], buf1[256], *p;
FILE *fp, *fp1;
int act[27]; /* 次數/累計時間/pointer */
- time_t now;
+ time4_t now;
struct tm *ptime;
attach_SHM();
nice(10);
chdir(BBSHOME);
now = time(NULL) - ADJUST_M * 60; /* back to ancent */
- ptime = localtime(&now);
+ ptime = localtime4(&now);
memset(act, 0, sizeof(act));
printf("次數/累計時間\n");
@@ -205,7 +205,7 @@ main(int argc, char **argv)
printf("此時段最多同時上線:%d 過去:%d\n", a = SHM->max_user, k);
fclose(fp);
if (a > k) {
- ptime = localtime(&SHM->max_time);
+ ptime = localtime4(&SHM->max_time);
if ((fp1 = fopen("etc/history", "a"))) {
fprintf(fp1,
"◎ 【%02d/%02d/%02d %02d:%02d】"
@@ -222,7 +222,7 @@ main(int argc, char **argv)
} else
fclose(fp);
}
- ptime = localtime(&now);
+ ptime = localtime4(&now);
if (ptime->tm_hour) {
/* rotate one line in today_is */
@@ -254,7 +254,7 @@ main(int argc, char **argv)
printf("壓縮使用者上線監控\n");
/* Ptt 歷史事件處理 */
now = time(NULL) - ADJUST_M * 60; /* back to ancent */
- ptime = localtime(&now);
+ ptime = localtime4(&now);
attach_SHM();
if ((fp = fopen("etc/history.data", "r"))) { /* 單日最多次人次,同時上線
@@ -288,7 +288,7 @@ main(int argc, char **argv)
fclose(fp);
}
now += ADJUST_M * 60; /* back to future */
- ptime = localtime(&now);
+ ptime = localtime4(&now);
/* Ptt 節日處理 */
printf("節日處理\n");
diff --git a/util/angel.c b/util/angel.c
index 57417d0e..f074285f 100644
--- a/util/angel.c
+++ b/util/angel.c
@@ -114,7 +114,7 @@ int mailalertuser(char* userid)
void sendResult(){
int i;
FILE* fp;
- time_t t;
+ time4_t t;
fileheader_t header;
struct stat st;
char filename[512];
@@ -138,13 +138,13 @@ void sendResult(){
return;
}
- time(&t);
+ t = time(NULL);
fprintf(fp, "作者: Ptt 站方統計\n"
"標題: 小天使統計資料\n"
"時間: %s\n"
"\n現在全站小天使有 %d 位\n"
"\n小主人人數最多的 %d 位小天使:\n",
- ctime(&t), count, nReport);
+ Cdate(&t), count, nReport);
for (i = 0; i < nReport; ++i)
fprintf(fp, "%15s %5d 人\n", SHM->userid[list[i][1] - 1], list[i][0]);
fprintf(fp, "\n現在男女皆收的小天使有 %d 位\n"
diff --git a/util/buildir.c b/util/buildir.c
index cc69f57e..cccc8c8a 100644
--- a/util/buildir.c
+++ b/util/buildir.c
@@ -50,7 +50,7 @@ int main(int argc, char **argv)
if(stat(path, &st) == 0 && st.st_size > 0 &&
(fp = fopen(path, "r")) != NULL) {
char buf[512];
- time_t filetime;
+ time4_t filetime;
fileheader_t fhdr;
memset(&fhdr, 0, sizeof(fhdr));
@@ -60,7 +60,7 @@ int main(int argc, char **argv)
/* set file time */
filetime = atoi(dirlist[count]->d_name + 2);
if(filetime > 740000000) {
- struct tm *ptime = localtime(&filetime);
+ struct tm *ptime = localtime4(&filetime);
sprintf(fhdr.date, "%2d/%02d", ptime->tm_mon + 1,
ptime->tm_mday);
} else
diff --git a/util/checkdir.c b/util/checkdir.c
index bbb0b40e..5c98a874 100644
--- a/util/checkdir.c
+++ b/util/checkdir.c
@@ -63,6 +63,7 @@ int main(int argc, char **argv) {
continue;
}
pfh=fh;
+fh.recommend =0;
if(fo)
fwrite(&fh, sizeof(fh), 1, fo);
}
diff --git a/util/chkhbf.c b/util/chkhbf.c
index e63c13fe..2d416de1 100644
--- a/util/chkhbf.c
+++ b/util/chkhbf.c
@@ -5,7 +5,6 @@ struct {
char userid[IDLEN + 1];
time_t lastlogin, expire;
} explist[MAX_FRIEND];
-time_t now;
void usage(void)
{
diff --git a/util/countalldice.c b/util/countalldice.c
index 63354668..45944362 100644
--- a/util/countalldice.c
+++ b/util/countalldice.c
@@ -7,11 +7,7 @@
/*作者:Heat 於1997/10/2 */
/**********************************************/
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include "config.h"
+#include "bbs.h"
#define DICE_WIN BBSHOME "/etc/windice.log"
#define DICE_LOST BBSHOME "/etc/lostdice.log"
diff --git a/util/descrypt.c b/util/descrypt.c
index 6ea6dbe8..ecac9001 100644
--- a/util/descrypt.c
+++ b/util/descrypt.c
@@ -357,9 +357,12 @@ static int des_setkey(const char *key) {
if(!des_initialised)
des_init();
-
- rawkey0 = ntohl(*(unsigned long *) key);
- rawkey1 = ntohl(*(unsigned long *) (key + 4));
+
+#ifdef __linux__
+#include <netinet/in.h>
+#endif
+ rawkey0 = ntohl(*(uint32_t*) key);
+ rawkey1 = ntohl(*(uint32_t*) (key + 4));
if((rawkey0 | rawkey1)
&& rawkey0 == old_rawkey0
diff --git a/util/indexuser.c b/util/indexuser.c
index 8dde8f06..cc5ba78a 100644
--- a/util/indexuser.c
+++ b/util/indexuser.c
@@ -11,7 +11,7 @@ unsigned string_hash(unsigned char *s)
v = (v << 8) | (v >> 24);
v ^= toupper(*s++); /* note this is case insensitive */
}
- return (v * 2654435769UL) >> (32 - HASH_BITS);
+ return (v * 2654435769U) >> (32 - HASH_BITS);
}
diff --git a/util/initbbs.c b/util/initbbs.c
index f952b7ef..d1cddc1a 100644
--- a/util/initbbs.c
+++ b/util/initbbs.c
@@ -1,14 +1,5 @@
/* $Id$ */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include "config.h"
-#include "pttstruct.h"
-#include "perm.h"
+#include "bbs.h"
static void initDir() {
mkdir("adm", 0755);
diff --git a/util/merge_board.c b/util/merge_board.c
index 12f41346..4fc643c1 100644
--- a/util/merge_board.c
+++ b/util/merge_board.c
@@ -1,11 +1,5 @@
/* $Id$ */
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-#include <sys/types.h>
-#include "config.h"
-#include "pttstruct.h"
+#include "bbs.h"
typedef struct hash_t {
char *brdname;
@@ -28,7 +22,7 @@ unsigned int string_hash(unsigned char *s) {
v = (v << 8) | (v >> 24);
v ^= toupper(*s++); /* note this is case insensitive */
}
- return (v * 2654435769UL) >> (32 - 16);
+ return (v * 2654435769U) >> (32 - 16);
}
int is_exist(char *brdname) {
diff --git a/util/merge_passwd.c b/util/merge_passwd.c
index 20f59aae..7221e384 100644
--- a/util/merge_passwd.c
+++ b/util/merge_passwd.c
@@ -1,11 +1,5 @@
/* $Id$ */
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-#include <sys/types.h>
-#include "config.h"
-#include "pttstruct.h"
+#include "bbs.h"
typedef struct hash_t {
char *userid;
@@ -28,7 +22,7 @@ unsigned int string_hash(unsigned char *s) {
v = (v << 8) | (v >> 24);
v ^= toupper(*s++); /* note this is case insensitive */
}
- return (v * 2654435769UL) >> (32 - 16);
+ return (v * 2654435769U) >> (32 - 16);
}
int is_exist(char *userid) {
diff --git a/util/openticket.c b/util/openticket.c
index bcc58d0a..10a431d9 100644
--- a/util/openticket.c
+++ b/util/openticket.c
@@ -26,7 +26,7 @@ int main(int argc, char **argv)
int money, bet, n, total = 0, ticket[8] =
{0, 0, 0, 0, 0, 0, 0, 0};
FILE *fp;
- time_t now = time(NULL);
+ time4_t now = (time4_t)time(NULL);
char des[MAX_DES][200] =
{"", "", "", ""};
diff --git a/util/passwdconverter.c b/util/passwdconverter.c
index 85b2cf8f..86836d1f 100644
--- a/util/passwdconverter.c
+++ b/util/passwdconverter.c
@@ -10,8 +10,8 @@ typedef struct old_userec_t {
unsigned int userlevel;
unsigned short numlogins;
unsigned short numposts;
- time_t firstlogin;
- time_t lastlogin;
+ time4_t firstlogin;
+ time4_t lastlogin;
char lasthost[16];
int money;
char remoteuser[3]; /* 靽 桀瘝典啁 */
@@ -28,7 +28,7 @@ typedef struct old_userec_t {
unsigned char invisible;
unsigned int exmailbox;
chicken_t mychicken;
- time_t lastsong;
+ time4_t lastsong;
unsigned int loginview;
unsigned char channel; /* (unused?) */
unsigned short vl_count; /* ViolateLaw counter */
diff --git a/util/poststat.c b/util/poststat.c
index 08b17bc1..abd6ef0f 100644
--- a/util/poststat.c
+++ b/util/poststat.c
@@ -22,7 +22,7 @@ struct postrec
char author[13]; /* author name */
char board[13]; /* board name */
char title[66]; /* title name */
- time_t date; /* last post's date */
+ time4_t date; /* last post's date */
int number; /* post number */
struct postrec *next; /* next rec */
}
@@ -327,7 +327,7 @@ poststat(mytype)
int main(argc, argv)
char *argv[];
{
- time_t now;
+ time4_t now;
struct tm *ptime;
attach_SHM();
@@ -343,8 +343,8 @@ int main(argc, argv)
poststat(atoi(argv[2]));
return (0);
}
- time(&now);
- ptime = localtime(&now);
+ now = (time4_t)time(NULL);
+ ptime = localtime4(&now);
if (ptime->tm_hour == 0)
{
if (ptime->tm_mday == 1)
diff --git a/util/r2014convert.c b/util/r2014convert.c
index 766e6e1e..ca91f4c8 100644
--- a/util/r2014convert.c
+++ b/util/r2014convert.c
@@ -20,7 +20,7 @@ int main(){
return 0;
}
} else {
- time_t t = time(NULL);
+ time4_t t = (time4_t)time(NULL);
char* str = ctime(&t);
write(orig_fd, str, strlen(str));
}
diff --git a/util/reaper.c b/util/reaper.c
index 7904566d..f67d38ac 100644
--- a/util/reaper.c
+++ b/util/reaper.c
@@ -2,7 +2,7 @@
#define _UTIL_C_
#include "bbs.h"
-time_t now;
+time4_t now;
int invalid(char *userid) {
int i;
@@ -17,7 +17,7 @@ int invalid(char *userid) {
}
int check(int n, userec_t *u) {
- time_t d;
+ time4_t d;
char buf[256];
if(u->userid[0] != '\0') {
@@ -32,8 +32,7 @@ int check(int n, userec_t *u) {
int unum;
unum = searchuser(u->userid);
- strcpy(buf, ctime(&u->lastlogin));
- strtok(buf, "\n");
+ strcpy(buf, Cdate(&u->lastlogin));
syslog(LOG_NOTICE, "kill user(%d): %s %s", unum, u->userid, buf);
sprintf(buf, "mv home/%c/%s tmp/", u->userid[0], u->userid);
if(system(buf))
diff --git a/util/shmctl.c b/util/shmctl.c
index 60f31238..143bb64a 100644
--- a/util/shmctl.c
+++ b/util/shmctl.c
@@ -186,10 +186,8 @@ int utmpfix(int argc, char **argv)
if( nownum > lowerbound &&
idle[i].idle >
(timeout == -1 ? IDLE_TIMEOUT : timeout) ){
- sprintf(buf, "timeout(%s",
- ctime(&SHM->uinfo[which].lastact));
- buf[strlen(buf) - 1] = 0;
- strcat(buf, ")");
+ sprintf(buf, "timeout(%s)",
+ Cdate(&SHM->uinfo[which].lastact));
clean = buf;
if( SHM->uinfo[which].pid > 0 )
kill(SHM->uinfo[which].pid, SIGHUP);
diff --git a/util/shmsweep.c b/util/shmsweep.c
index 94d5291a..b448270f 100644
--- a/util/shmsweep.c
+++ b/util/shmsweep.c
@@ -1,11 +1,4 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <sys/stat.h>
-#include "config.h"
-#include "pttstruct.h"
+#include "bbs.h"
int main() {
#if 0
diff --git a/util/showboard.c b/util/showboard.c
index 7dee4002..0b473569 100644
--- a/util/showboard.c
+++ b/util/showboard.c
@@ -1,14 +1,6 @@
/* $Id$ */
/* 看板一覽表(sorted) */
-
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include "config.h"
-#include "pttstruct.h"
+#include "bbs.h"
boardheader_t allbrd[MAX_BOARD];
diff --git a/util/toplazyBM.c b/util/toplazyBM.c
index 7d03c07f..5e74478b 100644
--- a/util/toplazyBM.c
+++ b/util/toplazyBM.c
@@ -45,7 +45,7 @@ int main(int argc, char *argv[])
{
int bmid, i, j=0;
FILE *inf, *firef;
- time_t now=time(NULL);
+ time4_t now=time(NULL);
attach_SHM();
resolve_boards();
diff --git a/util/uhash_loader.c b/util/uhash_loader.c
index 86c47414..add528ba 100644
--- a/util/uhash_loader.c
+++ b/util/uhash_loader.c
@@ -1,28 +1,9 @@
/* $Id$ */
/* standalone uhash loader -- jochang */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-
-#ifdef __FreeBSD__
-#include <machine/param.h>
-#endif
-
-#include "config.h"
-#include "pttstruct.h"
-#include "common.h"
+#include "bbs.h"
unsigned string_hash(unsigned char *s);
-void add_to_uhash(int n, userec_t *id);
+void userec_add_to_uhash(int n, userec_t *id);
void fill_uhash(void);
void load_uhash(void);
@@ -93,7 +74,7 @@ void fill_uhash(void)
for (mimage = fimage; usernumber < fd; mimage += sizeof(userec_t))
{
- add_to_uhash(usernumber, (userec_t *)mimage);
+ userec_add_to_uhash(usernumber, (userec_t *)mimage);
usernumber++;
}
munmap(fimage, stbuf.st_size);
@@ -114,10 +95,10 @@ unsigned string_hash(unsigned char *s)
v = (v << 8) | (v >> 24);
v ^= toupper(*s++); /* note this is case insensitive */
}
- return (v * 2654435769UL) >> (32 - HASH_BITS);
+ return (v * 2654435769U) >> (32 - HASH_BITS);
}
-void add_to_uhash(int n, userec_t *user)
+void userec_add_to_uhash(int n, userec_t *user)
{
int *p, h = string_hash(user->userid);
strcpy(SHM->userid[n], user->userid);
diff --git a/util/userlist.c b/util/userlist.c
index 794a3daf..aa549a8a 100644
--- a/util/userlist.c
+++ b/util/userlist.c
@@ -1,11 +1,5 @@
-/* $id:$ */
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include "config.h"
-#include "pttstruct.h"
+/* $Id$ */
+#include "bbs.h"
SHM_t *SHM;
@@ -33,7 +27,7 @@ int main(int argc, char **argv) {
f = &SHM->uinfo[i];
printf(
- "%4d(%d) p[%d] i[%d] u[%s] n[%s] f[%s] m[%d] t[%ld]\n",
+ "%4d(%d) p[%d] i[%d] u[%s] n[%s] f[%s] m[%d] t[%d]\n",
++counter, i, f->pager, f->invisible, f->userid,
f->username, f->from, f->mode, f->lastact);
}
diff --git a/util/xchatd.c b/util/xchatd.c
index 22be9620..00c897e3 100644
--- a/util/xchatd.c
+++ b/util/xchatd.c
@@ -83,7 +83,7 @@ struct ChatUser
int uflag;
int clitype; /* Xshadow: client type. 1 for common client,
* 0 for bbs only client */
- time_t uptime; /* Thor: unused */
+ time4_t uptime; /* Thor: unused */
char userid[IDLEN + 1]; /* real userid */
char chatid[9]; /* chat id */
char lasthost[30]; /* host address */
@@ -223,12 +223,12 @@ logit(key, msg)
char *key;
char *msg;
{
- time_t now;
+ time4_t now;
struct tm *p;
char buf[512];
- time(&now);
- p = localtime(&now);
+ now = (time4_t)time(NULL);
+ p = localtime4(&now);
sprintf(buf, "%02d/%02d %02d:%02d:%02d %-13s%s\n",
p->tm_mon + 1, p->tm_mday,
p->tm_hour, p->tm_min, p->tm_sec, key, msg);
@@ -821,10 +821,9 @@ exit_room(user, mode, msg)
static char datemsg[32];
char *
-Ctime(clock)
- time_t *clock;
+Ctime(time4_t *clock)
{
- struct tm *t = localtime(clock);
+ struct tm *t = localtime4(clock);
static char week[] = "日一二三四五六";
sprintf(datemsg, "%d年%2d月%2d日%3d:%02d:%02d 星期%.2s",
@@ -891,9 +890,9 @@ chat_date(cu, msg)
ChatUser *cu;
char *msg;
{
- time_t thetime;
+ time4_t thetime;
- time(&thetime);
+ thetime = time(NULL);
sprintf(chatbuf, "◆ 標準時間: %s", Ctime(&thetime));
send_to_user(cu, chatbuf, 0, MSG_MESSAGE);
}
@@ -3288,7 +3287,7 @@ main()
register fd_set *rptr, *xptr;
fd_set rset, xset;
struct timeval tv;
- time_t uptime, tmaintain;
+ time4_t uptime, tmaintain;
msock = start_daemon();
diff --git a/util/yearsold.c b/util/yearsold.c
index a3a78d27..1418cd59 100644
--- a/util/yearsold.c
+++ b/util/yearsold.c
@@ -30,11 +30,11 @@ int main(int argc, char **argv)
FILE *fp;
int year, max, item, maxyear, totalyear;
int act[25];
- time_t now;
+ time4_t now;
struct tm *ptime;
now = time(NULL);
- ptime = localtime(&now);
+ ptime = localtime4(&now);
attach_SHM();
if(passwd_init())