summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mbbsd/admin.c17
-rw-r--r--mbbsd/announce.c7
-rw-r--r--mbbsd/bbs.c14
-rw-r--r--mbbsd/board.c11
-rw-r--r--mbbsd/cache.c10
-rw-r--r--mbbsd/cal.c11
-rw-r--r--mbbsd/calendar.c21
-rw-r--r--mbbsd/chat.c7
-rw-r--r--mbbsd/chc_play.c14
-rw-r--r--mbbsd/chicken.c24
-rw-r--r--mbbsd/dark.c5
-rw-r--r--mbbsd/edit.c5
-rw-r--r--mbbsd/gamble.c5
-rw-r--r--mbbsd/gomo.c15
-rw-r--r--mbbsd/io.c41
-rw-r--r--mbbsd/kaede.c4
-rw-r--r--mbbsd/lovepaper.c7
-rw-r--r--mbbsd/mail.c35
-rw-r--r--mbbsd/mbbsd.c12
-rw-r--r--mbbsd/menu.c12
-rw-r--r--mbbsd/more.c6
-rw-r--r--mbbsd/record.c15
-rw-r--r--mbbsd/register.c9
-rw-r--r--mbbsd/syspost.c8
-rw-r--r--mbbsd/talk.c29
-rw-r--r--mbbsd/user.c12
-rw-r--r--mbbsd/vote.c18
-rw-r--r--mbbsd/voteboard.c6
-rw-r--r--mbbsd/xyz.c6
29 files changed, 148 insertions, 238 deletions
diff --git a/mbbsd/admin.c b/mbbsd/admin.c
index 66043aa4..f97a3603 100644
--- a/mbbsd/admin.c
+++ b/mbbsd/admin.c
@@ -1,4 +1,4 @@
-/* $Id: admin.c,v 1.10 2002/05/10 19:34:51 in2 Exp $ */
+/* $Id: admin.c,v 1.11 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -19,7 +19,7 @@ extern char *msg_uid;
extern userec_t xuser;
extern char *err_uid;
extern boardheader_t *bcache;
-
+extern time_t now;
/* 使用者管理 */
int m_user() {
userec_t muser;
@@ -891,8 +891,7 @@ int scan_register_form(char *regfile, int automode, int neednum) {
if((fout = fopen(logfile, "a"))) {
for(n = 0; field[n]; n++)
fprintf(fout, "%s: %s\n", field[n], fdata[n]);
- n = time(NULL);
- fprintf(fout, "Date: %s\n", Cdate((time_t *) & n));
+ fprintf(fout, "Date: %s\n", Cdate(& now));
fprintf(fout, "Rejected: %s [%s]\n----\n",
uid, buf);
fclose(fout);
@@ -926,8 +925,7 @@ int scan_register_form(char *regfile, int automode, int neednum) {
if((fout = fopen(logfile, "a"))) {
for(n = 0; field[n]; n++)
fprintf(fout, "%s: %s\n", field[n], fdata[n]);
- n = time(NULL);
- fprintf(fout, "Date: %s\n", Cdate((time_t *) & n));
+ fprintf(fout, "Date: %s\n", Cdate(&now));
fprintf(fout, "Approved: %s\n", uid);
fprintf(fout, "----\n");
fclose(fout);
@@ -1046,8 +1044,7 @@ int give_money() {
FILE *fp, *fp2;
char *ptr, *id, *mn;
char buf[200] = {0}, tt[TTLEN + 1] = {0};
- time_t t = time(NULL);
- struct tm *pt = localtime(&t);
+ struct tm *pt = localtime(&now);
int to_all = 0, money = 0;
getdata(0, 0, "指定使用者(S) 全站使用者(A) 取消(Q)?[S]", buf, sizeof(buf), LCECHO);
@@ -1094,7 +1091,7 @@ int give_money() {
if(bad_user_id(uhash->userid[i]))
continue;
id = uhash->userid[i];
- give_id_money(id, money, fp2, tt, t);
+ give_id_money(id, money, fp2, tt, now);
}
} else {
if(!(fp = fopen("etc/givemoney.txt", "r+"))) {
@@ -1108,7 +1105,7 @@ int give_money() {
*ptr = '\0';
id = buf;
mn = ptr + 1;
- give_id_money(id, atoi(mn), fp2, tt, t);
+ give_id_money(id, atoi(mn), fp2, tt, now);
}
fclose(fp);
}
diff --git a/mbbsd/announce.c b/mbbsd/announce.c
index bc05fca6..0de45055 100644
--- a/mbbsd/announce.c
+++ b/mbbsd/announce.c
@@ -1,4 +1,4 @@
-/* $Id: announce.c,v 1.7 2002/05/10 19:34:51 in2 Exp $ */
+/* $Id: announce.c,v 1.8 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -25,6 +25,7 @@ extern int b_lines;
extern int p_lines;
extern int TagNum;
extern int currbid;
+extern time_t now;
static void g_showmenu(gmenu_t *pm) {
static char *mytype = "編 選 絲路之旅";
char *title, ch;
@@ -113,7 +114,6 @@ static FILE* my_open(char* path) {
FILE* ans = 0;
char buf[80];
struct stat st;
- time_t now = time(0);
if(stat(path, &st) == 0 && st.st_mtime < now - 3600 * 24 * 7) {
return fopen(path, "w");
@@ -213,9 +213,6 @@ static void go_proxy(char* fpath, item_t *node, int update) {
ch = str[1];
if(ch == (char) 0xbc &&
!(HAS_PERM(PERM_SYSOP) && currutmp->pager > 1)) {
- time_t now;
-
- time(&now);
fprintf(fo, "作者: %s (連線精華區)\n標題: %s\n時間: %s\n",
server, str + 3, ctime(&now)
);
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index bc853662..d4367447 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -1,4 +1,4 @@
-/* $Id: bbs.c,v 1.8 2002/05/11 16:42:45 in2 Exp $ */
+/* $Id: bbs.c,v 1.9 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -23,6 +23,7 @@ static int g_board_names(boardheader_t *fhdr) {
extern userec_t cuser;
extern void touchdircache(int bid);
extern int TagNum;
+extern time_t now;
static void mail_by_link(char* owner, char* title, char* path) {
char genbuf[200];
@@ -44,7 +45,6 @@ extern int usernum;
void anticrosspost() {
char buf[200];
- time_t now = time(NULL);
sprintf(buf,
"\033[1;33;46m%s \033[37;45mcross post 文章 \033[37m %s\033[m",
@@ -1482,11 +1482,11 @@ int b_note_edit_bname(int bid) {
outs(msg_cancel);
pressanykey();
} else {
- aborted = (fh->bupdate - time(0)) / 86400 + 1;
+ aborted = (fh->bupdate - now ) / 86400 + 1;
sprintf(buf,"%d", aborted > 0 ? aborted : 0);
getdata_buf(3, 0, "請設定有效期限(0 - 9999)天?", buf, 5, DOECHO);
aborted = atoi(buf);
- fh->bupdate = aborted ? time(0) + aborted * 86400 : 0;
+ fh->bupdate = aborted ? now + aborted * 86400 : 0;
substitute_record(fn_board, fh, sizeof(boardheader_t), bid);
}
return 0;
@@ -1853,7 +1853,7 @@ int Read() {
int stat0 = currstat, tmpbid=currutmp->brc_id;
char buf[40];
#ifdef LOG_BOARD
- time_t usetime = time(0);
+ time_t usetime = now;
#endif
setutmpmode(READING);
@@ -1870,7 +1870,7 @@ int Read() {
i_read(READING, buf, readtitle, readdoent, read_comms,
currbid);
#ifdef LOG_BOARD
- log_board(currboard, time(0) - usetime);
+ log_board(currboard, now - usetime);
#endif
brc_update();
@@ -1895,11 +1895,9 @@ void ReadSelect() {
#ifdef LOG_BOARD
static void log_board(char *mode, time_t usetime) {
- time_t now;
char buf[ 256 ];
if(usetime > 30) {
- now = time(0);
sprintf(buf, "USE %-20.20s Stay: %5ld (%s) %s",
mode, usetime ,cuser.userid ,ctime(&now));
log_file(FN_USEBOARD,buf);
diff --git a/mbbsd/board.c b/mbbsd/board.c
index 923bea0a..42addecf 100644
--- a/mbbsd/board.c
+++ b/mbbsd/board.c
@@ -1,4 +1,4 @@
-/* $Id: board.c,v 1.5 2002/04/28 19:35:28 in2 Exp $ */
+/* $Id: board.c,v 1.6 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -20,6 +20,7 @@
#define BRC_MAXNUM 80
extern userinfo_t *currutmp;
+extern time_t now;
static char *brc_getrecord(char *ptr, char *name, int *pnum, int *list) {
int num;
char *tmp;
@@ -279,9 +280,7 @@ void save_brdbuf() {
close(fd);
}
if( favbuf[-1] != 0x5c4d3e ){
- time_t now;
FILE *fp = fopen(BBSHOME "/log/memorybad", "a");
- time(&now);
fprintf(fp, "%s %s %d\n", cuser.userid, Cdatelite(&now), favbuf[-1]);
fclose(fp);
return;
@@ -927,7 +926,7 @@ static void choose_board(int newflag) {
brc_initial(ptr->bh->brdname);
if(ch == 'v') {
ptr->myattr &= ~BRD_UNREAD;
- zapbuf[ptr->bid-1] = time((time_t *) &brc_list[0]);
+ zapbuf[ptr->bid-1] = brc_list[0]=now;
} else
{
zapbuf[ptr->bid-1] = brc_list[0] = 1;
@@ -993,7 +992,7 @@ static void choose_board(int newflag) {
}
board_visit_time = zapbuf[ptr->bid-1];
if(!(ptr->myattr&BRD_ZAP))
- time((time_t *) &zapbuf[ptr->bid-1]);
+ zapbuf[ptr->bid-1]=now;
Read();
check_newpost(ptr);
head = -1;
@@ -1018,7 +1017,7 @@ static void choose_board(int newflag) {
if (!(currmode & MODE_MENU))/*如果還沒有小組長權限 */
set_menu_BM(ptr->bh->BM);
- if(time(NULL) < ptr->bh->bupdate) {
+ if(now < ptr->bh->bupdate) {
setbfile(buf, ptr->bh->brdname, fn_notes);
if(more(buf, NA) != -1)
pressanykey();
diff --git a/mbbsd/cache.c b/mbbsd/cache.c
index fef81942..a2d1c98a 100644
--- a/mbbsd/cache.c
+++ b/mbbsd/cache.c
@@ -1,4 +1,4 @@
-/* $Id: cache.c,v 1.22 2002/05/04 13:50:26 in2 Exp $ */
+/* $Id: cache.c,v 1.23 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -34,7 +34,7 @@ union semun {
struct seminfo *__buf; /* buffer for IPC_INFO */
};
#endif
-
+extern time_t now;
int fcache_semid;
/* the reason for "safe_sleep" is that we may call sleep during
@@ -330,7 +330,6 @@ void setutmpmode(int mode) {
/* 追蹤使用者 */
if(HAS_PERM(PERM_LOGUSER)) {
- time_t now = time(NULL);
char msg[200];
sprintf(msg, "%s setutmpmode to %s(%d) at %s",
cuser.userid, modestring(currutmp, 0), mode, Cdate(&now));
@@ -377,7 +376,6 @@ static int cmputmpuid(const void *i, const void *j){
}
void sort_utmp()
{
- time_t now=time(NULL);
int count, i, ns;
userinfo_t *uentp;
@@ -673,7 +671,7 @@ void resolve_boards() {
}
void touch_boards() {
- time(&(brdshm->touchtime));
+ brdshm->touchtime=now;
numboards = -1;
resolve_boards();
}
@@ -1016,7 +1014,7 @@ void hbflreload(int bid)
}
fclose(fp);
}
- hbfl[0] = time(NULL);
+ hbfl[0] = now;
memcpy(brdshm->hbfl[bid], hbfl, sizeof(hbfl));
}
diff --git a/mbbsd/cal.c b/mbbsd/cal.c
index 78204dc9..aec3320b 100644
--- a/mbbsd/cal.c
+++ b/mbbsd/cal.c
@@ -1,4 +1,4 @@
-/* $Id: cal.c,v 1.10 2002/05/10 12:36:00 lwms Exp $ */
+/* $Id: cal.c,v 1.11 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -14,6 +14,7 @@
extern struct utmpfile_t *utmpshm;
extern int usernum;
+extern time_t now;
/* 防堵 Multi play */
static int count_multiplay(int unmode) {
@@ -103,10 +104,8 @@ static int osong(char *defaultid) {
char receiver[45],ano[2];
FILE *fp,*fp1;// *fp2;
fileheader_t mail;
- time_t now;
int nsongs;
- now = time(NULL);
strcpy(buf, Cdatedate(&now));
lockreturn0(OSONG, LOCK_MULTI);
@@ -222,7 +221,7 @@ static int osong(char *defaultid) {
// do_append(OSONGMAIL "/.DIR", &mail2, sizeof(mail2));
if(do_append(OSONGPATH "/.DIR", &mail, sizeof(mail)) != -1) {
- cuser.lastsong = time(NULL);
+ cuser.lastsong = now;
/* Jaky 超過 500 首歌就開始砍 */
nsongs=get_num_records(OSONGPATH "/.DIR", sizeof(mail));
if (nsongs > 500){
@@ -341,13 +340,11 @@ int p_exmail() {
void mail_redenvelop(char* from, char* to, int money, char mode){
char genbuf[200];
fileheader_t fhdr;
- time_t now;
FILE* fp;
sprintf(genbuf, "home/%c/%s", to[0], to);
stampfile(genbuf, &fhdr);
if (!(fp = fopen(genbuf, "w")))
return;
- now = time(NULL);
fprintf(fp, "作者: %s\n"
"標題: 招財進寶\n"
"時間: %s\n"
@@ -382,7 +379,6 @@ int give_tax(int money)
int p_give() {
int money, tax;
char id[IDLEN + 1], genbuf[90];
- time_t now = time(0);
move(1,0);
usercomplete("這位幸運兒的id:", id);
@@ -396,7 +392,6 @@ int p_give() {
if ( money - tax <= 0 ) return 0; /* 繳完稅就沒錢給了 */
deumoney(searchuser(id), money - tax);
demoney(-money);
- now = time(NULL);
sprintf(genbuf,"%s\t給%s\t%d\t%s", cuser.userid, id, money - tax,
ctime(&now));
log_file(FN_MONEY, genbuf);
diff --git a/mbbsd/calendar.c b/mbbsd/calendar.c
index 78ca46cf..371a8f79 100644
--- a/mbbsd/calendar.c
+++ b/mbbsd/calendar.c
@@ -1,4 +1,4 @@
-/* $Id: calendar.c,v 1.1 2002/03/07 15:13:48 in2 Exp $ */
+/* $Id: calendar.c,v 1.2 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -9,6 +9,7 @@
#include "proto.h"
#include "modes.h"
+extern time_t now;
typedef struct event_t {
int year, month, day, days;
int color;
@@ -232,16 +233,14 @@ static int GenerateCalendar(char **buf, int y, int m, int today, event_t *e) {
int calendar() {
char **buf;
- time_t t;
- struct tm now;
+ struct tm snow;
int i, y, m, today, lines = 0;
event_t *head = NULL, *e = NULL;
/* initialize date */
- time(&t);
- memcpy(&now, localtime(&t), sizeof(struct tm));
- today = Days(now.tm_year + 1900, now.tm_mon + 1, now.tm_mday);
- y = now.tm_year + 1900, m = now.tm_mon + 1;
+ memcpy(&snow, localtime(&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;
/* read event */
head = e = ReadEvent(today);
@@ -265,10 +264,10 @@ int calendar() {
outs(buf[i]);
if(i == 0) {
prints("\t\33[1;37m現在是 %d.%02d.%02d %2d:%02d:%02d%cm\33[m",
- now.tm_year + 1900, now.tm_mon + 1, now.tm_mday,
- (now.tm_hour == 0 || now.tm_hour == 12) ?
- 12 : now.tm_hour % 12, now.tm_min, now.tm_sec,
- now.tm_hour >= 12 ? 'p' : 'a');
+ snow.tm_year + 1900, snow.tm_mon + 1, snow.tm_mday,
+ (snow.tm_hour == 0 || snow.tm_hour == 12) ?
+ 12 : snow.tm_hour % 12, snow.tm_min, snow.tm_sec,
+ snow.tm_hour >= 12 ? 'p' : 'a');
} else if(i >= 2 && e) {
prints("\t\33[1;37m(\33[%dm%3d\33[37m)\33[m %02d/%02d %s",
e->color, e->days - today,
diff --git a/mbbsd/chat.c b/mbbsd/chat.c
index 4825379b..e7e7846a 100644
--- a/mbbsd/chat.c
+++ b/mbbsd/chat.c
@@ -1,4 +1,4 @@
-/* $Id: chat.c,v 1.2 2002/04/28 19:35:28 in2 Exp $ */
+/* $Id: chat.c,v 1.3 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -20,6 +20,7 @@ extern userinfo_t *currutmp;
static int chatline;
static int stop_line; /* next line of bottom of message window area */
static FILE *flog;
+extern time_t now;
static void printchatline(char *str) {
move(chatline, 0);
@@ -192,11 +193,9 @@ static void chat_help(char *arg) {
}
static void chat_date() {
- time_t thetime;
char genbuf[200];
- time(&thetime);
- sprintf(genbuf, "◆ " BBSNAME "標準時間: %s", Cdate(&thetime));
+ sprintf(genbuf, "◆ " BBSNAME "標準時間: %s", Cdate(&now));
printchatline(genbuf);
}
diff --git a/mbbsd/chc_play.c b/mbbsd/chc_play.c
index 86c17fbc..8f3e432c 100644
--- a/mbbsd/chc_play.c
+++ b/mbbsd/chc_play.c
@@ -1,4 +1,4 @@
-/* $Id: chc_play.c,v 1.1 2002/03/07 15:13:48 in2 Exp $ */
+/* $Id: chc_play.c,v 1.2 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <time.h>
#include <unistd.h>
@@ -12,7 +12,7 @@
extern userinfo_t *currutmp;
extern int usernum;
-
+extern time_t now;
typedef int (*play_func_t)(int, board_t, board_t);
static int chc_ipass = 0, chc_hepass = 0;
@@ -35,9 +35,9 @@ static int hisplay(int s, board_t board, board_t tmpbrd) {
int start_time;
int endgame = 0, endturn = 0;
- start_time = time(NULL);
+ start_time = now;
while(!endturn) {
- chc_lefttime = CHC_TIMEOUT - (time(NULL) - start_time);
+ chc_lefttime = CHC_TIMEOUT - (now - start_time);
if(chc_lefttime < 0) {
chc_lefttime = 0;
@@ -95,15 +95,15 @@ static int myplay(int s, board_t board, board_t tmpbrd) {
int endgame = 0, endturn = 0;
chc_ipass = 0, chc_selected = 0;
- start_time = time(NULL);
- chc_lefttime = CHC_TIMEOUT - (time(NULL) - start_time);
+ start_time = now;
+ chc_lefttime = CHC_TIMEOUT - (now - start_time);
bell();
while(!endturn) {
chc_drawline(board, TIME_ROW);
chc_movecur(chc_cursor.r, chc_cursor.c);
oflush();
ch = igetkey();
- chc_lefttime = CHC_TIMEOUT - (time(NULL) - start_time);
+ chc_lefttime = CHC_TIMEOUT - (now - start_time);
if(chc_lefttime < 0)
ch = 'q';
switch(ch) {
diff --git a/mbbsd/chicken.c b/mbbsd/chicken.c
index f13b68dc..c3bc1fa0 100644
--- a/mbbsd/chicken.c
+++ b/mbbsd/chicken.c
@@ -1,4 +1,4 @@
-/* $Id: chicken.c,v 1.2 2002/04/28 19:35:29 in2 Exp $ */
+/* $Id: chicken.c,v 1.3 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -57,7 +57,7 @@ enum {
};
extern userec_t cuser;
-
+extern time_t now;
static chicken_t *mychicken = &cuser.mychicken;
static int age;
@@ -108,7 +108,6 @@ int reload_chicken() {
static int new_chicken() {
char buf[150];
int price;
- time_t now;
clear();
move(2,0);
@@ -140,7 +139,6 @@ static int new_chicken() {
getdata(8, 0, "幫牠取個好名字:", mychicken->name,
sizeof(mychicken->name), DOECHO);
- now = time(NULL);
sprintf(buf,"\033[31m%s \033[m養了一隻叫\033[33m %s \033[m的 "
"\033[32m%s\033[m 於 %s",cuser.userid,
mychicken->name,chicken_type[(int)mychicken->type],ctime(&now));
@@ -214,9 +212,9 @@ extern char *BBSName;
void show_chicken_data(chicken_t *thechicken, chicken_t *pkchicken) {
char buf[1024];
- age = ((time(NULL) - thechicken->cbirth)/ (60*60*24));
+ age = ((now - thechicken->cbirth)/ (60*60*24));
if(age < 0) {
- thechicken->birthday = thechicken->cbirth = time(NULL)-10*(60*60*24);
+ thechicken->birthday = thechicken->cbirth = now-10*(60*60*24);
age = 10;
}
/*Ptt:debug*/
@@ -418,7 +416,6 @@ static void ch_kill() {
chicken_type[(int)mychicken->type]);
getdata_str(23, 0, buf, ans, sizeof(ans), DOECHO, "N");
if(ans[0] == 'y') {
- time_t now = time(NULL);
vice(100,"棄養寵物費");
more(CHICKEN_PIC "/deadth",YEA);
@@ -454,7 +451,6 @@ static int ch_sell() {
time_change[(int)mychicken->type][HP_MAX]) * 3 / 2 -
mychicken->sick;
char buf[150],ans[4];
- time_t now = time(NULL);
if(money < 0)
money =0 ;
@@ -514,10 +510,10 @@ static void geting_old(int *hp, int *weight, int diff, int age) {
/* 依時間變動的資料 */
void time_diff(chicken_t *thechicken) {
int diff;
- int theage = ((time(NULL) - thechicken->cbirth)/ (60 * 60 * 24));
+ int theage = ((now - thechicken->cbirth)/ (60 * 60 * 24));
thechicken->type %= NUM_KINDS ;
- diff = (time(NULL)-thechicken->lastvisit)/60;
+ diff = (now-thechicken->lastvisit)/60;
if((diff) < 1)
return;
@@ -525,7 +521,7 @@ void time_diff(chicken_t *thechicken) {
if(theage > 13 ) /* 老死 */
geting_old(&thechicken->hp_max, &thechicken->weight, diff, age);
- thechicken->lastvisit = time(NULL);
+ thechicken->lastvisit = now;
thechicken->weight -= thechicken->hp_max * diff / 540; /* 體重 */
if(thechicken->weight < 1) {
thechicken->sick -= thechicken->weight / 10; /* 餓得病氣上升 */
@@ -613,7 +609,6 @@ static void check_sick() {
static int deadtype(chicken_t *thechicken) {
int i;
char buf[150];
- time_t now = time(NULL);
if(thechicken->hp <= 0) /* hp用盡 */
i = 1;
@@ -676,7 +671,6 @@ int isdeadth(chicken_t *thechicken) {
static void ch_changename() {
char buf[150], newname[20] = "";
- time_t now = time(NULL);
getdata_str(b_lines - 1, 0, "嗯..改個好名字吧:", newname, 18, DOECHO,
mychicken->name);
@@ -780,7 +774,7 @@ static int recover_chicken(chicken_t *thechicken) {
int price = egg_price[(int)thechicken->type],
money = price + (rand() % price);
- if(time(NULL) - thechicken->lastvisit > (60 * 60 * 24 * 7))
+ if(now - thechicken->lastvisit > (60 * 60 * 24 * 7))
return 0;
outmsg("\033[33;44m★靈界守衛\033[37;45m 別害怕 我是來幫你的 \033[m");
bell();
@@ -831,7 +825,7 @@ int chicken_main() {
lockreturn0(CHICKEN, LOCK_MULTI);
reload_chicken();
- age = ((time(NULL) - mychicken->cbirth)/ (60*60*24));
+ age = ((now - mychicken->cbirth)/ (60*60*24));
if(!mychicken->name[0] && !recover_chicken(mychicken) && !new_chicken()) {
unlockutmpmode();
return 0;
diff --git a/mbbsd/dark.c b/mbbsd/dark.c
index 1b084407..ee691577 100644
--- a/mbbsd/dark.c
+++ b/mbbsd/dark.c
@@ -1,4 +1,4 @@
-/* $Id: dark.c,v 1.2 2002/04/27 15:50:17 in2 Exp $ */
+/* $Id: dark.c,v 1.3 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -13,6 +13,7 @@
#define RED 1
#define BLACK 0
+extern time_t now;
typedef short int sint;
typedef struct item {
@@ -97,7 +98,7 @@ static void brd_rand() {
bzero(brd, sizeof(brd));
bzero(tem, sizeof(tem));
bzero(&curr, sizeof(curr));
- srand(getpid()%2731+time(NULL)%3219);
+ srand(getpid()%2731+now%3219);
for(y=0;y<4;y++)
for(x=0;x<8;x++)
while(1) {
diff --git a/mbbsd/edit.c b/mbbsd/edit.c
index 9806526d..9ad0566f 100644
--- a/mbbsd/edit.c
+++ b/mbbsd/edit.c
@@ -1,4 +1,4 @@
-/* $Id: edit.c,v 1.7 2002/05/01 04:42:16 in2 Exp $ */
+/* $Id: edit.c,v 1.8 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -44,6 +44,7 @@ extern userinfo_t *currutmp;
extern int KEY_ESC_arg;
extern char reset_color[];
extern char trans_buffer[256];
+extern time_t now;
#define KEEP_EDITING -2
#define BACKUP_LIMIT 100
@@ -735,7 +736,6 @@ static void read_file(char *fpath) {
extern userec_t cuser;
void write_header(FILE *fp) {
- time_t now = time(0);
if(curredit & EDIT_MAIL || curredit & EDIT_LIST) {
fprintf(fp, "%s %s (%s)\n", str_author1, cuser.userid,
@@ -1007,7 +1007,6 @@ write_file(char *fpath, int saveheader, int *islocal) {
#endif
)
{
- time(&now);
ptime = localtime(&now);
fprintf(fp,
"※ 編輯: %-15s 來自: %-20s (%02d/%02d %02d:%02d)\n",
diff --git a/mbbsd/gamble.c b/mbbsd/gamble.c
index a2fc3c37..64f04848 100644
--- a/mbbsd/gamble.c
+++ b/mbbsd/gamble.c
@@ -1,4 +1,4 @@
-/* $Id: gamble.c,v 1.2 2002/03/09 17:27:57 in2 Exp $ */
+/* $Id: gamble.c,v 1.3 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <time.h>
#include <string.h>
@@ -15,6 +15,7 @@ extern int usernum;
#ifndef _BBS_UTIL_C_
extern userec_t cuser;
extern int b_lines;
+extern time_t now;
#define MAX_ITEM 8 //最大 賭項(item) 個數
#define MAX_ITEM_LEN 30 //最大 每一賭項名字長度
@@ -28,7 +29,6 @@ int post_msg(char* bname, char* title, char *msg, char* author)
FILE *fp;
int bid;
fileheader_t fhdr;
- time_t now = time(0);
char genbuf[256];
/* 在 bname 版發表新文章 */
@@ -237,7 +237,6 @@ int openticket(int bid) {
char path[128],buf[256],outcome[128];
int i, money=0, count, bet, price, total = 0, ticket[8]={0,0,0,0,0,0,0,0};
boardheader_t *bh=getbcache(bid);
- time_t now = time(NULL);
FILE *fp, *fp1;
setbpath(path, bh->brdname);
diff --git a/mbbsd/gomo.c b/mbbsd/gomo.c
index 41650c77..190d6f71 100644
--- a/mbbsd/gomo.c
+++ b/mbbsd/gomo.c
@@ -1,4 +1,4 @@
-/* $Id: gomo.c,v 1.2 2002/04/28 19:35:29 in2 Exp $ */
+/* $Id: gomo.c,v 1.3 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -15,6 +15,7 @@
extern int usernum;
extern userinfo_t *currutmp;
+extern time_t now;
char ku[BRDSIZ][BRDSIZ];
static char *chess[] = { "●", "○" };
@@ -185,7 +186,7 @@ int gomoku(int fd) {
me = !(my->turn) + 1;
he = my->turn + 1;
win = 1;
- tick=time(0) + MAX_TIME;
+ tick=now + MAX_TIME;
lastcount = MAX_TIME;
setutmpmode(M_FIVE);
clear();
@@ -224,8 +225,8 @@ int gomoku(int fd) {
for(;;) {
move(13, 40);
outs(my->turn ? "輪到自己下了!": "等待對方下子..");
- if(lastcount != tick-time(0)) {
- lastcount = tick-time(0);
+ if(lastcount != tick-now) {
+ lastcount = tick-now;
move(18, 40);
prints("%s時間還剩%d:%02d\n", my->turn ? "你的" : "對方",
lastcount / 60, lastcount % 60);
@@ -303,7 +304,7 @@ int gomoku(int fd) {
if(ch == I_OTHERDATA) {
ch = recv(fd, &mv, sizeof(Horder_t), 0);
if(ch != sizeof(Horder_t)) {
- lastcount=tick-time(0);
+ lastcount=tick-now;
if(lastcount >=0) {
win = 1;
cuser.five_lose--;
@@ -346,7 +347,7 @@ int gomoku(int fd) {
win = chkmv(&mv, he, he == BBLACK);
HO_add(&mv);
hislasttick = tick;
- tick = time(0) + MAX_TIME;
+ tick = now + MAX_TIME;
ku[(int)mv.x][(int)mv.y] = he;
bell();
BGOTO(mv.x, mv.y);
@@ -382,7 +383,7 @@ int gomoku(int fd) {
win = chkmv( &mv, me, me == BBLACK);
ku[(int)mv.x][(int)mv.y] = me;
mylasttick = tick;
- tick = time(0) + MAX_TIME; /*倒數*/
+ tick = now + MAX_TIME; /*倒數*/
lastcount = MAX_TIME;
if(send(fd, &mv, sizeof(Horder_t), 0) != sizeof(Horder_t))
break;
diff --git a/mbbsd/io.c b/mbbsd/io.c
index 79a3874f..c969be8e 100644
--- a/mbbsd/io.c
+++ b/mbbsd/io.c
@@ -1,4 +1,4 @@
-/* $Id: io.c,v 1.9 2002/04/28 19:35:29 in2 Exp $ */
+/* $Id: io.c,v 1.10 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -41,28 +41,7 @@ static char outbuf[OBUFSIZE], inbuf[IBUFSIZE];
static int obufsize = 0, ibufsize = 0;
static int icurrchar = 0;
-/* ----------------------------------------------------- */
-/* 定時顯示動態看板 */
-/* ----------------------------------------------------- */
-extern userec_t cuser;
-
-static void hit_alarm_clock() {
- if(HAS_PERM(PERM_NOTIMEOUT) || PERM_HIDE(currutmp) || currstat == MAILALL)
- return;
-// if(time(0) - currutmp->lastact > IDLE_TIMEOUT - 2) {
- if(time(0) - currutmp->lastact > curr_idle_timeout - 2) {
- clear();
- if(currpid > 0) kill(currpid, SIGHUP);
- }
-// alarm(IDLE_TIMEOUT);
- alarm(curr_idle_timeout);
-}
-
-void init_alarm() {
- signal(SIGALRM, (void (*)(int))hit_alarm_clock);
-// alarm(IDLE_TIMEOUT);
- alarm(curr_idle_timeout);
-}
+time_t now;
/* ----------------------------------------------------- */
/* output routines */
@@ -148,7 +127,7 @@ int watermode = -1, wmofo = -1;
static int dogetch() {
int len;
-
+ static int count=0;
if(ibufsize <= icurrchar) {
if(flushf)
@@ -195,10 +174,20 @@ static int dogetch() {
}
if(currutmp)
- currutmp->lastact = time(0);
+ {
+ now= time(0);
+ if(now-currutmp->lastact<3)
+ count=0;
+ else
+ {
+ if(++count>100)
+ system_abort();
+ }
+ currutmp->lastact = now;
+ }
return inbuf[icurrchar++];
}
-
+extern userec_t cuser;
static int water_which_flag=0;
int igetch() {
register int ch;
diff --git a/mbbsd/kaede.c b/mbbsd/kaede.c
index c0bd5103..d3f9355b 100644
--- a/mbbsd/kaede.c
+++ b/mbbsd/kaede.c
@@ -1,4 +1,4 @@
-/* $Id: kaede.c,v 1.1 2002/03/07 15:13:48 in2 Exp $ */
+/* $Id: kaede.c,v 1.2 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <string.h>
#include <time.h>
@@ -11,6 +11,7 @@
extern struct utmpfile_t *utmpshm;
extern userec_t cuser;
+extern time_t now;
char *Ptt_prints(char *str, int mode) {
char *po , strbuf[256];
@@ -21,7 +22,6 @@ char *Ptt_prints(char *str, int mode) {
strcpy(str, strbuf);
}
while((po = strstr(str, "\033*t"))) {
- time_t now = time(0);
po[0] = 0;
sprintf(strbuf, "%s%s", str, Cdate(&now));
diff --git a/mbbsd/lovepaper.c b/mbbsd/lovepaper.c
index 92330db7..dffdee69 100644
--- a/mbbsd/lovepaper.c
+++ b/mbbsd/lovepaper.c
@@ -1,4 +1,4 @@
-/* $Id: lovepaper.c,v 1.2 2002/04/28 19:35:29 in2 Exp $ */
+/* $Id: lovepaper.c,v 1.3 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -14,19 +14,18 @@
#define DATA "etc/lovepaper.dat"
extern userec_t cuser;
+extern time_t now;
int x_love() {
char buf1[200], save_title[TTLEN + 1];
char receiver[61], path[STRLEN] = "home/";
int x, y = 0, tline = 0, poem = 0;
FILE *fp, *fpo;
- time_t timenow;
struct tm *gtime;
fileheader_t mhdr;
setutmpmode(LOVE);
- time(&timenow);
- gtime = localtime(&timenow);
+ gtime = localtime(&now);
sprintf(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 34c629cb..35b6a000 100644
--- a/mbbsd/mail.c
+++ b/mbbsd/mail.c
@@ -1,4 +1,4 @@
-/* $Id: mail.c,v 1.6 2002/05/10 19:34:51 in2 Exp $ */
+/* $Id: mail.c,v 1.7 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -44,7 +44,7 @@ extern pid_t currpid;
extern int usernum;
extern char *str_mail_address;
extern userec_t cuser;
-
+extern time_t now;
char currmaildir[32];
static char msg_cc[] = "\033[32m[群組名單]\033[m\n";
static char listfile[] = "list.0";
@@ -879,11 +879,10 @@ static int mail_del(int ent, fileheader_t *fhdr, char *direct) {
setdirpath(genbuf, direct, fhdr->filename);
unlink(genbuf);
if((currmode & MODE_SELECT)) {
- int now;
-
+ int index;
sethomedir(genbuf, cuser.userid);
- now = getindex(genbuf, fhdr->filename, sizeof(fileheader_t));
- delete_file(genbuf, sizeof(fileheader_t), now, cmpfilename);
+ index = getindex(genbuf, fhdr->filename, sizeof(fileheader_t));
+ delete_file(genbuf, sizeof(fileheader_t), index, cmpfilename);
}
return DIRCHANGED;
}
@@ -905,11 +904,11 @@ static int mail_read(int ent, fileheader_t *fhdr, char *direct) {
if(more_result != -1) {
fhdr->filemode |= FILE_READ;
if((currmode & MODE_SELECT)) {
- int now;
+ int index;
- now = getindex(currmaildir, fhdr->filename,
+ index = getindex(currmaildir, fhdr->filename,
sizeof(fileheader_t));
- substitute_record(currmaildir, fhdr, sizeof(*fhdr), now);
+ substitute_record(currmaildir, fhdr, sizeof(*fhdr), index);
substitute_record(direct, fhdr, sizeof(*fhdr), ent);
}
else
@@ -967,10 +966,10 @@ static int mail_read(int ent, fileheader_t *fhdr, char *direct) {
bug_possible = YEA;
#endif
if((currmode & MODE_SELECT)) {
- int now;
+ int index;
- now = getindex(currmaildir, fhdr->filename, sizeof(fileheader_t));
- substitute_record(currmaildir, fhdr, sizeof(*fhdr), now);
+ index = getindex(currmaildir, fhdr->filename, sizeof(fileheader_t));
+ substitute_record(currmaildir, fhdr, sizeof(*fhdr), index);
substitute_record(direct, fhdr, sizeof(*fhdr), ent);
} else
substitute_record(currmaildir, fhdr, sizeof(*fhdr), ent);
@@ -1063,10 +1062,10 @@ static int mail_mark(int ent, fileheader_t *fhdr, char *direct) {
fhdr->filemode ^= FILE_MARKED;
if((currmode & MODE_SELECT)) {
- int now;
+ int index;
- now = getindex(currmaildir, fhdr->filename, sizeof(fileheader_t));
- substitute_record(currmaildir, fhdr, sizeof(*fhdr), now);
+ index = getindex(currmaildir, fhdr->filename, sizeof(fileheader_t));
+ substitute_record(currmaildir, fhdr, sizeof(*fhdr), index);
substitute_record(direct, fhdr, sizeof(*fhdr), ent);
} else
substitute_record(currmaildir, fhdr, sizeof(*fhdr), ent);
@@ -1282,7 +1281,6 @@ static int mail_waterball(int ent, fileheader_t *fhdr, char *direct)
static char address[60], cmode = 1;
char fname[500], genbuf[200];
FILE *fp;
- int now;
if(!address[0])
strcpy(address, cuser.email);
@@ -1310,7 +1308,6 @@ static int mail_waterball(int ent, fileheader_t *fhdr, char *direct)
getdata(b_lines - 1, 0, "使用模式(0/1)? [1]", fname, 3, LCECHO);
cmode = (fname[0] != '0' && fname[0] != '1') ? 1 : fname[0] - '0';
- now = time(NULL);
sprintf(fname, BBSHOME "/jobspool/water.src.%s-%d",
cuser.userid, now);
sprintf(genbuf, "cp " BBSHOME "/home/%c/%s/%s %s",
@@ -1402,7 +1399,6 @@ static int bbs_sendmail(char *fpath, char *title, char *receiver) {
/* 中途攔截 */
if((ptr = strchr(receiver, ';'))) {
struct tm *ptime;
- time_t now;
*ptr = '\0';
}
@@ -1489,7 +1485,7 @@ int bsmtp(char *fpath, char *title, char *rcpt, int method) {
return send_inner_mail(fpath, title, hacker);
}
- chrono = time(NULL);
+ chrono = now;
if(method != MQ_JUSTIFY) { /* 認證信 */
/* stamp the queue file */
strcpy(buf, "out/");
@@ -1563,7 +1559,6 @@ int doforward(char *direct, fileheader_t *fh, int mode) {
/* 追蹤使用者 */
if(HAS_PERM(PERM_LOGUSER)) {
- time_t now = time(NULL);
char msg[200];
sprintf(msg, "%s mailforward to %s at %s",
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index 496ea00f..9a46738a 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -1,4 +1,4 @@
-/* $Id: mbbsd.c,v 1.24 2002/04/28 19:35:29 in2 Exp $ */
+/* $Id: mbbsd.c,v 1.25 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -39,7 +39,7 @@ extern int t_lines, t_columns; /* Screen size / width */
extern int b_lines; /* Screen bottom line number: t_lines-1 */
extern userinfo_t *currutmp;
extern int curr_idle_timeout;
-
+extern time_t now;
static void do_aloha (char *hello);
#if 0
@@ -175,7 +175,6 @@ void
log_usies (char *mode, char *mesg)
{
char genbuf[200];
- time_t now = time (0);
if (!mesg)
sprintf (genbuf, cuser.userid[0] ? "%s %s %-12s Stay:%d (%s)" :
@@ -233,7 +232,7 @@ u_exit (char *mode)
log_usies (mode, NULL);
}
-static void
+void
system_abort ()
{
if (currmode)
@@ -778,11 +777,6 @@ static void
setup_utmp (int mode)
{
userinfo_t uinfo;
- /*
- char buf[80];
- char remotebuf[1024];
- time_t now = time(NULL);
- */
memset (&uinfo, 0, sizeof (uinfo));
uinfo.pid = currpid = getpid ();
uinfo.uid = usernum;
diff --git a/mbbsd/menu.c b/mbbsd/menu.c
index f65a1e89..5108606e 100644
--- a/mbbsd/menu.c
+++ b/mbbsd/menu.c
@@ -1,4 +1,4 @@
-/* $Id: menu.c,v 1.7 2002/05/08 22:31:23 in2 Exp $ */
+/* $Id: menu.c,v 1.8 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
@@ -21,7 +21,7 @@ extern char reset_color[];
extern userinfo_t *currutmp;
extern char *BBSName;
extern int b_lines; /* Screen bottom line number: t_lines-1 */
-
+extern time_t now;
/* help & menu processring */
static int refscreen = NA;
extern char *boardprefix;
@@ -122,8 +122,8 @@ void movie(int i) {
static short history[MAX_HISTORY];
static char myweek[] = "天一二三四五六";
const char *msgs[] = {"關閉", "打開", "拔掉", "防水","好友"};
- time_t now = time(NULL);
struct tm *ptime = localtime(&now);
+ int j;
if((currstat != CLASS) && (cuser.uflag & MOVIE_FLAG) &&
!ptt->busystate && ptt->max_film > 0) {
@@ -136,8 +136,8 @@ void movie(int i) {
i = 1 + (int)(((float)ptt->max_film *
rand()) / (RAND_MAX + 1.0));
- for(now = ptt->max_history; now >= 0; now--)
- if(i == history[now]) {
+ for(j = ptt->max_history; j >= 0; j--)
+ if(i == history[j]) {
i = 0;
break;
}
@@ -145,7 +145,7 @@ void movie(int i) {
}
memcpy(history, &history[1], ptt->max_history * sizeof(short));
- history[ptt->max_history] = now = i;
+ history[ptt->max_history] = j = i;
if(i == 999) /* Goodbye my friend */
i = 0;
diff --git a/mbbsd/more.c b/mbbsd/more.c
index f8d32c61..87d71fe9 100644
--- a/mbbsd/more.c
+++ b/mbbsd/more.c
@@ -1,4 +1,4 @@
-/* $Id: more.c,v 1.12 2002/04/28 19:35:29 in2 Exp $ */
+/* $Id: more.c,v 1.13 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -24,7 +24,7 @@ extern char *str_post1;
extern char *str_post2;
extern char *msg_seperator;
extern char reset_color[];
-
+extern time_t now;
#define MORE_BUFSIZE 4096
#define MORE_WINSIZE 4096
#define STR_ANSICODE "[0123456789;,"
@@ -780,7 +780,7 @@ static int more_web(char *fpath, int promptend) {
#ifdef LOCAL_PROXY
/* 先找 local disk 的 proxy */
- time(&dtime);
+ dtime=now;
sprintf(userfile,"hproxy/%s%s",hostname,file);
if(dashf(userfile) && (dtime - dasht(userfile)) < HPROXYDAY * 24 * 60
&& more(userfile,promptend)) {
diff --git a/mbbsd/record.c b/mbbsd/record.c
index b572b7cf..2f82b372 100644
--- a/mbbsd/record.c
+++ b/mbbsd/record.c
@@ -1,4 +1,4 @@
-/* $Id: record.c,v 1.3 2002/04/15 20:00:22 in2 Exp $ */
+/* $Id: record.c,v 1.4 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
@@ -17,7 +17,7 @@
#define BUFSIZE 512
extern char *str_reply;
-
+extern time_t now;
static void PttLock(int fd, int size, int mode) {
static struct flock lock_it;
int ret;
@@ -116,7 +116,7 @@ force_open (char *fname)
int fd;
time_t expire;
- expire = time(NULL) - 3600; /* lock 存在超過一個小時就是有問題! */
+ expire = now - 3600; /* lock 存在超過一個小時就是有問題! */
if (dasht (fname) < expire) return -1;
unlink(fname);
@@ -422,14 +422,13 @@ int apply_record(char *fpath, int (*fptr)(), int size) {
/* mail / post 時,依據時間建立檔案,加上郵戳 */
int stampfile(char *fpath, fileheader_t *fh) {
register char *ip = fpath;
- time_t dtime;
+ time_t dtime=now;
struct tm *ptime;
int fp = 0;
if(access(fpath, X_OK | R_OK | W_OK))
mkdir(fpath, 0755);
- time(&dtime);
while (*(++ip));
*ip++ = '/';
do {
@@ -447,13 +446,12 @@ int stampfile(char *fpath, fileheader_t *fh) {
void stampdir(char *fpath, fileheader_t *fh) {
register char *ip = fpath;
- time_t dtime;
+ time_t dtime=now;
struct tm *ptime;
if(access(fpath, X_OK | R_OK | W_OK))
mkdir(fpath, 0755);
- time(&dtime);
while(*(++ip));
*ip++ = '/';
do {
@@ -467,13 +465,12 @@ void stampdir(char *fpath, fileheader_t *fh) {
void stamplink(char *fpath, fileheader_t *fh) {
register char *ip = fpath;
- time_t dtime;
+ time_t dtime=now;
struct tm *ptime;
if(access(fpath, X_OK | R_OK | W_OK))
mkdir(fpath, 0755);
- time(&dtime);
while(*(++ip));
*ip++ = '/';
do {
diff --git a/mbbsd/register.c b/mbbsd/register.c
index 53acc82f..36b30f46 100644
--- a/mbbsd/register.c
+++ b/mbbsd/register.c
@@ -1,4 +1,4 @@
-/* $Id: register.c,v 1.3 2002/04/28 19:35:29 in2 Exp $ */
+/* $Id: register.c,v 1.4 2002/05/13 03:20:04 ptt Exp $ */
#define _XOPEN_SOURCE
#include <stdio.h>
@@ -21,7 +21,7 @@ extern char *str_new;
extern char *msg_uid;
extern int t_lines, t_columns; /* Screen size / width */
extern char *str_mail_address;
-
+extern time_t now;
/* password encryption */
static char pwbuf[14];
@@ -111,7 +111,6 @@ static int compute_user_value(userec_t *urec, time_t clock) {
int check_and_expire_account(int uid,userec_t *urec)
{
userec_t zerorec;
- time_t now=time(NULL);
char genbuf[200],genbuf2[200];
int val;
if((val = compute_user_value(urec, now)) < 0) {
@@ -153,7 +152,7 @@ int getnewuserid() {
int fd, i;
memset(&zerorec, 0, sizeof(zerorec));
- clock = time(NULL);
+ clock = now;
/* Lazy method : 先找尋已經清除的過期帳號 */
if((i = searchnewuser(0)) == 0) {
@@ -265,7 +264,7 @@ void new_register() {
}
newuser.userlevel = PERM_DEFAULT;
newuser.uflag = COLOR_FLAG | BRDSORT_FLAG | MOVIE_FLAG;
- newuser.firstlogin = newuser.lastlogin = time(NULL);
+ newuser.firstlogin = newuser.lastlogin = now;
newuser.money = 0;
newuser.pager = 1;
allocid = getnewuserid();
diff --git a/mbbsd/syspost.c b/mbbsd/syspost.c
index c7bd163b..6145be26 100644
--- a/mbbsd/syspost.c
+++ b/mbbsd/syspost.c
@@ -1,4 +1,4 @@
-/* $Id: syspost.c,v 1.5 2002/05/08 14:11:33 lwms Exp $ */
+/* $Id: syspost.c,v 1.6 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <string.h>
#include <time.h>
@@ -11,11 +11,10 @@
extern char *str_permid[];
extern userec_t cuser;
-
+extern time_t now;
void post_change_perm(int oldperm, int newperm, char *sysopid, char *userid) {
FILE *fp;
fileheader_t fhdr;
- time_t now = time(0);
char genbuf[200], reason[30];
int i, flag=0;
@@ -56,13 +55,11 @@ void post_change_perm(int oldperm, int newperm, char *sysopid, char *userid) {
void post_violatelaw(char* crime, char* police, char* reason, char* result){
char genbuf[200];
fileheader_t fhdr;
- time_t now;
FILE *fp;
strcpy(genbuf, "boards/S/Security");
stampfile(genbuf, &fhdr);
if(!(fp = fopen(genbuf,"w")))
return;
- now = time(NULL);
fprintf(fp, "作者: [Ptt法院] 看板: Security\n"
"標題: [報告] %-20s 違法判決報告\n"
"時間: %s\n"
@@ -78,7 +75,6 @@ void post_violatelaw(char* crime, char* police, char* reason, char* result){
stampfile(genbuf, &fhdr);
if(!(fp = fopen(genbuf,"w")))
return;
- now = time(NULL);
fprintf(fp, "作者: [Ptt法院] 看板: ViolateLaw\n"
"標題: [報告] %-20s 違法判決報告\n"
"時間: %s\n"
diff --git a/mbbsd/talk.c b/mbbsd/talk.c
index ef96ca35..8937df3d 100644
--- a/mbbsd/talk.c
+++ b/mbbsd/talk.c
@@ -1,4 +1,4 @@
-/* $Id: talk.c,v 1.32 2002/05/11 16:53:25 in2 Exp $ */
+/* $Id: talk.c,v 1.33 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <string.h>
#include <errno.h>
@@ -47,7 +47,7 @@ extern boardheader_t *bcache;
extern int curr_idle_timeout;
extern userec_t cuser;
extern userec_t xuser;
-
+extern time_t now;
static char *IdleTypeTable[] = {
"偶在花呆啦", "情人來電", "覓食中", "拜見周公", "假死狀態", "我在思考"
@@ -590,7 +590,6 @@ int my_write(pid_t pid, char *prompt, char *id, int flag, userinfo_t *puin)
char msg[80], destid[IDLEN + 1];
char genbuf[200], buf[200], c0 = currutmp->chatid[0];
unsigned char mode0 = currutmp->mode;
- time_t now;
struct tm *ptime;
userinfo_t *uin;
uin = (puin != NULL) ? puin : (userinfo_t *)search_ulist_pid(pid);
@@ -607,7 +606,6 @@ int my_write(pid_t pid, char *prompt, char *id, int flag, userinfo_t *puin)
currutmp->chatid[0] = 3;
currstat = XMODE;
- time(&now);
ptime = localtime(&now);
if(flag == 0) {
@@ -665,7 +663,6 @@ int my_write(pid_t pid, char *prompt, char *id, int flag, userinfo_t *puin)
}
fri_stat=friend_stat(currutmp, uin);
- time(&now);
if(flag != 2) { /* aloha 的水球不用存下來 */
/* 存到自己的水球檔 */
if(!fp_writelog){
@@ -994,10 +991,8 @@ static void do_talk(int fd)
int im_leaving = 0;
FILE *log;
struct tm *ptime;
- time_t now;
char genbuf[200], fpath[100];
- time(&now);
ptime = localtime(&now);
sethomepath(fpath, cuser.userid);
@@ -1100,7 +1095,6 @@ static void do_talk(int fd)
extern unsigned char scr_lns;
int i;
- time(&now);
fprintf(flog, "\n\033[33;44m離別畫面 [%s] ... \033[m\n",
Cdatelite(&now));
for (i = 0; i < scr_lns; i++)
@@ -1549,23 +1543,6 @@ static int pickup_user_cmp(time_t now, int sortedway, int cmp_fri,
if (ifh_number && fri_stat & IFH) (*ifh_number)++;
if (hfm_number && fri_stat & HFM) (*hfm_number)++;
if (irh_number && fri_stat & IRH) (*irh_number)++;
-#if 0
-#ifdef SHOW_IDLE_TIME
- diff = now - uentp->lastact;
-#ifdef DOTIMEOUT
- /* in2: timeout拿到 shmctl utmpfix去做, 一小時一次就夠了 */
- /* prevent fault /dev mount from kicking out users */
- if ((diff > curr_idle_timeout + 10) &&
- (diff < 60 * 60 * 24 * 5)){
- if ((uentp->pid <= 0 || kill(uentp->pid, SIGHUP) == -1) &&
- (errno == ESRCH))
- purge_utmp(uentp);
- continue;
- }
-#endif
- pklist[count].idle = diff;
-#endif
-#endif
pklist[count].friend = fri_stat;
pklist[count].ui = uentp;
count++;
@@ -1640,7 +1617,7 @@ static void pickup_user(void)
if (utmpshm->uptime > freshtime || state == US_PICKUP ||
state ==US_RESORT){
state = US_PICKUP;
- time(&freshtime);
+ freshtime=now;
ifh_number=hfm_number=irh_number=bfriends_number = actor = ch = 0;
if(pickup_way==0)
sortedway=0;
diff --git a/mbbsd/user.c b/mbbsd/user.c
index 3cce4bc5..9f5d7245 100644
--- a/mbbsd/user.c
+++ b/mbbsd/user.c
@@ -1,4 +1,4 @@
-/* $Id: user.c,v 1.15 2002/04/28 19:35:29 in2 Exp $ */
+/* $Id: user.c,v 1.16 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -31,6 +31,7 @@ extern char *fn_register;
extern char *msg_nobody;
extern userec_t cuser;
extern userec_t xuser;
+extern time_t now;
static char *sex[8] = {
MSG_BIG_BOY, MSG_BIG_GIRL, MSG_LITTLE_BOY, MSG_LITTLE_GIRL,
@@ -110,7 +111,7 @@ void user_display(userec_t *u, int real) {
" user權限: %s\n",
u->justify, genbuf);
} else {
- diff = (time(0) - login_start_time) / 60;
+ diff = (now - login_start_time) / 60;
prints(" 停留期間: %d 小時 %2d 分\n",
diff / 60, diff % 60);
}
@@ -146,13 +147,11 @@ void user_display(userec_t *u, int real) {
void mail_violatelaw(char* crime, char* police, char* reason, char* result){
char genbuf[200];
fileheader_t fhdr;
- time_t now;
FILE *fp;
sprintf(genbuf, "home/%c/%s", crime[0], crime);
stampfile(genbuf, &fhdr);
if(!(fp = fopen(genbuf,"w")))
return;
- now = time(NULL);
fprintf(fp, "作者: [Ptt法院]\n"
"標題: [報告] 違法判決報告\n"
"時間: %s\n"
@@ -401,7 +400,6 @@ void uinfo_query(userec_t *u, int real, int unum) {
}
else{
char witness[3][32];
- time_t now = time(NULL);
for(i=0;i<3;i++){
if(!getdata(19+i, 0, "請輸入協助證明之使用者:",
witness[i], sizeof(witness[i]), DOECHO)){
@@ -523,14 +521,12 @@ void uinfo_query(userec_t *u, int real, int unum) {
if(money_change)
setumoney(unum,x.money);
passwd_update(unum, &x);
- now = time(0);
if(money_change) {
strcpy(genbuf, "boards/S/Security");
stampfile(genbuf, &fhdr);
if(!(fp = fopen(genbuf,"w")))
return;
- now = time(NULL);
fprintf(fp, "作者: [系統安全局] 看板: Security\n"
"標題: [公安報告] 站長修改金錢報告\n"
"時間: %s\n"
@@ -816,7 +812,6 @@ static void toregister(char *email, char *genbuf, char *phone, char *career,
char *ident, char *rname, char *addr, char *mobile)
{
FILE *fn;
- time_t now;
char buf[128];
sethomefile(buf, cuser.userid, "justify.wait");
@@ -857,7 +852,6 @@ static void toregister(char *email, char *genbuf, char *phone, char *career,
strncpy(cuser.email, email, sizeof(cuser.email));
if( email[0] == 'x' || email[0] == 'X' ){ /* 手動認證 */
if ((fn = fopen(fn_register, "a"))) {
- now = time(NULL);
fprintf(fn, "num: %d, %s", usernum, ctime(&now));
fprintf(fn, "uid: %s\n", cuser.userid);
fprintf(fn, "ident: %s\n", ident);
diff --git a/mbbsd/vote.c b/mbbsd/vote.c
index 9cc55b40..ca288481 100644
--- a/mbbsd/vote.c
+++ b/mbbsd/vote.c
@@ -1,4 +1,4 @@
-/* $Id: vote.c,v 1.6 2002/04/28 19:35:29 in2 Exp $ */
+/* $Id: vote.c,v 1.7 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -122,7 +122,7 @@ static int b_nonzeroNum(char *buf) {
}
return i;
}
-
+extern time_t now;
static void vote_report(char *bname, char *fname, char *fpath) {
register char *ip;
time_t dtime;
@@ -135,7 +135,7 @@ static void vote_report(char *bname, char *fname, char *fpath) {
/* get a filename by timestamp */
- dtime = time(0);
+ dtime = now;
for(;;) {
sprintf(ip, "M.%ld.A", ++dtime);
fd = open(fpath, O_CREAT | O_EXCL | O_WRONLY, 0644);
@@ -185,7 +185,7 @@ static void b_result_one(boardheader_t *fh, int ind) {
char b_control[64];
char b_newresults[64];
char b_report[64];
- time_t closetime, now;
+ time_t closetime;
fh->bvote--;
@@ -233,7 +233,6 @@ static void b_result_one(boardheader_t *fh, int ind) {
if((tfp = fopen(b_newresults, "w")) == NULL)
return;
- now = time(NULL);
setbfile(buf, bname, STR_new_title);
if((xfp=fopen(buf,"r"))) {
@@ -295,12 +294,11 @@ static void b_result_one(boardheader_t *fh, int ind) {
static void b_result(boardheader_t *fh) {
FILE *cfp;
- time_t closetime, now;
+ time_t closetime;
int i;
char buf[STRLEN];
char temp[STRLEN];
- now = time(NULL);
for(i = 0; i < 20; i++) {
if(i)
sprintf(STR_new_control, "%s%d", STR_bv_control, i);
@@ -320,8 +318,6 @@ static void b_result(boardheader_t *fh) {
}
static int b_close(boardheader_t *fh) {
- time_t now;
- now = time(NULL);
if(fh->bvote == 2) {
if(fh->vtime < now - 3 * 86400) {
@@ -339,12 +335,10 @@ int b_closepolls() {
static char *fn_vote_polling = ".polling";
boardheader_t *fhp;
FILE *cfp;
- time_t now;
int pos, dirty;
time_t last;
char timebuf[100];
- now = time(NULL);
/* Edited by CharlieL for can't auto poll bug */
if((cfp = fopen(fn_vote_polling,"r"))) {
@@ -697,7 +691,7 @@ static int vote_maintain(char *bname) {
else if(closetime >10)
closetime = 10;
- closetime = closetime * 86400 + time(NULL);
+ closetime = closetime * 86400 + now;
setbfile(buf, bname, STR_new_control);
fp = fopen(buf, "w");
fprintf(fp, "00\n%lu\n", closetime);
diff --git a/mbbsd/voteboard.c b/mbbsd/voteboard.c
index dbc23412..8b92adb7 100644
--- a/mbbsd/voteboard.c
+++ b/mbbsd/voteboard.c
@@ -1,4 +1,4 @@
-/* $Id: voteboard.c,v 1.4 2002/04/28 19:35:29 in2 Exp $ */
+/* $Id: voteboard.c,v 1.5 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -21,6 +21,7 @@ extern int currbid;
extern boardheader_t *bcache;
extern int currmode;
extern userec_t cuser;
+extern time_t now;
void do_voteboardreply(fileheader_t *fhdr){
char genbuf[1024];
@@ -34,7 +35,7 @@ void do_voteboardreply(fileheader_t *fhdr){
int len;
int i, j;
int fd;
- time_t endtime, now = time(NULL);
+ time_t endtime;
int hastime = 0;
@@ -203,7 +204,6 @@ int do_voteboard() {
char fpath[80];
FILE* fp;
int temp, i;
- time_t now = time(NULL);
clear();
if(!(currmode & MODE_POST)) {
diff --git a/mbbsd/xyz.c b/mbbsd/xyz.c
index 1cac394a..daa0116e 100644
--- a/mbbsd/xyz.c
+++ b/mbbsd/xyz.c
@@ -1,4 +1,4 @@
-/* $Id: xyz.c,v 1.4 2002/05/06 13:34:11 ptt Exp $ */
+/* $Id: xyz.c,v 1.5 2002/05/13 03:20:04 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -22,7 +22,7 @@ extern char fromhost[];
extern userinfo_t *currutmp;
extern int curr_idle_timeout;
extern userec_t cuser;
-
+extern time_t now;
/* 各種統計及相關資訊列表 */
/* Ptt90年度大學聯招查榜系統 */
int x_90() {
@@ -194,7 +194,7 @@ int note() {
strcpy(myitem.userid, cuser.userid);
strncpy(myitem.username, cuser.username, 18);
myitem.username[18] = '\0';
- time(&(myitem.date));
+ myitem.date=now;
/* begin load file */
if((foo = fopen(".note", "a")) == NULL)