diff options
-rw-r--r-- | include/proto.h | 4 | ||||
-rw-r--r-- | include/pttstruct.h | 25 | ||||
-rw-r--r-- | mbbsd/friend.c | 4 | ||||
-rw-r--r-- | mbbsd/io.c | 4 | ||||
-rw-r--r-- | mbbsd/mbbsd.c | 67 | ||||
-rw-r--r-- | mbbsd/talk.c | 28 |
6 files changed, 76 insertions, 56 deletions
diff --git a/include/proto.h b/include/proto.h index 8122f5d5..5247ac7f 100644 --- a/include/proto.h +++ b/include/proto.h @@ -1,4 +1,4 @@ -/* $Id: proto.h,v 1.1 2002/03/07 15:13:48 in2 Exp $ */ +/* $Id: proto.h,v 1.2 2002/03/09 10:34:56 in2 Exp $ */ #ifndef INCLUDE_PROTO_H #define INCLUDE_PROTO_H @@ -416,7 +416,7 @@ char *modestring(userinfo_t * uentp, int simple); int isvisible(userinfo_t * me, userinfo_t * uentp); int t_users(); int cmpuids(int uid, userinfo_t * urec); -int my_write(pid_t pid, char *hint, char *id, int flag); +int my_write(pid_t pid, char *hint, char *id, int flag, userinfo_t *); void t_display_new(); void talkreply(); int t_monitor(); diff --git a/include/pttstruct.h b/include/pttstruct.h index 76a196a9..ea1e7d78 100644 --- a/include/pttstruct.h +++ b/include/pttstruct.h @@ -1,4 +1,4 @@ -/* $Id: pttstruct.h,v 1.1 2002/03/07 15:13:48 in2 Exp $ */ +/* $Id: pttstruct.h,v 1.2 2002/03/09 10:34:56 in2 Exp $ */ #ifndef INCLUDE_STRUCT_H #define INCLUDE_STRUCT_H @@ -191,23 +191,16 @@ typedef struct { int num, page, now, level; } gmenu_t; +#define FAVMAX 74 /* Max boards of Myfavorite */ +#define FAVGMAX 16 /* Max groups of Myfavorite */ +#define FAVGSLEN 8 /* Max Length of Description String */ + typedef struct msgque_t { pid_t pid; char userid[IDLEN + 1]; char last_call_in[80]; } msgque_t; -typedef struct water_t { - pid_t pid; - char userid[IDLEN + 1]; - msgque_t msg[MAX_REVIEW]; - int top, count; -} water_t; - -#define FAVMAX 74 /* Max boards of Myfavorite */ -#define FAVGMAX 16 /* Max groups of Myfavorite */ -#define FAVGSLEN 8 /* Max Length of Description String */ - typedef struct userinfo_t { int uid; /* Used to find user name in passwd file */ pid_t pid; /* kill() to notify user of talk request */ @@ -258,6 +251,14 @@ typedef struct userinfo_t { int mind; } userinfo_t; +typedef struct water_t { + pid_t pid; + char userid[IDLEN + 1], alive; + int top, count; + msgque_t msg[MAX_REVIEW]; + userinfo_t *uin; +} water_t; + typedef struct { fileheader_t *header; char mtitle[STRLEN]; diff --git a/mbbsd/friend.c b/mbbsd/friend.c index 3d2167ae..a51d3000 100644 --- a/mbbsd/friend.c +++ b/mbbsd/friend.c @@ -1,4 +1,4 @@ -/* $Id: friend.c,v 1.1 2002/03/07 15:13:48 in2 Exp $ */ +/* $Id: friend.c,v 1.2 2002/03/09 10:34:58 in2 Exp $ */ #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -330,7 +330,7 @@ static void friend_water(char *message, int type) { /* 群體水球 added by Ptt */ if((tuid = searchuser(userid)) && tuid != usernum && (uentp = (userinfo_t *) search_ulist(tuid)) && isvisible_uid(tuid)) - my_write(uentp->pid, message, uentp->userid, 1); + my_write(uentp->pid, message, uentp->userid, 1, NULL); } fclose(fp); } @@ -1,4 +1,4 @@ -/* $Id: io.c,v 1.1 2002/03/07 15:13:48 in2 Exp $ */ +/* $Id: io.c,v 1.2 2002/03/09 10:34:58 in2 Exp $ */ #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -259,7 +259,7 @@ int igetch() { show_last_call_in(0); watermode = 0; my_write(currutmp->msgs[0].pid, "水球丟過去 : ", - currutmp->msgs[0].userid, 0); + currutmp->msgs[0].userid, 0, NULL); i_newfd = my_newfd; /* 還原螢幕 */ diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index c4849da5..85f29642 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -1,4 +1,4 @@ -/* $Id: mbbsd.c,v 1.1 2002/03/07 15:13:48 in2 Exp $ */ +/* $Id: mbbsd.c,v 1.2 2002/03/09 10:34:58 in2 Exp $ */ #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -349,9 +349,15 @@ extern unsigned int currstat; water_t water[6], *swater[6], *water_which=&water[0]; char water_usies=0; extern int watermode; -static int add_history_water(water_t *w, msgque_t *msg) +static int add_history_water(water_t *w, msgque_t *msg, char mode) { - memcpy(&w->msg[w->top], msg, sizeof(msgque_t)); + // mode: 1: all data(including userid, pid); + // 0: only last_call_in + if( mode ) + memcpy(&w->msg[w->top], msg, sizeof(msgque_t)); + else + memcpy(&w->msg[w->top].last_call_in, msg->last_call_in, + sizeof(msg->last_call_in)); w->top++; w->top %= WATERMODE(WATER_OFO) ? 5 : MAX_REVIEW; @@ -364,34 +370,37 @@ static int add_history_water(water_t *w, msgque_t *msg) static int add_history(msgque_t *msg) { - int i,j; + int i = 0, j; water_t *tmp; - add_history_water(&water[0], msg); - for(i = 0 ; i < 5 && swater[i] ; i++ ) - if( swater[i]->pid == msg->pid ) - break; - if( i != 5 ){ - if( !swater[i] ){ - water_usies = i + 1; - swater[i] = &water[i + 1]; - strcpy(swater[i]->userid, msg->userid); - swater[i]->pid = msg->pid; + if( WATERMODE(WATER_ORIG) || WATERMODE(WATER_NEW) ) + add_history_water(&water[0], msg, 1); + if( WATERMODE(WATER_NEW) || WATERMODE(WATER_OFO) ){ + for(i = 0 ; i < 5 && swater[i] ; i++ ) + if( swater[i]->pid == msg->pid ) + break; + if( i != 5 ){ + if( !swater[i] ){ + water_usies = i + 1; + swater[i] = &water[i + 1]; + strcpy(swater[i]->userid, msg->userid); + swater[i]->pid = msg->pid; + } + tmp = swater[i]; } - tmp = swater[i]; - } - else{ - tmp = swater[4]; - memset(swater[4], 0, sizeof (water_t)); - strcpy(swater[4]->userid, msg->userid); - swater[4]->pid = msg->pid; - i = 4; + else{ + tmp = swater[4]; + memset(swater[4], 0, sizeof (water_t)); + strcpy(swater[4]->userid, msg->userid); + swater[4]->pid = msg->pid; + i = 4; + } + + for( j = i ; j > 0 ; j-- ) + swater[j] = swater[j - 1]; + swater[0] = tmp; + add_history_water(swater[0], msg, 0); } - - for( j = i ; j > 0 ; j-- ) - swater[j] = swater[j - 1]; - swater[0] = tmp; - add_history_water(swater[0], msg); - + if(WATERMODE(WATER_ORIG) || WATERMODE(WATER_NEW) ){ if( watermode > 0 && (water_which == swater[0] || water_which == &water[0]) ){ @@ -1015,7 +1024,7 @@ do_aloha (char *hello) if ((tuid = searchuser (userid)) && tuid != usernum && (uentp = (userinfo_t *) search_ulist (tuid)) && isvisible(uentp, currutmp)){ - my_write (uentp->pid, genbuf, uentp->userid, 2); + my_write (uentp->pid, genbuf, uentp->userid, 2, NULL); } } fclose (fp); diff --git a/mbbsd/talk.c b/mbbsd/talk.c index 3012b2d2..b5c99aad 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -1,4 +1,4 @@ -/* $Id: talk.c,v 1.1 2002/03/07 15:13:48 in2 Exp $ */ +/* $Id: talk.c,v 1.2 2002/03/09 10:34:58 in2 Exp $ */ #include <stdio.h> #include <string.h> #include <errno.h> @@ -466,7 +466,9 @@ void water_scr(water_t **currwater, int which, char type) int colors[] = {33, 37, 33, 37, 33}; move(8 + which, 28);prints(" "); move(8 + which, 28); - prints("\033[1;37;45m %-14s \033[0m", currwater[which]->userid); + prints("\033[1;37;45m %c %-14s \033[0m", + currwater[which]->alive ? ' ' : 'x', + currwater[which]->userid); for( i = 0 ; i < 5 ; ++i ){ move(16 + i, 4); prints(" "); @@ -489,7 +491,9 @@ void water_scr(water_t **currwater, int which, char type) prints("123456789012345678901234567890"); // refresh(); move(8 + which, 28); - prints("\033[1;37;44m %-13s \033[0m", currwater[which]->userid); + prints("\033[1;37;44m %c %-13s \033[0m", + currwater[which]->alive ? ' ' : 'x', + currwater[which]->userid); // refresh(); } } @@ -517,8 +521,14 @@ void my_write2(void) for( i = 0 ; i < 5 ; ++i ) if( currwater[i] == NULL || currwater[i]->pid == 0 ) break; - else + else{ + if( currwater[i]->uin == NULL ) + currwater[i]->uin = + (userinfo_t *)search_ulist_pid(currwater[i]->pid); + currwater[i]->alive = (strcmp(currwater[i]->userid, + currwater[i]->uin->userid) == 0); water_scr(currwater, i, 0); + } move(15, 4); prints("\033[0m \033[1;35m◇\033[1;36m────────────────" "─────────────────\033[1;35m◇\033[0m "); @@ -575,7 +585,7 @@ void my_write2(void) 80-strlen(tw->userid)-6, DOECHO) ) break; - my_write(tw->pid, msg, tw->userid, 4); + my_write(tw->pid, msg, tw->userid, 4, tw->uin); break; } } while( !done ); @@ -595,7 +605,7 @@ void my_write2(void) 5. 丟水球 flag = 0 6. my_write2 flag = 4 (pre-edit) but confirm */ -int my_write(pid_t pid, char *prompt, char *id, int flag) { +int my_write(pid_t pid, char *prompt, char *id, int flag, userinfo_t *puin) { int len, currstat0 = currstat, fri_stat; char msg[80], destid[IDLEN + 1]; char genbuf[200], buf[200], c0 = currutmp->chatid[0]; @@ -603,7 +613,7 @@ int my_write(pid_t pid, char *prompt, char *id, int flag) { time_t now; struct tm *ptime; userinfo_t *uin; - uin = (userinfo_t *)search_ulist_pid(pid); + uin = (puin != NULL) ? puin : (userinfo_t *)search_ulist_pid(pid); strcpy(destid, id); if(!uin && !(flag == 0 && water_which->count> 0)) { @@ -2107,7 +2117,7 @@ static void pickup_user() { (HAS_PERM(PERM_SYSOP) || (uentp->pager != 3 && (uentp->pager != 4 || fri_stat & HFM)))) - my_write(uentp->pid, genbuf, uentp->userid, HAS_PERM(PERM_SYSOP) ? 3 : 1); + my_write(uentp->pid, genbuf, uentp->userid, HAS_PERM(PERM_SYSOP) ? 3 : 1, NULL); } } break; @@ -2206,7 +2216,7 @@ static void pickup_user() { { cursor_show(num + 3 - head, 0); sprintf(genbuf, "Call-In %s :", uentp->userid); - my_write(uentp->pid, genbuf, uentp->userid, 0); + my_write(uentp->pid, genbuf, uentp->userid, 0, NULL); } } else if (ch == 'l') |