From 5c1267b97367b666bd24e6aadfd85ad3902a5b05 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 4 Jul 2018 16:17:57 +0300 Subject: [PATCH] doveadm service status: Support different number of fields returned by master --- src/doveadm/doveadm-master.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/doveadm/doveadm-master.c b/src/doveadm/doveadm-master.c index d6c927a53d..7ce8e183e0 100644 --- a/src/doveadm/doveadm-master.c +++ b/src/doveadm/doveadm-master.c @@ -152,6 +152,7 @@ static void cmd_service_stop(struct doveadm_cmd_context *cctx) static void cmd_service_status(struct doveadm_cmd_context *cctx) { const char *line, *const *services; + unsigned int fields_count; if (!doveadm_cmd_param_array(cctx, "service", &services)) services = NULL; @@ -171,6 +172,7 @@ static void cmd_service_status(struct doveadm_cmd_context *cctx) doveadm_print_header_simple("listen_pending"); doveadm_print_header_simple("listening"); doveadm_print_header_simple("doveadm_stop"); + fields_count = doveadm_print_get_headers_count(); alarm(5); while ((line = i_stream_read_next_line(input)) != NULL) { @@ -178,11 +180,14 @@ static void cmd_service_status(struct doveadm_cmd_context *cctx) break; T_BEGIN { const char *const *args = t_strsplit_tabescaped(line); - if (str_array_length(args) >= 12 && + if (args[0] != NULL && (services == NULL || str_array_find(services, args[0]))) { - for (unsigned int i = 0; i < 12; i++) + unsigned int i; + for (i = 0; i < fields_count && args[i] != NULL; i++) doveadm_print(args[i]); + for (; i < fields_count; i++) + doveadm_print(""); } } T_END; } -- 2.47.3