[dovecot-cvs] dovecot/src/lib-storage/index index-search.c, 1.125, 1.126

tss at dovecot.org tss at dovecot.org
Tue Apr 3 18:02:39 EEST 2007


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

Modified Files:
	index-search.c 
Log Message:
Search API cleanups



Index: index-search.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-search.c,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -d -r1.125 -r1.126
--- index-search.c	3 Apr 2007 14:51:26 -0000	1.125
+++ index-search.c	3 Apr 2007 15:02:37 -0000	1.126
@@ -62,7 +62,7 @@
 };
 
 struct search_arg_context {
-	struct header_search_context *hdr_search_ctx;
+	struct message_header_search_context *hdr_search_ctx;
 	struct message_body_search_context *body_search_ctx;
 };
 
@@ -332,12 +332,12 @@
 	return arg_ctx;
 }
 
-static struct header_search_context *
+static struct message_header_search_context *
 search_header_context(struct index_search_context *ctx,
 		      struct mail_search_arg *arg)
 {
 	struct search_arg_context *arg_ctx;
-	bool unknown_charset;
+	int ret;
 
 	arg_ctx = search_arg_context(ctx, arg);
 	if (arg_ctx->hdr_search_ctx != NULL) {
@@ -345,16 +345,16 @@
 		return arg_ctx->hdr_search_ctx;
 	}
 
-	arg_ctx->hdr_search_ctx =
-		message_header_search_init(ctx->search_pool, arg->value.str,
-					   ctx->mail_ctx.charset,
-					   &unknown_charset);
-	if (arg_ctx->hdr_search_ctx == NULL) {
-		ctx->error = unknown_charset ?
-			TXT_UNKNOWN_CHARSET : TXT_INVALID_SEARCH_KEY;
-	}
-
-	return arg_ctx->hdr_search_ctx;
+	ret = message_header_search_init(ctx->search_pool, arg->value.str,
+					 ctx->mail_ctx.charset,
+					 &arg_ctx->hdr_search_ctx);
+	if (ret > 0)
+		return arg_ctx->hdr_search_ctx;
+	if (ret == 0)
+		ctx->error = TXT_UNKNOWN_CHARSET;
+	else
+		ctx->error = TXT_INVALID_SEARCH_KEY;
+	return NULL;
 }
 
 static struct message_body_search_context *
@@ -386,7 +386,7 @@
 static void search_header_arg(struct mail_search_arg *arg,
 			      struct search_header_context *ctx)
 {
-        struct header_search_context *hdr_search_ctx;
+        struct message_header_search_context *hdr_search_ctx;
 	int ret;
 
 	/* first check that the field name matches to argument. */
@@ -446,12 +446,16 @@
 						     (unsigned int)-1, TRUE);
 			str = t_str_new(ctx->hdr->value_len);
 			message_address_write(str, addr);
-			ret = message_header_search(str_data(str), str_len(str),
-						    hdr_search_ctx) ? 1 : 0;
+			ret = message_header_search(hdr_search_ctx,
+						    str_data(str),
+						    str_len(str)) ? 1 : 0;
 		} else {
-			ret = message_header_search(ctx->hdr->full_value,
-						    ctx->hdr->full_value_len,
-						    hdr_search_ctx) ? 1 : 0;
+			if (message_header_search(hdr_search_ctx,
+						  ctx->hdr->full_value,
+						  ctx->hdr->full_value_len))
+				ret = 1;
+			else
+				ret = 0;
 		}
 		t_pop();
 	}



More information about the dovecot-cvs mailing list