changeset 1958:4dec6a3d79fd HEAD

s/custom flags/keywords/
author Timo Sirainen <tss@iki.fi>
date Sun, 02 May 2004 23:32:15 +0300
parents d77a2a1e9278
children 50e24ce4f9c3
files src/imap/client.c src/imap/client.h src/imap/cmd-append.c src/imap/cmd-select.c src/imap/cmd-store.c src/imap/commands-util.c src/imap/commands-util.h src/imap/common.h src/imap/mail-storage-callbacks.c src/imap/main.c src/lib-imap/imap-util.c src/lib-imap/imap-util.h src/lib-index/mail-index-sync-update.c src/lib-index/mail-index-sync.c src/lib-index/mail-index-transaction.c src/lib-index/mail-index-view-sync.c src/lib-index/mail-index.h src/lib-index/mail-transaction-log.h src/lib-mail/mail-types.h src/lib-storage/index/index-fetch.h src/lib-storage/index/index-mail.c src/lib-storage/index/index-search.c src/lib-storage/index/index-status.c src/lib-storage/index/index-storage.c src/lib-storage/index/index-storage.h src/lib-storage/index/maildir/maildir-save.c src/lib-storage/index/maildir/maildir-storage.c src/lib-storage/index/maildir/maildir-storage.h src/lib-storage/index/maildir/maildir-sync.c src/lib-storage/index/maildir/maildir-util.c src/lib-storage/index/mbox/mbox-save.c src/lib-storage/index/mbox/mbox-storage.c src/lib-storage/index/mbox/mbox-sync-private.h src/lib-storage/index/mbox/mbox-sync-update.c src/lib-storage/mail-storage-private.h src/lib-storage/mail-storage.c src/lib-storage/mail-storage.h src/lib-storage/proxy-mailbox.c src/pop3/mail-storage-callbacks.c
diffstat 39 files changed, 270 insertions(+), 330 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/client.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/imap/client.c	Sun May 02 23:32:15 2004 +0300
@@ -64,8 +64,7 @@
 					    imap_max_line_length);
         client->last_input = ioloop_time;
 
-	client->mailbox_flags.pool =
-		pool_alloconly_create("mailbox_custom_flags", 512);
+	client->keywords.pool = pool_alloconly_create("mailbox_keywords", 512);
 	client->namespaces = namespaces;
 
 	while (namespaces != NULL) {
@@ -99,7 +98,7 @@
 	i_stream_unref(client->input);
 	o_stream_unref(client->output);
 
-	pool_unref(client->mailbox_flags.pool);
+	pool_unref(client->keywords.pool);
 	i_free(client);
 
 	/* quit the program */
--- a/src/imap/client.h	Sun May 02 23:01:41 2004 +0300
+++ b/src/imap/client.h	Sun May 02 23:32:15 2004 +0300
@@ -8,11 +8,11 @@
 
 typedef int command_func_t(struct client *client);
 
-struct mailbox_custom_flags {
+struct mailbox_keywords {
 	pool_t pool; /* will be p_clear()ed when changed */
 
-	char **custom_flags;
-        unsigned int custom_flags_count;
+	char **keywords;
+        unsigned int keywords_count;
 };
 
 struct client {
@@ -23,7 +23,7 @@
 
         struct namespace *namespaces;
 	struct mailbox *mailbox;
-        struct mailbox_custom_flags mailbox_flags;
+        struct mailbox_keywords keywords;
 	unsigned int select_counter; /* increased when mailbox is changed */
 
 	time_t last_input;
--- a/src/imap/cmd-append.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/imap/cmd-append.c	Sun May 02 23:32:15 2004 +0300
@@ -52,7 +52,7 @@
 	struct imap_parser *save_parser;
 	struct imap_arg *args;
 	struct imap_arg_list *flags_list;
-        struct mailbox_custom_flags old_flags;
+        struct mailbox_keywords old_flags;
 	struct mail_full_flags flags;
 	struct istream *input;
 	time_t internal_date;
@@ -78,15 +78,15 @@
 		return TRUE;
 	}
 
-	if (mailbox_get_status(box, STATUS_CUSTOM_FLAGS, &status) < 0) {
+	if (mailbox_get_status(box, STATUS_KEYWORDS, &status) < 0) {
 		client_send_storage_error(client, storage);
 		mailbox_close(box);
 		return TRUE;
 	}
 	memset(&old_flags, 0, sizeof(old_flags));
         old_flags.pool = pool_datastack_create();
-	client_save_custom_flags(&old_flags, status.custom_flags,
-				 status.custom_flags_count);
+	client_save_keywords(&old_flags, status.keywords,
+			     status.keywords_count);
 
 	t = mailbox_transaction_begin(box, FALSE);
 
--- a/src/imap/cmd-select.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/imap/cmd-select.c	Sun May 02 23:32:15 2004 +0300
@@ -36,23 +36,23 @@
 
 	if (mailbox_get_status(box, STATUS_MESSAGES | STATUS_RECENT |
 			       STATUS_FIRST_UNSEEN_SEQ | STATUS_UIDVALIDITY |
-			       STATUS_UIDNEXT | STATUS_CUSTOM_FLAGS,
+			       STATUS_UIDNEXT | STATUS_KEYWORDS,
 			       &status) < 0) {
 		client_send_storage_error(client, storage);
 		mailbox_close(box);
 		return TRUE;
 	}
 
-	client_save_custom_flags(&client->mailbox_flags, status.custom_flags,
-				 status.custom_flags_count);
+	client_save_keywords(&client->keywords,
+			     status.keywords, status.keywords_count);
 
 	/* set client's mailbox only after getting status to make sure
 	   we're not sending any expunge/exists replies too early to client */
 	client->mailbox = box;
 	client->select_counter++;
 
-	client_send_mailbox_flags(client, box, status.custom_flags,
-				  status.custom_flags_count);
+	client_send_mailbox_flags(client, box, status.keywords,
+				  status.keywords_count);
 
 	client_send_line(client,
 		t_strdup_printf("* %u EXISTS", status.messages));
--- a/src/imap/cmd-store.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/imap/cmd-store.c	Sun May 02 23:32:15 2004 +0300
@@ -89,11 +89,11 @@
 	if (args[2].type == IMAP_ARG_LIST) {
 		if (!client_parse_mail_flags(client,
 					     IMAP_ARG_LIST(&args[2])->args,
-					     &client->mailbox_flags, &flags))
+					     &client->keywords, &flags))
 			return TRUE;
 	} else {
 		if (!client_parse_mail_flags(client, args+2,
-					     &client->mailbox_flags, &flags))
+					     &client->keywords, &flags))
 			return TRUE;
 	}
 
--- a/src/imap/commands-util.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/imap/commands-util.c	Sun May 02 23:32:15 2004 +0300
@@ -1,6 +1,7 @@
 /* Copyright (C) 2002-2003 Timo Sirainen */
 
 #include "common.h"
+#include "buffer.h"
 #include "str.h"
 #include "commands-util.h"
 #include "imap-util.h"
@@ -182,24 +183,24 @@
 			 t_strconcat(syntax ? "* BAD " : "* NO ", error, NULL));
 }
 
-static int is_valid_custom_flag(struct client *client,
-                                const struct mailbox_custom_flags *old_flags,
-				const char *flag)
+static int is_valid_keyword(struct client *client,
+			    const struct mailbox_keywords *old_keywords,
+			    const char *keyword)
 {
 	size_t i;
 
 	/* if it already exists, skip validity checks */
-	for (i = 0; i < old_flags->custom_flags_count; i++) {
-		if (old_flags->custom_flags[i] != NULL &&
-		    strcasecmp(old_flags->custom_flags[i], flag) == 0)
+	for (i = 0; i < old_keywords->keywords_count; i++) {
+		if (old_keywords->keywords[i] != NULL &&
+		    strcasecmp(old_keywords->keywords[i], keyword) == 0)
 			return TRUE;
 	}
 
-	if (strlen(flag) > max_custom_flag_length) {
+	if (strlen(keyword) > max_keyword_length) {
 		client_send_tagline(client,
-			t_strdup_printf("BAD Invalid flag name '%s': "
+			t_strdup_printf("BAD Invalid keyword name '%s': "
 					"Maximum length is %u characters",
-					flag, max_custom_flag_length));
+					keyword, max_keyword_length));
 		return FALSE;
 	}
 
@@ -207,19 +208,18 @@
 }
 
 int client_parse_mail_flags(struct client *client, struct imap_arg *args,
-                            const struct mailbox_custom_flags *old_flags,
+                            const struct mailbox_keywords *old_keywords,
 			    struct mail_full_flags *flags)
 {
-	/* @UNSAFE */
+	const char *const *keywords;
 	char *atom;
-	size_t max_flags, flag_pos, i;
-
-	max_flags = MAIL_CUSTOM_FLAGS_COUNT;
+	buffer_t *buffer;
+	size_t size, i;
 
 	memset(flags, 0, sizeof(*flags));
-	flags->custom_flags = t_new(const char *, max_flags);
+	buffer = buffer_create_dynamic(pool_datastack_create(),
+				       256, (size_t)-1);
 
-	flag_pos = 0;
 	while (args->type != IMAP_ARG_EOL) {
 		if (args->type != IMAP_ARG_ATOM) {
 			client_send_command_error(client,
@@ -248,57 +248,50 @@
 				return FALSE;
 			}
 		} else {
-			/* custom flag - first make sure it's not a duplicate */
-			for (i = 0; i < flag_pos; i++) {
-				if (strcasecmp(flags->custom_flags[i],
-					       atom) == 0)
+			/* keyword - first make sure it's not a duplicate */
+			keywords = buffer_get_data(buffer, &size);
+			size /= sizeof(const char *);
+			for (i = 0; i < size; i++) {
+				if (strcasecmp(keywords[i], atom) == 0)
 					break;
 			}
 
-			if (i == max_flags) {
-				client_send_tagline(client,
-					"Maximum number of different custom "
-					"flags exceeded");
-				return FALSE;
-			}
-
-			if (i == flag_pos) {
-				if (!is_valid_custom_flag(client, old_flags,
-							  atom))
+			if (i == size) {
+				if (!is_valid_keyword(client, old_keywords,
+						      atom))
 					return FALSE;
-				flags->flags |= 1 << (flag_pos +
-						      MAIL_CUSTOM_FLAG_1_BIT);
-				flags->custom_flags[flag_pos++] = atom;
+				buffer_append(buffer, &atom, sizeof(atom));
 			}
 		}
 
 		args++;
 	}
 
-	flags->custom_flags_count = flag_pos;
+	flags->keywords = buffer_get_modifyable_data(buffer, &size);
+	flags->keywords_count = size / sizeof(const char *);
 	return TRUE;
 }
 
-static const char *get_custom_flags_string(const char *custom_flags[],
-					   unsigned int custom_flags_count)
+static const char *
+get_keywords_string(const char *keywords[], unsigned int keywords_count)
 {
 	string_t *str;
 	unsigned int i;
 
-	/* first see if there even is custom flags */
-	for (i = 0; i < custom_flags_count; i++) {
-		if (custom_flags[i] != NULL)
+	/* first see if there even is keywords */
+	for (i = 0; i < keywords_count; i++) {
+		if (keywords[i] != NULL)
 			break;
 	}
 
-	if (i == custom_flags_count)
+	if (i == keywords_count)
 		return "";
 
 	str = t_str_new(256);
-	for (; i < custom_flags_count; i++) {
-		if (custom_flags[i] != NULL) {
+	for (; i < keywords_count; i++) {
+		if (keywords[i] != NULL) {
 			str_append_c(str, ' ');
-			str_append(str, custom_flags[i]);
+			str_append(str, keywords[i]);
 		}
 	}
 	return str_c(str);
@@ -307,12 +300,12 @@
 #define SYSTEM_FLAGS "\\Answered \\Flagged \\Deleted \\Seen \\Draft"
 
 void client_send_mailbox_flags(struct client *client, struct mailbox *box,
-			       const char *custom_flags[],
-			       unsigned int custom_flags_count)
+			       const char *keywords[],
+			       unsigned int keywords_count)
 {
 	const char *str;
 
-	str = get_custom_flags_string(custom_flags, custom_flags_count);
+	str = get_keywords_string(keywords, keywords_count);
 	client_send_line(client,
 		t_strconcat("* FLAGS ("SYSTEM_FLAGS, str, ")", NULL));
 
@@ -322,29 +315,27 @@
 	} else {
 		client_send_line(client,
 			t_strconcat("* OK [PERMANENTFLAGS ("SYSTEM_FLAGS, str,
-				    mailbox_allow_new_custom_flags(box) ?
+				    mailbox_allow_new_keywords(box) ?
 				    " \\*" : "", ")] Flags permitted.", NULL));
 	}
 }
 
-void client_save_custom_flags(struct mailbox_custom_flags *dest,
-			      const char *custom_flags[],
-			      unsigned int custom_flags_count)
+void client_save_keywords(struct mailbox_keywords *dest,
+			  const char *keywords[], unsigned int keywords_count)
 {
 	unsigned int i;
 
 	p_clear(dest->pool);
 
-	if (custom_flags_count == 0) {
-		dest->custom_flags = NULL;
-		dest->custom_flags_count = 0;
+	if (keywords_count == 0) {
+		dest->keywords = NULL;
+		dest->keywords_count = 0;
 		return;
 	}
 
-	dest->custom_flags =
-		p_new(dest->pool, char *, custom_flags_count);
-	dest->custom_flags_count = custom_flags_count;
+	dest->keywords = p_new(dest->pool, char *, keywords_count);
+	dest->keywords_count = keywords_count;
 
-	for (i = 0; i < custom_flags_count; i++)
-		dest->custom_flags[i] = p_strdup(dest->pool, custom_flags[i]);
+	for (i = 0; i < keywords_count; i++)
+		dest->keywords[i] = p_strdup(dest->pool, keywords[i]);
 }
--- a/src/imap/commands-util.h	Sun May 02 23:01:41 2004 +0300
+++ b/src/imap/commands-util.h	Sun May 02 23:32:15 2004 +0300
@@ -42,17 +42,16 @@
 /* Parse flags. Returns TRUE if successful, if not sends an error message to
    client. */
 int client_parse_mail_flags(struct client *client, struct imap_arg *args,
-                            const struct mailbox_custom_flags *old_flags,
+                            const struct mailbox_keywords *old_keywords,
 			    struct mail_full_flags *flags);
 
 /* Send FLAGS + PERMANENTFLAGS to client. */
 void client_send_mailbox_flags(struct client *client, struct mailbox *box,
-			       const char *custom_flags[],
-			       unsigned int custom_flags_count);
+			       const char *keywords[],
+			       unsigned int keywords_count);
 
-/* Copy custom flags into dest. dest must have been initialized. */
-void client_save_custom_flags(struct mailbox_custom_flags *dest,
-			      const char *custom_flags[],
-			      unsigned int custom_flags_count);
+/* Copy keywords into dest. dest must have been initialized. */
+void client_save_keywords(struct mailbox_keywords *dest,
+			  const char *keywords[], unsigned int keywords_count);
 
 #endif
--- a/src/imap/common.h	Sun May 02 23:01:41 2004 +0300
+++ b/src/imap/common.h	Sun May 02 23:32:15 2004 +0300
@@ -12,10 +12,10 @@
    by default. */
 #define DEFAULT_IMAP_MAX_LINE_LENGTH 65536
 
-#define DEFAULT_MAX_CUSTOM_FLAG_LENGTH 50
+#define DEFAULT_MAX_KEYWORD_LENGTH 50
 
 extern struct ioloop *ioloop;
-extern unsigned int max_custom_flag_length, mailbox_check_interval;
+extern unsigned int max_keyword_length, mailbox_check_interval;
 extern unsigned int imap_max_line_length;
 
 extern string_t *capability_string;
--- a/src/imap/mail-storage-callbacks.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/imap/mail-storage-callbacks.c	Sun May 02 23:32:15 2004 +0300
@@ -77,20 +77,16 @@
 	client_send_line(client, str);
 }
 
-static void new_custom_flags(struct mailbox *mailbox,
-			     const char *custom_flags[],
-			     unsigned int custom_flags_count, void *context)
+static void new_keywords(struct mailbox *mailbox, const char *keywords[],
+			 unsigned int keywords_count, void *context)
 {
 	struct client *client = context;
 
 	if (client->mailbox != mailbox)
 		return;
 
-	client_save_custom_flags(&client->mailbox_flags, custom_flags,
-				 custom_flags_count);
-
-	client_send_mailbox_flags(client, mailbox, custom_flags,
-				  custom_flags_count);
+	client_save_keywords(&client->keywords, keywords, keywords_count);
+	client_send_mailbox_flags(client, mailbox, keywords, keywords_count);
 }
 
 struct mail_storage_callbacks mail_storage_callbacks = {
@@ -100,5 +96,5 @@
 	expunge,
 	update_flags,
 	new_messages,
-	new_custom_flags
+	new_keywords
 };
--- a/src/imap/main.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/imap/main.c	Sun May 02 23:32:15 2004 +0300
@@ -22,7 +22,7 @@
         (getenv("LOGGED_IN") == NULL && getenv("IMAPLOGINTAG") == NULL)
 
 struct ioloop *ioloop;
-unsigned int max_custom_flag_length, mailbox_check_interval;
+unsigned int max_keyword_length, mailbox_check_interval;
 unsigned int imap_max_line_length;
 
 static struct module *modules;
@@ -114,9 +114,9 @@
 		DEFAULT_IMAP_MAX_LINE_LENGTH;
 
 	str = getenv("MAIL_MAX_FLAG_LENGTH");
-	max_custom_flag_length = str != NULL ?
+	max_keyword_length = str != NULL ?
 		(unsigned int)strtoul(str, NULL, 10) :
-		DEFAULT_MAX_CUSTOM_FLAG_LENGTH;
+		DEFAULT_MAX_KEYWORD_LENGTH;
 
 	str = getenv("MAILBOX_CHECK_INTERVAL");
 	mailbox_check_interval = str == NULL ? 0 :
--- a/src/lib-imap/imap-util.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-imap/imap-util.c	Sun May 02 23:32:15 2004 +0300
@@ -11,8 +11,6 @@
 	const char *sysflags;
 	unsigned int i;
 
-	i_assert(flags->custom_flags_count <= MAIL_CUSTOM_FLAGS_COUNT);
-
 	if (flags == 0)
 		return "";
 
@@ -28,33 +26,17 @@
 	if (*sysflags != '\0')
 		sysflags++;
 
-	if (flags->custom_flags_count == 0)
+	if (flags->keywords_count == 0)
 		return sysflags;
 
-	/* we have custom flags too */
+	/* we have keywords too */
 	str = t_str_new(256);
 	str_append(str, sysflags);
 
-#if 1
-	for (i = 0; i < flags->custom_flags_count; i++) {
+	for (i = 0; i < flags->keywords_count; i++) {
 		if (str_len(str) > 0)
 			str_append_c(str, ' ');
-		str_append(str, flags->custom_flags[i]);
+		str_append(str, flags->keywords[i]);
 	}
-#else // FIXME
-	if ((flags->flags & MAIL_CUSTOM_FLAGS_MASK) == 0)
-		return sysflags;
-
-	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, ' ');
-				str_append(str, name);
-			}
-		}
-	}
-#endif
 	return str_c(str);
 }
--- a/src/lib-imap/imap-util.h	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-imap/imap-util.h	Sun May 02 23:32:15 2004 +0300
@@ -3,20 +3,7 @@
 
 struct mail_full_flags;
 
-/* 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
-   file name using 'a'..'z' letters which gets us exactly the needed 26
-   flags. if more is added, the current code breaks. */
-enum {
-	MAIL_CUSTOM_FLAG_1_BIT	= 6,
-	MAIL_CUSTOM_FLAGS_COUNT	= 26,
-
-	MAIL_FLAGS_COUNT	= 32
-};
-
-/* 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. */
+/* Return flags as a space separated string. */
 const char *imap_write_flags(const struct mail_full_flags *flags);
 
 #endif
--- a/src/lib-index/mail-index-sync-update.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-index/mail-index-sync-update.c	Sun May 02 23:32:15 2004 +0300
@@ -63,16 +63,16 @@
 {
 	struct mail_index_record *rec, *end;
 	uint8_t flag_mask, old_flags;
-	custom_flags_mask_t custom_mask;
-	int i, update_custom;
+	keywords_mask_t keyword_mask;
+	int i, update_keywords;
 
-	update_custom = FALSE;
-	for (i = 0; i < INDEX_CUSTOM_FLAGS_BYTE_COUNT; i++) {
-		if (syncrec->add_custom_flags[i] != 0)
-			update_custom = TRUE;
-		if (syncrec->remove_custom_flags[i] != 0)
-			update_custom = TRUE;
-		custom_mask[i] = ~syncrec->remove_custom_flags[i];
+	update_keywords = FALSE;
+	for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++) {
+		if (syncrec->add_keywords[i] != 0)
+			update_keywords = TRUE;
+		if (syncrec->remove_keywords[i] != 0)
+			update_keywords = TRUE;
+		keyword_mask[i] = ~syncrec->remove_keywords[i];
 	}
 
 	flag_mask = ~syncrec->remove_flags;
@@ -81,11 +81,11 @@
 	for (; rec != end; rec++) {
 		old_flags = rec->flags;
 		rec->flags = (rec->flags & flag_mask) | syncrec->add_flags;
-		if (update_custom) {
-			for (i = 0; i < INDEX_CUSTOM_FLAGS_BYTE_COUNT; i++) {
-				rec->custom_flags[i] =
-					(rec->custom_flags[i]&custom_mask[i]) |
-					syncrec->add_custom_flags[i];
+		if (update_keywords) {
+			for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++) {
+				rec->keywords[i] =
+					(rec->keywords[i] & keyword_mask[i]) |
+					syncrec->add_keywords[i];
 			}
 		}
 
--- a/src/lib-index/mail-index-sync.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-index/mail-index-sync.c	Sun May 02 23:32:15 2004 +0300
@@ -216,11 +216,11 @@
 	rec->seq2 = update->seq2;
 
 	rec->add_flags = update->add_flags;
-	memcpy(rec->add_custom_flags, update->add_custom_flags,
-	       sizeof(rec->add_custom_flags));
+	memcpy(rec->add_keywords, update->add_keywords,
+	       sizeof(rec->add_keywords));
 	rec->remove_flags = update->remove_flags;
-	memcpy(rec->remove_custom_flags, update->remove_custom_flags,
-	       sizeof(rec->remove_custom_flags));
+	memcpy(rec->remove_keywords, update->remove_keywords,
+	       sizeof(rec->remove_keywords));
 }
 
 static int mail_index_sync_rec_check(struct mail_index_view *view,
@@ -461,17 +461,15 @@
 }
 
 void mail_index_sync_flags_apply(const struct mail_index_sync_rec *sync_rec,
-				 uint8_t *flags,
-				 custom_flags_mask_t custom_flags)
+				 uint8_t *flags, keywords_mask_t keywords)
 {
 	int i;
 
 	i_assert(sync_rec->type == MAIL_INDEX_SYNC_TYPE_FLAGS);
 
 	*flags = (*flags & ~sync_rec->remove_flags) | sync_rec->add_flags;
-	for (i = 0; i < INDEX_CUSTOM_FLAGS_BYTE_COUNT; i++) {
-		custom_flags[i] =
-			(custom_flags[i] & ~sync_rec->remove_custom_flags[i]) |
-			sync_rec->add_custom_flags[i];
+	for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++) {
+		keywords[i] = (keywords[i] & ~sync_rec->remove_keywords[i]) |
+			sync_rec->add_keywords[i];
 	}
 }
--- a/src/lib-index/mail-index-transaction.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-index/mail-index-transaction.c	Sun May 02 23:32:15 2004 +0300
@@ -248,39 +248,37 @@
 static void mail_index_record_modify_flags(struct mail_index_record *rec,
 					   enum modify_type modify_type,
 					   enum mail_flags flags,
-					   custom_flags_mask_t custom_flags)
+					   keywords_mask_t keywords)
 {
 	int i;
 
 	switch (modify_type) {
 	case MODIFY_REPLACE:
 		rec->flags = flags;
-		memcpy(rec->custom_flags, custom_flags,
-		       INDEX_CUSTOM_FLAGS_BYTE_COUNT);
+		memcpy(rec->keywords, keywords, INDEX_KEYWORDS_BYTE_COUNT);
 		break;
 	case MODIFY_ADD:
 		rec->flags |= flags;
-		for (i = 0; i < INDEX_CUSTOM_FLAGS_BYTE_COUNT; i++)
-			rec->custom_flags[i] |= custom_flags[i];
+		for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++)
+			rec->keywords[i] |= keywords[i];
 		break;
 	case MODIFY_REMOVE:
 		rec->flags &= ~flags;
-		for (i = 0; i < INDEX_CUSTOM_FLAGS_BYTE_COUNT; i++)
-			rec->custom_flags[i] &= ~custom_flags[i];
+		for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++)
+			rec->keywords[i] &= ~keywords[i];
 		break;
 	}
 }
 
-#define IS_COMPATIBLE_UPDATE(t, modify_type, flags, custom_flags) \
+#define IS_COMPATIBLE_UPDATE(t, modify_type, flags, keywords) \
 	((t)->last_update_modify_type == (modify_type) && \
 	 (t)->last_update.add_flags == (flags) && \
-	 memcmp((t)->last_update.add_custom_flags, custom_flags, \
-	        INDEX_CUSTOM_FLAGS_BYTE_COUNT) == 0)
+	 memcmp((t)->last_update.add_keywords, keywords, \
+	        INDEX_KEYWORDS_BYTE_COUNT) == 0)
 
 void mail_index_update_flags(struct mail_index_transaction *t, uint32_t seq,
 			     enum modify_type modify_type,
-			     enum mail_flags flags,
-			     custom_flags_mask_t custom_flags)
+			     enum mail_flags flags, keywords_mask_t keywords)
 {
 	struct mail_index_record *rec;
 	size_t pos;
@@ -292,7 +290,7 @@
 		pos = (seq - t->first_new_seq) * sizeof(*rec);
 		rec = buffer_get_space_unsafe(t->appends, pos, sizeof(*rec));
 		mail_index_record_modify_flags(rec, modify_type,
-					       flags, custom_flags);
+					       flags, keywords);
 		return;
 	}
 
@@ -303,13 +301,13 @@
 	   transaction (eg. 1:10 +seen, 1:10 +deleted) */
 	if (t->last_update.seq2 == seq-1) {
 		if (t->last_update.seq1 != 0 &&
-		    IS_COMPATIBLE_UPDATE(t, modify_type, flags, custom_flags)) {
+		    IS_COMPATIBLE_UPDATE(t, modify_type, flags, keywords)) {
 			t->last_update.seq2 = seq;
 			return;
 		}
 	} else if (t->last_update.seq1 == seq+1) {
 		if (t->last_update.seq1 != 0 &&
-		    IS_COMPATIBLE_UPDATE(t, modify_type, flags, custom_flags)) {
+		    IS_COMPATIBLE_UPDATE(t, modify_type, flags, keywords)) {
 			t->last_update.seq1 = seq;
 			return;
 		}
@@ -321,8 +319,8 @@
 	t->last_update_modify_type = modify_type;
 	t->last_update.seq1 = t->last_update.seq2 = seq;
 	t->last_update.add_flags = flags;
-	memcpy(t->last_update.add_custom_flags, custom_flags,
-	       INDEX_CUSTOM_FLAGS_BYTE_COUNT);
+	memcpy(t->last_update.add_keywords, keywords,
+	       INDEX_KEYWORDS_BYTE_COUNT);
 }
 
 static void
@@ -337,10 +335,8 @@
 		/* remove_flags = ~add_flags */
 		update->remove_flags =
 			~update->add_flags & MAIL_INDEX_FLAGS_MASK;
-		for (i = 0; i < INDEX_CUSTOM_FLAGS_BYTE_COUNT; i++) {
-			update->remove_custom_flags[i] =
-				~update->add_custom_flags[i];
-		}
+		for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++)
+			update->remove_keywords[i] = ~update->add_keywords[i];
 		break;
 	case MODIFY_ADD:
 		/* already in add_flags */
@@ -348,11 +344,10 @@
 	case MODIFY_REMOVE:
 		/* add_flags -> remove_flags */
 		update->remove_flags = update->add_flags;
-		memcpy(&update->remove_custom_flags, &update->add_custom_flags,
-		       INDEX_CUSTOM_FLAGS_BYTE_COUNT);
+		memcpy(&update->remove_keywords, &update->add_keywords,
+		       INDEX_KEYWORDS_BYTE_COUNT);
 		update->add_flags = 0;
-		memset(&update->add_custom_flags, 0,
-		       INDEX_CUSTOM_FLAGS_BYTE_COUNT);
+		memset(&update->add_keywords, 0, INDEX_KEYWORDS_BYTE_COUNT);
 		break;
 	}
 }
--- a/src/lib-index/mail-index-view-sync.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-index/mail-index-view-sync.c	Sun May 02 23:32:15 2004 +0300
@@ -181,11 +181,9 @@
 
 		old_flags = rec->flags;
 		rec->flags = (rec->flags & ~u->remove_flags) | u->add_flags;
-		for (i = 0; i < INDEX_CUSTOM_FLAGS_BYTE_COUNT; i++) {
-			rec->custom_flags[i] =
-				(rec->custom_flags[i] &
-				 ~u->remove_custom_flags[i]) |
-				u->add_custom_flags[i];
+		for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++) {
+			rec->keywords[i] = u->add_keywords[i] |
+				(rec->keywords[i] & ~u->remove_keywords[i]);
 		}
 
 		mail_index_header_update_counts(&map->hdr_copy, old_flags,
--- a/src/lib-index/mail-index.h	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-index/mail-index.h	Sun May 02 23:32:15 2004 +0300
@@ -8,9 +8,9 @@
 
 #define MAIL_INDEX_HEADER_MIN_SIZE 68
 
-/* Number of custom flags in mail_index_record. */
-#define INDEX_CUSTOM_FLAGS_COUNT (3*8)
-#define INDEX_CUSTOM_FLAGS_BYTE_COUNT ((INDEX_CUSTOM_FLAGS_COUNT*7)/8)
+/* Number of keywords in mail_index_record. */
+#define INDEX_KEYWORDS_COUNT (3*8)
+#define INDEX_KEYWORDS_BYTE_COUNT ((INDEX_KEYWORDS_COUNT*7)/8)
 
 enum mail_index_open_flags {
 	/* Create index if it doesn't exist */
@@ -54,7 +54,7 @@
 #define MAIL_INDEX_FLAGS_MASK \
 	(MAIL_ANSWERED | MAIL_FLAGGED | MAIL_DELETED | MAIL_SEEN | MAIL_DRAFT)
 
-typedef unsigned char custom_flags_mask_t[INDEX_CUSTOM_FLAGS_BYTE_COUNT];
+typedef unsigned char keywords_mask_t[INDEX_KEYWORDS_BYTE_COUNT];
 
 struct mail_index_header {
 	/* major version is increased only when you can't have backwards
@@ -97,7 +97,7 @@
 struct mail_index_record {
 	uint32_t uid;
 	uint8_t flags; /* mail_flags | mail_index_mail_flags */
-	custom_flags_mask_t custom_flags;
+	keywords_mask_t keywords;
 	uint32_t cache_offset;
 };
 
@@ -114,9 +114,9 @@
 
 	/* MAIL_INDEX_SYNC_TYPE_FLAGS: */
 	uint8_t add_flags;
-	custom_flags_mask_t add_custom_flags;
+	keywords_mask_t add_keywords;
 	uint8_t remove_flags;
-	custom_flags_mask_t remove_custom_flags;
+	keywords_mask_t remove_keywords;
 
 	/* MAIL_INDEX_SYNC_TYPE_APPEND: */
         const struct mail_index_record *appends;
@@ -255,8 +255,7 @@
 /* Update flags in index. */
 void mail_index_update_flags(struct mail_index_transaction *t, uint32_t seq,
 			     enum modify_type modify_type,
-			     enum mail_flags flags,
-			     custom_flags_mask_t custom_flags);
+			     enum mail_flags flags, keywords_mask_t keywords);
 
 /* Returns the last error code. */
 enum mail_index_error mail_index_get_last_error(struct mail_index *index);
@@ -272,7 +271,6 @@
 /* Apply changes in MAIL_INDEX_SYNC_TYPE_FLAGS typed sync records to given
    flags variables. */
 void mail_index_sync_flags_apply(const struct mail_index_sync_rec *sync_rec,
-				 uint8_t *flags,
-				 custom_flags_mask_t custom_flags);
+				 uint8_t *flags, keywords_mask_t keywords);
 
 #endif
--- a/src/lib-index/mail-transaction-log.h	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-index/mail-transaction-log.h	Sun May 02 23:32:15 2004 +0300
@@ -48,9 +48,9 @@
 struct mail_transaction_flag_update {
 	uint32_t seq1, seq2;
 	uint8_t add_flags;
-	custom_flags_mask_t add_custom_flags;
+	keywords_mask_t add_keywords;
 	uint8_t remove_flags;
-	custom_flags_mask_t remove_custom_flags;
+	keywords_mask_t remove_keywords;
 };
 
 struct mail_transaction_log *
--- a/src/lib-mail/mail-types.h	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-mail/mail-types.h	Sun May 02 23:32:15 2004 +0300
@@ -15,8 +15,8 @@
 struct mail_full_flags {
 	enum mail_flags flags;
 
-	const char **custom_flags;
-	unsigned int custom_flags_count;
+	const char **keywords;
+	unsigned int keywords_count;
 };
 
 enum modify_type {
--- a/src/lib-storage/index/index-fetch.h	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-storage/index/index-fetch.h	Sun May 02 23:32:15 2004 +0300
@@ -7,8 +7,8 @@
 	struct imap_message_cache *cache;
 	struct mail_index *index;
 
-	const char **custom_flags;
-	unsigned int custom_flags_count;
+	const char **keywords;
+	unsigned int keywords_count;
 
 	//struct mail_fetch_data *fetch_data;
 	struct ostream *output;
--- a/src/lib-storage/index/index-mail.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-storage/index/index-mail.c	Sun May 02 23:32:15 2004 +0300
@@ -170,9 +170,9 @@
 	struct index_mail_data *data = &mail->data;
 
 	data->flags.flags = data->rec->flags;
-	/*FIXME:data->flags.custom_flags =
-		mail_custom_flags_list_get(mail->ibox->index->custom_flags);
-	data->flags.custom_flags_count = MAIL_CUSTOM_FLAGS_COUNT;*/
+	/*FIXME:data->flags.keywords =
+		mail_keywords_list_get(mail->ibox->index->keywords);
+	data->flags.keywords_count = MAIL_KEYWORDS_COUNT;*/
 
 	return &data->flags;
 }
@@ -624,24 +624,24 @@
 {
 	struct index_mail *imail = (struct index_mail *)mail;
 	enum mail_flags modify_flags;
-	custom_flags_mask_t custom_flags;
+	keywords_mask_t keywords;
 
 	/* \Recent can't be changed */
 	modify_flags = flags->flags & ~MAIL_RECENT;
 
-	/*if (!index_mailbox_fix_custom_flags(ibox, &modify_flags,
-					    flags->custom_flags,
-					    flags->custom_flags_count))
+	/*if (!index_mailbox_fix_keywords(ibox, &modify_flags,
+					    flags->keywords,
+					    flags->keywords_count))
 		return FALSE;*/
 
-	memset(custom_flags, 0, sizeof(custom_flags));
+	memset(keywords, 0, sizeof(keywords));
 	mail_index_update_flags(imail->trans->trans, mail->seq, modify_type,
-				flags->flags, custom_flags);
+				flags->flags, keywords);
 
-	/*if (mail_custom_flags_has_changes(ibox->index->custom_flags)) {
-		storage->callbacks->new_custom_flags(&ibox->box,
-			mail_custom_flags_list_get(ibox->index->custom_flags),
-			MAIL_CUSTOM_FLAGS_COUNT, storage->callback_context);
+	/*if (mail_keywords_has_changes(ibox->index->keywords)) {
+		storage->callbacks->new_keywords(&ibox->box,
+			mail_keywords_list_get(ibox->index->keywords),
+			MAIL_KEYWORDS_COUNT, storage->callback_context);
 	}*/
 
 	return 0;
--- a/src/lib-storage/index/index-search.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-storage/index/index-search.c	Sun May 02 23:32:15 2004 +0300
@@ -83,23 +83,23 @@
 			  const struct mail_index_record *rec,
 			  const char *value)
 {
-	const char **custom_flags;
+	const char **keywords;
 	int i;
 
-	for (i = 0; i < INDEX_CUSTOM_FLAGS_BYTE_COUNT; i++) {
-		if (rec->custom_flags[i] != 0)
+	for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++) {
+		if (rec->keywords[i] != 0)
 			break;
 	}
 
-	if (i == INDEX_CUSTOM_FLAGS_BYTE_COUNT)
-		return FALSE; /* no custom flags set */
+	if (i == INDEX_KEYWORDS_BYTE_COUNT)
+		return FALSE; /* no keywords set */
 
-	/*FIXME:custom_flags = mail_custom_flags_list_get(index->custom_flags);
-	for (i = 0; i < MAIL_CUSTOM_FLAGS_COUNT; i++) {
-		if (custom_flags[i] != NULL &&
-		    strcasecmp(custom_flags[i], value) == 0) {
+	/*FIXME:keywords = mail_keywords_list_get(index->keywords);
+	for (i = 0; i < MAIL_KEYWORDS_COUNT; i++) {
+		if (keywords[i] != NULL &&
+		    strcasecmp(keywords[i], value) == 0) {
 			return rec->msg_flags &
-				(1 << (MAIL_CUSTOM_FLAG_1_BIT+i));
+				(1 << (MAIL_KEYWORD_1_BIT+i));
 		}
 	}*/
 
--- a/src/lib-storage/index/index-status.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-storage/index/index-status.c	Sun May 02 23:32:15 2004 +0300
@@ -8,17 +8,17 @@
 	 STATUS_UIDVALIDITY | STATUS_UNSEEN | STATUS_FIRST_UNSEEN_SEQ)
 
 /*static void
-get_custom_flags(struct mail_custom_flags *mcf, struct mailbox_status *status)
+get_keywords(struct mail_keywords *mcf, struct mailbox_status *status)
 {
 	const char **flags;
 	unsigned int i;
 
-	status->custom_flags_count = MAIL_CUSTOM_FLAGS_COUNT;
-	status->custom_flags = t_new(const char *, MAIL_CUSTOM_FLAGS_COUNT);
+	status->keywords_count = MAIL_KEYWORDS_COUNT;
+	status->keywords = t_new(const char *, MAIL_KEYWORDS_COUNT);
 
-	flags = mail_custom_flags_list_get(mcf);
-	for (i = 0; i < MAIL_CUSTOM_FLAGS_COUNT; i++)
-		status->custom_flags[i] = t_strdup(flags[i]);
+	flags = mail_keywords_list_get(mcf);
+	for (i = 0; i < MAIL_KEYWORDS_COUNT; i++)
+		status->keywords[i] = t_strdup(flags[i]);
 }*/
 
 int index_storage_get_status(struct mailbox *box,
@@ -58,8 +58,8 @@
 	if ((items & STATUS_RECENT) != 0)
 		status->recent = ibox->get_recent_count(ibox);
 
-	/*FIXME:if (items & STATUS_CUSTOM_FLAGS)
-		get_custom_flags(ibox, status);*/
+	/*FIXME:if (items & STATUS_KEYWORDS)
+		get_keywords(ibox, status);*/
 
 	mail_index_view_unlock(ibox->view);
 	return 0;
--- a/src/lib-storage/index/index-storage.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-storage/index/index-storage.c	Sun May 02 23:32:15 2004 +0300
@@ -383,7 +383,7 @@
 	return ibox->readonly;
 }
 
-int index_storage_allow_new_custom_flags(struct mailbox *box)
+int index_storage_allow_new_keywords(struct mailbox *box)
 {
 	struct index_mailbox *ibox = (struct index_mailbox *) box;
 
@@ -426,22 +426,21 @@
 	return FALSE;
 }
 
-int index_mailbox_fix_custom_flags(struct index_mailbox *ibox,
-				   enum mail_flags *flags,
-				   const char *custom_flags[],
-				   unsigned int custom_flags_count)
+int index_mailbox_fix_keywords(struct index_mailbox *ibox,
+			       enum mail_flags *flags,
+			       const char *keywords[],
+			       unsigned int keywords_count)
 {
 	/*FIXME:int ret;
 
-	ret = mail_custom_flags_fix_list(ibox->index,
-					 flags, custom_flags,
-					 custom_flags_count);
+	ret = mail_keywords_fix_list(ibox->index, flags, keywords,
+				     keywords_count);
 	switch (ret) {
 	case 1:
 		return TRUE;
 	case 0:
 		mail_storage_set_error(ibox->box.storage,
-			"Maximum number of different custom flags exceeded");
+			"Maximum number of different keywords exceeded");
 		return FALSE;
 	default:
 		return mail_storage_set_index_error(ibox);
--- a/src/lib-storage/index/index-storage.h	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-storage/index/index-storage.h	Sun May 02 23:32:15 2004 +0300
@@ -117,13 +117,13 @@
 void index_storage_mailbox_free(struct mailbox *box);
 
 int index_storage_is_readonly(struct mailbox *box);
-int index_storage_allow_new_custom_flags(struct mailbox *box);
+int index_storage_allow_new_keywords(struct mailbox *box);
 int index_storage_is_inconsistent(struct mailbox *box);
 
-int index_mailbox_fix_custom_flags(struct index_mailbox *ibox,
-				   enum mail_flags *flags,
-				   const char *custom_flags[],
-				   unsigned int custom_flags_count);
+int index_mailbox_fix_keywords(struct index_mailbox *ibox,
+			       enum mail_flags *flags,
+			       const char *keywords[],
+			       unsigned int keywords_count);
 
 unsigned int index_storage_get_recent_count(struct mail_index_view *view);
 
--- a/src/lib-storage/index/maildir/maildir-save.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-storage/index/maildir/maildir-save.c	Sun May 02 23:32:15 2004 +0300
@@ -137,9 +137,9 @@
 	ctx = t->save_ctx;
 
 	mail_flags = flags->flags;
-	/*FIXME:if (!index_mailbox_fix_custom_flags(ibox, &mail_flags,
-					    flags->custom_flags,
-					    flags->custom_flags_count))
+	/*FIXME:if (!index_mailbox_fix_keywords(ibox, &mail_flags,
+					    flags->keywords,
+					    flags->keywords_count))
 		return FALSE;*/
 
 	t_push();
--- a/src/lib-storage/index/maildir/maildir-storage.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-storage/index/maildir/maildir-storage.c	Sun May 02 23:32:15 2004 +0300
@@ -845,7 +845,7 @@
 	NULL, /* storage */
 
 	index_storage_is_readonly,
-        index_storage_allow_new_custom_flags,
+        index_storage_allow_new_keywords,
 	maildir_storage_close,
 	index_storage_get_status,
 	maildir_storage_sync,
--- a/src/lib-storage/index/maildir/maildir-storage.h	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-storage/index/maildir/maildir-storage.h	Sun May 02 23:32:15 2004 +0300
@@ -67,9 +67,9 @@
 int maildir_sync_last_commit(struct index_mailbox *ibox);
 
 int maildir_filename_get_flags(const char *fname, enum mail_flags *flags_r,
-			       custom_flags_mask_t custom_flags_r);
+			       keywords_mask_t keywords_r);
 const char *maildir_filename_set_flags(const char *fname, enum mail_flags flags,
-				       custom_flags_mask_t custom_flags);
+				       keywords_mask_t keywords);
 
 unsigned int maildir_hash(const void *p);
 int maildir_cmp(const void *p1, const void *p2);
--- a/src/lib-storage/index/maildir/maildir-sync.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-storage/index/maildir/maildir-sync.c	Sun May 02 23:32:15 2004 +0300
@@ -226,14 +226,14 @@
 	const char *newpath;
 	enum mail_flags flags;
 	uint8_t flags8;
-        custom_flags_mask_t custom_flags;
+        keywords_mask_t keywords;
 
-	(void)maildir_filename_get_flags(path, &flags, custom_flags);
+	(void)maildir_filename_get_flags(path, &flags, keywords);
 
 	flags8 = flags;
-	mail_index_sync_flags_apply(&ctx->sync_rec, &flags8, custom_flags);
+	mail_index_sync_flags_apply(&ctx->sync_rec, &flags8, keywords);
 
-	newpath = maildir_filename_set_flags(path, flags8, custom_flags);
+	newpath = maildir_filename_set_flags(path, flags8, keywords);
 	if (rename(path, newpath) == 0) {
 		ibox->dirty_cur_time = ioloop_time;
 		return 1;
@@ -505,7 +505,7 @@
         enum maildir_uidlist_rec_flag uflags;
 	const char *filename;
 	enum mail_flags flags;
-	custom_flags_mask_t custom_flags;
+	keywords_mask_t keywords;
 	uint32_t sync_stamp;
 	int ret;
 
@@ -527,7 +527,7 @@
 	seq = 0;
 	iter = maildir_uidlist_iter_init(ibox->uidlist);
 	while (maildir_uidlist_iter_next(iter, &uid, &uflags, &filename)) {
-		maildir_filename_get_flags(filename, &flags, custom_flags);
+		maildir_filename_get_flags(filename, &flags, keywords);
 
 	__again:
 		seq++;
@@ -539,7 +539,7 @@
 		if (seq > hdr->messages_count) {
 			mail_index_append(trans, uid, &seq);
 			mail_index_update_flags(trans, seq, MODIFY_REPLACE,
-						flags, custom_flags);
+						flags, keywords);
 			continue;
 		}
 
@@ -572,12 +572,12 @@
 			continue;
 		}
 
-		maildir_filename_get_flags(filename, &flags, custom_flags);
+		maildir_filename_get_flags(filename, &flags, keywords);
 		if ((uint8_t)flags != (rec->flags & MAIL_FLAGS_MASK) ||
-		    memcmp(custom_flags, rec->custom_flags,
-			   INDEX_CUSTOM_FLAGS_BYTE_COUNT) != 0) {
+		    memcmp(keywords, rec->keywords,
+			   INDEX_KEYWORDS_BYTE_COUNT) != 0) {
 			mail_index_update_flags(trans, seq, MODIFY_REPLACE,
-						flags, custom_flags);
+						flags, keywords);
 		}
 	}
 	maildir_uidlist_iter_deinit(iter);
--- a/src/lib-storage/index/maildir/maildir-util.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-storage/index/maildir/maildir-util.c	Sun May 02 23:32:15 2004 +0300
@@ -54,13 +54,13 @@
 }
 
 int maildir_filename_get_flags(const char *fname, enum mail_flags *flags_r,
-			       custom_flags_mask_t custom_flags_r)
+			       keywords_mask_t keywords_r)
 {
 	const char *info;
 	unsigned int num;
 
 	*flags_r = 0;
-	memset(custom_flags_r, 0, INDEX_CUSTOM_FLAGS_BYTE_COUNT);
+	memset(keywords_r, 0, INDEX_KEYWORDS_BYTE_COUNT);
 
 	info = strchr(fname, ':');
 	if (info == NULL || info[1] != '2' || info[2] != ',')
@@ -85,10 +85,9 @@
 			break;
 		default:
 			if (*info >= 'a' && *info <= 'z') {
-				/* custom flag */
+				/* keyword */
 				num = (*info - 'a');
-				custom_flags_r[num / CHAR_BIT] |=
-					num % CHAR_BIT;
+				keywords_r[num / CHAR_BIT] |= num % CHAR_BIT;
 				break;
 			}
 
@@ -101,20 +100,20 @@
 }
 
 const char *maildir_filename_set_flags(const char *fname, enum mail_flags flags,
-				       custom_flags_mask_t custom_flags)
+				       keywords_mask_t keywords)
 {
 	string_t *flags_str;
 	const char *info, *oldflags;
 	int i, nextflag;
 
-	if (custom_flags != NULL) {
-		/* see if any custom flags are given */
-		for (i = 0; i < INDEX_CUSTOM_FLAGS_BYTE_COUNT; i++) {
-			if (custom_flags[i] != 0)
+	if (keywords != NULL) {
+		/* see if any keywords are given */
+		for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++) {
+			if (keywords[i] != 0)
 				break;
 		}
-		if (i == INDEX_CUSTOM_FLAGS_BYTE_COUNT)
-			custom_flags = NULL;
+		if (i == INDEX_KEYWORDS_BYTE_COUNT)
+			keywords = NULL;
 	}
 
 	/* remove the old :info from file name, and get the old flags */
@@ -166,13 +165,13 @@
 			flags &= ~MAIL_DELETED;
 		}
 
-		if (custom_flags != NULL && nextflag > 'a') {
-			for (i = 0; i < INDEX_CUSTOM_FLAGS_COUNT; i++) {
-				if ((custom_flags[i / CHAR_BIT] &
+		if (keywords != NULL && nextflag > 'a') {
+			for (i = 0; i < INDEX_KEYWORDS_COUNT; i++) {
+				if ((keywords[i / CHAR_BIT] &
 				     (1 << (i % CHAR_BIT))) != 0)
 					str_append_c(flags_str, 'a' + i);
 			}
-			custom_flags = NULL;
+			keywords = NULL;
 		}
 
 		if (*oldflags == '\0' || *oldflags == ',')
--- a/src/lib-storage/index/mbox/mbox-save.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-storage/index/mbox/mbox-save.c	Sun May 02 23:32:15 2004 +0300
@@ -144,23 +144,23 @@
 	return str_c(str);
 }
 
-static const char *get_custom_flags(const struct mail_full_flags *flags)
+static const char *get_keywords(const struct mail_full_flags *flags)
 {
 	string_t *str;
 	unsigned int field;
 	unsigned int i;
 
-	if ((flags->flags & MAIL_CUSTOM_FLAGS_MASK) == 0)
+	if ((flags->flags & MAIL_KEYWORDS_MASK) == 0)
 		return "";
 
 	str = t_str_new(256);
-	field = 1 << MAIL_CUSTOM_FLAG_1_BIT;
-	for (i = 0; i < flags->custom_flags_count; i++) {
-		const char *custom_flag = flags->custom_flags[i];
+	field = 1 << MAIL_KEYWORD_1_BIT;
+	for (i = 0; i < flags->keywords_count; i++) {
+		const char *keyword = flags->keywords[i];
 
-		if ((flags->flags & field) && custom_flag != NULL) {
+		if ((flags->flags & field) && keyword != NULL) {
 			str_append_c(str, ' ');
-			str_append(str, custom_flag);
+			str_append(str, keyword);
 		}
 
 		field <<= 1;
@@ -192,9 +192,9 @@
 		}
 		ctx->content_length_offset = ctx->output->offset;
 
-		/* calculate how much space custom flags and content-length
+		/* calculate how much space keywords and content-length
 		   value needs, then write that amount of spaces. */
-		space = strlen(get_custom_flags(ctx->flags));
+		space = strlen(get_keywords(ctx->flags));
 		space += sizeof("X-Keywords: ");
 		space += MBOX_HEADER_EXTRA_SPACE + MAX_INT_STRLEN + 1;
 
@@ -258,8 +258,8 @@
 	if (o_stream_send_str(ctx->output, str) < 0)
 		return write_error(ctx);
 
-	/* write custom flags into X-Keywords */
-	str = get_custom_flags(ctx->flags);
+	/* write keywords into X-Keywords */
+	str = get_keywords(ctx->flags);
 	if (o_stream_send_str(ctx->output, str) < 0)
 		return write_error(ctx);
 
@@ -281,9 +281,9 @@
 	   they need to be checked/added though. */
 	ctx->flags = flags;
 	real_flags = flags->flags;
-	if (!index_mailbox_fix_custom_flags(ctx->ibox, &real_flags,
-					    flags->custom_flags,
-					    flags->custom_flags_count))
+	if (!index_mailbox_fix_keywords(ctx->ibox, &real_flags,
+					flags->keywords,
+					flags->keywords_count))
 		return FALSE;
 
 	t_push();
--- a/src/lib-storage/index/mbox/mbox-storage.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-storage/index/mbox/mbox-storage.c	Sun May 02 23:32:15 2004 +0300
@@ -5,7 +5,7 @@
 #include "mkdir-parents.h"
 #include "unlink-directory.h"
 #include "subscription-file/subscription-file.h"
-#include "mail-custom-flags.h"
+#include "mail-keywords.h"
 #include "mbox-index.h"
 #include "mbox-lock.h"
 #include "mbox-storage.h"
@@ -852,7 +852,7 @@
 	NULL, /* storage */
 
 	index_storage_is_readonly,
-        index_storage_allow_new_custom_flags,
+        index_storage_allow_new_keywords,
 	mbox_storage_close,
 	mbox_storage_lock,
 	index_storage_get_status,
--- a/src/lib-storage/index/mbox/mbox-sync-private.h	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-storage/index/mbox/mbox-sync-private.h	Sun May 02 23:32:15 2004 +0300
@@ -28,7 +28,7 @@
 struct mbox_mail {
 	uint32_t uid;
 	uint8_t flags;
-	custom_flags_mask_t custom_flags;
+	keywords_mask_t keywords;
 
 	uoff_t space_offset; /* if space is negative, points to beginning */
 	off_t space;
--- a/src/lib-storage/index/mbox/mbox-sync-update.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-storage/index/mbox/mbox-sync-update.c	Sun May 02 23:32:15 2004 +0300
@@ -15,7 +15,7 @@
 	}
 }
 static void keywords_append(struct mbox_sync_mail_context *ctx,
-			    custom_flags_mask_t custom_flags)
+			    keywords_mask_t keywords)
 {
 	// FIXME
 }
@@ -33,7 +33,7 @@
 		str_printfa(ctx->header, "X-IMAPbase: %u %u",
 			    ctx->sync_ctx->hdr->uid_validity,
 			    ctx->sync_ctx->next_uid);
-		//FIXME:keywords_append(ctx, all_custom_flags);
+		//FIXME:keywords_append(ctx, all_keywords);
 		str_append_c(ctx->header, '\n');
 	}
 
@@ -60,8 +60,8 @@
 	}
 
 	have_keywords = FALSE;
-	for (i = 0; i < INDEX_CUSTOM_FLAGS_BYTE_COUNT; i++) {
-		if (ctx->mail->custom_flags[i] != 0) {
+	for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++) {
+		if (ctx->mail->keywords[i] != 0) {
 			have_keywords = TRUE;
 			break;
 		}
@@ -70,7 +70,7 @@
 	if (ctx->hdr_pos[MBOX_HDR_X_KEYWORDS] == (size_t)-1 && have_keywords) {
 		ctx->hdr_pos[MBOX_HDR_X_KEYWORDS] = str_len(ctx->header);
 		str_append(ctx->header, "X-Keywords: ");
-		keywords_append(ctx, ctx->mail->custom_flags);
+		keywords_append(ctx, ctx->mail->keywords);
 		str_append_c(ctx->header, '\n');
 	}
 
@@ -113,15 +113,14 @@
 			     struct mail_index_sync_rec *update)
 {
 	uint8_t old_flags;
-	custom_flags_mask_t old_custom_flags;
+	keywords_mask_t old_keywords;
 
 	if (update != NULL) {
 		old_flags = ctx->mail->flags;
-		memcpy(old_custom_flags, ctx->mail->custom_flags,
-		       sizeof(old_custom_flags));
+		memcpy(old_keywords, ctx->mail->keywords, sizeof(old_keywords));
 
 		mail_index_sync_flags_apply(update, &ctx->mail->flags,
-					    ctx->mail->custom_flags);
+					    ctx->mail->keywords);
 
 		if ((old_flags & STATUS_FLAGS_MASK) !=
 		    (ctx->mail->flags & STATUS_FLAGS_MASK))
@@ -129,8 +128,8 @@
 		if ((old_flags & XSTATUS_FLAGS_MASK) !=
 		    (ctx->mail->flags & XSTATUS_FLAGS_MASK))
 			mbox_sync_update_xstatus(ctx);
-		if (memcmp(old_custom_flags, ctx->mail->custom_flags,
-			   sizeof(old_custom_flags)) != 0)
+		if (memcmp(old_keywords, ctx->mail->keywords,
+			   sizeof(old_keywords)) != 0)
 			mbox_sync_update_xkeywords(ctx);
 	}
 
--- a/src/lib-storage/mail-storage-private.h	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-storage/mail-storage-private.h	Sun May 02 23:32:15 2004 +0300
@@ -59,7 +59,7 @@
 	struct mail_storage *storage;
 
 	int (*is_readonly)(struct mailbox *box);
-	int (*allow_new_custom_flags)(struct mailbox *box);
+	int (*allow_new_keywords)(struct mailbox *box);
 
 	int (*close)(struct mailbox *box);
 
--- a/src/lib-storage/mail-storage.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-storage/mail-storage.c	Sun May 02 23:32:15 2004 +0300
@@ -355,9 +355,9 @@
 	return box->is_readonly(box);
 }
 
-int mailbox_allow_new_custom_flags(struct mailbox *box)
+int mailbox_allow_new_keywords(struct mailbox *box)
 {
-	return box->allow_new_custom_flags(box);
+	return box->allow_new_keywords(box);
 }
 
 int mailbox_get_status(struct mailbox *box,
--- a/src/lib-storage/mail-storage.h	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-storage/mail-storage.h	Sun May 02 23:32:15 2004 +0300
@@ -36,7 +36,7 @@
 	STATUS_UIDVALIDITY	= 0x08,
 	STATUS_UNSEEN		= 0x10,
 	STATUS_FIRST_UNSEEN_SEQ	= 0x20,
-	STATUS_CUSTOM_FLAGS	= 0x40
+	STATUS_KEYWORDS		= 0x40
 };
 
 enum mailbox_name_status {
@@ -128,8 +128,8 @@
 	unsigned int diskspace_full:1;
 
 	/* may be allocated from data stack */
-	unsigned int custom_flags_count;
-	const char **custom_flags;
+	unsigned int keywords_count;
+	const char **keywords;
 };
 
 struct mail_storage_callbacks {
@@ -155,10 +155,10 @@
 			     unsigned int messages_count,
 			     unsigned int recent_count, void *context);
 	/* FLAGS, PERMANENTFLAGS */
-	void (*new_custom_flags)(struct mailbox *mailbox,
-				 const char *custom_flags[],
-				 unsigned int custom_flags_count,
-				 void *context);
+	void (*new_keywords)(struct mailbox *mailbox,
+			     const char *keywords[],
+			     unsigned int keywords_count,
+			     void *context);
 
 };
 
@@ -271,8 +271,8 @@
 /* Returns TRUE if mailbox is read-only. */
 int mailbox_is_readonly(struct mailbox *box);
 
-/* Returns TRUE if mailbox currently supports adding custom flags. */
-int mailbox_allow_new_custom_flags(struct mailbox *box);
+/* Returns TRUE if mailbox currently supports adding keywords. */
+int mailbox_allow_new_keywords(struct mailbox *box);
 
 /* Gets the mailbox status information. */
 int mailbox_get_status(struct mailbox *box,
--- a/src/lib-storage/proxy-mailbox.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/lib-storage/proxy-mailbox.c	Sun May 02 23:32:15 2004 +0300
@@ -11,11 +11,11 @@
 	return p->box->is_readonly(p->box);
 }
 
-static int _allow_new_custom_flags(struct mailbox *box)
+static int _allow_new_keywords(struct mailbox *box)
 {
 	struct proxy_mailbox *p = (struct proxy_mailbox *) box;
 
-	return p->box->allow_new_custom_flags(p->box);
+	return p->box->allow_new_keywords(p->box);
 }
 
 static int _close(struct mailbox *box)
@@ -111,7 +111,7 @@
 	pb->storage = box->storage;
 
 	pb->is_readonly = _is_readonly;
-	pb->allow_new_custom_flags = _allow_new_custom_flags;
+	pb->allow_new_keywords = _allow_new_keywords;
 	pb->close = _close;
 	pb->get_status = _get_status;
 	pb->sync = _sync;
--- a/src/pop3/mail-storage-callbacks.c	Sun May 02 23:01:41 2004 +0300
+++ b/src/pop3/mail-storage-callbacks.c	Sun May 02 23:32:15 2004 +0300
@@ -66,10 +66,10 @@
 {
 }
 
-static void new_custom_flags(struct mailbox *mailbox __attr_unused__,
-			     const char *custom_flags[] __attr_unused__,
-			     unsigned int custom_flags_count __attr_unused__,
-			     void *context __attr_unused__)
+static void new_keywords(struct mailbox *mailbox __attr_unused__,
+			 const char *keywords[] __attr_unused__,
+			 unsigned int keywords_count __attr_unused__,
+			 void *context __attr_unused__)
 {
 }
 
@@ -80,5 +80,5 @@
 	expunge,
 	update_flags,
 	new_messages,
-	new_custom_flags
+	new_keywords
 };