xref: /original-bsd/usr.bin/tail/misc.c (revision 9e0ce84d)
1 /*-
2  * Copyright (c) 1991 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Edward Sze-Tyan Wang.
7  *
8  * %sccs.include.redist.c%
9  */
10 
11 #ifndef lint
12 static char sccsid[] = "@(#)misc.c	5.1 (Berkeley) 07/21/91";
13 #endif /* not lint */
14 
15 #include <sys/types.h>
16 #include <sys/stat.h>
17 #include <errno.h>
18 #include <unistd.h>
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include "extern.h"
23 
24 void
25 ierr()
26 {
27 	err("%s: %s", fname, strerror(errno));
28 }
29 
30 void
31 oerr()
32 {
33 	err("stdout: %s", strerror(errno));
34 }
35 
36 #if __STDC__
37 #include <stdarg.h>
38 #else
39 #include <varargs.h>
40 #endif
41 
42 void
43 #if __STDC__
44 err(const char *fmt, ...)
45 #else
46 err(fmt, va_alist)
47 	char *fmt;
48 	va_dcl
49 #endif
50 {
51 	va_list ap;
52 #if __STDC__
53 	va_start(ap, fmt);
54 #else
55 	va_start(ap);
56 #endif
57 	(void)fprintf(stderr, "tail: ");
58 	(void)vfprintf(stderr, fmt, ap);
59 	va_end(ap);
60 	(void)fprintf(stderr, "\n");
61 	exit(1);
62 	/* NOTREACHED */
63 }
64