[dovecot-cvs] dovecot/src/lib-storage/index index-search.c, 1.132, 1.133

tss at dovecot.org tss at dovecot.org
Sun May 13 16:23:07 EEST 2007


Update of /var/lib/cvs/dovecot/src/lib-storage/index
In directory talvi:/tmp/cvs-serv12374/lib-storage/index

Modified Files:
	index-search.c 
Log Message:
Parse search dates already in IMAP code.



Index: index-search.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-search.c,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -d -r1.132 -r1.133
--- index-search.c	4 Apr 2007 10:28:37 -0000	1.132
+++ index-search.c	13 May 2007 13:23:04 -0000	1.133
@@ -9,7 +9,6 @@
 #include "message-date.h"
 #include "message-search.h"
 #include "message-parser.h"
-#include "imap-date.h"
 #include "index-storage.h"
 #include "index-mail.h"
 #include "index-sort.h"
@@ -186,14 +185,13 @@
 
 /* Returns >0 = matched, 0 = not matched, -1 = unknown */
 static int search_arg_match_cached(struct index_search_context *ctx,
-				   enum mail_search_arg_type type,
-				   const char *value)
+				   struct mail_search_arg *arg)
 {
-	time_t date, search_time;
 	uoff_t virtual_size, search_size;
+	time_t date;
 	int timezone_offset;
 
-	switch (type) {
+	switch (arg->type) {
 	/* internal dates */
 	case SEARCH_BEFORE:
 	case SEARCH_ON:
@@ -202,17 +200,14 @@
 		if (date == (time_t)-1)
 			return -1;
 
-		if (!imap_parse_date(value, &search_time))
-			return 0;
-
-		switch (type) {
+		switch (arg->type) {
 		case SEARCH_BEFORE:
-			return date < search_time;
+			return date < arg->value.time;
 		case SEARCH_ON:
-			return date >= search_time &&
-				date < search_time + 3600*24;
+			return date >= arg->value.time &&
+				date < arg->value.time + 3600*24;
 		case SEARCH_SINCE:
-			return date >= search_time;
+			return date >= arg->value.time;
 		default:
 			/* unreachable */
 			break;
@@ -229,17 +224,14 @@
 			return -1;
 		date += timezone_offset * 60;
 
-		if (!imap_parse_date(value, &search_time))
-			return 0;
-
-		switch (type) {
+		switch (arg->type) {
 		case SEARCH_SENTBEFORE:
-			return date < search_time;
+			return date < arg->value.time;
 		case SEARCH_SENTON:
-			return date >= search_time &&
-				date < search_time + 3600*24;
+			return date >= arg->value.time &&
+				date < arg->value.time + 3600*24;
 		case SEARCH_SENTSINCE:
-			return date >= search_time;
+			return date >= arg->value.time;
 		default:
 			/* unreachable */
 			break;
@@ -252,8 +244,8 @@
 		if (virtual_size == (uoff_t)-1)
 			return -1;
 
-		search_size = str_to_uoff_t(value);
-		if (type == SEARCH_SMALLER)
+		search_size = str_to_uoff_t(arg->value.str);
+		if (arg->type == SEARCH_SMALLER)
 			return virtual_size < search_size;
 		else
 			return virtual_size > search_size;
@@ -266,8 +258,7 @@
 static void search_cached_arg(struct mail_search_arg *arg,
 			      struct index_search_context *ctx)
 {
-	switch (search_arg_match_cached(ctx, arg->type,
-					arg->value.str)) {
+	switch (search_arg_match_cached(ctx, arg)) {
 	case -1:
 		/* unknown */
 		break;
@@ -280,18 +271,15 @@
 	}
 }
 
-static int search_sent(enum mail_search_arg_type type, const char *search_value,
+static int search_sent(enum mail_search_arg_type type, time_t search_time,
 		       const unsigned char *sent_value, size_t sent_value_len)
 {
-	time_t search_time, sent_time;
+	time_t sent_time;
 	int timezone_offset;
 
 	if (sent_value == NULL)
 		return 0;
 
-	if (!imap_parse_date(search_value, &search_time))
-		return 0;
-
 	/* NOTE: RFC-3501 specifies that timezone is ignored
 	   in searches. sent_time is returned as UTC, so change it. */
 	if (!message_date_parse(sent_value, sent_value_len,
@@ -361,7 +349,7 @@
 				ctx->hdr->use_full_value = TRUE;
 				return;
 			}
-			ret = search_sent(arg->type, arg->value.str,
+			ret = search_sent(arg->type, arg->value.time,
 					  ctx->hdr->full_value,
 					  ctx->hdr->full_value_len);
 			ARG_SET_RESULT(arg, ret);



More information about the dovecot-cvs mailing list