From bf8204c8c0a279ccb5bb5e4a44c3119fe821573f Mon Sep 17 00:00:00 2001
From: edgrif <edgrif>
Date: Wed, 3 Mar 2010 11:01:21 +0000
Subject: [PATCH] add code to support turning on/off debug messages.

---
 src/include/ZMap/zmapXRemote.h         | 11 +++++----
 src/zmapControl/remote/zmapXRemote.c   | 33 +++++++++++++++++++++++---
 src/zmapControl/remote/zmapXRemote_P.h | 29 +++++++---------------
 3 files changed, 45 insertions(+), 28 deletions(-)

diff --git a/src/include/ZMap/zmapXRemote.h b/src/include/ZMap/zmapXRemote.h
index d2749b281..295347598 100755
--- a/src/include/ZMap/zmapXRemote.h
+++ b/src/include/ZMap/zmapXRemote.h
@@ -29,9 +29,9 @@
  *
  * Exported functions: See ZMap/zmapXRemote.h (this file)
  * HISTORY:
- * Last edited: Jan 17 09:10 2010 (edgrif)
+ * Last edited: Mar  2 10:44 2010 (edgrif)
  * Created: Wed Apr 13 19:02:52 2005 (rds)
- * CVS info:   $Id: zmapXRemote.h,v 1.23 2010-01-18 09:02:50 edgrif Exp $
+ * CVS info:   $Id: zmapXRemote.h,v 1.24 2010-03-03 11:01:21 edgrif Exp $
  *-------------------------------------------------------------------
  */
 
@@ -52,10 +52,10 @@
 /* These are here just to allow checking */
 
 #ifdef ED_G_NEVER_INCLUDE_THIS_CODE
-#define ZMAP_XREMOTE_CURRENT_VERSION      "$Revision: 1.23 $"
+#define ZMAP_XREMOTE_CURRENT_VERSION      "$Revision: 1.24 $"
 #endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
 
-#define ZMAP_XREMOTE_CURRENT_VERSION      "$Revision: 1.23 $"
+#define ZMAP_XREMOTE_CURRENT_VERSION      "$Revision: 1.24 $"
 
 #define ZMAP_XREMOTE_CURRENT_VERSION_ATOM "_ZMAP_XREMOTE_VERSION"
 #define ZMAP_XREMOTE_APPLICATION_ATOM     "_ZMAP_XREMOTE_APP"
@@ -155,6 +155,9 @@ extern gboolean externalPerl;
 /* ================================================ */
 /* COMMON MODE METHODS */
 /* ================================================ */
+
+void zMapXRemoteSetDebug(gboolean debug_on) ;
+
 ZMapXRemoteObj zMapXRemoteNew(void);     /* This just returns the object and checks XOpenDisplay(getenv(DISPLAY)) */
 
 void zMapXRemoteSetRequestAtomName(ZMapXRemoteObj object, char *name); /* Better set in zMapXRemoteInitServer if Server though */
diff --git a/src/zmapControl/remote/zmapXRemote.c b/src/zmapControl/remote/zmapXRemote.c
index b4593c355..3d6090dcf 100755
--- a/src/zmapControl/remote/zmapXRemote.c
+++ b/src/zmapControl/remote/zmapXRemote.c
@@ -26,15 +26,15 @@
  *
  * Exported functions: See ZMap/zmapXRemote.h
  * HISTORY:
- * Last edited: Feb 10 16:47 2010 (edgrif)
+ * Last edited: Mar  2 10:51 2010 (edgrif)
  * Created: Wed Apr 13 19:04:48 2005 (rds)
- * CVS info:   $Id: zmapXRemote.c,v 1.44 2010-02-10 16:52:09 edgrif Exp $
+ * CVS info:   $Id: zmapXRemote.c,v 1.45 2010-03-03 11:01:21 edgrif Exp $
  *-------------------------------------------------------------------
  */
 
 #include "zmapXRemote_P.h"
 
-gboolean externalPerl = TRUE;
+
 
 enum
   {
@@ -96,6 +96,33 @@ static void zmapXRemoteUnLock();
 static gboolean zmapXRemoteIsLocked();
 
 
+
+/* An external global which controls the two modes of the code
+ * 
+ * - compiled into ZMap
+ * 
+ * - compiled into a Perl module for otterlace to use.
+ * 
+ */
+gboolean externalPerl = TRUE ;
+
+
+/* Controls debugging output. */
+static gboolean debug_G = FALSE ;
+
+
+/* Can be called at any time and controls debugging for all instances of ZMapXRemoteObj,
+ * TRUE turns debugging on and FALSE turns it off again. */
+void zMapXRemoteSetDebug(gboolean debug_on)
+{
+  debug_G = debug_on ;
+
+  return ;
+}
+
+
+
+
 /*!
  * \brief Create a ZMapXRemoteObj handle for later use
  *
diff --git a/src/zmapControl/remote/zmapXRemote_P.h b/src/zmapControl/remote/zmapXRemote_P.h
index f9fa6e3b5..eae84d43b 100755
--- a/src/zmapControl/remote/zmapXRemote_P.h
+++ b/src/zmapControl/remote/zmapXRemote_P.h
@@ -26,9 +26,9 @@
  *
  * Exported functions: None
  * HISTORY:
- * Last edited: Feb 19 10:22 2010 (edgrif)
+ * Last edited: Mar  2 10:56 2010 (edgrif)
  * Created: Thu Apr 14 13:07:51 2005 (rds)
- * CVS info:   $Id: zmapXRemote_P.h,v 1.20 2010-02-19 10:23:00 edgrif Exp $
+ * CVS info:   $Id: zmapXRemote_P.h,v 1.21 2010-03-03 11:01:21 edgrif Exp $
  *-------------------------------------------------------------------
  */
 
@@ -73,31 +73,18 @@ typedef struct
 
 /*====================== DEBUGGING =========================*/
 
-
-
-#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
-#define DO_DEBUGGING
-#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
-
-
-
-#ifdef DO_DEBUGGING
-
 extern char *ZMAP_X_PROGRAM_G ;
 
+
 #define zmapXDebug(FORMAT, ...)                           \
 G_STMT_START {                                             \
-  g_printerr("[%s] [" ZMAP_MSG_FORMAT_STRING "] " FORMAT,  \
-	     ZMAP_X_PROGRAM_G,				   \
-	     ZMAP_MSG_FUNCTION_MACRO,			   \
-	     __VA_ARGS__) ;				   \
+  if (debug_G)                                             \
+    g_printerr("[%s] [" ZMAP_MSG_FORMAT_STRING "] " FORMAT,	\
+	       ZMAP_X_PROGRAM_G,				\
+	       ZMAP_MSG_FUNCTION_MACRO,				\
+	       __VA_ARGS__) ;					\
 } G_STMT_END
 
-#else
-
-#define zmapXDebug(FORMAT, ...) do {} while(0)
-
-#endif
 /*==========================================================*/
 
 
-- 
GitLab