summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/proto.h6
-rw-r--r--mbbsd/io.c22
-rw-r--r--mbbsd/mbbsd.c121
-rw-r--r--mbbsd/talk.c65
4 files changed, 125 insertions, 89 deletions
diff --git a/include/proto.h b/include/proto.h
index ca62fed5..8604aab5 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -1,4 +1,4 @@
-/* $Id: proto.h,v 1.3 2002/03/09 17:44:39 in2 Exp $ */
+/* $Id: proto.h,v 1.4 2002/03/14 08:17:43 in2 Exp $ */
#ifndef INCLUDE_PROTO_H
#define INCLUDE_PROTO_H
@@ -261,6 +261,8 @@ int do_send(char *userid, char *title);
void my_send(char *uident);
/* mbbsd */
+void show_call_in(int save, int which);
+void write_request (int sig);
void log_usies(char *mode, char *mesg);
void log_user(char *msg);
void abort_bbs(int sig);
@@ -409,7 +411,7 @@ void post_change_perm(int oldperm, int newperm, char *sysopid, char *userid);
/* talk */
int cmpwatermtime(const void *a, const void *b);
-void water_scr(water_t **currwater, int which, char type);
+//void water_scr(water_t *tw, int which, char type);
void my_write2(void);
int t_idle();
char *modestring(userinfo_t * uentp, int simple);
diff --git a/mbbsd/io.c b/mbbsd/io.c
index 1f13ffeb..c0e796df 100644
--- a/mbbsd/io.c
+++ b/mbbsd/io.c
@@ -1,4 +1,4 @@
-/* $Id: io.c,v 1.2 2002/03/09 10:34:58 in2 Exp $ */
+/* $Id: io.c,v 1.3 2002/03/14 08:17:45 in2 Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -124,10 +124,20 @@ int num_in_buf() {
}
int watermode = -1;
-/* Ptt 水球回顧用的參數 */
-/* watermode = -1 沒在回水球
- = 0 在回上一顆水球 (Ctrl-R)
- > 0 在回前 n 顆水球 (Ctrl-R Ctrl-R) */
+/*
+ WATERMODE(WATER_ORIG) | WATERMODE(WATER_NEW):
+ Ptt 水球回顧用的參數
+ watermode = -1 沒在回水球
+ = 0 在回上一顆水球 (Ctrl-R)
+ > 0 在回前 n 顆水球 (Ctrl-R Ctrl-R)
+
+ WATERMODE(WATER_OFO) by in2
+ watermode = -1 沒在回水球
+ = 0 正在回水球
+ = 1 回水球間又接到水球
+ watermode >=0 時收到水球將只顯示, 不會到water[]裡,
+ 待回完水球的時候一次寫入.
+*/
/*
dogetch() is not reentrant-safe. SIGUSR[12] might happen at any time,
@@ -256,7 +266,7 @@ int igetch() {
/* 如果正在talk的話先不處理對方送過來的封包 (不去select) */
my_newfd = i_newfd;
i_newfd = 0;
- show_last_call_in(0);
+ show_call_in(0, 0);
watermode = 0;
my_write(currutmp->msgs[0].pid, "水球丟過去 : ",
currutmp->msgs[0].userid, 0, NULL);
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index b0f0dd55..3a38aabb 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -1,4 +1,4 @@
-/* $Id: mbbsd.c,v 1.5 2002/03/12 16:54:36 in2 Exp $ */
+/* $Id: mbbsd.c,v 1.6 2002/03/14 08:17:45 in2 Exp $ */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -320,11 +320,11 @@ extern char *fn_writelog;
FILE *fp_writelog = NULL;
void
-show_last_call_in (int save)
+show_call_in(int save, int which)
{
char buf[200];
sprintf (buf, "\033[1;33;46m★%s\033[37;45m %s \033[m",
- currutmp->msgs[0].userid, currutmp->msgs[0].last_call_in);
+ currutmp->msgs[which].userid, currutmp->msgs[which].last_call_in);
move (b_lines, 0);
clrtoeol ();
refresh ();
@@ -416,66 +416,91 @@ add_history(msgque_t *msg)
return i;
}
-static void
+void
write_request (int sig)
{
+ int i;
+ /*
struct tm *ptime;
time_t now;
time (&now);
ptime = localtime (&now);
-
- if (!WATERMODE(WATER_OFO) &&
- currutmp->mode != 0 &&
- currutmp->pager != 0 &&
- cuser.userlevel != 0 &&
- currutmp->msgcount != 0 &&
- currutmp->mode != TALK &&
- currutmp->mode != EDITING &&
- currutmp->mode != CHATING &&
- currutmp->mode != PAGE &&
- currutmp->mode != IDLE &&
- currutmp->mode != MAILALL && currutmp->mode != MONITOR){
- int i;
- char c0 = currutmp->chatid[0];
- int currstat0 = currstat;
- unsigned char mode0 = currutmp->mode;
-
- currutmp->mode = 0;
- currutmp->chatid[0] = 2;
- currstat = XMODE;
-
- do{
+ */
+ if( WATERMODE(WATER_OFO) ){
+ /* sig = SIGUSR2 waterball come in
+ 0 flush to water[] (by my_write2())
+ */
+ if( sig != 0 ){
+ if( watermode == 0 ) /* 正在回水球 */
+ watermode = 1;
bell ();
- show_last_call_in (1);
- igetch ();
- currutmp->msgcount--;
- if (currutmp->msgcount >= MAX_MSGS){
- /* this causes chaos... jochang */
- raise (SIGFPE);
+ show_call_in(1, currutmp->msgcount - 1);
+ refresh ();
+ }
+
+ if( sig == 0 || /* 回水球的時候又有水球進來, 回完後一次寫回去 */
+ watermode == -1 ){ /* 不在回水球模式 */
+ do{
+ add_history(&currutmp->msgs[0]);
+ for (i = 0; i < currutmp->msgcount; i++)
+ currutmp->msgs[i] = currutmp->msgs[i + 1];
}
-
- add_history(&currutmp->msgs[0]);
- for (i = 0; i < currutmp->msgcount; i++)
- currutmp->msgs[i] = currutmp->msgs[i + 1];
+ while (currutmp->msgcount);
+ currutmp->msgcount = 0;
}
- while (currutmp->msgcount);
- currutmp->chatid[0] = c0;
- currutmp->mode = mode0;
- currstat = currstat0;
}
else{
- bell ();
- show_last_call_in (1);
- add_history(&currutmp->msgs[0]);
-
- refresh ();
- currutmp->msgcount = 0;
+ if (currutmp->mode != 0 &&
+ currutmp->pager != 0 &&
+ cuser.userlevel != 0 &&
+ currutmp->msgcount != 0 &&
+ currutmp->mode != TALK &&
+ currutmp->mode != EDITING &&
+ currutmp->mode != CHATING &&
+ currutmp->mode != PAGE &&
+ currutmp->mode != IDLE &&
+ currutmp->mode != MAILALL && currutmp->mode != MONITOR){
+ char c0 = currutmp->chatid[0];
+ int currstat0 = currstat;
+ unsigned char mode0 = currutmp->mode;
+
+ currutmp->mode = 0;
+ currutmp->chatid[0] = 2;
+ currstat = XMODE;
+
+ do{
+ bell ();
+ show_call_in(1, 0);
+ igetch ();
+ currutmp->msgcount--;
+ if (currutmp->msgcount >= MAX_MSGS){
+ /* this causes chaos... jochang */
+ raise (SIGFPE);
+ }
+
+ add_history(&currutmp->msgs[0]);
+ for (i = 0; i < currutmp->msgcount; i++)
+ currutmp->msgs[i] = currutmp->msgs[i + 1];
+ }
+ while (currutmp->msgcount);
+ currutmp->chatid[0] = c0;
+ currutmp->mode = mode0;
+ currstat = currstat0;
+ }
+ else{
+ bell ();
+ show_call_in(1, 0);
+ add_history(&currutmp->msgs[0]);
+
+ refresh ();
+ currutmp->msgcount = 0;
+ }
}
}
#if 0
-static void
+void
write_request (int sig)
{
int i, mtimemin, wu;
@@ -512,7 +537,7 @@ write_request (int sig)
water[wu].msgtop %= 5;
bell ();
- show_last_call_in (1);
+ show_call_in(1, 0);
refresh();
if( watermode == 0 ){ /* in waterball selection mode
diff --git a/mbbsd/talk.c b/mbbsd/talk.c
index 5499d18f..5edf29a0 100644
--- a/mbbsd/talk.c
+++ b/mbbsd/talk.c
@@ -1,4 +1,4 @@
-/* $Id: talk.c,v 1.6 2002/03/12 16:54:36 in2 Exp $ */
+/* $Id: talk.c,v 1.7 2002/03/14 08:17:45 in2 Exp $ */
#include <stdio.h>
#include <string.h>
#include <errno.h>
@@ -435,7 +435,7 @@ int my_query(char *uident)
static char t_last_write[200] = "";
-void water_scr(water_t **currwater, int which, char type)
+void water_scr(water_t *tw, int which, char type)
{
if( type == 1 ){
int i;
@@ -443,24 +443,24 @@ void water_scr(water_t **currwater, int which, char type)
move(8 + which, 28);prints(" ");
move(8 + which, 28);
prints("\033[1;37;45m %c %-14s \033[0m",
- currwater[which]->alive ? ' ' : 'x',
- currwater[which]->userid);
+ tw->alive ? ' ' : 'x',
+ tw->userid);
for( i = 0 ; i < 5 ; ++i ){
move(16 + i, 4);
prints(" ");
move(16 + i, 4);
- if( currwater[which]->msg[ (currwater[which]->top-i+4) % 5 ].last_call_in[0] != 0 )
+ if( tw->msg[ (tw->top - i + 4) % 5 ].last_call_in[0] != 0 )
prints("\033[0m \033[1;%d;44m★%-64s\033[0m \n",
colors[i],
- currwater[which]->msg[ (currwater[which]->top-i+4) % 5 ].last_call_in);
+ tw->msg[ (tw->top - i + 4) % 5 ].last_call_in);
else
prints("\033[0m \n");
}
move(0, 0);prints(" ");
move(0, 0);
- prints("\033[0m反擊 %s:", currwater[which]->userid);
+ prints("\033[0m反擊 %s:", tw->userid);
clrtoeol();
- move(0, strlen(currwater[which]->userid) + 6);
+ move(0, strlen(tw->userid) + 6);
}
else{
move(8 + which, 28);
@@ -468,17 +468,17 @@ void water_scr(water_t **currwater, int which, char type)
// refresh();
move(8 + which, 28);
prints("\033[1;37;44m %c %-13s \033[0m",
- currwater[which]->alive ? ' ' : 'x',
- currwater[which]->userid);
+ tw->alive ? ' ' : 'x',
+ tw->userid);
// refresh();
}
}
void my_write2(void)
{
- int i, ch, currstat0, currwater_usies;
+ int i, ch, currstat0;
char genbuf[256], msg[80], done = 0, c0, which;
- water_t *tw, *currwater[5];
+ water_t *tw;
unsigned char mode0;
watermode = 0;
@@ -490,19 +490,17 @@ void my_write2(void)
currstat = XMODE;
// init screen
- memcpy(currwater, swater, sizeof(water_t*) * 5);
- currwater_usies = water_usies;
move(7, 28);
prints("\033[1;33;46m ↑ 水球反擊對象 ↓\033[0m");
for( i = 0 ; i < 5 ; ++i )
- if( currwater[i] == NULL || currwater[i]->pid == 0 )
+ if( swater[i] == NULL || swater[i]->pid == 0 )
break;
else{
- if( currwater[i]->alive &&
- (currwater[i]->pid != currwater[i]->uin->pid ||
- strcmp(currwater[i]->userid, currwater[i]->uin->userid)) )
- currwater[i]->alive = 0;
- water_scr(currwater, i, 0);
+ if( swater[i]->alive &&
+ (swater[i]->pid != swater[i]->uin->pid ||
+ strcmp(swater[i]->userid, swater[i]->uin->userid)) )
+ swater[i]->alive = 0;
+ water_scr(swater[i], i, 0);
}
move(15, 4);
prints("\033[0m \033[1;35m◇\033[1;36m────────────────"
@@ -513,7 +511,7 @@ void my_write2(void)
move(21, 4);prints(" ");
move(21, 4);
prints("\033[0m \033[1;37;46m%-66s\033[0m \n", t_last_write);
- water_scr(currwater, 0, 1);
+ water_scr(swater[0], 0, 1);
refresh();
which = 0;
@@ -521,20 +519,20 @@ void my_write2(void)
switch( (ch = igetkey()) ){
case Ctrl('T'):
case KEY_UP:
- if( currwater_usies != 1 ){
- water_scr(currwater, which, 0);
- which = (which - 1 + currwater_usies) % currwater_usies;
- water_scr(currwater, which, 1);
+ if( water_usies != 1 ){
+ water_scr(swater[(int)which], which, 0);
+ which = (which - 1 + water_usies) % water_usies;
+ water_scr(swater[(int)which], which, 1);
refresh();
}
break;
case KEY_DOWN:
case Ctrl('R'):
- if( currwater_usies != 1 ){
- water_scr(currwater, which, 0);
- which = (which + 1 + currwater_usies) % currwater_usies;
- water_scr(currwater, which, 1);
+ if( water_usies != 1 ){
+ water_scr(swater[(int)which], which, 0);
+ which = (which + 1 + water_usies) % water_usies;
+ water_scr(swater[(int)which], which, 1);
refresh();
}
break;
@@ -545,8 +543,7 @@ void my_write2(void)
default:
done = 1;
- watermode = 1;
- tw = currwater[(int)which];
+ tw = swater[(int)which];
if( !tw->alive )
break;
@@ -568,10 +565,12 @@ void my_write2(void)
}
} while( !done );
- watermode = -1;
currstat = currstat0;
currutmp->chatid[0] = c0;
currutmp->mode = mode0;
+ if( watermode == 1 )
+ write_request(0);
+ watermode = -1;
}
/*
@@ -2356,7 +2355,7 @@ void talkreply(void)
prints("對方來自 [%s],共上站 %d 次,文章 %d 篇\n",
uip->from, xuser.numlogins, xuser.numposts);
showplans(uip->userid);
- show_last_call_in(0);
+ show_call_in(0, 0);
sprintf(genbuf, "你想跟 %s %s啊?請選擇(Y/N/A/B/C/D/E/F/1/2)[N] ",
page_requestor, sig_des[sig]);