dovecot-2.0: doveadm fetch: If invalid fetch field is given, pri...

dovecot at dovecot.org dovecot at dovecot.org
Wed Apr 28 23:15:53 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/1ec4eb879f0e
changeset: 11207:1ec4eb879f0e
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Apr 28 23:15:50 2010 +0300
description:
doveadm fetch: If invalid fetch field is given, print list of available fields.

diffstat:

 src/doveadm/doveadm-mail-fetch.c |  16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diffs (41 lines):

diff -r c8981561c5f2 -r 1ec4eb879f0e src/doveadm/doveadm-mail-fetch.c
--- a/src/doveadm/doveadm-mail-fetch.c	Wed Apr 28 23:13:12 2010 +0300
+++ b/src/doveadm/doveadm-mail-fetch.c	Wed Apr 28 23:15:50 2010 +0300
@@ -16,6 +16,8 @@
 #include "doveadm-mail.h"
 #include "doveadm-mail-list-iter.h"
 
+#include <stdio.h>
+
 struct fetch_context {
 	struct mail_search_args *search_args;
 	struct ostream *output;
@@ -248,6 +250,16 @@
 	return NULL;
 }
 
+static void print_fetch_fields(void)
+{
+	unsigned int i;
+
+	fprintf(stderr, "Available fetch fields: %s", fetch_fields[0].name);
+	for (i = 1; i < N_ELEMENTS(fetch_fields); i++)
+		fprintf(stderr, " %s", fetch_fields[i].name);
+	fprintf(stderr, "\n");
+}
+
 static void parse_fetch_fields(struct fetch_context *ctx, const char *str)
 {
 	const char *const *fields, *name;
@@ -259,8 +271,10 @@
 		name = t_str_lcase(*fields);
 
 		field = fetch_field_find(name);
-		if (field == NULL)
+		if (field == NULL) {
+			print_fetch_fields();
 			i_fatal("Unknown fetch field: %s", name);
+		}
 		ctx->wanted_fields |= field->wanted_fields;
 
 		array_append(&ctx->fields, field, 1);


More information about the dovecot-cvs mailing list