=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/talk/get_addrs.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- src/usr.bin/talk/get_addrs.c 1998/04/28 22:13:23 1.3 +++ src/usr.bin/talk/get_addrs.c 1998/08/18 04:02:11 1.4 @@ -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 @@ { 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 @@ */ 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; }