dovecot-2.1: doveadm: Added flag to specify which column table f...

dovecot at dovecot.org dovecot at dovecot.org
Wed Feb 1 20:12:10 EET 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/56ff22125b7d
changeset: 14039:56ff22125b7d
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Feb 01 19:13:04 2012 +0200
description:
doveadm: Added flag to specify which column table formatter expands.
The default also was changed to last column, not first.

diffstat:

 src/doveadm/doveadm-director.c    |   2 +-
 src/doveadm/doveadm-print-table.c |  11 +++++++++--
 src/doveadm/doveadm-print.h       |   3 ++-
 src/doveadm/doveadm-proxy.c       |   2 +-
 src/doveadm/doveadm-stats.c       |   2 +-
 src/doveadm/doveadm-who.c         |   3 ++-
 6 files changed, 16 insertions(+), 7 deletions(-)

diffs (83 lines):

diff -r 4b783711a22e -r 56ff22125b7d src/doveadm/doveadm-director.c
--- a/src/doveadm/doveadm-director.c	Wed Feb 01 18:57:14 2012 +0200
+++ b/src/doveadm/doveadm-director.c	Wed Feb 01 19:13:04 2012 +0200
@@ -290,7 +290,7 @@
 		user_file_get_user_list(ctx->users_path, pool, users);
 
 	doveadm_print_init(DOVEADM_PRINT_TYPE_TABLE);
-	doveadm_print_header_simple("user");
+	doveadm_print_header("user", "user", DOVEADM_PRINT_HEADER_FLAG_EXPAND);
 	doveadm_print_header_simple("mail server ip");
 	doveadm_print_header_simple("expire time");
 
diff -r 4b783711a22e -r 56ff22125b7d src/doveadm/doveadm-print-table.c
--- a/src/doveadm/doveadm-print-table.c	Wed Feb 01 18:57:14 2012 +0200
+++ b/src/doveadm/doveadm-print-table.c	Wed Feb 01 19:13:04 2012 +0200
@@ -103,8 +103,15 @@
 			break;
 		}
 	}
-	if (max_length < ctx->columns)
-		headers[0].length += (ctx->columns - max_length) / 2;
+	if (max_length < ctx->columns) {
+		for (i = 0; i < hdr_count; i++) {
+			if ((headers[i].flags & DOVEADM_PRINT_HEADER_FLAG_EXPAND) != 0) {
+				i++;
+				break;
+			}
+		}
+		headers[i-1].length += (ctx->columns - max_length) / 2;
+	}
 }
 
 static void doveadm_print_next(const char *value)
diff -r 4b783711a22e -r 56ff22125b7d src/doveadm/doveadm-print.h
--- a/src/doveadm/doveadm-print.h	Wed Feb 01 18:57:14 2012 +0200
+++ b/src/doveadm/doveadm-print.h	Wed Feb 01 19:13:04 2012 +0200
@@ -8,7 +8,8 @@
 enum doveadm_print_header_flags {
 	DOVEADM_PRINT_HEADER_FLAG_RIGHT_JUSTIFY 	= 0x01,
 	DOVEADM_PRINT_HEADER_FLAG_STICKY	 	= 0x02,
-	DOVEADM_PRINT_HEADER_FLAG_HIDE_TITLE	 	= 0x04
+	DOVEADM_PRINT_HEADER_FLAG_HIDE_TITLE	 	= 0x04,
+	DOVEADM_PRINT_HEADER_FLAG_EXPAND	 	= 0x08
 };
 
 extern const struct doveadm_print_vfuncs *doveadm_print_vfuncs_all[];
diff -r 4b783711a22e -r 56ff22125b7d src/doveadm/doveadm-proxy.c
--- a/src/doveadm/doveadm-proxy.c	Wed Feb 01 18:57:14 2012 +0200
+++ b/src/doveadm/doveadm-proxy.c	Wed Feb 01 19:13:04 2012 +0200
@@ -68,7 +68,7 @@
 	ctx = cmd_proxy_init(argc, argv, "a:", cmd_proxy_list);
 
 	doveadm_print_init(DOVEADM_PRINT_TYPE_TABLE);
-	doveadm_print_header_simple("username");
+	doveadm_print_header("username", "username", DOVEADM_PRINT_HEADER_FLAG_EXPAND);
 	doveadm_print_header("service", "proto", 0);
 	doveadm_print_header("src-ip", "src ip", 0);
 	doveadm_print_header("dest-ip", "dest ip", 0);
diff -r 4b783711a22e -r 56ff22125b7d src/doveadm/doveadm-stats.c
--- a/src/doveadm/doveadm-stats.c	Wed Feb 01 18:57:14 2012 +0200
+++ b/src/doveadm/doveadm-stats.c	Wed Feb 01 19:13:04 2012 +0200
@@ -423,7 +423,7 @@
 	doveadm_print_deinit();
 	doveadm_print_init(DOVEADM_PRINT_TYPE_TABLE);
 
-	doveadm_print_header_simple("USER");
+	doveadm_print_header("USER", "USER", DOVEADM_PRINT_HEADER_FLAG_EXPAND);
 	doveadm_print_header_simple("SERVICE");
 	doveadm_print_header_simple("%CPU");
 	doveadm_print_header_simple("%SYS");
diff -r 4b783711a22e -r 56ff22125b7d src/doveadm/doveadm-who.c
--- a/src/doveadm/doveadm-who.c	Wed Feb 01 18:57:14 2012 +0200
+++ b/src/doveadm/doveadm-who.c	Wed Feb 01 19:13:04 2012 +0200
@@ -298,7 +298,8 @@
 		who_lookup(&ctx, who_aggregate_line);
 		who_print(&ctx);
 	} else {
-		doveadm_print_header_simple("username");
+		doveadm_print_header("username", "username",
+				     DOVEADM_PRINT_HEADER_FLAG_EXPAND);
 		doveadm_print_header("service", "proto", 0);
 		doveadm_print_header_simple("pid");
 		doveadm_print_header_simple("ip");


More information about the dovecot-cvs mailing list