summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mbbsd/bbs.c20
-rw-r--r--mbbsd/cal.c4
-rw-r--r--mbbsd/chat.c7
-rw-r--r--mbbsd/dice.c13
-rw-r--r--mbbsd/io.c2
-rw-r--r--mbbsd/mbbsd.c69
-rw-r--r--mbbsd/menu.c40
-rw-r--r--mbbsd/screen.c15
-rw-r--r--mbbsd/talk.c2
-rw-r--r--mbbsd/var.c4
10 files changed, 81 insertions, 95 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index bb7d7f9a..85c894a6 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -100,7 +100,6 @@ save_violatelaw()
*/
static time_t board_note_time;
-static char *brd_title;
void
set_board()
@@ -113,12 +112,10 @@ set_board()
u_exit("access control violation!");
}
board_note_time = bp->bupdate;
- brd_title = bp->BM;
- if (brd_title[0] <= ' ')
- brd_title = "徵求中";
- snprintf(currBM, sizeof(currBM), "板主:%s", brd_title);
- brd_title = ((bp->bvote != 2 && bp->bvote) ? "本看板進行投票中" :
- bp->title + 7);
+ if(bp->BM[0] <= ' ')
+ strcpy(currBM, "徵求中");
+ else
+ snprintf(currBM, sizeof(currBM), "板主:%s", bp->BM);
currmode = (currmode & (MODE_DIRTY | MODE_MENU)) | MODE_STARTED;
if (HAS_PERM(PERM_ALLBOARD) || is_BM_cache(currbid))
@@ -130,6 +127,15 @@ set_board()
static void
readtitle()
{
+ boardheader_t *bp;
+ char *brd_title;
+
+ bp = getbcache(currbid);
+ if(bp->bvote != 2 && bp->bvote)
+ brd_title = "本看板進行投票中";
+ else
+ brd_title = bp->title + 7;
+
showtitle(currBM, brd_title);
outs("[←]離開 [→]閱\讀 [^P]發表文章 [b]備忘錄 [d]刪除 [z]精華區 "
"[TAB]文摘 [h]elp\n\033[7m 編號 日 期 作 者 文 章 標 題"
diff --git a/mbbsd/cal.c b/mbbsd/cal.c
index fceaf2b1..37123a01 100644
--- a/mbbsd/cal.c
+++ b/mbbsd/cal.c
@@ -409,11 +409,11 @@ p_give()
int
p_sysinfo(void)
{
- char buf[128], *cpuloadstr;
+ char *cpuloadstr;
int load;
extern char *compile_time;
- load = cpuload(buf);
+ load = cpuload(NULL);
cpuloadstr = (load < 5 ? "良好" : (load < 20 ? "尚可" : "過重"));
clear();
diff --git a/mbbsd/chat.c b/mbbsd/chat.c
index d7ea2f53..11988f9f 100644
--- a/mbbsd/chat.c
+++ b/mbbsd/chat.c
@@ -57,10 +57,8 @@ chat_send(int fd, char *buf)
return (send(fd, genbuf, len, 0) == len);
}
-static char chatroom[IDLEN];/* Chat-Room Name */
-
static int
-chat_recv(int fd, char *chatid)
+chat_recv(int fd, char chatroom[IDLEN], char *chatid)
{
static char buf[128];
static int bufstart = 0;
@@ -299,6 +297,7 @@ static int chatid_len = 10;
int
t_chat()
{
+ char chatroom[IDLEN];/* Chat-Room Name */
char inbuf[80], chatid[20], lastcmd[MAXLASTCMD][80], *ptr = "";
struct sockaddr_in sin;
struct hostent *h;
@@ -415,7 +414,7 @@ t_chat()
printchatline("◆ 噹!郵差又來了...");
}
if (ch == I_OTHERDATA) {/* incoming */
- if (chat_recv(cfd, chatid) == -1) {
+ if (chat_recv(cfd, chatroom, chatid) == -1) {
chatting = chat_send(cfd, "/b");
break;
}
diff --git a/mbbsd/dice.c b/mbbsd/dice.c
index 12572965..8fb0a9f9 100644
--- a/mbbsd/dice.c
+++ b/mbbsd/dice.c
@@ -1,4 +1,4 @@
-/* $Id: dice.c,v 1.7 2003/01/16 12:23:03 kcwu Exp $ */
+/* $Id$ */
#include "bbs.h"
#define DICE_TXT BBSHOME "/etc/dice.txt"
@@ -332,7 +332,7 @@ dice_main(void)
char input[10], data[256], ch;
dicedata_t table[256];
int bet[3], index, money = 0, i, ya = 0, j, total, sig = 0;
- FILE *winfp /* , *lostfp */ ;
+ FILE *winfp;
more(DICE_TXT, NA);
reload_money();
@@ -344,8 +344,7 @@ dice_main(void)
}
lockreturn0(DICE, LOCK_MULTI);
winfp = fopen(DICE_WIN, "a");
- /* lostfp = fopen(DICE_LOST,"a"); */
- if (!winfp /* || !lostfp */ )
+ if (!winfp)
return 0;
do {
@@ -433,7 +432,6 @@ dice_main(void)
if (i == 0) {
fclose(winfp);
- /* fclose(lostfp); */
unlockutmpmode();
return 0;
}
@@ -445,10 +443,6 @@ dice_main(void)
continue;
ya = bingo(flag, table[j].mybet);
if (ya == 0) {
- /*
- * sprintf(data, "%-15s 輸了 %-8d $", cuser.userid,
- * table[j].mymoney); fprintf(lostfp, "%s\n", data);
- */
continue;
}
demoney(table[j].mymoney * ya + table[j].mymoney);
@@ -482,7 +476,6 @@ dice_main(void)
input, 2, LCECHO);
} while (input[0] != 'n' && input[0] != 'N');
fclose(winfp);
- /* fclose(lostfp); */
unlockutmpmode();
return 0;
}
diff --git a/mbbsd/io.c b/mbbsd/io.c
index 6f3cff9e..bb09d79f 100644
--- a/mbbsd/io.c
+++ b/mbbsd/io.c
@@ -492,7 +492,7 @@ getans(char *prompt)
{
char ans[5];
- getdata(t_lines - 1, 0, prompt, ans, sizeof(ans), LCECHO);
+ getdata(b_lines, 0, prompt, ans, sizeof(ans), LCECHO);
return ans[0];
}
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index f9bc80b3..e419cc1d 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -92,29 +92,6 @@ reapchild(int sig)
while ((pid = waitpid(-1, &state, WNOHANG | WUNTRACED)) > 0);
}
-#define BANNER \
-"【" BBSNAME "】◎ 台大流行網 ◎(" MYHOSTNAME ") 調幅(" MYIP ") "
-/* check load and print approriate banner string in buf */
-static int
-chkload(char *buf, int length)
-{
- char cpu_load[30];
- int i;
-
- i = cpuload(cpu_load);
-
- buf[0] = 0;
-#ifdef INSCREEN
- if( i > MAX_CPULOAD ){
- strlcpy(buf, BANNER "\r\n系統過載, 請稍後再來\r\n", length);
- }
-#else
- snprintf(buf, length, BANNER "%s\r\n",
- (i > MAX_CPULOAD ? "高負荷量,請稍後再來(請利用port 3000~3010連線)" : ""));
-#endif
- return i > MAX_CPULOAD ? 1 : 0;
-}
-
void
log_user(char *msg)
{
@@ -1371,41 +1348,49 @@ static int
check_ban_and_load(int fd)
{
FILE *fp;
- static char buf[256];
static time_t chkload_time = 0;
static int overload = 0; /* overload or banned, update every 1
* sec */
static int banned = 0;
#ifdef INSCREEN
- write(fd, INSCREEN, strlen(INSCREEN));
+ write(fd, INSCREEN, sizeof(INSCREEN));
+#else
+#define BANNER \
+"【" BBSNAME "】◎ 台大流行網 ◎(" MYHOSTNAME ") 調幅(" MYIP ") \r\n"
+ write(fd, BANNER, sizeof(BANNER));
#endif
if ((time(0) - chkload_time) > 1) {
- overload = chkload(buf, sizeof(buf));
- banned = !access(BBSHOME "/BAN", R_OK) &&
- (strcmp(fromhost, "localhost") != 0);
+ overload = 0;
+ banned = 0;
+
+ if(cpuload(NULL) > MAX_CPULOAD)
+ overload = 1;
+ else if (SHM->UTMPnumber >= MAX_ACTIVE
+#ifdef DYMAX_ACTIVE
+ || (SHM->GV2.e.dymaxactive > 2000 &&
+ SHM->UTMPnumber >= SHM->GV2.e.dymaxactive)
+#endif
+ ) {
+ ++SHM->GV2.e.toomanyusers;
+ overload = 2;
+ } else if(!access(BBSHOME "/" BAN_FILE, R_OK))
+ banned = 1;
+
chkload_time = time(0);
}
- write(fd, buf, strlen(buf));
- if (banned && (fp = fopen(BBSHOME "/BAN", "r"))) {
- // XXX this will mess up buf
+ if(overload == 1)
+ write(fd, "系統過載, 請稍後再來\r\n", 22);
+ else if(overload == 2)
+ write(fd, "由於人數過多,請您稍後再來。", 28);
+ else if (banned && (fp = fopen(BBSHOME "/" BAN_FILE, "r"))) {
+ char buf[256];
while (fgets(buf, sizeof(buf), fp))
write(fd, buf, strlen(buf));
fclose(fp);
}
- if (SHM->UTMPnumber >= MAX_ACTIVE
-#ifdef DYMAX_ACTIVE
- || (SHM->GV2.e.dymaxactive > 2000 &&
- SHM->UTMPnumber >= SHM->GV2.e.dymaxactive)
-#endif
- ) {
- ++SHM->GV2.e.toomanyusers;
- snprintf(buf, sizeof(buf), "由於人數過多,請您稍後再來。");
- write(fd, buf, strlen(buf));
- overload = 1;
- }
if (banned || overload)
return -1;
diff --git a/mbbsd/menu.c b/mbbsd/menu.c
index bca66e7b..1e42410c 100644
--- a/mbbsd/menu.c
+++ b/mbbsd/menu.c
@@ -92,7 +92,27 @@ showtitle(char *title, char *mid)
#define FILMROW 11
static unsigned char menu_row = 12;
static unsigned char menu_column = 20;
-static char mystatus[160];
+
+static void
+show_status(void)
+{
+ int i;
+ struct tm *ptime = localtime(&now);
+ char mystatus[160];
+ char *myweek = "天一二三四五六";
+ const char *msgs[] = {"關閉", "打開", "拔掉", "防水", "好友"};
+
+ i = ptime->tm_wday << 1;
+ snprintf(mystatus, sizeof(mystatus),
+ "\033[34;46m[%d/%d 星期%c%c %d:%02d]\033[1;33;45m%-14s"
+ "\033[30;47m 目前坊裡有 \033[31m%d\033[30m人, 我是\033[31m%-12s"
+ "\033[30m[扣機]\033[31m%s\033[0m",
+ ptime->tm_mon + 1, ptime->tm_mday, myweek[i], myweek[i + 1],
+ ptime->tm_hour, ptime->tm_min, currutmp->birth ?
+ "生日要請客唷" : SHM->today_is,
+ SHM->UTMPnumber, cuser.userid, msgs[currutmp->pager]);
+ outmsg(mystatus);
+}
static int
u_movie()
@@ -105,9 +125,6 @@ void
movie(int i)
{
static short history[MAX_HISTORY];
- char *myweek = "天一二三四五六";
- const char *msgs[] = {"關閉", "打開", "拔掉", "防水", "好友"};
- struct tm *ptime = localtime(&now);
int j;
if ((currstat != CLASS) && (cuser.uflag & MOVIE_FLAG) &&
@@ -140,16 +157,7 @@ movie(int i)
Jaky_outs(SHM->notes[i], 11); /* 只印11行就好 */
outs(reset_color);
}
- i = ptime->tm_wday << 1;
- snprintf(mystatus, sizeof(mystatus),
- "\033[34;46m[%d/%d 星期%c%c %d:%02d]\033[1;33;45m%-14s"
- "\033[30;47m 目前坊裡有 \033[31m%d\033[30m人, 我是\033[31m%-12s"
- "\033[30m[扣機]\033[31m%s\033[0m",
- ptime->tm_mon + 1, ptime->tm_mday, myweek[i], myweek[i + 1],
- ptime->tm_hour, ptime->tm_min, currutmp->birth ?
- "生日要請客唷" : SHM->today_is,
- SHM->UTMPnumber, cuser.userid, msgs[currutmp->pager]);
- outmsg(mystatus);
+ show_status();
refresh();
}
@@ -193,7 +201,7 @@ domenu(int cmdmode, char *cmdtitle, int cmd, commands_t cmdtable[])
total = show_menu(cmdtable);
- outmsg(mystatus);
+ show_status();
lastcmdptr = pos = 0;
do {
@@ -296,7 +304,7 @@ domenu(int cmdmode, char *cmdtitle, int cmd, commands_t cmdtable[])
show_menu(cmdtable);
- outmsg(mystatus);
+ show_status();
refscreen = NA;
}
cursor_clear(menu_row + pos, menu_column);
diff --git a/mbbsd/screen.c b/mbbsd/screen.c
index 1f27dd86..24dffc4d 100644
--- a/mbbsd/screen.c
+++ b/mbbsd/screen.c
@@ -1,4 +1,4 @@
-/* $Id: screen.c,v 1.16 2003/06/28 08:42:37 kcwu Exp $ */
+/* $Id$ */
#include "bbs.h"
#ifdef SUPPORT_GB
@@ -217,11 +217,11 @@ clear()
register int i;
docls = YEA;
- cur_col = cur_ln = roll = downfrom = i = 0;
- do {
+ cur_col = cur_ln = roll = downfrom = 0;
+ for(i=0; i<scr_lns; i++) {
slp = &big_picture[i];
slp->mode = slp->len = slp->oldlen = 0;
- } while (++i < scr_lns);
+ }
}
void
@@ -473,12 +473,7 @@ outmsg(char *msg)
{
move(b_lines, 0);
clrtoeol();
-#ifdef SUPPORT_GB
- if (current_font_type == TYPE_GB)
- msg = hc_convert_str(msg, HC_BIGtoGB, HC_DO_SINGLE);
-#endif
- while (*msg)
- outc(*msg++);
+ outs(msg);
}
void
diff --git a/mbbsd/talk.c b/mbbsd/talk.c
index 7ccd1e87..7abb595a 100644
--- a/mbbsd/talk.c
+++ b/mbbsd/talk.c
@@ -396,7 +396,7 @@ my_query(char *uident)
return DONOTHING;
}
-static char t_last_write[200] = "";
+static char t_last_write[80];
void
water_scr(water_t * tw, int which, char type)
diff --git a/mbbsd/var.c b/mbbsd/var.c
index 5125442e..0ad9e78f 100644
--- a/mbbsd/var.c
+++ b/mbbsd/var.c
@@ -313,8 +313,8 @@ char *ModeTypeTable[MAX_MODES] = {
};
/* term.c */
-int b_lines = 23;
-int t_lines = 24;
+int b_lines = 23; // bottom line of screen
+int t_lines = 24; // term lines
int p_lines = 20;
int t_columns = 80;
char *strtstandout = "\33[7m";