Sun Dec 17 15:56:35 1995 Miles Bader <miles@gnu.ai.mit.edu>
[glibc.git] / misc / err.c
blob82719a87565d8fdbc8dfba7b39f6a94a7c6e496a
1 /* err.c --- 4.4BSD utility functions for error messages.
2 Copyright (C) 1995 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If
17 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
18 Cambridge, MA 02139, USA. */
20 #include <stdarg.h>
21 #include <err.h>
22 #include <stdlib.h>
23 #include <stdio.h>
25 extern char *__progname;
27 #define VA(call) \
28 { \
29 va_list ap; \
30 va_start (ap, format); \
31 call; \
32 va_end (ap); \
35 void
36 vwarn (const char *format, __gnuc_va_list ap)
38 fprintf (stderr, format, ap);
41 void
42 vwarnx (const char *format, __gnuc_va_list ap)
44 if (__progname)
45 fprintf (stderr, "%s: ", __progname);
46 fprintf (stderr, format, ap);
47 putc ('\n', stderr);
51 void
52 warn (const char *format, ...)
54 VA (vwarn (format, ap))
57 void
58 warnx (const char *format, ...)
60 VA (vwarnx (format, ap))
63 void
64 verr (int status, const char *format, __gnuc_va_list ap)
66 vwarn (format, ap);
67 exit (status);
70 void
71 verrx (int status, const char *format, __gnuc_va_list ap)
73 vwarnx (format, ap);
74 exit (status);
77 void
78 err (int status, const char *format, ...)
80 VA (verr (status, format, ap))
83 void
84 errx (int status, const char *format, ...)
86 VA (verrx (status, format, ap))