xref: /openbsd-src/usr.bin/tail/misc.c (revision 4c3aa5221481971528d2b80e7ad5c4366594a447)
1*4c3aa522Stedu /*	$OpenBSD: misc.c,v 1.9 2015/11/19 17:50:04 tedu Exp $	*/
2a8e7967cSmillert 
3a8e7967cSmillert /*-
4a8e7967cSmillert  * Copyright (c) 1991, 1993
5a8e7967cSmillert  *	The Regents of the University of California.  All rights reserved.
6a8e7967cSmillert  *
7a8e7967cSmillert  * This code is derived from software contributed to Berkeley by
8a8e7967cSmillert  * Edward Sze-Tyan Wang.
9a8e7967cSmillert  *
10a8e7967cSmillert  * Redistribution and use in source and binary forms, with or without
11a8e7967cSmillert  * modification, are permitted provided that the following conditions
12a8e7967cSmillert  * are met:
13a8e7967cSmillert  * 1. Redistributions of source code must retain the above copyright
14a8e7967cSmillert  *    notice, this list of conditions and the following disclaimer.
15a8e7967cSmillert  * 2. Redistributions in binary form must reproduce the above copyright
16a8e7967cSmillert  *    notice, this list of conditions and the following disclaimer in the
17a8e7967cSmillert  *    documentation and/or other materials provided with the distribution.
18f75387cbSmillert  * 3. Neither the name of the University nor the names of its contributors
19a8e7967cSmillert  *    may be used to endorse or promote products derived from this software
20a8e7967cSmillert  *    without specific prior written permission.
21a8e7967cSmillert  *
22a8e7967cSmillert  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23a8e7967cSmillert  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24a8e7967cSmillert  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25a8e7967cSmillert  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26a8e7967cSmillert  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27a8e7967cSmillert  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28a8e7967cSmillert  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29a8e7967cSmillert  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30a8e7967cSmillert  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31a8e7967cSmillert  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32a8e7967cSmillert  * SUCH DAMAGE.
33a8e7967cSmillert  */
34a8e7967cSmillert 
35a8e7967cSmillert #include <sys/types.h>
36a8e7967cSmillert #include <sys/stat.h>
37a727fb03Sotto 
38a8e7967cSmillert #include <err.h>
39a8e7967cSmillert #include <stdio.h>
40a727fb03Sotto 
41a8e7967cSmillert #include "extern.h"
42a8e7967cSmillert 
43a8e7967cSmillert void
ierr(const char * fname)44*4c3aa522Stedu ierr(const char *fname)
45a8e7967cSmillert {
46a8e7967cSmillert 	warn("%s", fname);
47a8e7967cSmillert 	rval = 1;
48a8e7967cSmillert }
49a8e7967cSmillert 
50a8e7967cSmillert void
oerr(void)511837a5caSderaadt oerr(void)
52a8e7967cSmillert {
53a8e7967cSmillert 	err(1, "stdout");
54a8e7967cSmillert }
55*4c3aa522Stedu 
printfname(const char * fname)56*4c3aa522Stedu void printfname(const char *fname)
57*4c3aa522Stedu {
58*4c3aa522Stedu 	static int first = 1;
59*4c3aa522Stedu 	(void)printf("%s==> %s <==\n", first ? "" : "\n", fname);
60*4c3aa522Stedu 	first = 0;
61*4c3aa522Stedu 	(void)fflush(stdout);
62*4c3aa522Stedu }
63