diff options
author | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-09-09 12:42:53 +0800 |
---|---|---|
committer | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-09-09 12:42:53 +0800 |
commit | 40fafbfba1a53581e9318c71d6366a24470173be (patch) | |
tree | 065380a6e4881de9c51609773d048f165b8fc988 | |
parent | fc5bd5742759eea401ffa112d696a3fe028675d1 (diff) | |
download | pttbbs-40fafbfba1a53581e9318c71d6366a24470173be.tar pttbbs-40fafbfba1a53581e9318c71d6366a24470173be.tar.gz pttbbs-40fafbfba1a53581e9318c71d6366a24470173be.tar.bz2 pttbbs-40fafbfba1a53581e9318c71d6366a24470173be.tar.lz pttbbs-40fafbfba1a53581e9318c71d6366a24470173be.tar.xz pttbbs-40fafbfba1a53581e9318c71d6366a24470173be.tar.zst pttbbs-40fafbfba1a53581e9318c71d6366a24470173be.zip |
fix chc bug, but still buggy
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2184 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | include/chc.h | 7 | ||||
-rw-r--r-- | include/common.h | 7 | ||||
-rw-r--r-- | include/config.h | 5 | ||||
-rw-r--r-- | include/proto.h | 1 | ||||
-rw-r--r-- | mbbsd/chc.c | 20 | ||||
-rw-r--r-- | mbbsd/more.c | 2 | ||||
-rw-r--r-- | mbbsd/talk.c | 26 |
7 files changed, 44 insertions, 24 deletions
diff --git a/include/chc.h b/include/chc.h index 9305ab0d..416f1193 100644 --- a/include/chc.h +++ b/include/chc.h @@ -19,6 +19,13 @@ #define CHC_PERSONAL 4 /* ¥´ÃÐ */ #define CHC_WATCH_PERSONAL 8 /* Æ[¤H¥´ÃÐ */ +#define CHE_O(c) ((c) >> 3) +#define CHE_P(c) ((c) & 7) +#define RTL(x) (((x) - 3) >> 1) +#define dim(x) (sizeof(x) / sizeof(x[0])) +#define LTR(x) ((x) * 2 + 3) +#define CHE(a, b) ((a) | ((b) << 3)) + #define BLACK_COLOR "\033[1;36m" #define RED_COLOR "\033[1;31m" #define BLACK_REVERSE "\033[1;37;46m" diff --git a/include/common.h b/include/common.h index c830454a..04a351dd 100644 --- a/include/common.h +++ b/include/common.h @@ -178,13 +178,6 @@ #define I_TIMEOUT (-2) /* Used for the getchar routine select call */ #define I_OTHERDATA (-333) /* interface, (-3) will conflict with chinese */ -#define CHE_O(c) ((c) >> 3) -#define CHE_P(c) ((c) & 7) -#define RTL(x) (((x) - 3) >> 1) -#define dim(x) (sizeof(x) / sizeof(x[0])) -#define LTR(x) ((x) * 2 + 3) -#define CHE(a, b) ((a) | ((b) << 3)) - #define MAX_MODES 127 #ifndef MIN diff --git a/include/config.h b/include/config.h index 3b75d63b..7b05978c 100644 --- a/include/config.h +++ b/include/config.h @@ -117,6 +117,9 @@ #define ADD_EXMAILBOX 0 /* ÃØ°e«H½c */ #endif +/* more.c ¤¤¤å³¹¶¼Æ¤W(lines/22), +4 for safe */ +#define MAX_PAGES (MAX_EDIT_LINE / 22 + 4) + /* ¥H¤UÁÙ¥¼¾ã²z */ #define MAX_FRIEND (256) /* ¸ü¤J cache ¤§³Ì¦hªB¤Í¼Æ¥Ø */ #define MAX_REJECT (32) /* ¸ü¤J cache ¤§³Ì¦hÃa¤H¼Æ¥Ø */ @@ -130,7 +133,6 @@ #define MAX_LOGIN_INFO (128) /* ³Ì¦h¤W½u³qª¾¤H¼Æ */ #define MAX_POST_INFO (32) /* ³Ì¦h·s¤å³¹³qª¾¤H¼Æ */ #define MAX_NAMELIST (128) /* ³Ì¦h¨ä¥L¯S§O¦W³æ¤H¼Æ */ -#define MAX_PAGES (999) /* more.c ¤¤¤å³¹¶¼Æ¤W(lines/22) */ #define MAX_KEEPMAIL (200) /* ³Ì¦h«O¯d´X«Ê MAIL¡H */ #define MAX_NOTE (20) /* ³Ì¦h«O¯d´X½g¯d¨¥¡H */ #define MAX_SIGLINES (6) /* ñ¦WÀɤޤJ³Ì¤j¦æ¼Æ */ @@ -141,7 +143,6 @@ #define LOGINATTEMPTS (3) /* ³Ì¤j¶i¯¸¥¢»~¦¸¼Æ */ #define WHERE /* ¬O§_¦³¬G¶m¥\¯à */ #undef LOG_BOARD /* ¬ÝªO¬O§_log */ -#undef SUPPORT_GB /* ¬O§_¤ä´©gb */ #define LOGINASNEW /* ±Ä¥Î¤W¯¸¥Ó½Ð±b¸¹¨î«× */ diff --git a/include/proto.h b/include/proto.h index 0d66649f..f86e0a24 100644 --- a/include/proto.h +++ b/include/proto.h @@ -330,6 +330,7 @@ void add_distinct(char *fname, char *line); void u_exit(char *mode); void talk_request(int sig); int reply_connection_request(userinfo_t *uip); +int establish_talk_connection(userinfo_t *uip); void my_talk(userinfo_t * uin, int fri_stat, char defact); /* menu */ diff --git a/mbbsd/chc.c b/mbbsd/chc.c index 5ab93a00..759c9749 100644 --- a/mbbsd/chc.c +++ b/mbbsd/chc.c @@ -5,8 +5,6 @@ #define CHC_TIMEOUT 300 #define CHC_LOG "chc_log" /* log file name */ -extern userinfo_t *uip; - typedef int (*play_func_t) (int, chcusr_t *, chcusr_t *, board_t, board_t); typedef struct drc_t { @@ -197,14 +195,16 @@ chc_drawline(board_t board, chcusr_t *user1, chcusr_t *user2, int line) j = board[RTL(line)][i]; if ((line & 1) == 1 && j) { if (chc_selected && - chc_select.r == RTL(line) && chc_select.c == i) + chc_select.r == RTL(line) && chc_select.c == i) { prints("%s%s\033[m", CHE_O(j) == 0 ? BLACK_REVERSE : RED_REVERSE, chess_str[CHE_O(j)][CHE_P(j)]); - else + } + else { prints("%s%s\033[m", CHE_O(j) == 0 ? BLACK_COLOR : RED_COLOR, chess_str[CHE_O(j)][CHE_P(j)]); + } } else prints("%c%c", chess_brd[line - 3][i * 4], chess_brd[line - 3][i * 4 + 1]); @@ -840,11 +840,17 @@ chc_watch_request(int signo) return; for(tmp = act_list; tmp->next != NULL; tmp = tmp->next); tmp->next = (chc_act_list *)malloc(sizeof(chc_act_list)); + tmp->next->sock = establish_talk_connection(&SHM->uinfo[currutmp->destuip]); + if (tmp->next->sock < 0) { + free(tmp->next); + tmp->next = NULL; + return; + } + tmp = tmp->next; - tmp->sock = reply_connection_request(uip); - if (tmp->sock < 0) - return; tmp->next = NULL; + + /* what if the spectator get off-line intentionally !? (SIGPIPE) */ write(tmp->sock, chc_bp, sizeof(board_t)); write(tmp->sock, &chc_my, sizeof(chc_my)); write(tmp->sock, &chc_turn, sizeof(chc_turn)); diff --git a/mbbsd/more.c b/mbbsd/more.c index 5feb34b7..80f59947 100644 --- a/mbbsd/more.c +++ b/mbbsd/more.c @@ -1,5 +1,7 @@ /* $Id$ */ #include "bbs.h" + +/* §â³o¨âÓ size ½Õ¨ì¤@¶ªº½d³ò¬O¤£¬O¯à°§C¤£¥²nªº IO ? */ #define MORE_BUFSIZE 4096 #define MORE_WINSIZE 4096 #define STR_ANSICODE "[0123456789;," diff --git a/mbbsd/talk.c b/mbbsd/talk.c index e96ed86e..eb51d4f4 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -2697,10 +2697,7 @@ t_talk() int reply_connection_request(userinfo_t *uip) { - int a; char buf[4], genbuf[200]; - struct hostent *h; - struct sockaddr_in sin; if (uip->mode != PAGE) { snprintf(genbuf, sizeof(genbuf), @@ -2708,6 +2705,16 @@ reply_connection_request(userinfo_t *uip) getdata(0, 0, genbuf, buf, sizeof(buf), LCECHO); return -1; } + return establish_talk_connection(uip); +} + +int +establish_talk_connection(userinfo_t *uip) +{ + int a; + struct hostent *h; + struct sockaddr_in sin; + currutmp->msgcount = 0; strlcpy(save_page_requestor, page_requestor, sizeof(save_page_requestor)); memset(page_requestor, 0, sizeof(page_requestor)); @@ -2719,7 +2726,10 @@ reply_connection_request(userinfo_t *uip) sin.sin_family = h->h_addrtype; memcpy(&sin.sin_addr, h->h_addr, h->h_length); sin.sin_port = uip->sockaddr; - a = socket(sin.sin_family, SOCK_STREAM, 0); + if ((a = socket(sin.sin_family, SOCK_STREAM, 0)) < 0) { + perror("connect err"); + return -1; + } if ((connect(a, (struct sockaddr *) & sin, sizeof(sin)))) { perror("connect err"); return -1; @@ -2980,14 +2990,14 @@ AngelNotOnline(){ outs("\nÍ¢¯d¨¥µ¹§A¡G\n"); outs("\033[1;31;44m¡ó¢s¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢t\033[37m" "¤p¤Ñ¨Ï¯d¨¥\033[31m¢u¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢s¡ó\033[m\n"); - outs("\033[1;31mùú¢t\033[32m ¤p¤Ñ¨Ï " - " \033[31m¢uùû\033[m\n"); + outs("\033[1;31m¢~¢t\033[32m ¤p¤Ñ¨Ï " + " \033[31m¢u¢¡\033[m\n"); while (fgets(buf, sizeof(buf), fp)) { buf[strlen(buf) - 1] = 0; prints("\033[1;31m¢x\033[m%-74.74s\033[1;31m¢x\033[m\n", buf); } - outs("\033[1;31mùü¢s¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w" - "¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢sùý\033[m\n"); + outs("\033[1;31m¢¢¢s¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w" + "¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢s¢£\033[m\n"); outs("\033[1;31;44m¡ó¢r¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w" "¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢r¡ó\033[m\n"); |