1*416b512eSroy /* $NetBSD: misc.c,v 1.9 2010/02/10 10:33:45 roy Exp $ */
2fb937a59Sjtc
3dab5e017Scgd /*-
4fb937a59Sjtc * Copyright (c) 1991, 1993
5fb937a59Sjtc * The Regents of the University of California. All rights reserved.
6dab5e017Scgd *
7dab5e017Scgd * Redistribution and use in source and binary forms, with or without
8dab5e017Scgd * modification, are permitted provided that the following conditions
9dab5e017Scgd * are met:
10dab5e017Scgd * 1. Redistributions of source code must retain the above copyright
11dab5e017Scgd * notice, this list of conditions and the following disclaimer.
12dab5e017Scgd * 2. Redistributions in binary form must reproduce the above copyright
13dab5e017Scgd * notice, this list of conditions and the following disclaimer in the
14dab5e017Scgd * documentation and/or other materials provided with the distribution.
1589aaa1bbSagc * 3. Neither the name of the University nor the names of its contributors
16dab5e017Scgd * may be used to endorse or promote products derived from this software
17dab5e017Scgd * without specific prior written permission.
18dab5e017Scgd *
19dab5e017Scgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20dab5e017Scgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21dab5e017Scgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22dab5e017Scgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23dab5e017Scgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24dab5e017Scgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25dab5e017Scgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26dab5e017Scgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27dab5e017Scgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28dab5e017Scgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29dab5e017Scgd * SUCH DAMAGE.
30dab5e017Scgd */
31dab5e017Scgd
322aa5d6b7Slukem #include <sys/cdefs.h>
33*416b512eSroy __RCSID("$NetBSD: misc.c,v 1.9 2010/02/10 10:33:45 roy Exp $");
34dab5e017Scgd
35bfd39f4aSlukem #include <err.h>
36dab5e017Scgd #include <errno.h>
372aa5d6b7Slukem #include <fcntl.h>
38dab5e017Scgd #include <stdio.h>
39dab5e017Scgd #include <stdlib.h>
40dab5e017Scgd #include <string.h>
412aa5d6b7Slukem #include <unistd.h>
42dab5e017Scgd #include "extern.h"
43dab5e017Scgd
44dab5e017Scgd void
tset_cat(const char * file)45*416b512eSroy tset_cat(const char *file)
46dab5e017Scgd {
47dab5e017Scgd register int fd, nr, nw;
48dab5e017Scgd char buf[1024];
49dab5e017Scgd
50dab5e017Scgd if ((fd = open(file, O_RDONLY, 0)) < 0)
51bfd39f4aSlukem err(1, "%s", file);
52dab5e017Scgd
53dab5e017Scgd while ((nr = read(fd, buf, sizeof(buf))) > 0)
54dab5e017Scgd if ((nw = write(STDERR_FILENO, buf, nr)) == -1)
55bfd39f4aSlukem err(1, "write to stderr");
56dab5e017Scgd if (nr != 0)
57bfd39f4aSlukem err(1, "%s", file);
58dab5e017Scgd (void)close(fd);
59dab5e017Scgd }
60dab5e017Scgd
6188d3d7c5Slukem int
outc(int c)62*416b512eSroy outc(int c)
63dab5e017Scgd {
64*416b512eSroy
6588d3d7c5Slukem return (putc(c, stderr));
66dab5e017Scgd }
67