summaryrefslogtreecommitdiff
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.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/usr.bin/talk/io.c b/usr.bin/talk/io.c
index e1ddb6ec4bd..8438b80e98a 100644
--- a/usr.bin/talk/io.c
+++ b/usr.bin/talk/io.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: io.c,v 1.4 1998/04/27 15:45:50 pjanzen Exp $ */
+/* $OpenBSD: io.c,v 1.5 1998/04/28 22:13:28 pjanzen Exp $ */
/* $NetBSD: io.c,v 1.4 1994/12/09 02:14:20 jtc Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: io.c,v 1.4 1998/04/27 15:45:50 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: io.c,v 1.5 1998/04/28 22:13:28 pjanzen Exp $";
#endif /* not lint */
/*
@@ -47,24 +47,23 @@ static char rcsid[] = "$OpenBSD: io.c,v 1.4 1998/04/27 15:45:50 pjanzen Exp $";
* ctl.c
*/
+#include "talk.h"
#include <sys/ioctl.h>
#include <sys/time.h>
#include <stdio.h>
#include <errno.h>
-#include <string.h>
-#include "talk.h"
+#include <unistd.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;
+ fd_set read_template, read_set;
+ int nb;
char buf[BUFSIZ];
struct timeval wait;
@@ -81,13 +80,14 @@ talk()
message("Connection established\007\007\007");
#endif
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;
@@ -102,7 +102,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) {
@@ -111,7 +111,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
@@ -125,13 +125,11 @@ talk()
}
}
-extern int errno;
-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;
{
@@ -147,6 +145,7 @@ p_error(string)
/*
* Display string in the standard location
*/
+void
message(string)
char *string;
{