Deleted Added
sdiff udiff text old ( 12097 ) new ( 19190 )
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

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

46
47#include <sys/param.h>
48#include <sys/signal.h>
49#include <sys/stat.h>
50#include <sys/file.h>
51#include <sys/time.h>
52#include <utmp.h>
53#include <ctype.h>
54#include <pwd.h>
55#include <stdio.h>
56#include <string.h>
57
58extern int errno;
59
60main(argc, argv)
61 int argc;

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

97
98 /* check args */
99 switch (argc) {
100 case 2:
101 search_utmp(argv[1], tty, mytty, myuid);
102 do_write(tty, mytty, myuid);
103 break;
104 case 3:
105 if (!strncmp(argv[2], "/dev/", 5))
106 argv[2] += 5;
107 if (utmp_chk(argv[1], argv[2])) {
108 (void)fprintf(stderr,
109 "write: %s is not logged in on %s.\n",
110 argv[1], argv[2]);
111 exit(1);
112 }
113 if (term_chk(argv[2], &msgsok, &atime, 1))

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

227term_chk(tty, msgsokP, atimeP, showerror)
228 char *tty;
229 int *msgsokP, showerror;
230 time_t *atimeP;
231{
232 struct stat s;
233 char path[MAXPATHLEN];
234
235 (void)sprintf(path, "/dev/%s", tty);
236 if (stat(path, &s) < 0) {
237 if (showerror)
238 (void)fprintf(stderr,
239 "write: %s: %s\n", path, strerror(errno));
240 return(1);
241 }
242 *msgsokP = (s.st_mode & (S_IWRITE >> 3)) != 0; /* group write bit */
243 *atimeP = s.st_atime;

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

259
260 /* Determine our login name before the we reopen() stdout */
261 if ((login = getlogin()) == NULL)
262 if (pwd = getpwuid(myuid))
263 login = pwd->pw_name;
264 else
265 login = "???";
266
267 (void)sprintf(path, "/dev/%s", tty);
268 if ((freopen(path, "w", stdout)) == NULL) {
269 (void)fprintf(stderr, "write: %s: %s\n", path, strerror(errno));
270 exit(1);
271 }
272
273 (void)signal(SIGINT, done);
274 (void)signal(SIGHUP, done);
275

--- 55 unchanged lines hidden ---