From: Timo Sirainen Date: Wed, 4 Jul 2018 13:17:57 +0000 (+0300) Subject: doveadm service status: Support different number of fields returned by master X-Git-Tag: 2.3.9~1607 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c1267b97367b666bd24e6aadfd85ad3902a5b05;p=thirdparty%2Fdovecot%2Fcore.git doveadm service status: Support different number of fields returned by master --- 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; }