]> git.saurik.com Git - apple/libc.git/blobdiff - mach/fprintf_stderr.c
Libc-262.tar.gz
[apple/libc.git] / mach / fprintf_stderr.c
diff --git a/mach/fprintf_stderr.c b/mach/fprintf_stderr.c
new file mode 100644 (file)
index 0000000..a2f70f7
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * @OSF_FREE_COPYRIGHT@
+ * 
+ */
+
+#include <mach/mach.h>
+#include <mach/mach_init.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+int (*vprintf_stderr_func)(const char *format, va_list ap);
+
+
+/* This function allows the writing of a mach error message to an
+ * application-controllable output method, the default being to
+ * use printf if no other method is specified by the application.
+ *
+ * To override, set the global (static) function pointer vprintf_stderr to
+ * a function which takes the same parameters as vprintf.
+ */
+
+int fprintf_stderr(const char *format, ...)
+{
+        va_list args;
+       int retval;
+
+       va_start(args, format);
+       if (vprintf_stderr_func == NULL)
+               retval = vprintf(format, args);
+       else
+               retval = (*vprintf_stderr_func)(format, args);
+       va_end(args);
+
+       return retval;
+}