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#include <sys/cdefs.h> 38 39__FBSDID("$FreeBSD: head/usr.bin/write/write.c 87682 2001-12-11 22:34:38Z markm $"); 40 |
41#ifndef lint 42static const char copyright[] = 43"@(#) Copyright (c) 1989, 1993\n\ 44 The Regents of the University of California. All rights reserved.\n"; |
45#endif |
46 47#ifndef lint |
48static const char sccsid[] = "@(#)write.c 8.1 (Berkeley) 6/6/93"; |
49#endif |
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 const char *login; 257 char *nows; 258 struct passwd *pwd; |
259 time_t now; 260 char path[MAXPATHLEN], host[MAXHOSTNAMELEN], line[512]; 261 262 /* Determine our login name before the we reopen() stdout */ 263 if ((login = getlogin()) == NULL) { 264 if ((pwd = getpwuid(myuid))) 265 login = pwd->pw_name; 266 else --- 20 unchanged lines hidden (view full) --- 287 wr_fputs(line); 288} 289 290/* 291 * done - cleanup and exit 292 */ 293void 294done(n) |
295 int n __unused; |
296{ 297 (void)printf("EOF\r\n"); 298 exit(0); 299} 300 301/* 302 * wr_fputs - like fputs(), but makes control characters visible and 303 * turns \n into \r\n 304 */ 305void 306wr_fputs(s) |
307 unsigned char *s; |
308{ 309 310#define PUTC(c) if (putchar(c) == EOF) err(1, NULL); 311 312 for (; *s != '\0'; ++s) { 313 if (*s == '\n') { 314 PUTC('\r'); 315 } else if (((*s & 0x80) && *s < 0xA0) || --- 19 unchanged lines hidden --- |