Deleted Added
sdiff udiff text old ( 92922 ) new ( 97454 )
full compact
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Jef Poskanzer and Craig Leres of the Lawrence Berkeley Laboratory.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 33 unchanged lines hidden (view full) ---

42
43#if 0
44#ifndef lint
45static char sccsid[] = "@(#)write.c 8.1 (Berkeley) 6/6/93";
46#endif
47#endif
48
49#include <sys/cdefs.h>
50__FBSDID("$FreeBSD: head/usr.bin/write/write.c 92922 2002-03-22 01:42:45Z imp $");
51
52#include <sys/param.h>
53#include <sys/signal.h>
54#include <sys/stat.h>
55#include <sys/file.h>
56#include <sys/time.h>
57#include <ctype.h>
58#include <err.h>

--- 22 unchanged lines hidden (view full) ---

81 register char *cp;
82 time_t atime;
83 uid_t myuid;
84 int msgsok, myttyfd;
85 char tty[MAXPATHLEN], *mytty;
86
87 (void)setlocale(LC_CTYPE, "");
88
89 /* check that sender has write enabled */
90 if (isatty(fileno(stdin)))
91 myttyfd = fileno(stdin);
92 else if (isatty(fileno(stdout)))
93 myttyfd = fileno(stdout);
94 else if (isatty(fileno(stderr)))
95 myttyfd = fileno(stderr);
96 else

--- 6 unchanged lines hidden (view full) ---

103 exit(1);
104 if (!msgsok)
105 errx(1, "you have write permission turned off");
106
107 myuid = getuid();
108
109 /* check args */
110 switch (argc) {
111 case 2:
112 search_utmp(argv[1], tty, mytty, myuid);
113 do_write(tty, mytty, myuid);
114 break;
115 case 3:
116 if (!strncmp(argv[2], _PATH_DEV, strlen(_PATH_DEV)))
117 argv[2] += strlen(_PATH_DEV);
118 if (utmp_chk(argv[1], argv[2]))
119 errx(1, "%s is not logged in on %s", argv[1], argv[2]);
120 if (term_chk(argv[2], &msgsok, &atime, 1))
121 exit(1);
122 if (myuid && !msgsok)
123 errx(1, "%s has messages disabled on %s", argv[1], argv[2]);
124 do_write(argv[2], mytty, myuid);
125 break;
126 default:
127 usage();
128 }
129 done(0);
130 return (0);
131}
132

--- 204 unchanged lines hidden ---