summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/args.c2
-rw-r--r--mbbsd/convert.c25
-rw-r--r--mbbsd/io.c36
-rw-r--r--mbbsd/mbbsd.c2
-rw-r--r--mbbsd/screen.c47
-rw-r--r--mbbsd/talk.c8
-rw-r--r--mbbsd/term.c9
-rw-r--r--mbbsd/topsong.c2
-rw-r--r--mbbsd/var.c4
-rw-r--r--mbbsd/vice.c2
10 files changed, 105 insertions, 32 deletions
diff --git a/mbbsd/args.c b/mbbsd/args.c
index bf36827b..32156517 100644
--- a/mbbsd/args.c
+++ b/mbbsd/args.c
@@ -1,4 +1,4 @@
-/* $Id: args.c,v 1.8 2003/06/26 01:04:03 kcwu Exp $ */
+/* $Id$ */
#include "bbs.h"
#ifdef HAVE_SETPROCTITLE
diff --git a/mbbsd/convert.c b/mbbsd/convert.c
index f07e21db..390ca286 100644
--- a/mbbsd/convert.c
+++ b/mbbsd/convert.c
@@ -1,6 +1,31 @@
/* $Id: convert.c 1374 2003-11-27 14:11:40Z victor $ */
#include "bbs.h"
+/*
+ * 只有當 CONVERT 這個 option 開起來時才會用到這些東西。
+ *
+ * Main idea
+ * =========
+ * 為了達到跟原本 read/write 的 transparency,這邊分別對每種 encoding 定義
+ * 了他們的 converting function。外界使用時透過 read_wrapper 跟 write_wrapper
+ * (function pointer),所以只須把 wrapper 指到 convert.c 中定義的 converting
+ * function 即可達到目的。
+ *
+ * 目前在轉換 encoding 方面,使用了 libhz 這個 library。
+ *
+ * Subroutines
+ * ===========
+ *
+ * void set_converting_type(int which);
+ * 事實上,這邊不希望外界直接 override wrapper 的值。使用這個界面可以設定
+ * 轉換的 encoding。
+ *
+ * which 可以是:
+ * CONV_NORMAL 不作轉換
+ * CONV_GB Big5 <-> GB
+ * CONV_UTF8 Big5 <-> UTF-8
+ */
+
#ifdef CONVERT
extern read_write_type write_type;
diff --git a/mbbsd/io.c b/mbbsd/io.c
index aee1d04a..fa9b7b5c 100644
--- a/mbbsd/io.c
+++ b/mbbsd/io.c
@@ -1,14 +1,24 @@
/* $Id$ */
#include "bbs.h"
-// XXX why linux use smaller buffer?
-#if defined(linux)
-#define OBUFSIZE 2048
-#define IBUFSIZE 128
-#else
+/*
+ * Mechanism
+ * =========
+ * 每次 output 的時候,會先寫到 output buffer。如果這時候 buffer 滿了、
+ * 或是呼叫 oflush() 時, buffer 才會被寫出。
+ *
+ * int ochar(char c)
+ * 寫一個 c 到 output buffer
+ *
+ * void output(char *s, int len)
+ * 寫一個長度為 len 的字串 s 到 output buffer
+ *
+ * void oflush(void)
+ * 把 buffer 寫出去
+ */
+
#define OBUFSIZE 4096
#define IBUFSIZE 256
-#endif
static char outbuf[OBUFSIZE], inbuf[IBUFSIZE];
static int obufsize = 0, ibufsize = 0;
@@ -19,6 +29,20 @@ static int icurrchar = 0;
/* ----------------------------------------------------- */
#ifdef CONVERT
+/*
+ * CONVERT
+ * =======
+ * pttbbs 支援 Big5<->GB 與 Big5<->UTF-8 之間的 encoding 轉換。這個功能
+ * 主要在 io.c 裡面達成。
+ *
+ * io.c 裡面在處理 read 跟 write 時,用了 read_wrapper 跟 write_wrapper
+ * 這兩個 function pointer。一般情況下,也就是不轉換 encoding 時,是指到
+ * read(2) 跟 write(2) 兩個 system call。否則會指到 convert.c 裡面定義的轉
+ * 換函式。
+ *
+ * convert.c 中定義了轉換的 interface,詳見 convert.c。
+ */
+
read_write_type write_type = (read_write_type)write;
read_write_type read_type = read;
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index 529f0931..062908b1 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -527,7 +527,7 @@ login_query()
#else
show_file("etc/Welcome", 1, -1, NO_RELOAD);
#endif
- output("1", 1);
+ output("1", 1); ///???????????
attempts = 0;
diff --git a/mbbsd/screen.c b/mbbsd/screen.c
index 04dcec40..056ffec4 100644
--- a/mbbsd/screen.c
+++ b/mbbsd/screen.c
@@ -7,6 +7,7 @@
#define o_standup() output(strtstandout,strtstandoutlen)
#define o_standdown() output(endstandout,endstandoutlen)
+
static unsigned char cur_ln = 0, cur_col = 0;
static unsigned char docls, downfrom = 0;
static unsigned char standing = NA;
@@ -15,15 +16,16 @@ static int scrollcnt, tc_col, tc_line;
#define MODIFIED (1) /* if line has been modifed, screen output */
#define STANDOUT (2) /* if this line has a standout region */
-int tputs(const char *str, int affcnt, int (*putc) (int));
void
initscr()
{
if (!big_picture) {
- scr_lns = t_lines;
+#ifdef Try_to_remove_these_code
+ scr_lns = scr_lns;
scr_cols = ANSILINELEN;
/* scr_cols = MIN(t_columns, ANSILINELEN); */
+#endif
big_picture = (screenline_t *) calloc(scr_lns, sizeof(screenline_t));
docls = YEA;
}
@@ -75,14 +77,29 @@ rel_move(int was_col, int was_ln, int new_col, int new_ln)
do_move(new_col, new_ln);
}
+/*
+ */
static void
standoutput(char *buf, int ds, int de, int sso, int eso)
{
- int st_start, st_end;
-
if (eso <= ds || sso >= de) {
output(buf + ds, de - ds);
} else {
+#if 0
+ if (sso > ds) // does is not happened?
+ output(buf + ds, sso - ds);
+ else
+ vmsg("!!!!!!");
+ o_standup();
+ output(buf + sso, de - sso);
+ o_standdown();
+ if (de > eso) // does is not happened?
+ output(buf + eso, de - eso);
+ else
+ vmsg("!!!!!!");
+#else
+ short st_start, st_end;
+
st_start = MAX(sso, ds);
st_end = MIN(eso, de);
if (sso > ds)
@@ -92,6 +109,7 @@ standoutput(char *buf, int ds, int de, int sso, int eso)
o_standdown();
if (de > eso)
output(buf + eso, de - eso);
+#endif
}
}
@@ -113,7 +131,7 @@ redoscr()
else
output((char *)bp->data, len);
tc_col += len;
- if (tc_col >= t_columns) {
+ if (tc_col >= t_columns) {
/* XXX Is this code right? */
if (automargins)
tc_col = t_columns - 1;
@@ -125,6 +143,7 @@ redoscr()
}
}
bp->mode &= ~(MODIFIED);
+ // oldlen = len ?
bp->oldlen = len;
}
}
@@ -233,6 +252,7 @@ clrtoeol()
if (cur_col <= slp->sso)
slp->mode &= ~STANDOUT;
+ // XXX
if (cur_col > slp->oldlen) {
for (ln = slp->len; ln <= cur_col; ln++)
slp->data[ln] = ' ';
@@ -301,7 +321,7 @@ outch(unsigned char c)
}
if (slp->data[cur_col] != c) {
slp->data[cur_col] = c;
- if ((slp->mode & MODIFIED) != MODIFIED)
+ if (!(slp->mode & MODIFIED))
slp->smod = slp->emod = cur_col;
slp->mode |= MODIFIED;
if (cur_col > slp->emod)
@@ -325,15 +345,18 @@ parsecolor(char *buf)
{
char *val;
char data[24];
+ short len = 0;
data[0] = '\0';
val = (char *)strtok(buf, ";");
while (val) {
if (atoi(val) < 30) {
- if (data[0])
- strcat(data, ";");
- strcat(data, val);
+ if (data[0]) {
+ data[len++] = ';';
+ data[len] = 0;
+ }
+ strcpy(&data[len], val);
}
val = (char *)strtok(NULL, ";");
}
@@ -436,7 +459,7 @@ void
prints(char *fmt,...)
{
va_list args;
- char buff[1024];
+ char buff[256];
va_start(args, fmt);
vsnprintf(buff, sizeof(buff), fmt, args);
@@ -449,7 +472,7 @@ mouts(int y, int x, char *str)
{
move(y, x);
clrtoeol();
- prints("%s",str);
+ outs(str);
}
void
@@ -498,6 +521,7 @@ region_scroll_up(int top, int bottom)
refresh();
}
+/* 開始反白 - 瑩幕上之後的訊息開始反白輸出 */
void
standout()
{
@@ -511,6 +535,7 @@ standout()
}
}
+/* 結束反白 */
void
standend()
{
diff --git a/mbbsd/talk.c b/mbbsd/talk.c
index e5936862..b710c66d 100644
--- a/mbbsd/talk.c
+++ b/mbbsd/talk.c
@@ -494,9 +494,9 @@ my_write2(void)
currstat = DBACK;
//init screen
- move(7, 28);
+ move(WB_OFO_USER_TOP, WB_OFO_USER_LEFT);
prints("\033[1;33;46m ↑ 水球反擊對象 ↓\033[0m");
- for (i = 0; i < 5; ++i)
+ for (i = 0; i < WB_OFO_USER_HEIGHT; ++i)
if (swater[i] == NULL || swater[i]->pid == 0)
break;
else {
@@ -506,10 +506,10 @@ my_write2(void)
swater[i]->uin = (userinfo_t *) search_ulist_pid(swater[i]->pid);
water_scr(swater[i], i, 0);
}
- move(15, 4);
+ move(WB_OFO_MSG_TOP, WB_OFO_MSG_LEFT);
prints("\033[0m \033[1;35m◇\033[1;36m────────────────"
"─────────────────\033[1;35m◇\033[0m ");
- move(22, 4);
+ move(WB_OFO_MSG_BOTTOM, WB_OFO_MSG_LEFT);
prints(" \033[1;35m◇\033[1;36m────────────────"
"─────────────────\033[1;35m◇\033[0m ");
water_scr(swater[0], 0, 1);
diff --git a/mbbsd/term.c b/mbbsd/term.c
index 555840d1..df21211f 100644
--- a/mbbsd/term.c
+++ b/mbbsd/term.c
@@ -1,13 +1,6 @@
/* $Id$ */
#include "bbs.h"
-int tgetent(const char *bp, char *name);
-char *tgetstr(const char *id, char **area);
-int tgetflag(const char *id);
-int tgetnum(const char *id);
-int tputs(const char *str, int affcnt, int (*putc) (int));
-char *tparm(const char *str,...);
-char *tgoto(const char *cap, int col, int row);
static struct termios tty_state, tty_new;
@@ -78,7 +71,9 @@ term_resize(int sig)
}
t_lines = newsize.ws_row;
t_columns = newsize.ws_col;
+#ifdef Try_to_remove_these_code
scr_lns = t_lines; /* XXX: scr_lns 跟 t_lines 有什麼不同, 為何分成兩個 */
+#endif
b_lines = t_lines - 1;
p_lines = t_lines - 4;
diff --git a/mbbsd/topsong.c b/mbbsd/topsong.c
index 015f7de5..81f4d0c6 100644
--- a/mbbsd/topsong.c
+++ b/mbbsd/topsong.c
@@ -1,4 +1,4 @@
-/* $Id: topsong.c,v 1.6 2002/07/27 10:04:34 kcwu Exp $ */
+/* $Id$ */
#include "bbs.h"
#define MAX_SONGS 300
diff --git a/mbbsd/var.c b/mbbsd/var.c
index c499663b..c0773882 100644
--- a/mbbsd/var.c
+++ b/mbbsd/var.c
@@ -401,8 +401,12 @@ char chc_warnmsg[64], *chc_mateid;
/* screen.c */
screenline_t *big_picture = NULL;
+#ifdef Try_to_remove_these_code
unsigned char scr_lns;
unsigned short scr_cols;
+#endif
+#define scr_lns t_lines
+#define scr_cols t_columns
char roll;
/* gomo.c */
diff --git a/mbbsd/vice.c b/mbbsd/vice.c
index e774479c..d66f498d 100644
--- a/mbbsd/vice.c
+++ b/mbbsd/vice.c
@@ -1,4 +1,4 @@
-/* $Id: vice.c,v 1.9 2003/06/28 08:49:26 kcwu Exp $ */
+/* $Id$ */
#include "bbs.h"
#define VICE_PLAY BBSHOME "/etc/vice/vice.play"