dovecot-1.2: Added imap_args_to_str()
dovecot at dovecot.org
dovecot at dovecot.org
Fri Feb 6 21:41:04 EET 2009
details: http://hg.dovecot.org/dovecot-1.2/rev/b7ebdade6cbd
changeset: 8729:b7ebdade6cbd
user: Timo Sirainen <tss at iki.fi>
date: Fri Feb 06 13:38:54 2009 -0500
description:
Added imap_args_to_str()
diffstat:
2 files changed, 53 insertions(+)
src/lib-imap/imap-util.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++
src/lib-imap/imap-util.h | 3 ++
diffs (84 lines):
diff -r da19acbae79e -r b7ebdade6cbd src/lib-imap/imap-util.c
--- a/src/lib-imap/imap-util.c Fri Feb 06 13:38:26 2009 -0500
+++ b/src/lib-imap/imap-util.c Fri Feb 06 13:38:54 2009 -0500
@@ -3,7 +3,9 @@
#include "lib.h"
#include "array.h"
#include "str.h"
+#include "strescape.h"
#include "mail-types.h"
+#include "imap-parser.h"
#include "imap-util.h"
void imap_write_flags(string_t *dest, enum mail_flags flags,
@@ -52,3 +54,51 @@ void imap_write_seq_range(string_t *dest
str_printfa(dest, ":%u", range[i].seq2);
}
}
+
+void imap_args_to_str(string_t *dest, const struct imap_arg *args)
+{
+ const ARRAY_TYPE(imap_arg_list) *list;
+ bool first = TRUE;
+
+ for (; args->type != IMAP_ARG_EOL; args++) {
+ if (first)
+ first = FALSE;
+ else
+ str_append_c(dest, ' ');
+
+ switch (args->type) {
+ case IMAP_ARG_NIL:
+ str_append(dest, "NIL");
+ break;
+ case IMAP_ARG_ATOM:
+ str_append(dest, IMAP_ARG_STR(args));
+ break;
+ case IMAP_ARG_STRING:
+ str_append_c(dest, '"');
+ str_append(dest, str_escape(IMAP_ARG_STR(args)));
+ str_append_c(dest, '"');
+ break;
+ case IMAP_ARG_LITERAL: {
+ const char *strarg = IMAP_ARG_STR(args);
+ str_printfa(dest, "{%"PRIuSIZE_T"}\r\n",
+ strlen(strarg));
+ str_append(dest, strarg);
+ break;
+ }
+ case IMAP_ARG_LIST:
+ str_append_c(dest, '(');
+ list = IMAP_ARG_LIST(args);
+ imap_args_to_str(dest, array_idx(list, 0));
+ str_append_c(dest, ')');
+ break;
+ case IMAP_ARG_LITERAL_SIZE:
+ case IMAP_ARG_LITERAL_SIZE_NONSYNC:
+ str_printfa(dest, "{%"PRIuUOFF_T"}\r\n",
+ IMAP_ARG_LITERAL_SIZE(args));
+ str_append(dest, "<too large>");
+ break;
+ case IMAP_ARG_EOL:
+ i_unreached();
+ }
+ }
+}
diff -r da19acbae79e -r b7ebdade6cbd src/lib-imap/imap-util.h
--- a/src/lib-imap/imap-util.h Fri Feb 06 13:38:26 2009 -0500
+++ b/src/lib-imap/imap-util.h Fri Feb 06 13:38:54 2009 -0500
@@ -4,6 +4,7 @@
#include "seq-range-array.h"
enum mail_flags;
+struct imap_arg;
/* Write flags as a space separated string. */
void imap_write_flags(string_t *dest, enum mail_flags flags,
@@ -11,5 +12,7 @@ void imap_write_flags(string_t *dest, en
/* Write sequence range as IMAP sequence-set */
void imap_write_seq_range(string_t *dest, const ARRAY_TYPE(seq_range) *array);
+/* Write IMAP args to given string. The string is mainly useful for humans. */
+void imap_args_to_str(string_t *dest, const struct imap_arg *args);
#endif
More information about the dovecot-cvs
mailing list