[gtk-vnc-devel] [patch] Enable debugging messages



Hi, folks.

With this patch all we need to do in order to have debug messages in
terminal is to call configure script with --enable-debug parameter.

I've added a new file - utils.h - and moved definition of GVNC_DEBUG
macro from gvnc.c to there, allowing other files have access to debug
procedure.

Cheers,
-- 
Jonh Wendell
jonh wendell gmail com (MSN / Google Talk)

Linux User #114432
https://launchpad.net/~wendell
diff -r b1c48ddc01d9 configure.ac
--- a/configure.ac	Wed Aug 22 15:10:12 2007 -0400
+++ b/configure.ac	Tue Aug 28 16:56:35 2007 -0300
@@ -113,6 +113,15 @@ if test "$WITH_PYTHON" = "yes"; then
   fi
 fi
 
+dnl --enable-debug=(yes|no)
+AC_ARG_ENABLE(debug, [  --enable-debug=[no/yes] turn on debugging [default=no]],,enable_debug=no)
+if test "$enable_debug" = "yes"; then
+  DEBUG_CFLAGS="-DENABLE_DEBUG"
+else
+  DEBUG_CFLAGS=""
+fi
+AC_SUBST(DEBUG_CFLAGS)
+
 AM_CONDITIONAL(WITH_PYTHON, [test "$WITH_PYTHON" = "yes"])
 
 AM_CONDITIONAL(WITH_EXAMPLES, [test "$WITH_EXAMPLES" = "yes"])
diff -r b1c48ddc01d9 src/Makefile.am
--- a/src/Makefile.am	Wed Aug 22 15:10:12 2007 -0400
+++ b/src/Makefile.am	Tue Aug 28 16:56:35 2007 -0300
@@ -5,7 +5,8 @@ lib_LTLIBRARIES = libgtk-vnc-1.0.la
 
 libgtk_vnc_1_0_la_LIBADD = @GTK_LIBS@ @GNUTLS_LIBS@
 libgtk_vnc_1_0_la_CFLAGS = @GTK_CFLAGS@ @GNUTLS_CFLAGS@ @WARNING_CFLAGS@ \
-                           -DSYSCONFDIR=\""$(sysconfdir)"\"
+                           -DSYSCONFDIR=\""$(sysconfdir)"\" \
+                           @DEBUG_CFLAGS@
 libgtk_vnc_1_0_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libgtk-vnc_sym.version \
                             -version-info 0:1:0
 
@@ -18,7 +19,8 @@ libgtk_vnc_1_0_la_SOURCES = blt.h blt1.h
 	d3des.h d3des.c \
 	gvnc.h gvnc.c \
 	vncdisplay.h vncdisplay.c \
-	vncshmimage.h vncshmimage.c
+	vncshmimage.h vncshmimage.c \
+	utils.h
 
 if WITH_PYTHON
 pyexec_LTLIBRARIES = gtkvnc.la
@@ -26,7 +28,7 @@ gtkvnc_la_LIBADD = libgtk-vnc-1.0.la @PY
 gtkvnc_la_LIBADD = libgtk-vnc-1.0.la @PYGTK_LIBS@
 # Auto-generated C code for Python binding is full of compiler warnings :-(
 #gtkvnc_la_CFLAGS = @GTK_CFLAGS@ @WARNING_CFLAGS@ @PYTHON_INCLUDES@ @PYGTK_CFLAGS@
-gtkvnc_la_CFLAGS = @GTK_CFLAGS@ @PYTHON_INCLUDES@ @PYGTK_CFLAGS@
+gtkvnc_la_CFLAGS = @GTK_CFLAGS@ @PYTHON_INCLUDES@ @PYGTK_CFLAGS@ @DEBUG_CFLAGS@
 gtkvnc_la_LDFLAGS = -module -avoid-version -fPIC
 gtkvnc_la_SOURCES = vncmodule.c vncmodule.defs.c
 
diff -r b1c48ddc01d9 src/gvnc.c
--- a/src/gvnc.c	Wed Aug 22 15:10:12 2007 -0400
+++ b/src/gvnc.c	Tue Aug 28 16:56:35 2007 -0300
@@ -31,6 +31,7 @@
 #include "coroutine.h"
 #include "d3des.h"
 
+#include "utils.h"
 #include <gnutls/gnutls.h>
 #include <gnutls/x509.h>
 
@@ -122,23 +123,6 @@ struct gvnc
 	int xmit_buffer_capacity;
 	int xmit_buffer_size;
 };
-
-
-#define DEBUG 0
-#if DEBUG
-#define GVNC_DEBUG(fmt, ...) do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
-
-#if DEBUG == 2
-static void debug_log(int level, const char* str)
-{
-	GVNC_DEBUG("%d %s", level, str);
-}
-#endif
-
-#else
-#define GVNC_DEBUG(fmt, ...) do { } while (0)
-#endif
-
 
 #define nibhi(a) (((a) >> 4) & 0x0F)
 #define niblo(a) ((a) & 0x0F)
@@ -504,11 +488,6 @@ static gboolean gvnc_tls_initialize(void
 		return FALSE;
 	if (gnutls_dh_params_generate2 (dh_params, DH_BITS) < 0)
 		return FALSE;
-
-#if DEBUG == 2
-	gnutls_global_set_log_level(10);
-	gnutls_global_set_log_function(debug_log);
-#endif
 
 	tlsinitialized = TRUE;
 
diff -r b1c48ddc01d9 src/utils.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/utils.h	Tue Aug 28 16:56:35 2007 -0300
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2006  Anthony Liguori <anthony codemonkey ws>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ *  GTK VNC Widget
+ */
+
+#ifdef ENABLE_DEBUG
+#define GVNC_DEBUG(fmt, ...) do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
+#else
+#define GVNC_DEBUG(fmt, ...) do { } while (0)
+#endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]