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
--- 20 unchanged lines hidden (view full) ---
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#ifndef lint
38static const char copyright[] =
39"@(#) Copyright (c) 1989, 1993\n\
40 The Regents of the University of California. All rights reserved.\n";
41#endif /* not lint */
42
43#ifndef lint
44#if 0
45static char sccsid[] = "@(#)write.c 8.1 (Berkeley) 6/6/93";
46#endif
47static const char rcsid[] =
48 "$FreeBSD: head/usr.bin/write/write.c 50477 1999-08-28 01:08:13Z peter $";
49#endif /* not lint */
50
51#include <sys/param.h>
52#include <sys/signal.h>
53#include <sys/stat.h>
54#include <sys/file.h>
55#include <sys/time.h>
56#include <ctype.h>
57#include <err.h>
--- 190 unchanged lines hidden (view full) ---
248/*
249 * do_write - actually make the connection
250 */
251void
252do_write(tty, mytty, myuid)
253 char *tty, *mytty;
254 uid_t myuid;
255{
256 register char *login, *nows;
257 register struct passwd *pwd;
258 time_t now;
259 char path[MAXPATHLEN], host[MAXHOSTNAMELEN], line[512];
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
--- 20 unchanged lines hidden (view full) ---
286 wr_fputs(line);
287}
288
289/*
290 * done - cleanup and exit
291 */
292void
293done(n)
294int n; /* signal number */
295{
296 (void)printf("EOF\r\n");
297 exit(0);
298}
299
300/*
301 * wr_fputs - like fputs(), but makes control characters visible and
302 * turns \n into \r\n
303 */
304void
305wr_fputs(s)
306 register unsigned char *s;
307{
308
309#define PUTC(c) if (putchar(c) == EOF) err(1, NULL);
310
311 for (; *s != '\0'; ++s) {
312 if (*s == '\n') {
313 PUTC('\r');
314 } else if (((*s & 0x80) && *s < 0xA0) ||
--- 19 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
--- 20 unchanged lines hidden (view full) ---
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#ifndef lint
38static const char copyright[] =
39"@(#) Copyright (c) 1989, 1993\n\
40 The Regents of the University of California. All rights reserved.\n";
41#endif /* not lint */
42
43#ifndef lint
44#if 0
45static char sccsid[] = "@(#)write.c 8.1 (Berkeley) 6/6/93";
46#endif
47static const char rcsid[] =
48 "$FreeBSD: head/usr.bin/write/write.c 50477 1999-08-28 01:08:13Z peter $";
49#endif /* not lint */
50
51#include <sys/param.h>
52#include <sys/signal.h>
53#include <sys/stat.h>
54#include <sys/file.h>
55#include <sys/time.h>
56#include <ctype.h>
57#include <err.h>
--- 190 unchanged lines hidden (view full) ---
248/*
249 * do_write - actually make the connection
250 */
251void
252do_write(tty, mytty, myuid)
253 char *tty, *mytty;
254 uid_t myuid;
255{
256 register char *login, *nows;
257 register struct passwd *pwd;
258 time_t now;
259 char path[MAXPATHLEN], host[MAXHOSTNAMELEN], line[512];
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
--- 20 unchanged lines hidden (view full) ---
286 wr_fputs(line);
287}
288
289/*
290 * done - cleanup and exit
291 */
292void
293done(n)
294int n; /* signal number */
295{
296 (void)printf("EOF\r\n");
297 exit(0);
298}
299
300/*
301 * wr_fputs - like fputs(), but makes control characters visible and
302 * turns \n into \r\n
303 */
304void
305wr_fputs(s)
306 register unsigned char *s;
307{
308
309#define PUTC(c) if (putchar(c) == EOF) err(1, NULL);
310
311 for (; *s != '\0'; ++s) {
312 if (*s == '\n') {
313 PUTC('\r');
314 } else if (((*s & 0x80) && *s < 0xA0) ||
--- 19 unchanged lines hidden ---