xref: /original-bsd/usr.bin/cmp/misc.c (revision ea3a8ee8)
1 /*-
2  * Copyright (c) 1991 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)misc.c	5.2 (Berkeley) 06/21/92";
10 #endif /* not lint */
11 
12 #include <sys/types.h>
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include "extern.h"
16 
17 void
18 eofmsg(file)
19 	char *file;
20 {
21 	if (!sflag)
22 		(void)fprintf(stderr, "cmp: EOF on %s\n", file);
23 	exit(1);
24 }
25 
26 void
27 diffmsg(file1, file2, byte, line)
28 	char *file1, *file2;
29 	off_t byte, line;
30 {
31 	if (!sflag)
32 		(void)printf("%s %s differ: char %qd, line %qd\n",
33 		    file1, file2, byte, line);
34 	exit(1);
35 }
36 
37 #if __STDC__
38 #include <stdarg.h>
39 #else
40 #include <varargs.h>
41 #endif
42 
43 void
44 #if __STDC__
45 err(const char *fmt, ...)
46 #else
47 err(fmt, va_alist)
48 	char *fmt;
49 	va_dcl
50 #endif
51 {
52 	va_list ap;
53 #if __STDC__
54 	va_start(ap, fmt);
55 #else
56 	va_start(ap);
57 #endif
58 	(void)fprintf(stderr, "cmp: ");
59 	(void)vfprintf(stderr, fmt, ap);
60 	va_end(ap);
61 	(void)fprintf(stderr, "\n");
62 	exit(2);
63 	/* NOTREACHED */
64 }
65