diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/talk/ctl.c | 16 | ||||
-rw-r--r-- | usr.bin/talk/ctl_transact.c | 10 | ||||
-rw-r--r-- | usr.bin/talk/init_disp.c | 21 | ||||
-rw-r--r-- | usr.bin/talk/invite.c | 15 | ||||
-rw-r--r-- | usr.bin/talk/io.c | 30 | ||||
-rw-r--r-- | usr.bin/talk/look_up.c | 8 | ||||
-rw-r--r-- | usr.bin/talk/talk.h | 5 |
7 files changed, 44 insertions, 61 deletions
diff --git a/usr.bin/talk/ctl.c b/usr.bin/talk/ctl.c index 2ef77d20f1d..7e2394a9c96 100644 --- a/usr.bin/talk/ctl.c +++ b/usr.bin/talk/ctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ctl.c,v 1.4 1998/08/18 04:02:09 millert Exp $ */ +/* $OpenBSD: ctl.c,v 1.5 1999/03/03 20:43:30 millert Exp $ */ /* $NetBSD: ctl.c,v 1.3 1994/12/09 02:14:10 jtc Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)ctl.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: ctl.c,v 1.4 1998/08/18 04:02:09 millert Exp $"; +static char rcsid[] = "$OpenBSD: ctl.c,v 1.5 1999/03/03 20:43:30 millert Exp $"; #endif /* not lint */ /* @@ -76,12 +76,12 @@ open_sockt() my_addr.sin_port = 0; sockt = socket(AF_INET, SOCK_STREAM, 0); if (sockt <= 0) - p_error("Bad socket"); + quit("Bad socket", 1); if (bind(sockt, (struct sockaddr *)&my_addr, sizeof(my_addr)) != 0) - p_error("Binding local socket"); + quit("Binding local socket", 1); length = sizeof(my_addr); if (getsockname(sockt, (struct sockaddr *)&my_addr, &length) == -1) - p_error("Bad address for socket"); + quit("Bad address for socket", 1); } /* open the ctl socket */ @@ -94,14 +94,14 @@ open_ctl() ctl_addr.sin_addr = my_machine_addr; ctl_sockt = socket(AF_INET, SOCK_DGRAM, 0); if (ctl_sockt <= 0) - p_error("Bad socket"); + quit("Bad socket", 1); if (bind(ctl_sockt, (struct sockaddr *)&ctl_addr, sizeof(ctl_addr)) != 0) - p_error("Couldn't bind to control socket"); + quit("Couldn't bind to control socket", 1); length = sizeof(ctl_addr); if (getsockname(ctl_sockt, (struct sockaddr *)&ctl_addr, &length) == -1) - p_error("Bad address for ctl socket"); + quit("Bad address for ctl socket", 1); } /* print_addr is a debug print routine */ diff --git a/usr.bin/talk/ctl_transact.c b/usr.bin/talk/ctl_transact.c index 6fb08f5709c..ccf9c8ab00a 100644 --- a/usr.bin/talk/ctl_transact.c +++ b/usr.bin/talk/ctl_transact.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ctl_transact.c,v 1.5 1998/08/18 04:02:10 millert Exp $ */ +/* $OpenBSD: ctl_transact.c,v 1.6 1999/03/03 20:43:30 millert Exp $ */ /* $NetBSD: ctl_transact.c,v 1.3 1994/12/09 02:14:12 jtc Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)ctl_transact.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: ctl_transact.c,v 1.5 1998/08/18 04:02:10 millert Exp $"; +static char rcsid[] = "$OpenBSD: ctl_transact.c,v 1.6 1999/03/03 20:43:30 millert Exp $"; #endif /* not lint */ #include "talk.h" @@ -86,14 +86,14 @@ ctl_transact(target, msg, type, rp) if (cc != sizeof (msg)) { if (errno == EINTR) continue; - p_error("Error on write to talk daemon"); + quit("Error on write to talk daemon", 1); } read_mask = ctl_mask; nready = select(32, &read_mask, 0, 0, &wait); if (nready < 0) { if (errno == EINTR) continue; - p_error("Error waiting for daemon response"); + quit("Error waiting for daemon response", 1); } } while (nready == 0); /* @@ -106,7 +106,7 @@ ctl_transact(target, msg, type, rp) if (cc < 0) { if (errno == EINTR) continue; - p_error("Error on read from talk daemon"); + quit("Error on read from talk daemon", 1); } read_mask = ctl_mask; /* an immediate poll */ diff --git a/usr.bin/talk/init_disp.c b/usr.bin/talk/init_disp.c index 2e543dc40df..cf2d55b064c 100644 --- a/usr.bin/talk/init_disp.c +++ b/usr.bin/talk/init_disp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_disp.c,v 1.7 1998/12/20 23:54:08 millert Exp $ */ +/* $OpenBSD: init_disp.c,v 1.8 1999/03/03 20:43:30 millert Exp $ */ /* $NetBSD: init_disp.c,v 1.6 1994/12/09 02:14:17 jtc Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)init_disp.c 8.2 (Berkeley) 2/16/94"; #endif -static char rcsid[] = "$OpenBSD: init_disp.c,v 1.7 1998/12/20 23:54:08 millert Exp $"; +static char rcsid[] = "$OpenBSD: init_disp.c,v 1.8 1999/03/03 20:43:30 millert Exp $"; #endif /* not lint */ /* @@ -121,10 +121,10 @@ set_edit_chars() ? CWERASE : tty.c_cc[VWERASE]; cc = write(sockt, buf, sizeof(buf)); if (cc != sizeof(buf) ) - p_error("Lost the connection"); + quit("Lost the connection", 1); cc = read(sockt, buf, sizeof(buf)); if (cc != sizeof(buf) ) - p_error("Lost the connection"); + quit("Lost the connection", 1); his_win.cerase = buf[0]; his_win.kill = buf[1]; his_win.werase = buf[2]; @@ -135,15 +135,16 @@ sig_sent(dummy) int dummy; { - message("Connection closing. Exiting"); - quit(); + quit("Connection closing. Exiting", 0); } /* * All done talking...hang up the phone and reset terminal thingy's */ void -quit() +quit(warning, do_perror) + char *warning; + int do_perror; { if (curses_initialized) { @@ -154,5 +155,11 @@ quit() } if (invitation_waiting) send_delete(); + if (warning) { + if (do_perror) + warn(warning); + else + warnx(warning); + } exit(0); } diff --git a/usr.bin/talk/invite.c b/usr.bin/talk/invite.c index 4bf49412099..0dd3fdce747 100644 --- a/usr.bin/talk/invite.c +++ b/usr.bin/talk/invite.c @@ -1,4 +1,4 @@ -/* $OpenBSD: invite.c,v 1.6 1998/08/18 04:02:15 millert Exp $ */ +/* $OpenBSD: invite.c,v 1.7 1999/03/03 20:43:30 millert Exp $ */ /* $NetBSD: invite.c,v 1.3 1994/12/09 02:14:18 jtc Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)invite.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: invite.c,v 1.6 1998/08/18 04:02:15 millert Exp $"; +static char rcsid[] = "$OpenBSD: invite.c,v 1.7 1999/03/03 20:43:30 millert Exp $"; #endif /* not lint */ #include "talk.h" @@ -83,7 +83,7 @@ invite_remote() itimer.it_value.tv_usec = 0; itimer.it_interval = itimer.it_value; if (listen(sockt, 5) != 0) - p_error("Error on attempt to listen for caller"); + quit("Error on attempt to listen for caller", 1); #ifdef MSG_EOR /* copy new style sockaddr to old, swap family (short in old) */ msg.addr = *(struct osockaddr *)&my_addr; /* XXX new to old style*/ @@ -109,7 +109,7 @@ invite_remote() while ((new_sockt = accept(sockt, &rp, &rplen)) < 0) { if (errno == EINTR) continue; - p_error("Unable to connect with your party"); + quit("Unable to connect with your party", 1); } close(sockt); sockt = new_sockt; @@ -182,11 +182,8 @@ announce_invite() current_state = "Trying to connect to your party's talk daemon"; ctl_transact(his_machine_addr, msg, ANNOUNCE, &response); remote_id = response.id_num; - if (response.answer != SUCCESS) { - if (response.answer < NANSWERS) - message(answers[response.answer]); - quit(); - } + if (response.answer != SUCCESS) + quit(response.answer < NANSWERS ? answers[response.answer] : NULL, 0); /* leave the actual invitation on my talk daemon */ ctl_transact(my_machine_addr, msg, LEAVE_INVITE, &response); local_id = response.id_num; diff --git a/usr.bin/talk/io.c b/usr.bin/talk/io.c index 6fe63de6b2a..c4fd13c0397 100644 --- a/usr.bin/talk/io.c +++ b/usr.bin/talk/io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: io.c,v 1.8 1999/03/03 15:42:46 millert Exp $ */ +/* $OpenBSD: io.c,v 1.9 1999/03/03 20:43:30 millert 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.8 1999/03/03 15:42:46 millert Exp $"; +static char rcsid[] = "$OpenBSD: io.c,v 1.9 1999/03/03 20:43:30 millert Exp $"; #endif /* not lint */ /* @@ -95,16 +95,13 @@ talk() continue; } /* panic, we don't know what happened */ - p_error("Unexpected error from select"); - quit(); + quit("Unexpected error from select", 1); } if (FD_ISSET(sockt, &read_set)) { /* There is data on sockt */ nb = read(sockt, buf, sizeof buf); - if (nb <= 0) { - message("Connection closed. Exiting"); - quit(); - } + if (nb <= 0) + quit("Connection closed. Exiting", 0); display(&his_win, buf, nb); } if (FD_ISSET(fileno(stdin), &read_set)) { @@ -122,23 +119,6 @@ talk() } /* - * 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; -{ - wmove(my_win.x_win, current_line%my_win.x_nlines, 0); - wprintw(my_win.x_win, "[%s : %s (%d)]\n", - string, strerror(errno), errno); - wrefresh(my_win.x_win); - move(LINES-1, 0); - refresh(); - quit(); -} - -/* * Display string in the standard location */ void diff --git a/usr.bin/talk/look_up.c b/usr.bin/talk/look_up.c index 114ed88c4fe..e31825ea744 100644 --- a/usr.bin/talk/look_up.c +++ b/usr.bin/talk/look_up.c @@ -1,4 +1,4 @@ -/* $OpenBSD: look_up.c,v 1.5 1998/08/18 04:02:18 millert Exp $ */ +/* $OpenBSD: look_up.c,v 1.6 1999/03/03 20:43:30 millert Exp $ */ /* $NetBSD: look_up.c,v 1.3 1994/12/09 02:14:21 jtc Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)look_up.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: look_up.c,v 1.5 1998/08/18 04:02:18 millert Exp $"; +static char rcsid[] = "$OpenBSD: look_up.c,v 1.6 1999/03/03 20:43:30 millert Exp $"; #endif /* not lint */ #include "talk.h" @@ -72,7 +72,7 @@ check_local() current_state = "Waiting to connect with caller"; do { if (ntohs(response.addr.sa_family) != AF_INET) - p_error("Response uses invalid network address"); + quit("Response uses invalid network address", 1); errno = 0; if (connect(sockt, (struct sockaddr *)&response.addr, sizeof (response.addr)) != -1) @@ -90,7 +90,7 @@ check_local() open_sockt(); return (0); } - p_error("Unable to connect with initiator"); + quit("Unable to connect with initiator", 1); /*NOTREACHED*/ } diff --git a/usr.bin/talk/talk.h b/usr.bin/talk/talk.h index ecff149cb76..5d8c76696da 100644 --- a/usr.bin/talk/talk.h +++ b/usr.bin/talk/talk.h @@ -1,4 +1,4 @@ -/* $OpenBSD: talk.h,v 1.4 1998/08/18 04:02:26 millert Exp $ */ +/* $OpenBSD: talk.h,v 1.5 1999/03/03 20:43:31 millert Exp $ */ /* $NetBSD: talk.h,v 1.3 1994/12/09 02:14:27 jtc Exp $ */ /* @@ -82,8 +82,7 @@ void message __P((char *)); void open_ctl __P((void)); void open_sockt __P((void)); void print_addr __P((struct sockaddr_in)); -void p_error __P((char *)); -void quit __P((void)); +void quit __P((char *, int)); int readwin __P((WINDOW *, int, int)); void re_invite __P((int)); void send_delete __P((void)); |