changeset 19804:cffa74926d5b

doveadm: Add kludge to support field array to fieldstr conversion
author Aki Tuomi <aki.tuomi@dovecot.fi>
date Mon, 22 Feb 2016 18:20:59 +0200
parents 4247beae5c8d
children f569111ef855
files src/doveadm/doveadm-mail.c
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/doveadm/doveadm-mail.c	Mon Feb 15 15:14:25 2016 +0200
+++ b/src/doveadm/doveadm-mail.c	Mon Feb 22 18:20:59 2016 +0200
@@ -885,6 +885,7 @@
 {
 	struct doveadm_mail_cmd_context *ctx;
 	const char *wildcard_user;
+	const char *fieldstr;
 	ARRAY_TYPE(const_string) pargv;
 	int i;
 	struct doveadm_mail_cmd mail_cmd = {
@@ -895,7 +896,7 @@
 
 	ctx->iterate_all_users = FALSE;
 	wildcard_user = NULL;
-	t_array_init(&pargv, 8);
+	p_array_init(&pargv, ctx->pool, 8);
 
 	for(i=0;i<argc;i++) {
 		if (!argv[i].value_set)
@@ -922,6 +923,13 @@
 		} else if (ctx->v.parse_arg != NULL && argv[i].short_opt != '\0') {
 			optarg = (char*)argv[i].value.v_string;
 			ctx->v.parse_arg(ctx, argv[i].short_opt);
+		} else if (strcmp(argv[i].name, "field") == 0) {
+			/* mailbox status, fetch: convert an array into a
+			   single space-separated parameter (alternative to
+			   fieldstr) */
+			fieldstr = p_array_const_string_join(ctx->pool,
+					&argv[i].value.v_array, " ");
+			array_append(&pargv, &fieldstr, 1);
 		} else if ((argv[i].flags & CMD_PARAM_FLAG_POSITIONAL) != 0) {
 			/* feed this into pargv */
 			if (argv[i].type == CMD_PARAM_ARRAY)