summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2010-06-19 10:51:22 +0100
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-06-28 13:37:13 +0100
commitae740ed87ef3508b65143efaef1ac2c09e9b9f02 (patch)
tree1fbcaea2445100c9c47ace0bb44d68fb4956a93c
parent800589c0d525d64b3a25e4dd3725402b74609756 (diff)
downloadevolution-data-server-ae740ed87ef3508b65143efaef1ac2c09e9b9f02.tar.gz
Allow debugging to be enabled with CAMEL_DEBUG environment variable
CAMEL_DEBUG=imapx will enable all debugging, or 'imapx:command', 'imapx:token' etc. will enable certain types. Not entirely sure if 'debug' and 'extra' are the correct names for the old 'd()' and 'e()' debug output... (cherry picked from commit 22c8df8da28c4146a151a10efbb80cd5222923d7)
-rw-r--r--camel/providers/imapx/camel-imapx-folder.c3
-rw-r--r--camel/providers/imapx/camel-imapx-server.c8
-rw-r--r--camel/providers/imapx/camel-imapx-store-summary.c4
-rw-r--r--camel/providers/imapx/camel-imapx-stream.c4
-rw-r--r--camel/providers/imapx/camel-imapx-utils.c29
-rw-r--r--camel/providers/imapx/camel-imapx-utils.h13
-rw-r--r--camel/providers/imapx/camel-imapx-view-summary.c5
7 files changed, 53 insertions, 13 deletions
diff --git a/camel/providers/imapx/camel-imapx-folder.c b/camel/providers/imapx/camel-imapx-folder.c
index 75840f6a1..c62700576 100644
--- a/camel/providers/imapx/camel-imapx-folder.c
+++ b/camel/providers/imapx/camel-imapx-folder.c
@@ -39,6 +39,7 @@
#include "camel/camel-string-utils.h"
#include "camel-folder-search.h"
+#include "camel-imapx-utils.h"
#include "camel-imapx-store.h"
#include "camel-imapx-folder.h"
#include "camel-imapx-summary.h"
@@ -50,7 +51,7 @@
#include <stdlib.h>
#include <string.h>
-#define d(x)
+#define d(x) camel_imapx_debug(debug, x)
#define CF_CLASS(o) (CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(o)))
static CamelObjectClass *parent_class;
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index ed546841f..f5d5033fd 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -53,8 +53,8 @@
#include "camel-imapx-store.h"
#include "camel-imapx-summary.h"
-#define c(x)
-#define e(x)
+#define c(x) camel_imapx_debug(command, x)
+#define e(x) camel_imapx_debug(extra, x)
#define CFS_CLASS(x) ((CamelFolderSummaryClass *)((CamelObject *)x)->klass)
@@ -870,8 +870,8 @@ imapx_command_start_next(CamelIMAPXServer *is, CamelException *ex)
c(printf("** Starting next command\n"));
if (is->literal != NULL || is->select_pending != NULL) {
- c(if (is->select_pending))
- c(printf("* no, waiting for literal/pending select '%s'\n", is->select_pending->full_name));
+ c(if (is->select_pending)
+ printf("* no, waiting for literal/pending select '%s'\n", is->select_pending->full_name));
/* TODO prolly start the store operations which do not require any folder to be selected */
return;
diff --git a/camel/providers/imapx/camel-imapx-store-summary.c b/camel/providers/imapx/camel-imapx-store-summary.c
index bc0854f12..6ee84e798 100644
--- a/camel/providers/imapx/camel-imapx-store-summary.c
+++ b/camel/providers/imapx/camel-imapx-store-summary.c
@@ -36,8 +36,8 @@
#include "camel-imapx-utils.h"
#include "camel-imapx-store-summary.h"
-#define d(x)
-#define io(x) /* io debug */
+#define d(x) camel_imapx_debug(debug, x)
+#define io(x) camel_imapx_debug(io, x)
#define CAMEL_IMAPX_STORE_SUMMARY_VERSION_0 (0)
diff --git a/camel/providers/imapx/camel-imapx-stream.c b/camel/providers/imapx/camel-imapx-stream.c
index 9d5f8dfe7..ac8cb647d 100644
--- a/camel/providers/imapx/camel-imapx-stream.c
+++ b/camel/providers/imapx/camel-imapx-stream.c
@@ -37,8 +37,8 @@
#include "camel-imapx-stream.h"
#include "camel-imapx-exception.h"
-#define t(x)
-#define io(x)
+#define t(x) camel_imapx_debug(token, x)
+#define io(x) camel_imapx_debug(io, x)
static CamelObjectClass *parent_class = NULL;
diff --git a/camel/providers/imapx/camel-imapx-utils.c b/camel/providers/imapx/camel-imapx-utils.c
index e67cd4aae..6b280c553 100644
--- a/camel/providers/imapx/camel-imapx-utils.c
+++ b/camel/providers/imapx/camel-imapx-utils.c
@@ -7,6 +7,7 @@
#include <camel/camel-store.h>
#include <camel/camel-utf8.h>
#include <camel/camel-string-utils.h>
+#include <camel/camel-debug.h>
#include "camel-imapx-folder.h"
#include "camel-imapx-stream.h"
@@ -17,9 +18,32 @@
#include "libedataserver/e-memory.h"
/* high-level parser state */
-#define p(x)
+#define p(x) camel_imapx_debug(parse, x)
/* debug */
-#define d(x)
+#define d(x) camel_imapx_debug(debug, x)
+
+gint camel_imapx_debug_flags;
+
+#define debug_set_flag(flag) do { \
+ if ((CAMEL_IMAPX_DEBUG_ALL & CAMEL_IMAPX_DEBUG_ ## flag) && \
+ camel_debug("imapx:" #flag)) \
+ camel_imapx_debug_flags |= CAMEL_IMAPX_DEBUG_ ## flag; \
+ } while (0)
+
+static void camel_imapx_set_debug_flags(void)
+{
+ if (camel_debug("imapx")) {
+ camel_imapx_debug_flags = CAMEL_IMAPX_DEBUG_ALL;
+ return;
+ }
+
+ debug_set_flag(command);
+ debug_set_flag(debug);
+ debug_set_flag(extra);
+ debug_set_flag(io);
+ debug_set_flag(token);
+ debug_set_flag(parse);
+}
#include "camel-imapx-tokenise.h"
#define SUBFOLDER_DIR_NAME "subfolders"
@@ -1898,6 +1922,7 @@ void imapx_utils_init(void)
imapx_specials[i] = v;
}
+ camel_imapx_set_debug_flags();
}
guchar imapx_is_mask(const gchar *p)
diff --git a/camel/providers/imapx/camel-imapx-utils.h b/camel/providers/imapx/camel-imapx-utils.h
index e05f23ef5..8bcd763e4 100644
--- a/camel/providers/imapx/camel-imapx-utils.h
+++ b/camel/providers/imapx/camel-imapx-utils.h
@@ -220,6 +220,19 @@ guchar imapx_is_mask(const gchar *p);
#define imapx_is_atom(s) (imapx_is_mask(s) & IMAPX_TYPE_ATOM_CHAR)
+extern gint camel_imapx_debug_flags;
+#define CAMEL_IMAPX_DEBUG_command (1<<0)
+#define CAMEL_IMAPX_DEBUG_debug (1<<1)
+#define CAMEL_IMAPX_DEBUG_extra (1<<2)
+#define CAMEL_IMAPX_DEBUG_io (1<<3)
+#define CAMEL_IMAPX_DEBUG_token (1<<4)
+#define CAMEL_IMAPX_DEBUG_parse (1<<5)
+
+/* Set this to zero to remove all debug output at build time */
+#define CAMEL_IMAPX_DEBUG_ALL ((1<<6)-1)
+
+#define camel_imapx_debug(type, ...) do { if (camel_imapx_debug_flags & CAMEL_IMAPX_DEBUG_ALL & CAMEL_IMAPX_DEBUG_ ## type) { __VA_ARGS__ ; } } while (0)
+
/* ********************************************************************** */
void imapx_utils_init(void);
diff --git a/camel/providers/imapx/camel-imapx-view-summary.c b/camel/providers/imapx/camel-imapx-view-summary.c
index b8a6a3e30..20d01f27f 100644
--- a/camel/providers/imapx/camel-imapx-view-summary.c
+++ b/camel/providers/imapx/camel-imapx-view-summary.c
@@ -27,12 +27,13 @@
#include "camel-record.h"
#include "camel-imapx-view-summary.h"
+#include "camel-imapx-utils.h"
/* NB, this is only for the messy iterator_get interface, which could be better hidden */
#include "libdb/dist/db.h"
-#define io(x)
-#define d(x) (printf("%s(%d): ", __FILE__, __LINE__),(x))
+#define d(x) camel_imapx_debug(debug, x)
+#define io(x) camel_imapx_debug(io, x)
#define CVSD_CLASS(x) ((CamelViewSummaryDiskClass *)((CamelObject *)x)->klass)
#define CVS_CLASS(x) ((CamelViewSummaryClass *)((CamelObject *)x)->klass)