[syslinux:master] dprintf: add the ability to log to stdio

syslinux-bot for H. Peter Anvin hpa at zytor.com
Mon Jun 20 21:21:11 PDT 2011


Commit-ID:  24ea7f3ece30a586a149dfb60c49b6a6f92dd17e
Gitweb:     http://syslinux.zytor.com/commit/24ea7f3ece30a586a149dfb60c49b6a6f92dd17e
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Mon, 20 Jun 2011 21:19:17 -0700
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Mon, 20 Jun 2011 21:19:17 -0700

dprintf: add the ability to log to stdio

Add the ability to redirect dprintf to stdio when there is no other
choice.

Signed-off-by: H. Peter Anvin <hpa at zytor.com>


---
 com32/include/dprintf.h |   20 +++++++++++++++++---
 com32/lib/dprintf.c     |    2 ++
 com32/lib/vdprintf.c    |    4 ++++
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/com32/include/dprintf.h b/com32/include/dprintf.h
index 30a21ad..4bdf7a7 100644
--- a/com32/include/dprintf.h
+++ b/com32/include/dprintf.h
@@ -7,15 +7,29 @@
 
 #ifdef DEBUG
 
-#include <stdio.h>
+# include <stdio.h>
 
+# ifdef DEBUG_STDIO
+#  define dprintf  printf
+#  define vdprintf vprintf
+# else
 void dprintf(const char *, ...);
 void vdprintf(const char *, va_list);
+# endif
+
+# if DEBUG >= 2
+/* Really verbose debugging... */
+#  define dprintf2  dprintf
+#  define vdprintf2 vdprintf
+# else
+#  define dprintf2(fmt, ...)	((void)(0))
+#  define vdprintf2(fmt, ap)	((void)(0))
+# endif
 
 #else
 
-#define dprintf(fmt, ...)	((void)(0))
-#define vdprintf(fmt, ap)	((void)(0))
+# define dprintf(fmt, ...)	((void)(0))
+# define vdprintf(fmt, ap)	((void)(0))
 
 #endif /* DEBUG */
 
diff --git a/com32/lib/dprintf.c b/com32/lib/dprintf.c
index 900c0a4..aad1174 100644
--- a/com32/lib/dprintf.c
+++ b/com32/lib/dprintf.c
@@ -9,6 +9,7 @@
 #define DEBUG 1
 #include <dprintf.h>
 
+#ifndef dprintf
 void dprintf(const char *format, ...)
 {
     va_list ap;
@@ -17,3 +18,4 @@ void dprintf(const char *format, ...)
     vdprintf(format, ap);
     va_end(ap);
 }
+#endif
diff --git a/com32/lib/vdprintf.c b/com32/lib/vdprintf.c
index d74f278..c1f90a6 100644
--- a/com32/lib/vdprintf.c
+++ b/com32/lib/vdprintf.c
@@ -14,6 +14,8 @@
 #define DEBUG 1
 #include <dprintf.h>
 
+#ifndef vdprintf
+
 #define BUFFER_SIZE	4096
 
 enum serial_port_regs {
@@ -114,3 +116,5 @@ void vdprintf(const char *format, va_list ap)
     while (rv--)
 	debug_putc(*p++);
 }
+
+#endif /* vdprintf */



More information about the Syslinux-commits mailing list