1*dcbf1a1fSlukem /* $NetBSD: misc.c,v 1.12 2009/04/11 12:16:12 lukem Exp $ */
294f6fc8eStls
346ef75acStls /*-
446ef75acStls * Copyright (c) 1991, 1993, 1994
546ef75acStls * The Regents of the University of California. All rights reserved.
646ef75acStls *
746ef75acStls * Redistribution and use in source and binary forms, with or without
846ef75acStls * modification, are permitted provided that the following conditions
946ef75acStls * are met:
1046ef75acStls * 1. Redistributions of source code must retain the above copyright
1146ef75acStls * notice, this list of conditions and the following disclaimer.
1246ef75acStls * 2. Redistributions in binary form must reproduce the above copyright
1346ef75acStls * notice, this list of conditions and the following disclaimer in the
1446ef75acStls * documentation and/or other materials provided with the distribution.
1589aaa1bbSagc * 3. Neither the name of the University nor the names of its contributors
1646ef75acStls * may be used to endorse or promote products derived from this software
1746ef75acStls * without specific prior written permission.
1846ef75acStls *
1946ef75acStls * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2046ef75acStls * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2146ef75acStls * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2246ef75acStls * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2346ef75acStls * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2446ef75acStls * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2546ef75acStls * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2646ef75acStls * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2746ef75acStls * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2846ef75acStls * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2946ef75acStls * SUCH DAMAGE.
3046ef75acStls */
3146ef75acStls
3218ce2540Slukem #include <sys/cdefs.h>
3346ef75acStls #ifndef lint
3494f6fc8eStls #if 0
3546ef75acStls static char sccsid[] = "@(#)misc.c 8.3 (Berkeley) 4/2/94";
3694f6fc8eStls #else
37*dcbf1a1fSlukem __RCSID("$NetBSD: misc.c,v 1.12 2009/04/11 12:16:12 lukem Exp $");
3894f6fc8eStls #endif
3946ef75acStls #endif /* not lint */
4046ef75acStls
4146ef75acStls #include <sys/types.h>
4246ef75acStls
4346ef75acStls #include <err.h>
4446ef75acStls #include <stdio.h>
4546ef75acStls #include <stdlib.h>
4646ef75acStls
4746ef75acStls #include "extern.h"
4846ef75acStls
4946ef75acStls void
errmsg(const char * file,off_t byte,off_t line)50*dcbf1a1fSlukem errmsg(const char *file, off_t byte, off_t line)
51dc2a5030Schristos {
52dc2a5030Schristos if (lflag)
5302f63becSchristos err(ERR_EXIT, "%s: char %lld, line %lld", file,
5402f63becSchristos (long long)byte, (long long)line);
55dc2a5030Schristos else
56dc2a5030Schristos err(ERR_EXIT, "%s", file);
57dc2a5030Schristos }
58dc2a5030Schristos
59dc2a5030Schristos void
eofmsg(const char * file,off_t byte,off_t line)60*dcbf1a1fSlukem eofmsg(const char *file, off_t byte, off_t line)
6146ef75acStls {
62e538b980Schristos if (!sflag) {
63e538b980Schristos if (!lflag)
6446ef75acStls warnx("EOF on %s", file);
65e538b980Schristos else {
66e538b980Schristos if (line > 0)
67e538b980Schristos warnx("EOF on %s: char %lld, line %lld",
68e538b980Schristos file, (long long)byte, (long long)line);
69e538b980Schristos else
70e538b980Schristos warnx("EOF on %s: char %lld",
71e538b980Schristos file, (long long)byte);
72e538b980Schristos }
73e538b980Schristos }
7446ef75acStls exit(DIFF_EXIT);
7546ef75acStls }
7646ef75acStls
7746ef75acStls void
diffmsg(const char * file1,const char * file2,off_t byte,off_t line)78*dcbf1a1fSlukem diffmsg(const char *file1, const char *file2, off_t byte, off_t line)
7946ef75acStls {
8046ef75acStls if (!sflag)
81c2b84904Slukem (void)printf("%s %s differ: char %lld, line %lld\n",
8266f7b9fdSmrg file1, file2, (long long)byte, (long long)line);
8346ef75acStls exit(DIFF_EXIT);
8446ef75acStls }
85