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