]>
cygwin.com Git - cygwin-apps/cygutils.git/blob - src/col/err.c
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 /* 2002-05-22 David A. Willis: modified license to the 'BSD no advert'
31 * license, as required by the Director of the Office of
32 * Technology Licensing of the University of California on
34 * See http://www.opensource.org/licenses/bsd-license.html
35 * 2002-05-22 David A. Willis: "Ported" code for compilation under
36 * ix86-pc-cygwin (just added the #if HAVE_CONFIG_H block,
40 #if defined(LIBC_SCCS) && !defined(lint)
41 static char sccsid
[] = "@(#)err.c 8.1 (Berkeley) 6/4/93";
42 #endif /* LIBC_SCCS and not lint */
51 /* These headers are included via common.h, except for <err.h> */
52 /* err.h is located in CWD, so include using " " instead of < > */
68 #ifdef HAVE___PROGNAME
69 extern char *__progname
; /* Program name, from crt0. */
70 #else /* ! HAVE___PROGNAME */
71 /* Eugh! People shouldn't rely on crt0 defining things like this. For
72 example, linux doesn't define __progname. So each program has to call
73 err_setprogname() to register its name. */
74 /* don't define __progname, we're not allowed to use that namespace */
75 static const char *progname
;
76 #define __progname progname
77 #endif /* ! HAVE___PROGNAME */
80 #ifndef HAVE___PROGNAME
81 /* sane C compiler, so none of this messy __STDC__ guff */
83 /* sets __progname to point into argv[0] at the right place. Takes
84 argv[0], and finds where 'the right place' is. */
85 void err_setprogname(const char *argv0
)
87 __progname
= strrchr(argv0
, '/');
88 if (__progname
==NULL
|| *__progname
==0)
93 #else /* HAVE___PROGNAME */
94 #define err_setprogname(x) (void *)0
95 #endif /* HAVE___PROGNAME */
100 err(int eval
, const char *fmt
, ...)
102 err(eval
, fmt
, va_alist
)
127 (void)fprintf(stderr
, "%s: ", __progname
);
129 (void)vfprintf(stderr
, fmt
, ap
);
130 (void)fprintf(stderr
, ": ");
132 (void)fprintf(stderr
, "%s\n", strerror(sverrno
));
138 errx(int eval
, const char *fmt
, ...)
140 errx(eval
, fmt
, va_alist
)
152 verrx(eval
, fmt
, ap
);
162 (void)fprintf(stderr
, "%s: ", __progname
);
164 (void)vfprintf(stderr
, fmt
, ap
);
165 (void)fprintf(stderr
, "\n");
171 warn(const char *fmt
, ...)
196 (void)fprintf(stderr
, "%s: ", __progname
);
198 (void)vfprintf(stderr
, fmt
, ap
);
199 (void)fprintf(stderr
, ": ");
201 (void)fprintf(stderr
, "%s\n", strerror(sverrno
));
206 warnx(const char *fmt
, ...)
228 (void)fprintf(stderr
, "%s: ", __progname
);
230 (void)vfprintf(stderr
, fmt
, ap
);
231 (void)fprintf(stderr
, "\n");
This page took 0.044473 seconds and 5 git commands to generate.