chiark / gitweb /
Add debugging support.
authorJacob Nevins <jacobn@chiark.greenend.org.uk>
Sat, 25 Jun 2005 17:24:03 +0000 (17:24 +0000)
committerJacob Nevins <jacobn@chiark.greenend.org.uk>
Sat, 25 Jun 2005 17:24:03 +0000 (17:24 +0000)
[originally from svn r6018]

gtk.c

diff --git a/gtk.c b/gtk.c
index 2cbbde444deb87205f8ebd26b10f1d1d9392a808..4b789cbed4052b19e3d631b12eceb046f2750178 100644 (file)
--- a/gtk.c
+++ b/gtk.c
 #define USE_PANGO
 #endif
 
+#ifdef DEBUGGING
+static FILE *debug_fp = NULL;
+
+void dputs(char *buf)
+{
+    if (!debug_fp) {
+        debug_fp = fopen("debug.log", "w");
+    }
+
+    fputs(buf, stderr);
+
+    if (debug_fp) {
+        fputs(buf, debug_fp);
+        fflush(debug_fp);
+    }
+}
+
+void debug_printf(char *fmt, ...)
+{
+    char buf[4096];
+    va_list ap;
+
+    va_start(ap, fmt);
+    vsprintf(buf, fmt, ap);
+    dputs(buf);
+    va_end(ap);
+}
+#endif
+
 /* ----------------------------------------------------------------------
  * Error reporting functions used elsewhere.
  */