Deleted Added
full compact
write.c (12097) write.c (19190)
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>
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 <paths.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:
55#include <pwd.h>
56#include <stdio.h>
57#include <string.h>
58
59extern int errno;
60
61main(argc, argv)
62 int argc;

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

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

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

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

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

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

--- 55 unchanged lines hidden ---