summaryrefslogtreecommitdiff
path: root/usr.bin/talk/get_names.c
diff options
context:
space:
mode:
authorPhilippe Charnier <charnier@FreeBSD.org>1998-01-14 07:21:14 +0000
committerPhilippe Charnier <charnier@FreeBSD.org>1998-01-14 07:21:14 +0000
commit20868061ee3c06243e6e4aa990e0a9c4c23b800b (patch)
tree5450cc754c91d5a5a85e15b552009e408da9aa19 /usr.bin/talk/get_names.c
parent69036300b207e8104228a78221e1eb5ed7f0afe9 (diff)
downloadsrc-test2-20868061ee3c06243e6e4aa990e0a9c4c23b800b.tar.gz
src-test2-20868061ee3c06243e6e4aa990e0a9c4c23b800b.zip
Notes
Diffstat (limited to 'usr.bin/talk/get_names.c')
-rw-r--r--usr.bin/talk/get_names.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/usr.bin/talk/get_names.c b/usr.bin/talk/get_names.c
index 793ce7210b8c..762f4ff83700 100644
--- a/usr.bin/talk/get_names.c
+++ b/usr.bin/talk/get_names.c
@@ -32,17 +32,28 @@
*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)get_names.c 8.1 (Berkeley) 6/6/93";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
-#include <unistd.h>
+#include <err.h>
+#include <pwd.h>
#include <string.h>
#include <sys/param.h>
-#include <pwd.h>
#include "talk.h"
extern CTL_MSG msg;
+static void
+usage(void)
+{
+ fprintf(stderr, "usage: talk person [ttyname]\n");
+ exit(1);
+}
+
/*
* Determine the local and remote user, tty, and machines
*/
@@ -57,21 +68,15 @@ get_names(argc, argv)
char *my_tty, *his_tty;
register char *cp;
- if (argc < 2 ) {
- printf("Usage: talk user [ttyname]\n");
- exit(-1);
- }
- if (!isatty(0)) {
- printf("Standard input must be a tty, not a pipe or a file\n");
- exit(-1);
- }
+ if (argc < 2 )
+ usage();
+ if (!isatty(0))
+ errx(1, "standard input must be a tty, not a pipe or a file");
if ((my_name = getlogin()) == NULL) {
struct passwd *pw;
- if ((pw = getpwuid(getuid())) == NULL) {
- printf("You don't exist. Go away.\n");
- exit(-1);
- }
+ if ((pw = getpwuid(getuid())) == NULL)
+ errx(1, "you don't exist. Go away");
my_name = pw->pw_name;
}
gethostname(hostname, sizeof (hostname));