[dovecot-cvs] dovecot/src/lib-imap imap-util.c,1.8,1.9 imap-util.h,1.5,1.6

cras at procontrol.fi cras at procontrol.fi
Wed Jul 23 05:44:18 EEST 2003


Update of /home/cvs/dovecot/src/lib-imap
In directory danu:/tmp/cvs-serv15228/lib-imap

Modified Files:
	imap-util.c imap-util.h 
Log Message:
API change for updating message flags.



Index: imap-util.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-util.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- imap-util.c	5 Jan 2003 13:09:52 -0000	1.8
+++ imap-util.c	23 Jul 2003 01:44:16 -0000	1.9
@@ -4,39 +4,39 @@
 #include "str.h"
 #include "imap-util.h"
 
-const char *imap_write_flags(enum mail_flags flags, const char *custom_flags[],
-			     unsigned int custom_flags_count)
+const char *imap_write_flags(const struct mail_full_flags *flags)
 {
 	string_t *str;
 	const char *sysflags, *name;
 	unsigned int i;
 
-	i_assert(custom_flags_count <= MAIL_CUSTOM_FLAGS_COUNT);
+	i_assert(flags->custom_flags_count <= MAIL_CUSTOM_FLAGS_COUNT);
 
 	if (flags == 0)
 		return "";
 
-	sysflags = t_strconcat((flags & MAIL_ANSWERED) ? " \\Answered" : "",
-			       (flags & MAIL_FLAGGED) ? " \\Flagged" : "",
-			       (flags & MAIL_DELETED) ? " \\Deleted" : "",
-			       (flags & MAIL_SEEN) ? " \\Seen" : "",
-			       (flags & MAIL_DRAFT) ? " \\Draft" : "",
-			       (flags & MAIL_RECENT)  ? " \\Recent" : "",
-			       NULL);
+	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 & MAIL_CUSTOM_FLAGS_MASK) == 0)
+	if ((flags->flags & MAIL_CUSTOM_FLAGS_MASK) == 0)
 		return sysflags;
 
 	/* we have custom flags too */
 	str = t_str_new(256);
 	str_append(str, sysflags);
 
-	for (i = 0; i < custom_flags_count; i++) {
-		if (flags & (1 << (i + MAIL_CUSTOM_FLAG_1_BIT))) {
-			name = custom_flags[i];
+	for (i = 0; i < flags->custom_flags_count; i++) {
+		if (flags->flags & (1 << (i + MAIL_CUSTOM_FLAG_1_BIT))) {
+			name = flags->custom_flags[i];
 			if (name != NULL && *name != '\0') {
 				if (str_len(str) > 0)
 					str_append_c(str, ' ');

Index: imap-util.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-util.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- imap-util.h	5 Jan 2003 13:09:52 -0000	1.5
+++ imap-util.h	23 Jul 2003 01:44:16 -0000	1.6
@@ -16,6 +16,13 @@
 	MAIL_CUSTOM_FLAGS_MASK	= 0xfffffc0
 };
 
+struct mail_full_flags {
+	enum mail_flags flags;
+
+	const char **custom_flags;
+	unsigned int custom_flags_count;
+};
+
 /* growing number of flags isn't very easy. biggest problem is that they're
    stored into unsigned int, which is 32bit almost everywhere. another thing
    to remember is that with maildir format, the custom flags are stored into
@@ -28,9 +35,8 @@
 	MAIL_FLAGS_COUNT	= 32
 };
 
-/* Return flags as a space separated string. custom_flags[] is a list of
-   names for custom flags, flags having NULL or "" entry are ignored. */
-const char *imap_write_flags(enum mail_flags flags, const char *custom_flags[],
-			     unsigned int custom_flags_count);
+/* Return flags as a space separated string. If custom flags don't have entry
+   in flags->custom_flags[], or if it's NULL or "" the flag s ignored. */
+const char *imap_write_flags(const struct mail_full_flags *flags);
 
 #endif



More information about the dovecot-cvs mailing list