[dovecot-cvs] dovecot/src/lib-imap imap-util.c, 1.11, 1.12 imap-util.h, 1.9, 1.10

cras at dovecot.org cras at dovecot.org
Mon Jul 12 14:35:53 EEST 2004


Update of /home/cvs/dovecot/src/lib-imap
In directory talvi:/tmp/cvs-serv2470/lib-imap

Modified Files:
	imap-util.c imap-util.h 
Log Message:
Broke mailbox_sync() into iterator.



Index: imap-util.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-util.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- imap-util.c	2 May 2004 20:32:15 -0000	1.11
+++ imap-util.c	12 Jul 2004 11:35:51 -0000	1.12
@@ -5,38 +5,33 @@
 #include "mail-types.h"
 #include "imap-util.h"
 
-const char *imap_write_flags(const struct mail_full_flags *flags)
+void imap_write_flags(string_t *dest, const struct mail_full_flags *flags)
 {
-	string_t *str;
-	const char *sysflags;
 	unsigned int i;
+	size_t size;
 
-	if (flags == 0)
-		return "";
-
-	sysflags = t_strconcat(
-		(flags->flags & MAIL_ANSWERED) ? " \\Answered" : "",
-		(flags->flags & MAIL_FLAGGED) ? " \\Flagged" : "",
-		(flags->flags & MAIL_DELETED) ? " \\Deleted" : "",
-		(flags->flags & MAIL_SEEN) ? " \\Seen" : "",
-		(flags->flags & MAIL_DRAFT) ? " \\Draft" : "",
-		(flags->flags & MAIL_RECENT)  ? " \\Recent" : "",
-		NULL);
-
-	if (*sysflags != '\0')
-		sysflags++;
-
-	if (flags->keywords_count == 0)
-		return sysflags;
-
-	/* we have keywords too */
-	str = t_str_new(256);
-	str_append(str, sysflags);
+	size = str_len(dest);
+	if ((flags->flags & MAIL_ANSWERED) != 0)
+		str_append(dest, "\\Answered ");
+	if ((flags->flags & MAIL_FLAGGED) != 0)
+		str_append(dest, "\\Flagged ");
+	if ((flags->flags & MAIL_DELETED) != 0)
+		str_append(dest, "\\Deleted ");
+	if ((flags->flags & MAIL_SEEN) != 0)
+		str_append(dest, "\\Seen ");
+	if ((flags->flags & MAIL_DRAFT) != 0)
+		str_append(dest, "\\Draft ");
+	if ((flags->flags & MAIL_RECENT) != 0)
+		str_append(dest, "\\Recent ");
 
-	for (i = 0; i < flags->keywords_count; i++) {
-		if (str_len(str) > 0)
-			str_append_c(str, ' ');
-		str_append(str, flags->keywords[i]);
+	if (flags->keywords_count > 0) {
+		/* we have keywords too */
+		for (i = 0; i < flags->keywords_count; i++) {
+			str_append(dest, flags->keywords[i]);
+			str_append_c(dest, ' ');
+		}
 	}
-	return str_c(str);
+
+	if (str_len(dest) != size)
+		str_truncate(dest, str_len(dest)-1);
 }

Index: imap-util.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-util.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- imap-util.h	2 May 2004 20:32:15 -0000	1.9
+++ imap-util.h	12 Jul 2004 11:35:51 -0000	1.10
@@ -4,6 +4,6 @@
 struct mail_full_flags;
 
 /* Return flags as a space separated string. */
-const char *imap_write_flags(const struct mail_full_flags *flags);
+void imap_write_flags(string_t *dest, const struct mail_full_flags *flags);
 
 #endif



More information about the dovecot-cvs mailing list