dovecot-2.1: doveadm instance list: Added -c parameter to easily...

dovecot at dovecot.org dovecot at dovecot.org
Mon Jun 4 21:22:04 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/ee5d838ebcbb
changeset: 14550:ee5d838ebcbb
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Jun 04 21:21:52 2012 +0300
description:
doveadm instance list: Added -c parameter to easily get the instance's config path.

diffstat:

 src/doveadm/doveadm-instance.c |  35 ++++++++++++++++++++++++++++-------
 1 files changed, 28 insertions(+), 7 deletions(-)

diffs (66 lines):

diff -r d85421a77fa1 -r ee5d838ebcbb src/doveadm/doveadm-instance.c
--- a/src/doveadm/doveadm-instance.c	Mon Jun 04 21:21:28 2012 +0300
+++ b/src/doveadm/doveadm-instance.c	Mon Jun 04 21:21:52 2012 +0300
@@ -5,6 +5,7 @@
 #include "doveadm.h"
 #include "doveadm-print.h"
 
+#include <stdio.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <signal.h>
@@ -48,19 +49,39 @@
 	struct master_instance_list_iter *iter;
 	const struct master_instance *inst;
 	const char *pidfile_path;
+	bool show_config = FALSE;
+	int c;
 
-	doveadm_print_init(DOVEADM_PRINT_TYPE_TABLE);
-	doveadm_print_header("path", "path", DOVEADM_PRINT_HEADER_FLAG_EXPAND);
-	doveadm_print_header_simple("name");
-	doveadm_print_header_simple("last used");
-	doveadm_print_header_simple("running");
+	while ((c = getopt(argc, argv, "c")) > 0) {
+		switch (c) {
+		case 'c':
+			show_config = TRUE;
+			break;
+		default:
+			help(&doveadm_cmd_instance[0]);
+		}
+	}
+	argv += optind;
+
+	if (!show_config) {
+		doveadm_print_init(DOVEADM_PRINT_TYPE_TABLE);
+		doveadm_print_header("path", "path", DOVEADM_PRINT_HEADER_FLAG_EXPAND);
+		doveadm_print_header_simple("name");
+		doveadm_print_header_simple("last used");
+		doveadm_print_header_simple("running");
+	}
 
 	list = master_instance_list_init(MASTER_INSTANCE_PATH);
 	iter = master_instance_list_iterate_init(list);
 	while ((inst = master_instance_iterate_list_next(iter)) != NULL) {
-		if (argc > 1 && strcmp(argv[1], inst->name) != 0)
+		if (argv[0] != NULL && strcmp(argv[0], inst->name) != 0)
 			continue;
 
+		if (show_config) {
+			printf("%s\n", inst->config_path == NULL ? "" :
+			       inst->config_path);
+			continue;
+		}
 		doveadm_print(inst->base_dir);
 		doveadm_print(inst->name);
 		doveadm_print(unixdate2str(inst->last_used));
@@ -98,7 +119,7 @@
 }
 
 struct doveadm_cmd doveadm_cmd_instance[] = {
-	{ cmd_instance_list, "instance list", "[<name>]" },
+	{ cmd_instance_list, "instance list", "[-c] [<name>]" },
 	{ cmd_instance_remove, "instance remove", "<name> | <base dir>" }
 };
 


More information about the dovecot-cvs mailing list