summaryrefslogtreecommitdiff
path: root/libc/misc
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-10-09 09:02:05 +0000
committerEric Andersen <andersen@codepoet.org>2003-10-09 09:02:05 +0000
commit61011662018fa98c4610c1ae826e417678cd5c80 (patch)
tree5b6d645acb1fc99674908c1cee4ec65bbdc470bc /libc/misc
parentc7db7879f7dbda66ec2e61022b3a3266bfec9aac (diff)
Patch from Rob McMullen:
Here's a patch... Since they aren't SUSv3 functions, I don't know if they'll ever get officially added, but it helps with BSD porting and allows quite a few Gentoo ebuilds to compile without changing anything. Rob
Diffstat (limited to 'libc/misc')
-rw-r--r--libc/misc/error/error.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/libc/misc/error/error.c b/libc/misc/error/error.c
index ed1d91070..60a9d8af8 100644
--- a/libc/misc/error/error.c
+++ b/libc/misc/error/error.c
@@ -100,3 +100,77 @@ void __error_at_line (int status, int errnum, const char *file_name,
weak_alias (__error, error)
weak_alias (__error_at_line, error_at_line)
+
+
+#include "err.h"
+#include "errno.h"
+
+/* NORETURN */
+void verr (int status, const char *message, va_list args)
+{
+ fflush (stdout);
+
+ vfprintf (stderr, message, args);
+ if (errno) {
+ fprintf (stderr, ": %s", strerror (errno));
+ }
+ putc ('\n', stderr);
+ if (status)
+ exit (status);
+}
+
+/* NORETURN */
+void verrx (int status, const char *message, va_list args)
+{
+ fflush (stdout);
+
+ vfprintf (stderr, message, args);
+ if (status)
+ exit (status);
+}
+
+void vwarn (const char *message, va_list args)
+{
+ verr (0, message, args);
+}
+
+void vwarnx (const char *message, va_list args)
+{
+ verrx (0, message, args);
+}
+
+void err (int status, const char *message, ...)
+{
+ va_list args;
+
+ va_start (args, message);
+ verr (status, message, args);
+ va_end (args);
+}
+
+void errx (int status, const char *message, ...)
+{
+ va_list args;
+
+ va_start (args, message);
+ verrx (status, message, args);
+ va_end (args);
+}
+
+void warn (const char *message, ...)
+{
+ va_list args;
+
+ va_start (args, message);
+ verr (0, message, args);
+ va_end (args);
+}
+
+void warnx (const char *message, ...)
+{
+ va_list args;
+
+ va_start (args, message);
+ verrx (0, message, args);
+ va_end (args);
+}