summaryrefslogtreecommitdiffstats
path: root/usr.bin/talk/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/talk/io.c')
-rw-r--r--usr.bin/talk/io.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/usr.bin/talk/io.c b/usr.bin/talk/io.c
index f7f31bd..f608654 100644
--- a/usr.bin/talk/io.c
+++ b/usr.bin/talk/io.c
@@ -49,28 +49,28 @@ static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 6/6/93";
#include "talk.h"
#define A_LONG_TIME 10000000
-#define STDIN_MASK (1<<fileno(stdin)) /* the bit mask for standard
- input */
/*
* The routine to do the actual talking
*/
+void
talk()
{
- register int read_template, sockt_mask;
- int read_set, nb;
+ int nb;
+ fd_set read_set, read_template;
char buf[BUFSIZ];
struct timeval wait;
message("Connection established\007\007\007");
current_line = 0;
- sockt_mask = (1<<sockt);
/*
* Wait on both the other process (sockt_mask) and
* standard input ( STDIN_MASK )
*/
- read_template = sockt_mask | STDIN_MASK;
+ FD_ZERO(&read_template);
+ FD_SET(sockt, &read_template);
+ FD_SET(fileno(stdin), &read_template);
for (;;) {
read_set = read_template;
wait.tv_sec = A_LONG_TIME;
@@ -85,7 +85,7 @@ talk()
p_error("Unexpected error from select");
quit();
}
- if (read_set & sockt_mask) {
+ if (FD_ISSET(sockt, &read_set)) {
/* There is data on sockt */
nb = read(sockt, buf, sizeof buf);
if (nb <= 0) {
@@ -94,7 +94,7 @@ talk()
}
display(&his_win, buf, nb);
}
- if (read_set & STDIN_MASK) {
+ if (FD_ISSET(fileno(stdin), &read_set)) {
/*
* We can't make the tty non_blocking, because
* curses's output routines would screw up
@@ -115,6 +115,7 @@ extern int sys_nerr;
* p_error prints the system error message on the standard location
* on the screen and then exits. (i.e. a curses version of perror)
*/
+void
p_error(string)
char *string;
{
@@ -130,6 +131,7 @@ p_error(string)
/*
* Display string in the standard location
*/
+void
message(string)
char *string;
{
OpenPOWER on IntegriCloud