[evolution-data-server] Move printf inside camel_imapx_debug() macro to make prefixes easier



commit 3b81e3a7ba1a08ce72e8970eb6d7a906d0f4343e
Author: David Woodhouse <David Woodhouse intel com>
Date:   Wed Sep 15 12:20:30 2010 +0100

    Move printf inside camel_imapx_debug() macro to make prefixes easier

 camel/providers/imapx/camel-imapx-conn-manager.c  |   17 +-
 camel/providers/imapx/camel-imapx-folder.c        |    4 +-
 camel/providers/imapx/camel-imapx-server.c        |  228 ++++++++++----------
 camel/providers/imapx/camel-imapx-store-summary.c |   25 +--
 camel/providers/imapx/camel-imapx-stream.c        |   42 ++--
 camel/providers/imapx/camel-imapx-utils.c         |   60 +++---
 camel/providers/imapx/camel-imapx-utils.h         |    6 +-
 camel/providers/imapx/camel-imapx-view-summary.c  |    3 -
 8 files changed, 193 insertions(+), 192 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-conn-manager.c b/camel/providers/imapx/camel-imapx-conn-manager.c
index 418476f..c018573 100644
--- a/camel/providers/imapx/camel-imapx-conn-manager.c
+++ b/camel/providers/imapx/camel-imapx-conn-manager.c
@@ -23,7 +23,7 @@
 #include "camel-imapx-conn-manager.h"
 #include "camel-imapx-utils.h"
 
-#define c(x) camel_imapx_debug(conman, x)
+#define c(...) camel_imapx_debug(conman, __VA_ARGS__)
 
 #define CAMEL_IMAPX_CONN_MANAGER_GET_PRIVATE(obj) \
 	(G_TYPE_INSTANCE_GET_PRIVATE \
@@ -127,7 +127,7 @@ imapx_conn_shutdown (CamelIMAPXServer *conn, CamelIMAPXConnManager *con_man)
 	   this all, because otherwise a deadlock will happen.
 	   The connection will be freed later anyway. */
 	if (con_man->priv->clearing_connections) {
-		c(printf ("%s: called on %p when clearing connections, skipping it...\n", G_STRFUNC, conn));
+		c("%s: called on %p when clearing connections, skipping it...\n", G_STRFUNC, conn);
 		return;
 	}
 
@@ -173,7 +173,7 @@ imapx_conn_update_select (CamelIMAPXServer *conn, const gchar *selected_folder,
 			jinfo = camel_imapx_server_get_job_queue_info (cinfo->conn);
 			if (!g_hash_table_lookup (jinfo->folders, cinfo->selected_folder)) {
 				g_hash_table_remove (cinfo->folders, cinfo->selected_folder);
-				c(printf ("Removed folder %s from connection folder list - select changed \n", cinfo->selected_folder));
+				c("Removed folder %s from connection folder list - select changed \n", cinfo->selected_folder);
 			}
 			camel_imapx_destroy_job_queue_info (jinfo);
 			g_free (cinfo->selected_folder);
@@ -218,7 +218,7 @@ imapx_find_connection (CamelIMAPXConnManager *con_man, const gchar *folder_name)
 
 			if (folder_name)
 				g_hash_table_insert (cinfo->folders, g_strdup (folder_name), GINT_TO_POINTER (1));
-			c(printf ("Found connection for %s and connection number %d \n", folder_name, i+1));
+			c("Found connection for %s and connection number %d \n", folder_name, i+1);
 			break;
 		}
 	}
@@ -229,11 +229,12 @@ imapx_find_connection (CamelIMAPXConnManager *con_man, const gchar *folder_name)
 
 		if (folder_name) {
 			g_hash_table_insert (cinfo->folders, g_strdup (folder_name), GINT_TO_POINTER (1));
-			c(printf ("Adding folder %s to connection number %d \n", folder_name, n+1));
+			c("Adding folder %s to connection number %d \n", folder_name, n+1);
 		}
 	}
 
-	c (g_assert (!(con_man->priv->n_connections == g_slist_length (con_man->priv->connections) && !conn)));
+	if (camel_debug_flag(conman))
+		g_assert (!(con_man->priv->n_connections == g_slist_length (con_man->priv->connections) && !conn));
 
 	CON_UNLOCK (con_man);
 
@@ -277,7 +278,7 @@ imapx_create_new_connection (CamelIMAPXConnManager *con_man, const gchar *folder
 
 	con_man->priv->connections = g_slist_prepend (con_man->priv->connections, cinfo);
 
-	c(printf ("Created new connection for %s and total connections %d \n", folder_name, g_slist_length (con_man->priv->connections)));
+	c("Created new connection for %s and total connections %d \n", folder_name, g_slist_length (con_man->priv->connections));
 
 	CON_UNLOCK (con_man);
 
@@ -368,7 +369,7 @@ camel_imapx_conn_manager_update_con_info (CamelIMAPXConnManager *con_man, CamelI
 		jinfo = camel_imapx_server_get_job_queue_info (cinfo->conn);
 		if (!g_hash_table_lookup (jinfo->folders, folder_name)) {
 			g_hash_table_remove (cinfo->folders, folder_name);
-			c(printf ("Removed folder %s from connection folder list - op done \n", folder_name));
+			c("Removed folder %s from connection folder list - op done \n", folder_name);
 		}
 		camel_imapx_destroy_job_queue_info (jinfo);
 	}
diff --git a/camel/providers/imapx/camel-imapx-folder.c b/camel/providers/imapx/camel-imapx-folder.c
index 0985640..5e457ab 100644
--- a/camel/providers/imapx/camel-imapx-folder.c
+++ b/camel/providers/imapx/camel-imapx-folder.c
@@ -37,7 +37,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#define d(x) camel_imapx_debug(debug, x)
+#define d(...) camel_imapx_debug(debug, __VA_ARGS__)
 
 G_DEFINE_TYPE (CamelIMAPXFolder, camel_imapx_folder, CAMEL_TYPE_OFFLINE_FOLDER)
 
@@ -50,7 +50,7 @@ camel_imapx_folder_new (CamelStore *store, const gchar *folder_dir, const gchar
 	gchar *summary_file, *state_file;
 	CamelIMAPXStore *istore;
 
-	d(printf("opening imap folder '%s'\n", folder_dir));
+	d("opening imap folder '%s'\n", folder_dir);
 
 	short_name = strrchr (folder_name, '/');
 	if (short_name)
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 8ce7111..d28981e 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -32,8 +32,8 @@
 #include <ws2tcpip.h>
 #endif
 
-#define c(x) camel_imapx_debug(command, x)
-#define e(x) camel_imapx_debug(extra, x)
+#define c(...) camel_imapx_debug(command, __VA_ARGS__)
+#define e(...) camel_imapx_debug(extra, __VA_ARGS__)
 
 #define CIF(x) ((CamelIMAPXFolder *)x)
 
@@ -392,21 +392,21 @@ imapx_uidset_add (struct _uidset_state *ss, CamelIMAPXCommand *ic, const gchar *
 
 	ss->uids++;
 
-	e(printf("uidset add '%s'\n", uid));
+	e("uidset add '%s'\n", uid);
 
 	if (ss->last == 0) {
-		e(printf(" start\n"));
+		e(" start\n");
 		camel_imapx_command_add(ic, "%d", uidn);
 		ss->entries++;
 		ss->start = uidn;
 	} else {
 		if (ss->last != uidn-1) {
 			if (ss->last == ss->start) {
-				e(printf(" ,next\n"));
+				e(" ,next\n");
 				camel_imapx_command_add(ic, ",%d", uidn);
 				ss->entries++;
 			} else {
-				e(printf(" :range\n"));
+				e(" :range\n");
 				camel_imapx_command_add(ic, ":%d,%d", ss->last, uidn);
 				ss->entries+=2;
 			}
@@ -418,7 +418,7 @@ imapx_uidset_add (struct _uidset_state *ss, CamelIMAPXCommand *ic, const gchar *
 
 	if ((ss->limit && ss->entries >= ss->limit)
 	    || (ss->total && ss->uids >= ss->total)) {
-		e(printf(" done, %d entries, %d uids\n", ss->entries, ss->uids));
+		e(" done, %d entries, %d uids\n", ss->entries, ss->uids);
 		imapx_uidset_done (ss, ic);
 		return 1;
 	}
@@ -542,7 +542,7 @@ imapx_command_addv (CamelIMAPXCommand *ic, const gchar *fmt, va_list ap)
 	gchar *fname = NULL, *encoded = NULL;
 	const gchar *full_name;
 
-	c(printf("adding command, fmt = '%s'\n", fmt));
+	c("adding command, fmt = '%s'\n", fmt);
 
 	p = fmt;
 	ps = fmt;
@@ -592,17 +592,17 @@ imapx_command_addv (CamelIMAPXCommand *ic, const gchar *fmt, va_list ap)
 					break;
 				case 'S': /* stream */
 					S = va_arg (ap, CamelStream *);
-					c(printf("got stream '%p'\n", S));
+					c("got stream '%p'\n", S);
 					imapx_command_add_part (ic, CAMEL_IMAPX_COMMAND_STREAM, S);
 					break;
 				case 'D': /* datawrapper */
 					D = va_arg (ap, CamelDataWrapper *);
-					c(printf("got data wrapper '%p'\n", D));
+					c("got data wrapper '%p'\n", D);
 					imapx_command_add_part (ic, CAMEL_IMAPX_COMMAND_DATAWRAPPER, D);
 					break;
 				case 'P': /* filename path */
 					P = va_arg (ap, gchar *);
-					c(printf("got file path '%s'\n", P));
+					c("got file path '%s'\n", P);
 					imapx_command_add_part (ic, CAMEL_IMAPX_COMMAND_FILE, P);
 					break;
 				case 't': /* token */
@@ -611,7 +611,7 @@ imapx_command_addv (CamelIMAPXCommand *ic, const gchar *fmt, va_list ap)
 					break;
 				case 's': /* simple string */
 					s = va_arg (ap, gchar *);
-					c(printf("got string '%s'\n", s));
+					c("got string '%s'\n", s);
 				output_string:
 					if (*s) {
 						guchar mask = imapx_is_mask (s);
@@ -647,7 +647,7 @@ imapx_command_addv (CamelIMAPXCommand *ic, const gchar *fmt, va_list ap)
 				case 'f': /* imap folder name */
 					folder = va_arg (ap, CamelFolder *);
 					full_name = camel_folder_get_full_name (folder);
-					c(printf("got folder '%s'\n", full_name));
+					c("got folder '%s'\n", full_name);
 					parent_store = camel_folder_get_parent_store (folder);
 					fname = camel_imapx_store_summary_full_from_path (((CamelIMAPXStore *) parent_store)->summary, full_name);
 					if (fname) {
@@ -677,13 +677,13 @@ imapx_command_addv (CamelIMAPXCommand *ic, const gchar *fmt, va_list ap)
 				case 'u':
 					if (llong) {
 						l = va_arg (ap, glong);
-						c(printf("got glong '%d'\n", (gint)l));
+						c("got glong '%d'\n", (gint)l);
 						memcpy (buffer, start, p-start);
 						buffer[p-start] = 0;
 						camel_stream_printf ((CamelStream *)ic->mem, buffer, l);
 					} else {
 						d = va_arg (ap, gint);
-						c(printf("got gint '%d'\n", d));
+						c("got gint '%d'\n", d);
 						memcpy (buffer, start, p-start);
 						buffer[p-start] = 0;
 						camel_stream_printf ((CamelStream *)ic->mem, buffer, d);
@@ -788,7 +788,7 @@ camel_imapx_command_close (CamelIMAPXCommand *ic)
 
 		byte_array = camel_stream_mem_get_byte_array (ic->mem);
 
-		c(printf("completing command buffer is [%d] '%.*s'\n", byte_array->len, (gint)byte_array->len, byte_array->data));
+		c("completing command buffer is [%d] '%.*s'\n", byte_array->len, (gint)byte_array->len, byte_array->data);
 		if (byte_array->len > 0)
 			imapx_command_add_part (ic, CAMEL_IMAPX_COMMAND_SIMPLE, NULL);
 
@@ -818,7 +818,7 @@ imapx_command_start (CamelIMAPXServer *imap, CamelIMAPXCommand *ic)
 
 	g_static_rec_mutex_lock (&imap->ostream_lock);
 
-	c(printf("Starting command (active=%d,%s) %c%05u %s\r\n", camel_dlist_length(&imap->active), imap->literal?" literal":"", imap->tagprefix, ic->tag, cp->data));
+	c("Starting command (active=%d,%s) %c%05u %s\r\n", camel_dlist_length(&imap->active), imap->literal?" literal":"", imap->tagprefix, ic->tag, cp->data);
 	if (!imap->stream || camel_stream_printf((CamelStream *)imap->stream, "%c%05u %s\r\n", imap->tagprefix, ic->tag, cp->data) == -1) {
 		g_set_error (
 			&ic->error, CAMEL_IMAPX_ERROR, 1,
@@ -852,7 +852,7 @@ static gboolean duplicate_fetch_or_refresh (CamelIMAPXServer *is, CamelIMAPXComm
 		return FALSE;
 
 	if (imapx_match_active_job (is, IMAPX_JOB_FETCH_NEW_MESSAGES|IMAPX_JOB_REFRESH_INFO, NULL)) {
-		c(printf("Not yet sending duplicate fetch/refresh %s command\n", ic->name));
+		c("Not yet sending duplicate fetch/refresh %s command\n", ic->name);
 		return TRUE;
 	}
 
@@ -883,20 +883,20 @@ imapx_command_start_next (CamelIMAPXServer *is, GError **error)
 	gint count = 0;
 	gint pri = -128;
 
-	c(printf("** Starting next command\n"));
+	c("** Starting next command\n");
 	if (is->literal) {
-		c(printf("* no; waiting for literal '%s'\n", is->literal->name));
+		c("* no; waiting for literal '%s'\n", is->literal->name);
 		return;
 	}
 
 	if (is->select_pending) {
-		c(printf("-- Checking job queue for non-folder jobs\n"));
+		c("-- Checking job queue for non-folder jobs\n");
 		ic = (CamelIMAPXCommand *)is->queue.head;
 		nc = ic->next;
 		while (nc && is->literal == NULL && count < MAX_COMMANDS && ic->pri >= pri) {
-			c(printf("-- %3d '%s'?\n", (gint)ic->pri, ic->name));
+			c("-- %3d '%s'?\n", (gint)ic->pri, ic->name);
 			if (!ic->select) {
-				c(printf("--> starting '%s'\n", ic->name));
+				c("--> starting '%s'\n", ic->name);
 				pri = ic->pri;
 				camel_dlist_remove ((CamelDListNode *)ic);
 				imapx_command_start (is, ic);
@@ -909,7 +909,7 @@ imapx_command_start_next (CamelIMAPXServer *is, GError **error)
 		if (count)
 			return;
 
-		c(printf("* no, waiting for pending select '%s'\n", camel_folder_get_full_name (is->select_pending)));
+		c("* no, waiting for pending select '%s'\n", camel_folder_get_full_name (is->select_pending));
 		return;
 	}
 
@@ -921,12 +921,12 @@ imapx_command_start_next (CamelIMAPXServer *is, GError **error)
 			   pending and we can go ahead and send a new command
 			   immediately. If it returns TRUE, we must wait. */
 			if (imapx_stop_idle (is, error)) {
-				c(printf ("waiting for idle to stop \n"));
+				c("waiting for idle to stop \n");
 				return;
 			}
 		} else if (empty && !imapx_in_idle (is)) {
 			imapx_start_idle (is);
-			c(printf ("starting idle \n"));
+			c("starting idle \n");
 			return;
 		}
 	}
@@ -934,34 +934,34 @@ imapx_command_start_next (CamelIMAPXServer *is, GError **error)
 	ic = (CamelIMAPXCommand *)is->queue.head;
 	nc = ic->next;
 	if (nc == NULL) {
-		c(printf("* no, no jobs\n"));
+		c("* no, no jobs\n");
 		return;
 	}
 
 	/* See if any queued jobs on this select first */
 	if (is->select_folder) {
-		c(printf("- we're selected on '%s', current jobs?\n",
-			 camel_folder_get_full_name (is->select_folder)));
+		c("- we're selected on '%s', current jobs?\n",
+		  camel_folder_get_full_name (is->select_folder));
 		for (ic = (CamelIMAPXCommand *)is->active.head;ic->next;ic=ic->next) {
-			c(printf("-  %3d '%s'\n", (gint)ic->pri, ic->name));
+			c("-  %3d '%s'\n", (gint)ic->pri, ic->name);
 			if (ic->pri > pri)
 				pri = ic->pri;
 			count++;
 			if (count > MAX_COMMANDS) {
-				c(printf("** too many jobs busy, waiting for results for now\n"));
+				c("** too many jobs busy, waiting for results for now\n");
 				return;
 			}
 		}
 
-		c(printf("-- Checking job queue\n"));
+		c("-- Checking job queue\n");
 		count = 0;
 		ic = (CamelIMAPXCommand *)is->queue.head;
 		nc = ic->next;
 		while (nc && is->literal == NULL && count < MAX_COMMANDS && ic->pri >= pri) {
-			c(printf("-- %3d '%s'?\n", (gint)ic->pri, ic->name));
+			c("-- %3d '%s'?\n", (gint)ic->pri, ic->name);
 			if (!ic->select || ((ic->select == is->select_folder) &&
 					    !duplicate_fetch_or_refresh (is, ic))) {
-				c(printf("--> starting '%s'\n", ic->name));
+				c("--> starting '%s'\n", ic->name);
 				pri = ic->pri;
 				camel_dlist_remove ((CamelDListNode *)ic);
 				imapx_command_start (is, ic);
@@ -985,8 +985,8 @@ imapx_command_start_next (CamelIMAPXServer *is, GError **error)
 	/* If we need to select a folder for the first command, do it now, once
 	   it is complete it will re-call us if it succeeded */
 	if (ic->select) {
-		c(printf("Selecting folder '%s' for command '%s'(%p)\n",
-			 camel_folder_get_full_name (ic->select), ic->name, ic));
+		c("Selecting folder '%s' for command '%s'(%p)\n",
+		  camel_folder_get_full_name (ic->select), ic->name, ic);
 		imapx_select (is, ic->select, FALSE, error);
 	} else {
 		pri = ic->pri;
@@ -995,7 +995,7 @@ imapx_command_start_next (CamelIMAPXServer *is, GError **error)
 		while (nc && is->literal == NULL && count < MAX_COMMANDS && ic->pri >= pri) {
 			if (!ic->select || (ic->select == is->select_folder &&
 					    !duplicate_fetch_or_refresh (is, ic))) {
-				c(printf("* queueing job %3d '%s'\n", (gint)ic->pri, ic->name));
+				c("* queueing job %3d '%s'\n", (gint)ic->pri, ic->name);
 				pri = ic->pri;
 				camel_dlist_remove ((CamelDListNode *)ic);
 				imapx_command_start (is, ic);
@@ -1028,12 +1028,12 @@ imapx_command_queue (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
 
 	camel_imapx_command_close (ic);
 
-	c(printf("enqueue job '%.*s'\n", ((CamelIMAPXCommandPart *)ic->parts.head)->data_size, ((CamelIMAPXCommandPart *)ic->parts.head)->data));
+	c("enqueue job '%.*s'\n", ((CamelIMAPXCommandPart *)ic->parts.head)->data_size, ((CamelIMAPXCommandPart *)ic->parts.head)->data);
 
 	QUEUE_LOCK (is);
 
 	if (is->state == IMAPX_SHUTDOWN) {
-		c(printf("refuse to queue job on disconnected server\n"));
+		c("refuse to queue job on disconnected server\n");
 		g_set_error (
 			&ic->error, CAMEL_IMAPX_ERROR, 1,
 			"Server disconnected");
@@ -1210,7 +1210,7 @@ imapx_untagged (CamelIMAPXServer *imap, GError **error)
 	gboolean lsub = FALSE;
 	struct _status_info *sinfo;
 
-	e(printf("got untagged response\n"));
+	e("got untagged response\n");
 	id = 0;
 	tok = camel_imapx_stream_token (imap->stream, &token, &len, error);
 	if (tok < 0)
@@ -1230,7 +1230,7 @@ imapx_untagged (CamelIMAPXServer *imap, GError **error)
 		return -1;
 	}
 
-	e(printf("Have token '%s' id %d\n", token, id));
+	e("Have token '%s' id %d\n", token, id);
 	p = token;
 	while ((c = *p))
 		*p++ = toupper((gchar) c);
@@ -1242,7 +1242,7 @@ imapx_untagged (CamelIMAPXServer *imap, GError **error)
 		imap->cinfo = imapx_parse_capability (imap->stream, error);
 		if (imap->cinfo == NULL)
 			return -1;
-		c(printf("got capability flags %08x\n", imap->cinfo->capa));
+		c("got capability flags %08x\n", imap->cinfo->capa);
 		return 0;
 	case IMAPX_EXPUNGE: {
 		guint32 expunge = id;
@@ -1252,7 +1252,7 @@ imapx_untagged (CamelIMAPXServer *imap, GError **error)
 		if (job)
 			break;
 
-		c(printf("expunged: %d\n", id));
+		c("expunged: %d\n", id);
 		if (imap->select_folder) {
 			gchar *uid = NULL;
 
@@ -1292,7 +1292,7 @@ imapx_untagged (CamelIMAPXServer *imap, GError **error)
 			return -1;
 		for (i = 0; i < uids->len; i++) {
 			gchar *uid = g_strdup_printf("%u", GPOINTER_TO_UINT(g_ptr_array_index (uids, i)));
-			c(printf("vanished: %s\n", uid));
+			c("vanished: %s\n", uid);
 			imapx_expunge_uid_from_summary (imap, uid, unsolicited);
 		}
 		g_ptr_array_free (uids, FALSE);
@@ -1318,7 +1318,7 @@ imapx_untagged (CamelIMAPXServer *imap, GError **error)
 		return 0;
 	}
 	case IMAPX_EXISTS:
-		c(printf("exists: %d\n", id));
+		c("exists: %d\n", id);
 		imap->exists = id;
 
 		if (imap->select_folder)
@@ -1335,7 +1335,7 @@ imapx_untagged (CamelIMAPXServer *imap, GError **error)
 
 		imapx_parse_flags (imap->stream, &flags, NULL, error);
 
-		c(printf("flags: %08x\n", flags));
+		c("flags: %08x\n", flags);
 		break;
 	}
 	case IMAPX_FETCH: {
@@ -1392,7 +1392,7 @@ imapx_untagged (CamelIMAPXServer *imap, GError **error)
 				g_object_ref (imap->select_folder);
 				folder = imap->select_folder;
 
-				c(printf("flag changed: %d\n", id));
+				c("flag changed: %d\n", id);
 
 				if (finfo->got & FETCH_UID) {
 					uid = finfo->uid;
@@ -1410,7 +1410,7 @@ imapx_untagged (CamelIMAPXServer *imap, GError **error)
 					} else {
 						/* This (UID + FLAGS for previously unknown message) might
 						   happen during a SELECT (QRESYNC). We should use it. */
-						c(printf("flags changed for unknown uid %s\n.", uid));
+						c("flags changed for unknown uid %s\n.", uid);
 					}
 					finfo->user_flags = NULL;
 				}
@@ -1509,10 +1509,10 @@ imapx_untagged (CamelIMAPXServer *imap, GError **error)
 						unsigned long long uidl = strtoull (mi->uid, NULL, 10);
 
 						if (uidl >= ifolder->uidnext_on_server) {
-							c(printf("Updating unread count for new message %s\n", mi->uid));
+							c("Updating unread count for new message %s\n", mi->uid);
 							((CamelIMAPXFolder *)job->folder)->unread_on_server++;
 						} else {
-							c(printf("Not updating unread count for new message %s\n", mi->uid));
+							c("Not updating unread count for new message %s\n", mi->uid);
 						}
 					}
 
@@ -1561,10 +1561,10 @@ imapx_untagged (CamelIMAPXServer *imap, GError **error)
 		// TODO: we want to make sure the names match?
 
 		if (job->u.list.flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED) {
-			c(printf("lsub: '%s' (%c)\n", linfo->name, linfo->separator));
+			c("lsub: '%s' (%c)\n", linfo->name, linfo->separator);
 
 		} else {
-			c(printf("list: '%s' (%c)\n", linfo->name, linfo->separator));
+			c("list: '%s' (%c)\n", linfo->name, linfo->separator);
 		}
 
 		if (job && g_hash_table_lookup (job->u.list.folders, linfo->name) == NULL) {
@@ -1578,7 +1578,7 @@ imapx_untagged (CamelIMAPXServer *imap, GError **error)
 		break;
 	}
 	case IMAPX_RECENT:
-		c(printf("recent: %d\n", id));
+		c("recent: %d\n", id);
 		imap->recent = id;
 		break;
 	case IMAPX_STATUS: {
@@ -1593,7 +1593,7 @@ imapx_untagged (CamelIMAPXServer *imap, GError **error)
 				gchar *path_name;
 
 				path_name = camel_imapx_store_summary_full_to_path (s, sinfo->name, ns->sep);
-				c(printf("Got folder path '%s' for full '%s'\n", path_name, sinfo->name));
+				c("Got folder path '%s' for full '%s'\n", path_name, sinfo->name);
 				if (path_name) {
 					ifolder = (gpointer)camel_store_get_folder (imap->store, path_name, 0, error);
 					g_free (path_name);
@@ -1606,7 +1606,7 @@ imapx_untagged (CamelIMAPXServer *imap, GError **error)
 				ifolder->uidnext_on_server = sinfo->uidnext;
 				ifolder->uidvalidity_on_server = sinfo->uidvalidity;
 			} else {
-				c(printf("Received STATUS for unknown folder '%s'\n", sinfo->name));
+				c("Received STATUS for unknown folder '%s'\n", sinfo->name);
 			}
 
 			g_free (sinfo->name);
@@ -1618,7 +1618,7 @@ imapx_untagged (CamelIMAPXServer *imap, GError **error)
 		guchar *token;
 
 		if (camel_imapx_stream_text (imap->stream, &token, NULL)) {
-			c(printf("BYE: %s\n", token));
+			c("BYE: %s\n", token);
 			g_set_error (
 				error, CAMEL_IMAPX_ERROR, 1,
 				"IMAP server said BYE: %s", token);
@@ -1627,7 +1627,7 @@ imapx_untagged (CamelIMAPXServer *imap, GError **error)
 		return -1;
 	}
 	case IMAPX_PREAUTH:
-		c(printf("preauthenticated\n"));
+		c("preauthenticated\n");
 		if (imap->state < IMAPX_AUTHENTICATED)
 			imap->state = IMAPX_AUTHENTICATED;
 		/* fall through... */
@@ -1640,18 +1640,18 @@ imapx_untagged (CamelIMAPXServer *imap, GError **error)
 			return -1;
 		switch (sinfo->condition) {
 		case IMAPX_CLOSED:
-			c(printf("previously selected folder is now closed\n"));
+			c("previously selected folder is now closed\n");
 			if (imap->select_pending && !imap->select_folder) {
 				imap->select_folder = imap->select_pending;
 			}
 			break;
 		case IMAPX_READ_WRITE:
 			imap->mode = IMAPX_MODE_READ|IMAPX_MODE_WRITE;
-			c(printf("folder is read-write\n"));
+			c("folder is read-write\n");
 			break;
 		case IMAPX_READ_ONLY:
 			imap->mode = IMAPX_MODE_READ;
-			c(printf("folder is read-only\n"));
+			c("folder is read-only\n");
 			break;
 		case IMAPX_UIDVALIDITY:
 			imap->uidvalidity = sinfo->u.uidvalidity;
@@ -1669,10 +1669,10 @@ imapx_untagged (CamelIMAPXServer *imap, GError **error)
 			imap->uidnext = sinfo->u.uidnext;
 			break;
 		case IMAPX_ALERT:
-			c(printf("ALERT!: %s\n", sinfo->text));
+			c("ALERT!: %s\n", sinfo->text);
 			break;
 		case IMAPX_PARSE:
-			c(printf("PARSE: %s\n", sinfo->text));
+			c("PARSE: %s\n", sinfo->text);
 			break;
 		case IMAPX_CAPABILITY:
 			if (sinfo->u.cinfo) {
@@ -1681,7 +1681,7 @@ imapx_untagged (CamelIMAPXServer *imap, GError **error)
 				sinfo->u.cinfo = NULL;
 				if (cinfo)
 					imapx_free_capability (cinfo);
-				c(printf("got capability flags %08x\n", imap->cinfo->capa));
+				c("got capability flags %08x\n", imap->cinfo->capa);
 			}
 			break;
 		default:
@@ -1691,7 +1691,7 @@ imapx_untagged (CamelIMAPXServer *imap, GError **error)
 		return 0;
 	default:
 		/* unknown response, just ignore it */
-		c(printf("unknown token: %s\n", token));
+		c("unknown token: %s\n", token);
 	}
 
 	return camel_imapx_stream_skip (imap->stream, error);
@@ -1712,7 +1712,7 @@ imapx_continuation (CamelIMAPXServer *imap, gboolean litplus, GError **error)
 	if (imapx_idle_supported (imap) && imapx_in_idle (imap)) {
 		camel_imapx_stream_skip (imap->stream, error);
 
-		c(printf("Got continuation response for IDLE \n"));
+		c("Got continuation response for IDLE \n");
 		IDLE_LOCK (imap->idle);
 		/* We might have actually sent the DONE already! */
 		if (imap->idle->state == IMAPX_IDLE_ISSUED)
@@ -1724,8 +1724,8 @@ imapx_continuation (CamelIMAPXServer *imap, gboolean litplus, GError **error)
 			imapx_command_idle_stop (imap, error);
 			imap->idle->state = IMAPX_IDLE_OFF;
 		} else {
-			c(printf("idle starts in wrong state %d\n",
-				 imap->idle->state));
+			c("idle starts in wrong state %d\n",
+				 imap->idle->state);
 		}
 		IDLE_UNLOCK (imap->idle);
 
@@ -1741,22 +1741,22 @@ imapx_continuation (CamelIMAPXServer *imap, gboolean litplus, GError **error)
 	if (!litplus) {
 		if (ic == NULL) {
 			camel_imapx_stream_skip (imap->stream, error);
-			c(printf("got continuation response with no outstanding continuation requests?\n"));
+			c("got continuation response with no outstanding continuation requests?\n");
 			return 1;
 		}
-		c(printf("got continuation response for data\n"));
+		c("got continuation response for data\n");
 	} else {
-		c(printf("sending LITERAL+ continuation\n"));
+		c("sending LITERAL+ continuation\n");
 	}
 
 	cp = ic->current;
 	switch (cp->type & CAMEL_IMAPX_COMMAND_MASK) {
 	case CAMEL_IMAPX_COMMAND_DATAWRAPPER:
-		c(printf("writing data wrapper to literal\n"));
+		c("writing data wrapper to literal\n");
 		camel_data_wrapper_write_to_stream ((CamelDataWrapper *)cp->ob, (CamelStream *)imap->stream, NULL);
 		break;
 	case CAMEL_IMAPX_COMMAND_STREAM:
-		c(printf("writing stream to literal\n"));
+		c("writing stream to literal\n");
 		camel_stream_write_to_stream ((CamelStream *)cp->ob, (CamelStream *)imap->stream, NULL);
 		break;
 	case CAMEL_IMAPX_COMMAND_AUTH: {
@@ -1770,7 +1770,7 @@ imapx_continuation (CamelIMAPXServer *imap, gboolean litplus, GError **error)
 		g_free (token);
 		if (resp == NULL)
 			return -1;
-		c(printf("got auth continuation, feeding token '%s' back to auth mech\n", resp));
+		c("got auth continuation, feeding token '%s' back to auth mech\n", resp);
 
 		camel_stream_write ((CamelStream *)imap->stream, resp, strlen (resp), NULL);
 		g_free (resp);
@@ -1783,7 +1783,7 @@ imapx_continuation (CamelIMAPXServer *imap, gboolean litplus, GError **error)
 	case CAMEL_IMAPX_COMMAND_FILE: {
 		CamelStream *file;
 
-		c(printf("writing file '%s' to literal\n", (gchar *)cp->ob));
+		c("writing file '%s' to literal\n", (gchar *)cp->ob);
 
 		// FIXME: errors
 		if (cp->ob && (file = camel_stream_fs_new_with_name (cp->ob, O_RDONLY, 0, NULL))) {
@@ -1811,7 +1811,7 @@ imapx_continuation (CamelIMAPXServer *imap, gboolean litplus, GError **error)
 	cp = cp->next;
 	if (cp->next) {
 		ic->current = cp;
-		c(printf("next part of command \"%c%05u: %s\"\n", imap->tagprefix, ic->tag, cp->data));
+		c("next part of command \"%c%05u: %s\"\n", imap->tagprefix, ic->tag, cp->data);
 		camel_stream_printf((CamelStream *)imap->stream, "%s\r\n", cp->data);
 		if (cp->type & (CAMEL_IMAPX_COMMAND_CONTINUATION|CAMEL_IMAPX_COMMAND_LITERAL_PLUS)) {
 			newliteral = ic;
@@ -1819,7 +1819,7 @@ imapx_continuation (CamelIMAPXServer *imap, gboolean litplus, GError **error)
 			g_assert (cp->next->next == NULL);
 		}
 	} else {
-		c(printf("%p: queueing continuation\n", ic));
+		c("%p: queueing continuation\n", ic);
 		camel_stream_printf((CamelStream *)imap->stream, "\r\n");
 	}
 
@@ -1858,7 +1858,7 @@ imapx_completion (CamelIMAPXServer *imap, guchar *token, gint len, GError **erro
 		return -1;
 	}
 
-	c(printf("Got completion response for command %05u '%s'\n", ic->tag, ic->name));
+	c("Got completion response for command %05u '%s'\n", ic->tag, ic->name);
 
 	if (camel_folder_change_info_changed (imap->changes)) {
 		if (imap->changes->uid_changed->len)
@@ -2014,7 +2014,7 @@ imapx_register_job (CamelIMAPXServer *is,
 		QUEUE_UNLOCK (is);
 
 	} else {
-		e(printf ("NO connection yet, maybe user cancelled jobs earlier ?"));
+		e ("NO connection yet, maybe user cancelled jobs earlier ?");
 		g_set_error (
 			error, CAMEL_SERVICE_ERROR,
 			CAMEL_SERVICE_ERROR_NOT_CONNECTED,
@@ -2216,7 +2216,7 @@ imapx_idle_thread (gpointer data)
 				imapx_server_fetch_new_messages (is, is->select_folder, TRUE, TRUE, &local_error);
 
 			if (local_error != NULL) {
-				e(printf ("Caught exception in idle thread:  %s \n", local_error->message));
+				e ("Caught exception in idle thread:  %s \n", local_error->message);
 				/* No way to asyncronously notify UI ? */
 				g_clear_error (&local_error);
 			}
@@ -2256,8 +2256,8 @@ imapx_stop_idle (CamelIMAPXServer *is, GError **error)
 		imapx_command_idle_stop (is, error);
 		idle->state = IMAPX_IDLE_OFF;
 		stopped = TRUE;
-		c(printf("Stopping idle after %ld seconds\n",
-			 (long)(now - idle->started)));
+		c("Stopping idle after %ld seconds\n",
+		  (long)(now - idle->started));
 	case IMAPX_IDLE_PENDING:
 		idle->state = IMAPX_IDLE_OFF;
 	case IMAPX_IDLE_OFF:
@@ -2361,7 +2361,7 @@ imapx_command_select_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
 		CamelDList failed;
 		CamelIMAPXCommand *cw, *cn;
 
-		c(printf("Select failed\n"));
+		c("Select failed\n");
 		camel_dlist_init (&failed);
 
 		QUEUE_LOCK (is);
@@ -2371,8 +2371,8 @@ imapx_command_select_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
 		if (is->select_pending) {
 			while (cn) {
 				if (cw->select && cw->select == is->select_pending) {
-					c(printf("Cancelling command '%s'(%p) for folder '%s'\n",
-						 cw->name, cw, camel_folder_get_full_name (cw->select)));
+					c("Cancelling command '%s'(%p) for folder '%s'\n",
+					  cw->name, cw, camel_folder_get_full_name (cw->select));
 					camel_dlist_remove ((CamelDListNode *)cw);
 					camel_dlist_addtail (&failed, (CamelDListNode *)cw);
 				}
@@ -2412,7 +2412,7 @@ imapx_command_select_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
 		is->state = IMAPX_INITIALISED;
 	} else {
 		CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) is->select_pending;
-		c(printf("Select ok!\n"));
+		c("Select ok!\n");
 
 		if (!is->select_folder) {
 			/* This could have been done earlier by a [CLOSED] status */
@@ -2513,7 +2513,7 @@ imapx_select (CamelIMAPXServer *is, CamelFolder *folder, gboolean forced, GError
 			uid = camel_folder_summary_uid_from_index (folder->summary, 0);
 
 		if (isum->modseq && ifolder->uidvalidity_on_server) {
-			c(printf("SELECT QRESYNC %" G_GUINT64_FORMAT " %" G_GUINT64_FORMAT "\n", ifolder->uidvalidity_on_server, isum->modseq));
+			c("SELECT QRESYNC %" G_GUINT64_FORMAT " %" G_GUINT64_FORMAT "\n", ifolder->uidvalidity_on_server, isum->modseq);
 			camel_imapx_command_add(ic, " (QRESYNC (%" G_GUINT64_FORMAT " %" G_GUINT64_FORMAT " %s:*", ifolder->uidvalidity_on_server, isum->modseq, uid?uid:"1");
 
 			if (total > 10) {
@@ -2552,7 +2552,7 @@ imapx_select (CamelIMAPXServer *is, CamelFolder *folder, gboolean forced, GError
 
 				g_string_prepend(seqs, " (");
 
-				c(printf("adding QRESYNC seq/uidset %s%s\n", seqs->str, uids->str));
+				c("adding QRESYNC seq/uidset %s%s\n", seqs->str, uids->str);
 				camel_imapx_command_add (ic, seqs->str);
 				camel_imapx_command_add (ic, uids->str);
 
@@ -2793,7 +2793,7 @@ imapx_connect_to_server (CamelIMAPXServer *is, GError **error)
 		camel_imapx_stream_ungettoken (is->stream, tok, token, len);
 		if (camel_imapx_stream_text (is->stream, &token, error))
 			return FALSE;
-		e(printf("Got unexpected line before greeting:  '%s'\n", token));
+		e("Got unexpected line before greeting:  '%s'\n", token);
 		g_free (token);
 	}
 
@@ -2851,7 +2851,7 @@ imapx_connect_to_server (CamelIMAPXServer *is, GError **error)
 		if (ic->status->condition == IMAPX_CAPABILITY) {
 			is->cinfo = ic->status->u.cinfo;
 			ic->status->u.cinfo = NULL;
-			c(printf("got capability flags %08x\n", is->cinfo->capa));
+			c("got capability flags %08x\n", is->cinfo->capa);
 		}
 
 		camel_imapx_command_free (ic);
@@ -2880,7 +2880,7 @@ imapx_connect_to_server (CamelIMAPXServer *is, GError **error)
 
 exit:
 	if (local_error != NULL) {
-		e(printf("Unable to connect %d %s \n", local_error->code, local_error->message));
+		e("Unable to connect %d %s \n", local_error->code, local_error->message);
 		g_propagate_error (error, local_error);
 		g_object_unref (is->stream);
 		is->stream = NULL;
@@ -2994,7 +2994,7 @@ imapx_reconnect (CamelIMAPXServer *is, GError **error)
 			if (ic->status->condition == IMAPX_CAPABILITY) {
 				is->cinfo = ic->status->u.cinfo;
 				ic->status->u.cinfo = NULL;
-				c(printf("got capability flags %08x\n", is->cinfo->capa));
+				c("got capability flags %08x\n", is->cinfo->capa);
 			}
 
 			authenticated = TRUE;
@@ -3345,7 +3345,7 @@ imapx_command_append_message_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
 
 	if (ic->error == NULL && ic->status->result == IMAPX_OK) {
 		if (ic->status->condition == IMAPX_APPENDUID) {
-			c(printf("Got appenduid %d %d\n", (gint)ic->status->u.appenduid.uidvalidity, (gint)ic->status->u.appenduid.uid));
+			c("Got appenduid %d %d\n", (gint)ic->status->u.appenduid.uidvalidity, (gint)ic->status->u.appenduid.uid);
 			if (ic->status->u.appenduid.uidvalidity == ifolder->uidvalidity_on_server) {
 				CamelFolderChangeInfo *changes;
 				gchar *uid;
@@ -3464,7 +3464,7 @@ imapx_index_next (GPtrArray *uids, CamelFolderSummary *s, guint index)
 
 		if (info && (strchr (camel_message_info_uid (info), '-') != NULL)) {
 			camel_message_info_free (info);
-			e(printf("Ignoring offline uid '%s'\n", camel_message_info_uid(info)));
+			e("Ignoring offline uid '%s'\n", camel_message_info_uid(info));
 		} else {
 			camel_message_info_free (info);
 			break;
@@ -3543,8 +3543,8 @@ imapx_command_step_fetch_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
 		uidl++;
 
 		if (uidl > ifolder->uidnext_on_server) {
-			c(printf("Updating uidnext_on_server for '%s' to %lld\n",
-				 camel_folder_get_full_name (job->folder), uidl));
+			c("Updating uidnext_on_server for '%s' to %lld\n",
+			  camel_folder_get_full_name (job->folder), uidl);
 			ifolder->uidnext_on_server = uidl;
 		}
 	}
@@ -3680,7 +3680,7 @@ imapx_job_scan_changes_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
 				continue;
 			}
 
-			e(printf("Message %s vanished\n", s_minfo->uid));
+			e("Message %s vanished\n", s_minfo->uid);
 			removed = g_slist_prepend (removed, (gpointer) g_strdup (s_minfo->uid));
 			camel_message_info_free (s_minfo);
 			j++;
@@ -3804,8 +3804,8 @@ imapx_command_fetch_new_messages_done (CamelIMAPXServer *is, CamelIMAPXCommand *
 		uidl++;
 
 		if (uidl > ifolder->uidnext_on_server) {
-			c(printf("Updating uidnext_on_server for '%s' to %lld\n",
-				 camel_folder_get_full_name (ic->job->folder), uidl));
+			c("Updating uidnext_on_server for '%s' to %lld\n",
+			  camel_folder_get_full_name (ic->job->folder), uidl);
 			ifolder->uidnext_on_server = uidl;
 		}
 	}
@@ -3965,12 +3965,12 @@ imapx_job_refresh_info_start (CamelIMAPXServer *is, CamelIMAPXJob *job)
 	if (is->use_qresync && isum->modseq && ifolder->uidvalidity_on_server)
 		can_qresync = TRUE;
 
-	e(printf("folder %s is %sselected, total %u / %u, unread %u / %u, modseq %llu / %llu, uidnext %u / %u: will %srescan\n",
-		 full_name, is_selected?"": "not ", total, ifolder->exists_on_server,
-		 folder->summary->unread_count, ifolder->unread_on_server,
-		 (unsigned long long)isum->modseq, (unsigned long long)ifolder->modseq_on_server,
-		 isum->uidnext, ifolder->uidnext_on_server,
-		 need_rescan?"":"not "));
+	e("folder %s is %sselected, total %u / %u, unread %u / %u, modseq %llu / %llu, uidnext %u / %u: will %srescan\n",
+	  full_name, is_selected?"": "not ", total, ifolder->exists_on_server,
+	  folder->summary->unread_count, ifolder->unread_on_server,
+	  (unsigned long long)isum->modseq, (unsigned long long)ifolder->modseq_on_server,
+	  isum->uidnext, ifolder->uidnext_on_server,
+	  need_rescan?"":"not ");
 
 	/* Fetch new messages first, so that they appear to the user ASAP */
 	if (ifolder->exists_on_server > total ||
@@ -3999,15 +3999,15 @@ imapx_job_refresh_info_start (CamelIMAPXServer *is, CamelIMAPXJob *job)
 		if (total != ifolder->exists_on_server ||
 		    folder->summary->unread_count != ifolder->unread_on_server ||
 		    (isum->modseq != ifolder->modseq_on_server)) {
-			c(printf("Eep, after QRESYNC we're out of sync. total %u / %u, unread %u / %u, modseq %" G_GUINT64_FORMAT " / %" G_GUINT64_FORMAT "\n",
-				 total, ifolder->exists_on_server,
-				 folder->summary->unread_count, ifolder->unread_on_server,
-				 isum->modseq, ifolder->modseq_on_server));
+			c("Eep, after QRESYNC we're out of sync. total %u / %u, unread %u / %u, modseq %" G_GUINT64_FORMAT " / %" G_GUINT64_FORMAT "\n",
+			  total, ifolder->exists_on_server,
+			  folder->summary->unread_count, ifolder->unread_on_server,
+			  isum->modseq, ifolder->modseq_on_server);
 		} else {
-			c(printf("OK, after QRESYNC we're still in sync. total %u / %u, unread %u / %u, modseq %" G_GUINT64_FORMAT " / %" G_GUINT64_FORMAT "\n",
-				 total, ifolder->exists_on_server,
-				 folder->summary->unread_count, ifolder->unread_on_server,
-				 isum->modseq, ifolder->modseq_on_server));
+			c("OK, after QRESYNC we're still in sync. total %u / %u, unread %u / %u, modseq %" G_GUINT64_FORMAT " / %" G_GUINT64_FORMAT "\n",
+			  total, ifolder->exists_on_server,
+			  folder->summary->unread_count, ifolder->unread_on_server,
+			  isum->modseq, ifolder->modseq_on_server);
 			goto done;
 		}
 	}
@@ -4107,7 +4107,7 @@ imapx_command_list_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
 			g_propagate_error (&ic->job->error, ic->error);
 	}
 
-	e(printf ("==== list or lsub completed ==== \n"));
+	e ("==== list or lsub completed ==== \n");
 	imapx_job_done (is, ic->job);
 	camel_imapx_command_free (ic);
 }
@@ -4459,7 +4459,7 @@ imapx_job_sync_changes_start (CamelIMAPXServer *is, CamelIMAPXJob *job)
 			if ((orset & flag) == 0)
 				continue;
 
-			c(printf("checking/storing %s flags '%s'\n", on?"on":"off", flags_table[j].name));
+			c("checking/storing %s flags '%s'\n", on?"on":"off", flags_table[j].name);
 			imapx_uidset_init (&ss, 0, 100);
 			for (i = 0; i < uids->len; i++) {
 				CamelIMAPXMessageInfo *info = (CamelIMAPXMessageInfo *)camel_folder_summary_uid
diff --git a/camel/providers/imapx/camel-imapx-store-summary.c b/camel/providers/imapx/camel-imapx-store-summary.c
index baa6903..cf262b4 100644
--- a/camel/providers/imapx/camel-imapx-store-summary.c
+++ b/camel/providers/imapx/camel-imapx-store-summary.c
@@ -32,8 +32,7 @@
 #include "camel-imapx-utils.h"
 #include "camel-imapx-store-summary.h"
 
-#define d(x) camel_imapx_debug(debug, x)
-#define io(x) camel_imapx_debug(io, x)
+#define d(...) camel_imapx_debug(debug, __VA_ARGS__)
 
 #define CAMEL_IMAPX_STORE_SUMMARY_VERSION_0 (0)
 
@@ -229,7 +228,7 @@ camel_imapx_store_summary_add_from_full (CamelIMAPXStoreSummary *s, const gchar
 	gchar *full_name;
 	CamelIMAPXStoreNamespace *ns;
 
-	d(printf("adding full name '%s' '%c'\n", full, dir_sep));
+	d("adding full name '%s' '%c'\n", full, dir_sep);
 
 	len = strlen (full);
 	full_name = alloca (len+1);
@@ -240,13 +239,13 @@ camel_imapx_store_summary_add_from_full (CamelIMAPXStoreSummary *s, const gchar
 	info = camel_imapx_store_summary_full_name (s, full_name);
 	if (info) {
 		camel_store_summary_info_free ((CamelStoreSummary *)s, (CamelStoreInfo *)info);
-		d(printf("  already there\n"));
+		d("  already there\n");
 		return info;
 	}
 
 	ns = camel_imapx_store_summary_namespace_find_full (s, full_name);
 	if (ns) {
-		d(printf("(found namespace for '%s' ns '%s') ", full_name, ns->path));
+		d("(found namespace for '%s' ns '%s') ", full_name, ns->path);
 		len = strlen (ns->full_name);
 		if (len >= strlen (full_name)) {
 			pathu8 = g_strdup (ns->path);
@@ -262,21 +261,21 @@ camel_imapx_store_summary_add_from_full (CamelIMAPXStoreSummary *s, const gchar
 				pathu8 = prefix;
 			}
 		}
-		d(printf(" (pathu8 = '%s')", pathu8));
+		d(" (pathu8 = '%s')", pathu8);
 	} else {
-		d(printf("(Cannot find namespace for '%s')\n", full_name));
+		d("(Cannot find namespace for '%s')\n", full_name);
 		pathu8 = camel_imapx_store_summary_full_to_path (s, full_name, dir_sep);
 	}
 
 	info = (CamelIMAPXStoreInfo *)camel_store_summary_add_from_path ((CamelStoreSummary *)s, pathu8);
 	if (info) {
-		d(printf("  '%s' -> '%s'\n", pathu8, full_name));
+		d("  '%s' -> '%s'\n", pathu8, full_name);
 		camel_store_info_set_string ((CamelStoreSummary *)s, (CamelStoreInfo *)info, CAMEL_IMAPX_STORE_INFO_FULL_NAME, full_name);
 
 		if (!g_ascii_strcasecmp(full_name, "inbox"))
 			info->info.flags |= CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_TYPE_INBOX;
 	} else {
-		d(printf("  failed\n"));
+		d("  failed\n");
 	}
 
 	g_free (pathu8);
@@ -296,7 +295,7 @@ camel_imapx_store_summary_full_from_path (CamelIMAPXStoreSummary *s, const gchar
 	if (ns)
 		name = camel_imapx_store_summary_path_to_full (s, path, ns->sep);
 
-	d(printf("looking up path %s -> %s\n", path, name?name:"not found"));
+	d("looking up path %s -> %s\n", path, name?name:"not found");
 
 	return name;
 }
@@ -330,7 +329,7 @@ CamelIMAPXStoreNamespace *camel_imapx_store_summary_namespace_new (CamelIMAPXSto
 
 void camel_imapx_store_summary_namespace_set (CamelIMAPXStoreSummary *s, CamelIMAPXStoreNamespace *ns)
 {
-	d(printf("Setting namesapce to '%s' '%c' -> '%s'\n", ns->full_name, ns->sep, ns->path));
+	d("Setting namesapce to '%s' '%c' -> '%s'\n", ns->full_name, ns->sep, ns->path);
 
 	/* CHEN not needed  */
 	camel_store_summary_touch ((CamelStoreSummary *)s);
@@ -370,7 +369,7 @@ camel_imapx_store_summary_namespace_find_full (CamelIMAPXStoreSummary *s, const
 	while (ns) {
 		if (ns->full_name)
 			len = strlen (ns->full_name);
-		d(printf("find_full: comparing namespace '%s' to name '%s'\n", ns->full_name, full));
+		d("find_full: comparing namespace '%s' to name '%s'\n", ns->full_name, full);
 		if (len == 0
 		    || (strncmp (ns->full_name, full, len) == 0
 			&& (full[len] == ns->sep || full[len] == 0)))
@@ -622,7 +621,7 @@ store_info_set_string (CamelStoreSummary *s, CamelStoreInfo *mi, gint type, cons
 
 	switch (type) {
 	case CAMEL_IMAPX_STORE_INFO_FULL_NAME:
-		d(printf("Set full name %s -> %s\n", isi->full_name, str));
+		d("Set full name %s -> %s\n", isi->full_name, str);
 		camel_store_summary_lock (s, CAMEL_STORE_SUMMARY_SUMMARY_LOCK);
 		g_free (isi->full_name);
 		isi->full_name = g_strdup (str);
diff --git a/camel/providers/imapx/camel-imapx-stream.c b/camel/providers/imapx/camel-imapx-stream.c
index 7af7f96..83b95d5 100644
--- a/camel/providers/imapx/camel-imapx-stream.c
+++ b/camel/providers/imapx/camel-imapx-stream.c
@@ -34,8 +34,8 @@
 #include "camel-imapx-utils.h"
 #include "camel-imapx-stream.h"
 
-#define t(x) camel_imapx_debug(token, x)
-#define io(x) camel_imapx_debug(io, x)
+#define t(...) camel_imapx_debug(token, __VA_ARGS__)
+#define io(...) camel_imapx_debug(io, __VA_ARGS__)
 
 G_DEFINE_TYPE (CamelIMAPXStream, camel_imapx_stream, CAMEL_TYPE_STREAM)
 
@@ -55,10 +55,10 @@ imapx_stream_fill (CamelIMAPXStream *is,
 			is->bufsize - (is->end - is->buf), error);
 		if (left > 0) {
 			is->end += left;
-			io(printf("camel_imapx_read: buffer is '%.*s'\n", (gint)(is->end - is->ptr), is->ptr));
+			io("camel_imapx_read: buffer is '%.*s'\n", (gint)(is->end - is->ptr), is->ptr);
 			return is->end - is->ptr;
 		} else {
-			io(printf("camel_imapx_read: -1\n"));
+			io("camel_imapx_read: -1\n");
 			/* If returning zero, camel_stream_read() doesn't consider
 			   that to be an error. But we do -- we should only be here
 			   if we *know* there are data to receive. So set the error
@@ -70,7 +70,7 @@ imapx_stream_fill (CamelIMAPXStream *is,
 		}
 	}
 
-	io(printf("camel_imapx_read: -1\n"));
+	io("camel_imapx_read: -1\n");
 
 	g_set_error (
 		error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
@@ -129,7 +129,7 @@ imapx_stream_read (CamelStream *stream,
 			return max;
 	}
 
-	io(printf("camel_imapx_read(literal): '%.*s'\n", (gint)max, buffer));
+	io("camel_imapx_read(literal): '%.*s'\n", (gint)max, buffer);
 
 	is->literal -= max;
 
@@ -144,7 +144,7 @@ imapx_stream_write (CamelStream *stream,
 {
 	CamelIMAPXStream *is = (CamelIMAPXStream *)stream;
 
-	io(printf("camel_imapx_write: '%.*s'\n", (gint)n, buffer));
+	io("camel_imapx_write: '%.*s'\n", (gint)n, buffer);
 
 	return camel_stream_write (is->source, buffer, n, error);
 }
@@ -218,7 +218,7 @@ static void camel_imapx_stream_grow (CamelIMAPXStream *is, guint len, guchar **b
 		is->bufsize <<= 1;
 	} while (is->bufsize <= len);
 
-	io(printf("Grow imapx buffers to %d bytes\n", is->bufsize));
+	io("Grow imapx buffers to %d bytes\n", is->bufsize);
 
 	is->tokenbuf = g_realloc (is->tokenbuf, is->bufsize + 1);
 	if (tokptr)
@@ -226,11 +226,11 @@ static void camel_imapx_stream_grow (CamelIMAPXStream *is, guint len, guchar **b
 	if (is->unget)
 		is->unget_token = is->tokenbuf + (is->unget_token - oldtok);
 
-	//io(printf("buf was %p, ptr %p end %p\n", is->buf, is->ptr, is->end));
+	//io("buf was %p, ptr %p end %p\n", is->buf, is->ptr, is->end);
 	is->buf = g_realloc (is->buf, is->bufsize + 1);
 	is->ptr = is->buf + (is->ptr - oldbuf);
 	is->end = is->buf + (is->end - oldbuf);
-	//io(printf("buf now %p, ptr %p end %p\n", is->buf, is->ptr, is->end));
+	//io("buf now %p, ptr %p end %p\n", is->buf, is->ptr, is->end);
 	if (bufptr)
 		*bufptr = is->buf + (*bufptr - oldbuf);
 }
@@ -322,7 +322,7 @@ camel_imapx_stream_atom (CamelIMAPXStream *is, guchar **data, guint *lenp, GErro
 		return IMAPX_TOK_ERROR;
 	default:
 		g_set_error (error, CAMEL_IMAPX_ERROR, 1, "expecting atom");
-		io(printf("expecting atom!\n"));
+		io("expecting atom!\n");
 		return IMAPX_TOK_PROTOCOL;
 	}
 }
@@ -360,7 +360,7 @@ camel_imapx_stream_astring (CamelIMAPXStream *is, guchar **data, GError **error)
 		return IMAPX_TOK_ERROR;
 	default:
 		g_set_error (error, CAMEL_IMAPX_ERROR, 1, "expecting astring");
-		io(printf("expecting astring!\n"));
+		io("expecting astring!\n");
 		return IMAPX_TOK_PROTOCOL;
 	}
 }
@@ -542,7 +542,7 @@ camel_imapx_stream_token (CamelIMAPXStream *is, guchar **data, guint *len, GErro
 	/*strchr("\n*()[]+", c)*/
 	if (imapx_is_token_char (c)) {
 		is->ptr = p;
-		t(printf("token '%c'\n", c));
+		t("token '%c'\n", c);
 		return c;
 	} else if (c == '{') {
 		literal = 0;
@@ -560,7 +560,7 @@ camel_imapx_stream_token (CamelIMAPXStream *is, guchar **data, guint *len, GErro
 								*len = literal;
 								is->ptr = p;
 								is->literal = literal;
-								t(printf("token LITERAL %d\n", literal));
+								t("token LITERAL %d\n", literal);
 								return IMAPX_TOK_LITERAL;
 							}
 						}
@@ -572,9 +572,9 @@ camel_imapx_stream_token (CamelIMAPXStream *is, guchar **data, guint *len, GErro
 					}
 				} else {
 					if (isdigit (c)) {
-						io(printf("Protocol error: literal too big\n"));
+						io("Protocol error: literal too big\n");
 					} else {
-						io(printf("Protocol error: literal contains invalid gchar %02x '%c'\n", c, isprint(c)?c:c));
+						io("Protocol error: literal contains invalid gchar %02x '%c'\n", c, isprint(c)?c:c);
 					}
 					goto protocol_error;
 				}
@@ -605,11 +605,11 @@ camel_imapx_stream_token (CamelIMAPXStream *is, guchar **data, guint *len, GErro
 					*o = 0;
 					*data = is->tokenbuf;
 					*len = o - is->tokenbuf;
-					t(printf("token STRING '%s'\n", is->tokenbuf));
+					t("token STRING '%s'\n", is->tokenbuf);
 					return IMAPX_TOK_STRING;
 				}
 				if (c == '\n' || c == '\r') {
-					io(printf("Protocol error: truncated string\n"));
+					io("Protocol error: truncated string\n");
 					goto protocol_error;
 				}
 				if (o >= oe) {
@@ -642,7 +642,7 @@ camel_imapx_stream_token (CamelIMAPXStream *is, guchar **data, guint *len, GErro
 					*o = 0;
 					*data = is->tokenbuf;
 					*len = o - is->tokenbuf;
-					t(printf("token TOKEN '%s'\n", is->tokenbuf));
+					t("token TOKEN '%s'\n", is->tokenbuf);
 					return digits?IMAPX_TOK_INT:IMAPX_TOK_TOKEN;
 				}
 
@@ -664,7 +664,7 @@ camel_imapx_stream_token (CamelIMAPXStream *is, guchar **data, guint *len, GErro
 
 	/* Protocol error, skip until next lf? */
 protocol_error:
-	io(printf("Got protocol error\n"));
+	io("Got protocol error\n");
 
 	if (c == '\n')
 		is->ptr = p-1;
@@ -757,7 +757,7 @@ camel_imapx_stream_skip (CamelIMAPXStream *is, GError **error)
 		if (tok == IMAPX_TOK_LITERAL) {
 			camel_imapx_stream_set_literal (is, len);
 			while ((tok = camel_imapx_stream_getl (is, &token, &len)) > 0) {
-				io(printf("Skip literal data '%.*s'\n", (gint)len, token));
+				io("Skip literal data '%.*s'\n", (gint)len, token);
 			}
 		}
 	} while (tok != '\n' && tok >= 0);
diff --git a/camel/providers/imapx/camel-imapx-utils.c b/camel/providers/imapx/camel-imapx-utils.c
index 8605856..3c6ee60 100644
--- a/camel/providers/imapx/camel-imapx-utils.c
+++ b/camel/providers/imapx/camel-imapx-utils.c
@@ -11,9 +11,9 @@
 #include "camel-imapx-utils.h"
 
 /* high-level parser state */
-#define p(x) camel_imapx_debug(parse, x)
+#define p(...) camel_imapx_debug(parse, __VA_ARGS__)
 /* debug */
-#define d(x) camel_imapx_debug(debug, x)
+#define d(...) camel_imapx_debug(debug, __VA_ARGS__)
 
 gint camel_imapx_debug_flags;
 extern gint camel_verbose_debug;
@@ -255,9 +255,9 @@ imapx_update_message_info_flags (CamelMessageInfo *info, guint32 server_flags, C
 		else if (server_cleared & CAMEL_MESSAGE_JUNK)
 			junk = -1;
 
-		d(printf("%s %s %s %s\n", xinfo->info.uid, read == 1 ? "read" : ( read == -1 ? "unread" : ""),
-					deleted == 1 ? "deleted" : ( deleted == -1 ? "undeleted" : ""),
-					junk == 1 ? "junk" : ( junk == -1 ? "unjunked" : "")));
+		d("%s %s %s %s\n", xinfo->info.uid, read == 1 ? "read" : ( read == -1 ? "unread" : ""),
+		  deleted == 1 ? "deleted" : ( deleted == -1 ? "undeleted" : ""),
+		  junk == 1 ? "junk" : ( junk == -1 ? "unjunked" : ""));
 
 		if (read) {
 			folder->summary->unread_count -= read;
@@ -460,7 +460,7 @@ imapx_parse_capability (CamelIMAPXStream *stream, GError **error)
 					break;
 				}
 			case IMAPX_TOK_INT:
-				d(printf(" cap: '%s'\n", token));
+				d(" cap: '%s'\n", token);
 				for (i = 0; i < G_N_ELEMENTS (capa_table); i++)
 					if (!strcmp ((gchar *) token, capa_table[i].name))
 						cinfo->capa |= capa_table[i].flag;
@@ -743,7 +743,7 @@ imapx_parse_param_list (CamelIMAPXStream *is, struct _camel_header_param **plist
 	guchar *token;
 	gchar *param;
 
-	p(printf("body_fld_param\n"));
+	p("body_fld_param\n");
 
 	/* body_fld_param  ::= "(" 1#(string SPACE string) ")" / nil */
 	tok = camel_imapx_stream_token (is, &token, &len, NULL);
@@ -802,14 +802,14 @@ imapx_parse_ext_optional (CamelIMAPXStream *is, GError **error)
 			dinfo->disposition = g_strdup ((gchar *) token);
 			imapx_parse_param_list (is, &dinfo->params, NULL);
 		case IMAPX_TOK_TOKEN:
-			d(printf("body_fld_dsp: NIL\n"));
+			d("body_fld_dsp: NIL\n");
 			break;
 		default:
 			g_set_error (error, CAMEL_IMAPX_ERROR, 1, "body_fld_disp: expecting nil or list");
 			return NULL;
 	}
 
-	p(printf("body_fld_lang\n"));
+	p("body_fld_lang\n");
 
 	/* body_fld_lang   ::= nstring / "(" 1#string ")" */
 
@@ -830,7 +830,7 @@ imapx_parse_ext_optional (CamelIMAPXStream *is, GError **error)
 			}
 			break;
 		case IMAPX_TOK_TOKEN:
-			d(printf("body_fld_lang = nil\n"));
+			d("body_fld_lang = nil\n");
 			/* treat as 'nil' */
 			break;
 		case IMAPX_TOK_STRING:
@@ -840,7 +840,7 @@ imapx_parse_ext_optional (CamelIMAPXStream *is, GError **error)
 			/* we have a literal string */
 			camel_imapx_stream_set_literal (is, len);
 			while ((tok = camel_imapx_stream_getl (is, &token, &len)) > 0) {
-				d(printf("Skip literal data '%.*s'\n", (gint)len, token));
+				d("Skip literal data '%.*s'\n", (gint)len, token);
 			}
 			break;
 
@@ -868,7 +868,7 @@ imapx_parse_body_fields (CamelIMAPXStream *is, GError **error)
 	   body_fld_desc SPACE body_fld_enc SPACE
 	   body_fld_octets */
 
-	p(printf("body_fields\n"));
+	p("body_fields\n");
 
 	cinfo = g_malloc0 (sizeof (*cinfo));
 
@@ -964,7 +964,7 @@ imapx_parse_address_list (CamelIMAPXStream *is, GError **error)
 				if (mbox == NULL) {
 					group = NULL;
 				} else {
-					d(printf("adding group '%s'\n", mbox));
+					d("adding group '%s'\n", mbox);
 					g_free (addr->name);
 					addr->name = mbox;
 					addr->type = CAMEL_HEADER_ADDRESS_GROUP;
@@ -974,7 +974,7 @@ imapx_parse_address_list (CamelIMAPXStream *is, GError **error)
 			} else {
 				addr->v.addr = g_strdup_printf("%s%s%s", mbox? mbox:"", host?"@":"", host?(gchar *)host:"");
 				g_free (mbox);
-				d(printf("adding address '%s'\n", addr->v.addr));
+				d("adding address '%s'\n", addr->v.addr);
 				if (group != NULL)
 					camel_header_address_add_member (group, addr);
 				else
@@ -985,7 +985,7 @@ imapx_parse_address_list (CamelIMAPXStream *is, GError **error)
 			} while (tok != ')');
 		}
 	} else {
-		d(printf("empty, nil '%s'\n", token));
+		d("empty, nil '%s'\n", token);
 	}
 
 	/* CHEN TODO handle exception at required places */
@@ -1011,7 +1011,7 @@ imapx_parse_envelope (CamelIMAPXStream *is, GError **error)
 	   SPACE env_cc SPACE env_bcc SPACE env_in_reply_to
 	   SPACE env_message_id ")" */
 
-	p(printf("envelope\n"));
+	p("envelope\n");
 
 	minfo = (CamelMessageInfoBase *)camel_message_info_new (NULL);
 
@@ -1125,7 +1125,7 @@ imapx_parse_body (CamelIMAPXStream *is, GError **error)
 
 	/* body            ::= "(" body_type_1part / body_type_mpart ")" */
 
-	p(printf("body\n"));
+	p("body\n");
 
 	tok = camel_imapx_stream_token (is, &token, &len, &local_error);
 	if (tok != '(') {
@@ -1151,7 +1151,7 @@ imapx_parse_body (CamelIMAPXStream *is, GError **error)
 			camel_imapx_stream_ungettoken (is, tok, token, len);
 		} while (tok == '(');
 
-		d(printf("media_subtype\n"));
+		d("media_subtype\n");
 
 		camel_imapx_stream_astring (is, &token, &local_error);
 		cinfo->type = camel_content_type_new("multipart", (gchar *) token);
@@ -1162,7 +1162,7 @@ imapx_parse_body (CamelIMAPXStream *is, GError **error)
 		   ;; MUST NOT be returned on non-extensible
 		   ;; "BODY" fetch */
 
-		d(printf("body_ext_mpart\n"));
+		d("body_ext_mpart\n");
 
 		tok = camel_imapx_stream_token (is, &token, &len, &local_error);
 		camel_imapx_stream_ungettoken (is, tok, token, len);
@@ -1189,11 +1189,11 @@ imapx_parse_body (CamelIMAPXStream *is, GError **error)
 		   body_type_msg   ::= media_message SPACE body_fields SPACE envelope
 		   SPACE body SPACE body_fld_lines */
 
-		d(printf("Single part body\n"));
+		d("Single part body\n");
 
 		cinfo = imapx_parse_body_fields (is, &local_error);
 
-		d(printf("envelope?\n"));
+		d("envelope?\n");
 
 		/* do we have an envelope following */
 		tok = camel_imapx_stream_token (is, &token, &len, &local_error);
@@ -1205,15 +1205,15 @@ imapx_parse_body (CamelIMAPXStream *is, GError **error)
 			//((CamelMessageInfoBase *)minfo)->content = imapx_parse_body (is);
 			camel_message_info_free (minfo);
 			minfo = NULL;
-			d(printf("Scanned envelope - what do i do with it?\n"));
+			d("Scanned envelope - what do i do with it?\n");
 		}
 
-		d(printf("fld_lines?\n"));
+		d("fld_lines?\n");
 
 		/* do we have fld_lines following? */
 		tok = camel_imapx_stream_token (is, &token, &len, &local_error);
 		if (tok == IMAPX_TOK_INT) {
-			d(printf("field lines: %s\n", token));
+			d("field lines: %s\n", token);
 			tok = camel_imapx_stream_token (is, &token, &len, &local_error);
 		}
 		camel_imapx_stream_ungettoken (is, tok, token, len);
@@ -1224,12 +1224,12 @@ imapx_parse_body (CamelIMAPXStream *is, GError **error)
 		   ;; MUST NOT be returned on non-extensible
 		   ;; "BODY" fetch */
 
-		d(printf("extension data?\n"));
+		d("extension data?\n");
 
 		if (tok != ')') {
 			camel_imapx_stream_nstring (is, &token, &local_error);
 
-			d(printf("md5: %s\n", token?(gchar *)token:"NIL"));
+			d("md5: %s\n", token?(gchar *)token:"NIL");
 
 			/* body_fld_dsp    ::= "(" string SPACE body_fld_param ")" / nil */
 
@@ -1247,7 +1247,7 @@ imapx_parse_body (CamelIMAPXStream *is, GError **error)
 	do {
 		tok = camel_imapx_stream_token (is, &token, &len, &local_error);
 		if (tok != ')') {
-			d(printf("Dropping extension data '%s'\n", token));
+			d("Dropping extension data '%s'\n", token);
 		}
 	} while (tok != ')');
 
@@ -1389,9 +1389,9 @@ imapx_dump_fetch (struct _fetch_info *finfo)
 	CamelStream *sout;
 	gint fd;
 
-	d(printf("Fetch info:\n"));
+	d("Fetch info:\n");
 	if (finfo == NULL) {
-		d(printf("Empty\n"));
+		d("Empty\n");
 		return;
 	}
 
@@ -1736,7 +1736,7 @@ imapx_parse_status (CamelIMAPXStream *is, GError **error)
 				break;
 			default:
 				sinfo->condition = IMAPX_UNKNOWN;
-				d(printf("Got unknown response code: %s: ignored\n", token));
+				d("Got unknown response code: %s: ignored\n", token);
 		}
 
 		/* ignore anything we dont know about */
diff --git a/camel/providers/imapx/camel-imapx-utils.h b/camel/providers/imapx/camel-imapx-utils.h
index 6722be2..d7faa34 100644
--- a/camel/providers/imapx/camel-imapx-utils.h
+++ b/camel/providers/imapx/camel-imapx-utils.h
@@ -252,7 +252,11 @@ extern gint camel_imapx_debug_flags;
 /* Set this to zero to remove all debug output at build time */
 #define CAMEL_IMAPX_DEBUG_ALL		((1<<7)-1)
 
-#define camel_imapx_debug(type, ...) do { if (camel_imapx_debug_flags & CAMEL_IMAPX_DEBUG_ALL & CAMEL_IMAPX_DEBUG_ ## type) { __VA_ARGS__ ; } } while (0)
+#define camel_debug_flag(type) (camel_imapx_debug_flags & CAMEL_IMAPX_DEBUG_ALL & CAMEL_IMAPX_DEBUG_ ## type)
+#define camel_imapx_debug(type, fmt, ...) do {				\
+		if (camel_debug_flag(type))				\
+			printf(fmt , ##__VA_ARGS__);			\
+	} while (0)
 
 /* ********************************************************************** */
 
diff --git a/camel/providers/imapx/camel-imapx-view-summary.c b/camel/providers/imapx/camel-imapx-view-summary.c
index 5bdf263..d57a48d 100644
--- a/camel/providers/imapx/camel-imapx-view-summary.c
+++ b/camel/providers/imapx/camel-imapx-view-summary.c
@@ -32,9 +32,6 @@
 /* NB, this is only for the messy iterator_get interface, which could be better hidden */
 #include "libdb/dist/db.h"
 
-#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)
 



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