dovecot: Added imap_logout_format setting with default to bytes=...

dovecot at dovecot.org dovecot at dovecot.org
Fri Jul 13 02:42:22 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/57b70f64f997
changeset: 5980:57b70f64f997
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Jul 13 02:40:47 2007 +0300
description:
Added imap_logout_format setting with default to bytes=%i/%o

diffstat:

7 files changed, 40 insertions(+), 3 deletions(-)
dovecot-example.conf              |    5 +++++
src/imap/client.c                 |   27 +++++++++++++++++++++++++--
src/imap/common.h                 |    1 +
src/imap/main.c                   |    7 ++++++-
src/master/master-settings-defs.c |    1 +
src/master/master-settings.c      |    1 +
src/master/master-settings.h      |    1 +

diffs (145 lines):

diff -r 433745f10290 -r 57b70f64f997 dovecot-example.conf
--- a/dovecot-example.conf	Fri Jul 13 02:37:19 2007 +0300
+++ b/dovecot-example.conf	Fri Jul 13 02:40:47 2007 +0300
@@ -549,6 +549,11 @@ protocol imap {
   # clients to request it with CAPABILITY command, so it saves one round-trip.
   # Many clients however don't understand it and ask the CAPABILITY anyway.
   #login_greeting_capability = no
+
+  # IMAP logout format string:
+  #  %i - total number of bytes read from client
+  #  %o - total number of bytes sent to client
+  #imap_logout_format = bytes=%i/%o
 
   # Override the IMAP CAPABILITY response.
   #imap_capability = 
diff -r 433745f10290 -r 57b70f64f997 src/imap/client.c
--- a/src/imap/client.c	Fri Jul 13 02:37:19 2007 +0300
+++ b/src/imap/client.c	Fri Jul 13 02:40:47 2007 +0300
@@ -2,9 +2,11 @@
 
 #include "common.h"
 #include "ioloop.h"
+#include "str.h"
 #include "network.h"
 #include "istream.h"
 #include "ostream.h"
+#include "var-expand.h"
 #include "commands.h"
 #include "mail-namespace.h"
 
@@ -70,6 +72,27 @@ void client_command_cancel(struct client
 	}
 }
 
+static const char *client_stats(struct client *client)
+{
+	static struct var_expand_table static_tab[] = {
+		{ 'i', NULL },
+		{ 'o', NULL },
+		{ '\0', NULL }
+	};
+	struct var_expand_table *tab;
+	string_t *str;
+
+	tab = t_malloc(sizeof(static_tab));
+	memcpy(tab, static_tab, sizeof(static_tab));
+
+	tab[0].value = dec2str(client->input->v_offset);
+	tab[1].value = dec2str(client->output->offset);
+
+	str = t_str_new(128);
+	var_expand(str, logout_format, tab);
+	return str_c(str);
+}
+
 void client_destroy(struct client *client, const char *reason)
 {
 	i_assert(!client->destroyed);
@@ -79,7 +102,7 @@ void client_destroy(struct client *clien
 		client->disconnected = TRUE;
 		if (reason == NULL)
 			reason = "Disconnected";
-		i_info("%s", reason);
+		i_info("%s %s", reason, client_stats(client));
 	}
 
 	i_stream_close(client->input);
@@ -128,7 +151,7 @@ void client_disconnect(struct client *cl
 	if (client->disconnected)
 		return;
 
-	i_info("Disconnected: %s", reason);
+	i_info("Disconnected: %s %s", reason, client_stats(client));
 	client->disconnected = TRUE;
 	(void)o_stream_flush(client->output);
 
diff -r 433745f10290 -r 57b70f64f997 src/imap/common.h
--- a/src/imap/common.h	Fri Jul 13 02:37:19 2007 +0300
+++ b/src/imap/common.h	Fri Jul 13 02:40:47 2007 +0300
@@ -34,6 +34,7 @@ extern unsigned int max_keyword_length;
 extern unsigned int max_keyword_length;
 extern unsigned int imap_max_line_length;
 extern enum client_workarounds client_workarounds;
+extern const char *logout_format;
 
 extern string_t *capability_string;
 
diff -r 433745f10290 -r 57b70f64f997 src/imap/main.c
--- a/src/imap/main.c	Fri Jul 13 02:37:19 2007 +0300
+++ b/src/imap/main.c	Fri Jul 13 02:40:47 2007 +0300
@@ -42,8 +42,9 @@ unsigned int max_keyword_length;
 unsigned int max_keyword_length;
 unsigned int imap_max_line_length;
 enum client_workarounds client_workarounds = 0;
+const char *logout_format;
+
 static struct io *log_io = NULL;
-
 static struct module *modules = NULL;
 static char log_prefix[128]; /* syslog() needs this to be permanent */
 static pool_t namespace_pool;
@@ -230,6 +231,10 @@ static void main_init(void)
 		(unsigned int)strtoul(str, NULL, 10) :
 		DEFAULT_MAX_KEYWORD_LENGTH;
 
+	logout_format = getenv("IMAP_LOGOUT_FORMAT");
+	if (logout_format == NULL)
+		logout_format = "bytes=%i/%o";
+
         parse_workarounds();
 
 	namespace_pool = pool_alloconly_create("namespaces", 1024);
diff -r 433745f10290 -r 57b70f64f997 src/master/master-settings-defs.c
--- a/src/master/master-settings-defs.c	Fri Jul 13 02:37:19 2007 +0300
+++ b/src/master/master-settings-defs.c	Fri Jul 13 02:40:47 2007 +0300
@@ -111,6 +111,7 @@ static struct setting_def setting_defs[]
 	DEF_INT(imap_max_line_length),
 	DEF_STR(imap_capability),
 	DEF_STR(imap_client_workarounds),
+	DEF_STR(imap_logout_format),
 
 	/* pop3 */
 	DEF_BOOL(pop3_no_flag_updates),
diff -r 433745f10290 -r 57b70f64f997 src/master/master-settings.c
--- a/src/master/master-settings.c	Fri Jul 13 02:37:19 2007 +0300
+++ b/src/master/master-settings.c	Fri Jul 13 02:40:47 2007 +0300
@@ -267,6 +267,7 @@ struct settings default_settings = {
 	MEMBER(imap_max_line_length) 65536,
 	MEMBER(imap_capability) "",
 	MEMBER(imap_client_workarounds) "outlook-idle",
+	MEMBER(imap_logout_format) "bytes=%i/%o",
 
 	/* pop3 */
 	MEMBER(pop3_no_flag_updates) FALSE,
diff -r 433745f10290 -r 57b70f64f997 src/master/master-settings.h
--- a/src/master/master-settings.h	Fri Jul 13 02:37:19 2007 +0300
+++ b/src/master/master-settings.h	Fri Jul 13 02:40:47 2007 +0300
@@ -123,6 +123,7 @@ struct settings {
 	unsigned int imap_max_line_length;
 	const char *imap_capability;
 	const char *imap_client_workarounds;
+	const char *imap_logout_format;
 
 	/* pop3 */
 	bool pop3_no_flag_updates;


More information about the dovecot-cvs mailing list