From bb73a7cd1089b3b50f0018dab4dd5f11dec1657f Mon Sep 17 00:00:00 2001 From: millert Date: Tue, 18 Aug 1998 04:02:09 +0000 Subject: Some changes inspired by FreeBSD... o Kill annoying spaces at the end of lines o sigaction, not sigvec o warn/err where sensible o hstrerror() not herror() o defaults for erase, kill, and werase if not set o kill a needless refresh() after the beeps that was messing up the screen --- usr.bin/talk/get_addrs.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'usr.bin/talk/get_addrs.c') diff --git a/usr.bin/talk/get_addrs.c b/usr.bin/talk/get_addrs.c index e21eedcdc78..d0286ece990 100644 --- a/usr.bin/talk/get_addrs.c +++ b/usr.bin/talk/get_addrs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: get_addrs.c,v 1.3 1998/04/28 22:13:23 pjanzen Exp $ */ +/* $OpenBSD: get_addrs.c,v 1.4 1998/08/18 04:02:11 millert Exp $ */ /* $NetBSD: get_addrs.c,v 1.3 1994/12/09 02:14:14 jtc Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)get_addrs.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: get_addrs.c,v 1.3 1998/04/28 22:13:23 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: get_addrs.c,v 1.4 1998/08/18 04:02:11 millert Exp $"; #endif /* not lint */ #include "talk.h" @@ -53,15 +53,13 @@ get_addrs(my_machine_name, his_machine_name) { struct hostent *hp; struct servent *sp; + extern int h_errno; msg.pid = htonl(getpid()); /* look up the address of the local host */ hp = gethostbyname(my_machine_name); - if (hp == NULL) { - fprintf(stderr, "talk: %s: ", my_machine_name); - herror((char *)NULL); - exit(-1); - } + if (hp == NULL) + errx(1, "%s: %s", my_machine_name, hstrerror(h_errno)); bcopy(hp->h_addr, (char *)&my_machine_addr, hp->h_length); /* * If the callee is on-machine, just copy the @@ -69,20 +67,14 @@ get_addrs(my_machine_name, his_machine_name) */ if (strcmp(his_machine_name, my_machine_name)) { hp = gethostbyname(his_machine_name); - if (hp == NULL) { - fprintf(stderr, "talk: %s: ", his_machine_name); - herror((char *)NULL); - exit(-1); - } + if (hp == NULL) + errx(1, "%s: %s", his_machine_name, hstrerror(h_errno)); bcopy(hp->h_addr, (char *) &his_machine_addr, hp->h_length); } else his_machine_addr = my_machine_addr; /* find the server's port */ sp = getservbyname("ntalk", "udp"); - if (sp == 0) { - fprintf(stderr, "talk: %s/%s: service is not registered.\n", - "ntalk", "udp"); - exit(-1); - } + if (sp == NULL) + errx(1, "ntalk/udp: service is not registered."); daemon_port = sp->s_port; } -- cgit v1.2.3-59-g8ed1b