From: Luiz Augusto von Dentz <luiz.dentz-...@nokia.com>

---
 lib/debug.h       |   13 ++++---------
 lib/obex.c        |   13 +++++++++++++
 lib/obex_main.c   |    4 ----
 lib/win32compat.c |    6 ------
 4 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/lib/debug.h b/lib/debug.h
index 4a1e81b..ba1ff34 100644
--- a/lib/debug.h
+++ b/lib/debug.h
@@ -20,29 +20,24 @@ static void log_debug(char *format, ...) {}
  *               1 for verification
  *              >2 for debug
  */
+extern int obex_debug;
+
 #if defined(_MSC_VER) && _MSC_VER < 1400
 static void DEBUG(int n, char *format, ...) {}
 
-#elif OBEX_DEBUG
-extern int obex_debug;
+#else
 #  define DEBUG(n, format, ...) \
           if (obex_debug >= (n)) \
             log_debug("%s%s(): " format, log_debug_prefix, __FUNCTION__, ## 
__VA_ARGS__)
-
-#else
-#  define DEBUG(n, format, ...)
 #endif
 
 
 /* use bitmask: 0x1 for sendbuff
  *              0x2 for receivebuff
  */
-#if OBEX_DUMP
 extern int obex_dump;
+
 #define DUMPBUFFER(n, label, msg) \
         if ((obex_dump & 0x3) & (n)) buf_dump(msg, label);
-#else
-#define DUMPBUFFER(n, label, msg)
-#endif
 
 #endif
diff --git a/lib/obex.c b/lib/obex.c
index 3440af1..a7e4721 100644
--- a/lib/obex.c
+++ b/lib/obex.c
@@ -88,14 +88,27 @@ obex_t * CALLAPI OBEX_Init(int transport, obex_event_t 
eventcb,
                                                        unsigned int flags)
 {
        obex_t *self;
+       char *env;
 
 #if OBEX_DEBUG
        obex_debug = OBEX_DEBUG;
+#else
+       obex_debug = -1;
 #endif
 #if OBEX_DUMP
        obex_dump = OBEX_DUMP;
+#else
+       obex_dump = 0;
 #endif
 
+       env = getenv("OBEX_DEBUG");
+       if (env)
+               obex_debug = atoi(env);
+
+       env = getenv("OBEX_DUMP");
+       if (env)
+               obex_dump = atoi(env);
+
        obex_return_val_if_fail(eventcb != NULL, NULL);
 
        self = malloc(sizeof(*self));
diff --git a/lib/obex_main.c b/lib/obex_main.c
index aff3aaf..2131a86 100644
--- a/lib/obex_main.c
+++ b/lib/obex_main.c
@@ -52,12 +52,8 @@
 
 #include <openobex/obex_const.h>
 
-#ifdef OBEX_DEBUG
 int obex_debug;
-#endif
-#ifdef OBEX_DUMP
 int obex_dump;
-#endif
 
 #include "cloexec.h"
 
diff --git a/lib/win32compat.c b/lib/win32compat.c
index 1f8ae95..9d120f5 100644
--- a/lib/win32compat.c
+++ b/lib/win32compat.c
@@ -30,15 +30,9 @@
 // The VC proprocessor can't handle variable argument macros,
 // so we are forced to do an ugly thing like this.
 
-#ifdef OBEX_DEBUG
-extern obex_debug;
-
 void DEBUG(unsigned int n, const char *format, void *a1, void *a2, void *a3, 
void *a4, 
                void *a5, void *a6, void *a7, void *a8, void *a9, void *a10)
 {
        if (n <= obex_debug)
                fprintf(stderr, format, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10);
 }
-#else
-void DEBUG(int n, const char *format, ...){};
-#endif
-- 
1.7.1


------------------------------------------------------------------------------
_______________________________________________
Openobex-users mailing list
Openobex-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/openobex-users

Reply via email to