]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Ported to Linux's Second Extended File System as part of the | |
3 | * dump and restore backup suit | |
4 | * Remy Card <card@Linux.EU.Org>, 1994, 1995, 1996 | |
5 | * | |
6 | */ | |
7 | ||
8 | /*- | |
9 | * Copyright (c) 1993 | |
10 | * The Regents of the University of California. All rights reserved. | |
11 | * | |
12 | * Redistribution and use in source and binary forms, with or without | |
13 | * modification, are permitted provided that the following conditions | |
14 | * are met: | |
15 | * 1. Redistributions of source code must retain the above copyright | |
16 | * notice, this list of conditions and the following disclaimer. | |
17 | * 2. Redistributions in binary form must reproduce the above copyright | |
18 | * notice, this list of conditions and the following disclaimer in the | |
19 | * documentation and/or other materials provided with the distribution. | |
20 | * 3. All advertising materials mentioning features or use of this software | |
21 | * must display the following acknowledgement: | |
22 | * This product includes software developed by the University of | |
23 | * California, Berkeley and its contributors. | |
24 | * 4. Neither the name of the University nor the names of its contributors | |
25 | * may be used to endorse or promote products derived from this software | |
26 | * without specific prior written permission. | |
27 | * | |
28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
38 | * SUCH DAMAGE. | |
39 | */ | |
40 | ||
41 | #if defined(LIBC_SCCS) && !defined(lint) | |
42 | static char sccsid[] = "@(#)err.c 8.1 (Berkeley) 6/4/93"; | |
43 | #endif /* LIBC_SCCS and not lint */ | |
44 | ||
45 | #include <err.h> | |
46 | #include <errno.h> | |
47 | #include <stdio.h> | |
48 | #include <stdlib.h> | |
49 | #include <string.h> | |
50 | ||
51 | #ifdef __STDC__ | |
52 | #include <stdarg.h> | |
53 | #else | |
54 | #include <varargs.h> | |
55 | #endif | |
56 | ||
57 | #include <config.h> | |
58 | ||
59 | extern char *__progname; /* Program name, from crt0. */ | |
60 | ||
61 | #ifndef HAVE_ERR | |
62 | __dead void | |
63 | #ifdef __STDC__ | |
64 | err(int eval, const char *fmt, ...) | |
65 | #else | |
66 | err(eval, fmt, va_alist) | |
67 | int eval; | |
68 | const char *fmt; | |
69 | va_dcl | |
70 | #endif | |
71 | { | |
72 | va_list ap; | |
73 | #if __STDC__ | |
74 | va_start(ap, fmt); | |
75 | #else | |
76 | va_start(ap); | |
77 | #endif | |
78 | verr(eval, fmt, ap); | |
79 | va_end(ap); | |
80 | } | |
81 | #endif | |
82 | ||
83 | #ifndef HAVE_VERR | |
84 | __dead void | |
85 | verr(eval, fmt, ap) | |
86 | int eval; | |
87 | const char *fmt; | |
88 | va_list ap; | |
89 | { | |
90 | int sverrno; | |
91 | ||
92 | sverrno = errno; | |
93 | (void)fprintf(stderr, "%s: ", __progname); | |
94 | if (fmt != NULL) { | |
95 | (void)vfprintf(stderr, fmt, ap); | |
96 | (void)fprintf(stderr, ": "); | |
97 | } | |
98 | (void)fprintf(stderr, "%s\n", strerror(sverrno)); | |
99 | exit(eval); | |
100 | } | |
101 | #endif | |
102 | ||
103 | #ifndef HAVE_ERRX | |
104 | __dead void | |
105 | #if __STDC__ | |
106 | errx(int eval, const char *fmt, ...) | |
107 | #else | |
108 | errx(eval, fmt, va_alist) | |
109 | int eval; | |
110 | const char *fmt; | |
111 | va_dcl | |
112 | #endif | |
113 | { | |
114 | va_list ap; | |
115 | #if __STDC__ | |
116 | va_start(ap, fmt); | |
117 | #else | |
118 | va_start(ap); | |
119 | #endif | |
120 | verrx(eval, fmt, ap); | |
121 | va_end(ap); | |
122 | } | |
123 | #endif | |
124 | ||
125 | #ifndef HAVE_VERRX | |
126 | __dead void | |
127 | verrx(eval, fmt, ap) | |
128 | int eval; | |
129 | const char *fmt; | |
130 | va_list ap; | |
131 | { | |
132 | (void)fprintf(stderr, "%s: ", __progname); | |
133 | if (fmt != NULL) | |
134 | (void)vfprintf(stderr, fmt, ap); | |
135 | (void)fprintf(stderr, "\n"); | |
136 | exit(eval); | |
137 | } | |
138 | #endif | |
139 | ||
140 | #ifndef HAVE_WARN | |
141 | void | |
142 | #if __STDC__ | |
143 | warn(const char *fmt, ...) | |
144 | #else | |
145 | warn(fmt, va_alist) | |
146 | const char *fmt; | |
147 | va_dcl | |
148 | #endif | |
149 | { | |
150 | va_list ap; | |
151 | #if __STDC__ | |
152 | va_start(ap, fmt); | |
153 | #else | |
154 | va_start(ap); | |
155 | #endif | |
156 | vwarn(fmt, ap); | |
157 | va_end(ap); | |
158 | } | |
159 | #endif | |
160 | ||
161 | #ifndef HAVE_VWARN | |
162 | void | |
163 | vwarn(fmt, ap) | |
164 | const char *fmt; | |
165 | va_list ap; | |
166 | { | |
167 | int sverrno; | |
168 | ||
169 | sverrno = errno; | |
170 | (void)fprintf(stderr, "%s: ", __progname); | |
171 | if (fmt != NULL) { | |
172 | (void)vfprintf(stderr, fmt, ap); | |
173 | (void)fprintf(stderr, ": "); | |
174 | } | |
175 | (void)fprintf(stderr, "%s\n", strerror(sverrno)); | |
176 | } | |
177 | #endif | |
178 | ||
179 | #ifndef HAVE_WARNX | |
180 | void | |
181 | #ifdef __STDC__ | |
182 | warnx(const char *fmt, ...) | |
183 | #else | |
184 | warnx(fmt, va_alist) | |
185 | const char *fmt; | |
186 | va_dcl | |
187 | #endif | |
188 | { | |
189 | va_list ap; | |
190 | #ifdef __STDC__ | |
191 | va_start(ap, fmt); | |
192 | #else | |
193 | va_start(ap); | |
194 | #endif | |
195 | vwarnx(fmt, ap); | |
196 | va_end(ap); | |
197 | } | |
198 | #endif | |
199 | ||
200 | #ifndef HAVE_VWARNX | |
201 | void | |
202 | vwarnx(fmt, ap) | |
203 | const char *fmt; | |
204 | va_list ap; | |
205 | { | |
206 | (void)fprintf(stderr, "%s: ", __progname); | |
207 | if (fmt != NULL) | |
208 | (void)vfprintf(stderr, fmt, ap); | |
209 | (void)fprintf(stderr, "\n"); | |
210 | } | |
211 | #endif |