[uClibc] err, warn, errx, warnx, and friends

Rob McMullen robm at flipturn.org
Sun Oct 5 15:59:19 UTC 2003


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

-------------- next part --------------
diff -urbBwpN -x '*.o' -x '*~' uClibc-vanilla-cvs/libc/misc/error/error.c uClibc/libc/misc/error/error.c
--- uClibc-vanilla-cvs/libc/misc/error/error.c	2002-04-05 18:32:54.000000000 -0500
+++ uClibc/libc/misc/error/error.c	2003-05-04 10:58:01.000000000 -0400
@@ -100,3 +100,77 @@ void __error_at_line (int status, int er
 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);
+}


More information about the uClibc mailing list