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 139718 2005-01-05 11:52:40Z cognet $");
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>
--- 12 unchanged lines hidden (view full) ---
71int term_chk(char *, int *, time_t *, int);
72void wr_fputs(unsigned char *s);
73void search_utmp(char *, char *, char *, uid_t);
74int utmp_chk(char *, char *);
75
76int
77main(int argc, char **argv)
78{
79 char *cp;
80 time_t atime;
81 uid_t myuid;
82 int msgsok, myttyfd;
83 char tty[MAXPATHLEN], *mytty;
84
85 (void)setlocale(LC_CTYPE, "");
86
87 while (getopt(argc, argv, "") != -1)
--- 7 unchanged lines hidden (view full) ---
95 else if (isatty(fileno(stdout)))
96 myttyfd = fileno(stdout);
97 else if (isatty(fileno(stderr)))
98 myttyfd = fileno(stderr);
99 else
100 errx(1, "can't find your tty");
101 if (!(mytty = ttyname(myttyfd)))
102 errx(1, "can't find your tty's name");
103 if ((cp = rindex(mytty, '/')))
104 mytty = cp + 1;
105 if (term_chk(mytty, &msgsok, &atime, 1))
106 exit(1);
107 if (!msgsok)
108 errx(1, "you have write permission turned off");
109
110 myuid = getuid();
111
112 /* check args */
--- 217 unchanged lines hidden ---
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 139718 2005-01-05 11:52:40Z cognet $");
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>
--- 12 unchanged lines hidden (view full) ---
71int term_chk(char *, int *, time_t *, int);
72void wr_fputs(unsigned char *s);
73void search_utmp(char *, char *, char *, uid_t);
74int utmp_chk(char *, char *);
75
76int
77main(int argc, char **argv)
78{
79 char *cp;
80 time_t atime;
81 uid_t myuid;
82 int msgsok, myttyfd;
83 char tty[MAXPATHLEN], *mytty;
84
85 (void)setlocale(LC_CTYPE, "");
86
87 while (getopt(argc, argv, "") != -1)
--- 7 unchanged lines hidden (view full) ---
95 else if (isatty(fileno(stdout)))
96 myttyfd = fileno(stdout);
97 else if (isatty(fileno(stderr)))
98 myttyfd = fileno(stderr);
99 else
100 errx(1, "can't find your tty");
101 if (!(mytty = ttyname(myttyfd)))
102 errx(1, "can't find your tty's name");
103 if ((cp = rindex(mytty, '/')))
104 mytty = cp + 1;
105 if (term_chk(mytty, &msgsok, &atime, 1))
106 exit(1);
107 if (!msgsok)
108 errx(1, "you have write permission turned off");
109
110 myuid = getuid();
111
112 /* check args */
--- 217 unchanged lines hidden ---