[dovecot-cvs] dovecot/src/lib-storage/index index-messageset.c,1.8,1.9 index-search.c,1.54,1.55

cras at procontrol.fi cras at procontrol.fi
Thu Jan 2 12:21:43 EET 2003


Update of /home/cvs/dovecot/src/lib-storage/index
In directory danu:/tmp/cvs-serv21738/lib-storage/index

Modified Files:
	index-messageset.c index-search.c 
Log Message:
Storage can now specify if errors should be sent to user as BAD or NO.
Some changes to messageset parsing as specified by latest IMAP4rev1 draft.
Bad charset error is prefixed with [BADCHARSET]. Fixed a crash in SEARCH the
last commit in it caused.



Index: index-messageset.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-messageset.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- index-messageset.c	25 Nov 2002 19:02:50 -0000	1.8
+++ index-messageset.c	2 Jan 2003 10:21:41 -0000	1.9
@@ -24,22 +24,18 @@
 
 static int mail_index_foreach(MailIndex *index,
 			      unsigned int seq, unsigned int seq2,
-			      MsgsetForeachFunc func, void *context,
-			      const char **error)
+			      MsgsetForeachFunc func, void *context)
 {
 	MailIndexRecord *rec;
 	const ModifyLogExpunge *expunges;
-	unsigned int idx_seq, expunges_before;
+	unsigned int idx_seq, expunges_before, temp;
 	int expunges_found;
 
 	if (seq > seq2) {
-		/* Second sequence can't be smaller than first - we could swap
-		   them but I think it's a bug in client if it does this,
-		   and better complain about it immediately than later let
-		   them wonder why it doesn't work with other imapds.. */
-		*error = t_strdup_printf("Invalid messageset range: %u > %u",
-					 seq, seq2);
-		return -2;
+		/* swap, as specified by latest IMAP4rev1 spec */
+		temp = seq;
+		seq = seq2;
+		seq2 = temp;
 	}
 
 	/* get list of expunged messages in our range. the expunges_before
@@ -108,8 +104,8 @@
 
 	*error = NULL;
 	if (messages_count == 0) {
-		/* no messages in mailbox */
-		return 1;
+		*error = "No messages in mailbox";
+		return -2;
 	}
 
 	all_found = TRUE;
@@ -168,8 +164,7 @@
 		}
 
 		t_push();
-		ret = mail_index_foreach(index, seq, seq2,
-					 func, context, error);
+		ret = mail_index_foreach(index, seq, seq2, func, context);
 		t_pop();
 		if (ret <= 0)
 			return ret;
@@ -182,19 +177,18 @@
 
 static int mail_index_uid_foreach(MailIndex *index,
 				  unsigned int uid, unsigned int uid2,
-				  MsgsetForeachFunc func, void *context,
-				  const char **error)
+				  MsgsetForeachFunc func, void *context)
 {
 	MailIndexRecord *rec;
 	const ModifyLogExpunge *expunges;
-	unsigned int client_seq, idx_seq, expunges_before;
+	unsigned int client_seq, idx_seq, expunges_before, temp;
 	int expunges_found;
 
 	if (uid > uid2) {
-		/* not allowed - see mail_index_foreach() */
-		*error = t_strdup_printf("Invalid uidset range: %u > %u",
-					 uid, uid2);
-		return -2;
+		/* swap, as specified by latest IMAP4rev1 spec */
+		temp = uid;
+		uid = uid2;
+		uid2 = temp;
 	}
 
 	/* get list of expunged messages in our range. */
@@ -290,12 +284,6 @@
 				}
 			} else {
 				uid2 = index->header->next_uid-1;
-				if (uid2 < uid) {
-					/* allow requesting "n:*" where n is
-					   larger than the actual (synced)
-					   messages count */
-					uid2 = uid;
-				}
 				input++;
 			}
 		}
@@ -308,18 +296,14 @@
 			return -2;
 		}
 
-		if (uid >= index->header->next_uid) {
-			/* too large .. ignore silently */
-		} else {
-			t_push();
-			ret = mail_index_uid_foreach(index, uid, uid2,
-						     func, context, error);
-			t_pop();
-			if (ret <= 0)
-				return ret;
-			if (ret == 2)
-				all_found = FALSE;
-		}
+		t_push();
+		ret = mail_index_uid_foreach(index, uid, uid2,
+					     func, context);
+		t_pop();
+		if (ret <= 0)
+			return ret;
+		if (ret == 2)
+			all_found = FALSE;
 	}
 
 	return all_found ? 1 : 2;
@@ -345,7 +329,8 @@
 	if (ret < 0) {
 		if (ret == -2) {
 			/* user error */
-			mail_storage_set_error(ibox->box.storage, "%s", error);
+			mail_storage_set_syntax_error(ibox->box.storage,
+						      "%s", error);
 		} else {
 			mail_storage_set_index_error(ibox);
 		}

Index: index-search.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-search.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- index-search.c	2 Jan 2003 09:19:49 -0000	1.54
+++ index-search.c	2 Jan 2003 10:21:41 -0000	1.55
@@ -26,7 +26,7 @@
 		(arg)->result = !(arg)->not ? (res) : -(res); \
 	} STMT_END
 
-#define TXT_UNKNOWN_CHARSET "Unknown charset"
+#define TXT_UNKNOWN_CHARSET "[BADCHARSET] Unknown charset"
 #define TXT_INVALID_SEARCH_KEY "Invalid search key"
 
 typedef struct {
@@ -403,6 +403,12 @@
 				/* we're just testing existence of the field.
 				   assume it matches with non-NIL values. */
 				ret = field != NULL ? 1 : 0;
+				break;
+			}
+
+			if (field == NULL) {
+				/* doesn't exist */
+				ret = 0;
 				break;
 			}
 




More information about the dovecot-cvs mailing list