/* * Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * The NEXTSTEP Software License Agreement specifies the terms * and conditions for redistribution. * * @(#)misc.c 8.1 (Berkeley) 6/9/93 */ #include #include #include #include #include #include #include "extern.h" void cat(file) char *file; { register int fd, nr, nw; char buf[1024]; if ((fd = open(file, O_RDONLY, 0)) < 0) err("%s: %s", file, strerror(errno)); while ((nr = read(fd, buf, sizeof(buf))) > 0) if ((nw = write(STDERR_FILENO, buf, nr)) == -1) err("write to stderr: %s", strerror(errno)); if (nr != 0) err("%s: %s", file, strerror(errno)); (void)close(fd); } void outc(c) int c; { (void)putc(c, stderr); } #if __STDC__ #include #else #include #endif void #if __STDC__ err(const char *fmt, ...) #else err(fmt, va_alist) char *fmt; va_dcl #endif { va_list ap; #if __STDC__ va_start(ap, fmt); #else va_start(ap); #endif (void)fprintf(stderr, "tset: "); (void)vfprintf(stderr, fmt, ap); va_end(ap); (void)fprintf(stderr, "\n"); exit(1); /* NOTREACHED */ }