summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-10-28 02:12:04 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-10-28 02:12:04 +0800
commit12352b4cbcf2e5d362fad88f34d68f618b88b202 (patch)
tree4631dad28966dc3bf072045996141d4a454418e4
parentac092d512c7e74a06eb70786f6c21c4734f9167d (diff)
downloadpttbbs-12352b4cbcf2e5d362fad88f34d68f618b88b202.tar
pttbbs-12352b4cbcf2e5d362fad88f34d68f618b88b202.tar.gz
pttbbs-12352b4cbcf2e5d362fad88f34d68f618b88b202.tar.bz2
pttbbs-12352b4cbcf2e5d362fad88f34d68f618b88b202.tar.lz
pttbbs-12352b4cbcf2e5d362fad88f34d68f618b88b202.tar.xz
pttbbs-12352b4cbcf2e5d362fad88f34d68f618b88b202.tar.zst
pttbbs-12352b4cbcf2e5d362fad88f34d68f618b88b202.zip
* change add_io(fd, 0) to vkey_attach()
* for add_io with timeout > 0, we need vkey_poll() so do it later. git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5003 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttbbs/include/proto.h4
-rw-r--r--pttbbs/mbbsd/ccw.c12
-rw-r--r--pttbbs/mbbsd/ch_dark.c2
-rw-r--r--pttbbs/mbbsd/chess.c2
-rw-r--r--pttbbs/mbbsd/io.c8
-rw-r--r--pttbbs/mbbsd/talk.c2
6 files changed, 19 insertions, 11 deletions
diff --git a/pttbbs/include/proto.h b/pttbbs/include/proto.h
index 0c20ff4e..f0a7e6ba 100644
--- a/pttbbs/include/proto.h
+++ b/pttbbs/include/proto.h
@@ -289,8 +289,8 @@ void add_io(int fd, int timeout);
int vkey(); // identical to igetch
void vkey_flush(); // identical to drop_input
int vkey_is_full(); // identical to input_isfull
-int vkey_detach(void); // works like to add_io(0, 0)
-// int vkey_attach(int fd); // works like add_io(fd, ...)
+int vkey_detach(void); // works like to add_io(0, 0)
+int vkey_attach(int fd); // works like add_io(fd, ...)
// int vkey_is_ready(); // works like (num_in_buf() > 0)
/* kaede */
diff --git a/pttbbs/mbbsd/ccw.c b/pttbbs/mbbsd/ccw.c
index 86f6cb0b..69a747d2 100644
--- a/pttbbs/mbbsd/ccw.c
+++ b/pttbbs/mbbsd/ccw.c
@@ -360,7 +360,7 @@ ccw_vgetcb_peek(int key, VGET_RUNTIME *prt GCC_UNUSED, void *instance)
fflush(ctx->log);
more(ctx->log_fpath, YEA);
- add_io(ctx->fd, 0);
+ vkey_attach(ctx->fd);
vscr_restore(scr);
}
return VGETCB_NEXT;
@@ -373,7 +373,7 @@ ccw_vgetcb_peek(int key, VGET_RUNTIME *prt GCC_UNUSED, void *instance)
if (vans("確定要離開嗎? [y/N]: ") == 'y')
ctx->abort = YEA;
- add_io(ctx->fd, 0);
+ vkey_attach(ctx->fd);
vscr_restore(scr);
// ccw_footer(ctx);
}
@@ -691,7 +691,7 @@ ccw_talk(int fd, int destuid)
fprintf(ctx.log, "[%s] 與 %s " CCW_CAP_TALK ":\n", Cdatelite(&now), ctx.remote_id);
// main processor
- add_io(fd, 0);
+ vkey_attach(fd);
ccw_process(&ctx);
// clean network resource
@@ -805,7 +805,7 @@ ccw_chat_footer(CCW_CTX *ctx)
ZA_Enter();
- add_io(ctx->fd, 0);
+ vkey_attach(ctx->fd);
vscr_restore(scr);
}
@@ -1146,7 +1146,7 @@ ccw_chat_peek_key(CCW_CTX *ctx, int key)
vkey_detach();
za = ZA_Select();
ccw_footer(ctx);
- add_io(ctx->fd, 0);
+ vkey_attach(ctx->fd);
vcur_restore(cur);
if (za)
ctx->abort_vget = 1;
@@ -1237,7 +1237,7 @@ ccw_chat(int fd)
fprintf(ctx.log, "[%s] 進入" CCW_CAP_CHAT ":\n", Cdatelite(&now));
// main processor
- add_io(fd, 0);
+ vkey_attach(fd);
ccw_process(&ctx);
// clean network resource
diff --git a/pttbbs/mbbsd/ch_dark.c b/pttbbs/mbbsd/ch_dark.c
index e6a16f6d..dc35b1df 100644
--- a/pttbbs/mbbsd/ch_dark.c
+++ b/pttbbs/mbbsd/ch_dark.c
@@ -398,7 +398,7 @@ main_dark(int fd, userinfo_t * uin)
if (currutmp->turn)
move(cury[0], curx[0]);
- add_io(fd, 0);
+ vkey_attach(fd);
while (end <= 0) {
if (uin->turn == 'w' || currutmp->turn == 'w') {
end = -1;
diff --git a/pttbbs/mbbsd/chess.c b/pttbbs/mbbsd/chess.c
index 6fa18627..daf385ae 100644
--- a/pttbbs/mbbsd/chess.c
+++ b/pttbbs/mbbsd/chess.c
@@ -23,7 +23,7 @@
#define CHESS_DRAWING_PHOTOED_TIME_ROW2 21
#define CHESS_DRAWING_PHOTOED_WARN_ROW 22
-#define CONNECT_PEER() add_io(info->sock, 0)
+#define CONNECT_PEER() vkey_attach(info->sock)
#define IGNORE_PEER() vkey_detach()
#define DO_WITHOUT_PEER(TIMEOUT,ACT,ELSE) \
diff --git a/pttbbs/mbbsd/io.c b/pttbbs/mbbsd/io.c
index f21afe7c..8e8c06b0 100644
--- a/pttbbs/mbbsd/io.c
+++ b/pttbbs/mbbsd/io.c
@@ -651,6 +651,14 @@ vkey_detach(void)
return r;
}
+int
+vkey_attach(int fd)
+{
+ int r = i_newfd;
+ add_io(fd, 0);
+ return r;
+}
+
/*
* wait user input for f seconds.
* return 1 if control key c is available.
diff --git a/pttbbs/mbbsd/talk.c b/pttbbs/mbbsd/talk.c
index 21f7fbea..bd02a86d 100644
--- a/pttbbs/mbbsd/talk.c
+++ b/pttbbs/mbbsd/talk.c
@@ -1393,7 +1393,7 @@ my_talk(userinfo_t * uin, int fri_stat, char defact)
uin->sig == SIG_GO || uin->sig == SIG_REVERSI)
ChessEstablishRequest(msgsock);
- add_io(msgsock, 0);
+ vkey_attach(msgsock);
while ((ch = vkey()) != I_OTHERDATA) {
if (ch == Ctrl('D')) {
vkey_detach();