1178525Sjb/*
2178525Sjb * CDDL HEADER START
3178525Sjb *
4178525Sjb * The contents of this file are subject to the terms of the
5178525Sjb * Common Development and Distribution License, Version 1.0 only
6178525Sjb * (the "License").  You may not use this file except in compliance
7178525Sjb * with the License.
8178525Sjb *
9178525Sjb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10178525Sjb * or http://www.opensolaris.org/os/licensing.
11178525Sjb * See the License for the specific language governing permissions
12178525Sjb * and limitations under the License.
13178525Sjb *
14178525Sjb * When distributing Covered Code, include this CDDL HEADER in each
15178525Sjb * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16178525Sjb * If applicable, add the following below this CDDL HEADER, with the
17178525Sjb * fields enclosed by brackets "[]" replaced with your own identifying
18178525Sjb * information: Portions Copyright [yyyy] [name of copyright owner]
19178525Sjb *
20178525Sjb * CDDL HEADER END
21178525Sjb */
22178525Sjb/*
23178525Sjb * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24178525Sjb * Use is subject to license terms.
25178525Sjb */
26178525Sjb
27178525Sjb#pragma ident	"%Z%%M%	%I%	%E% SMI"
28178525Sjb
29178525Sjb#include <stdio.h>
30178525Sjb#include <stdlib.h>
31178525Sjb#include <stdarg.h>
32178525Sjb#include <string.h>
33178525Sjb#include <errno.h>
34178525Sjb#include <elf.h>
35178525Sjb
36178525Sjb#include <util.h>
37178525Sjb
38178525Sjbvoid
39178525Sjbdie(char *format, ...)
40178525Sjb{
41178525Sjb	va_list ap;
42178525Sjb	int err = errno;
43277300Ssmh#ifndef illumos
44178539Sjb	const char *progname = getprogname();
45178539Sjb#endif
46178525Sjb
47178525Sjb	(void) fprintf(stderr, "%s: ", progname);
48178525Sjb
49178525Sjb	va_start(ap, format);
50178525Sjb	/* LINTED - variable format specifier */
51178525Sjb	(void) vfprintf(stderr, format, ap);
52178525Sjb	va_end(ap);
53178525Sjb
54178525Sjb	if (format[strlen(format) - 1] != '\n')
55178525Sjb		(void) fprintf(stderr, ": %s\n", strerror(err));
56178525Sjb
57277300Ssmh#ifndef illumos
58178539Sjb	exit(0);
59178539Sjb#else
60178525Sjb	exit(1);
61178539Sjb#endif
62178525Sjb}
63178525Sjb
64178525Sjbvoid
65178525Sjbelfdie(char *format, ...)
66178525Sjb{
67178525Sjb	va_list ap;
68277300Ssmh#ifndef illumos
69178539Sjb	const char *progname = getprogname();
70178539Sjb#endif
71178525Sjb
72178525Sjb	(void) fprintf(stderr, "%s: ", progname);
73178525Sjb
74178525Sjb	va_start(ap, format);
75178525Sjb	/* LINTED - variable format specifier */
76178525Sjb	(void) vfprintf(stderr, format, ap);
77178525Sjb	va_end(ap);
78178525Sjb
79178525Sjb	if (format[strlen(format) - 1] != '\n')
80178525Sjb		(void) fprintf(stderr, ": %s\n", elf_errmsg(elf_errno()));
81178525Sjb
82277300Ssmh#ifndef illumos
83178539Sjb	exit(0);
84178539Sjb#else
85178525Sjb	exit(1);
86178539Sjb#endif
87178525Sjb}
88