[dovecot-cvs] dovecot/src/lib-storage mail-search.c,1.12,1.13 mail-search.h,1.9,1.10 mail-storage.h,1.54,1.55 proxy-mailbox.c,1.1,1.2

cras at procontrol.fi cras at procontrol.fi
Thu Aug 7 00:15:36 EEST 2003


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

Modified Files:
	mail-search.c mail-search.h mail-storage.h proxy-mailbox.c 
Log Message:
Index cache file rewrite. It's not finished yet and mbox support is
completely broken. But it's getting difficult to maintain outside cvs :)



Index: mail-search.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/mail-search.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- mail-search.c	22 Apr 2003 18:11:35 -0000	1.12
+++ mail-search.c	6 Aug 2003 20:15:32 -0000	1.13
@@ -1,6 +1,7 @@
 /* Copyright (C) 2002 Timo Sirainen */
 
 #include "lib.h"
+#include "buffer.h"
 #include "mail-search.h"
 
 void mail_search_args_reset(struct mail_search_arg *args)
@@ -93,9 +94,11 @@
 	return result;
 }
 
-static void search_arg_analyze(struct mail_search_arg *arg, int *have_headers,
-			       int *have_body, int *have_text)
+static void
+search_arg_analyze(struct mail_search_arg *arg, buffer_t *headers,
+		   int *have_headers, int *have_body, int *have_text)
 {
+	static const char *date_hdr = "Date";
 	struct mail_search_arg *subarg;
 
 	if (arg->result != -1)
@@ -107,8 +110,9 @@
 		subarg = arg->value.subargs;
 		while (subarg != NULL) {
 			if (subarg->result == -1) {
-				search_arg_analyze(subarg, have_headers,
-						   have_body, have_text);
+				search_arg_analyze(subarg, headers,
+						   have_headers, have_body,
+						   have_text);
 			}
 
 			subarg = subarg->next;
@@ -117,14 +121,13 @@
 	case SEARCH_SENTBEFORE:
 	case SEARCH_SENTON:
 	case SEARCH_SENTSINCE:
-	case SEARCH_FROM:
-	case SEARCH_TO:
-	case SEARCH_CC:
-	case SEARCH_BCC:
-	case SEARCH_SUBJECT:
-	case SEARCH_IN_REPLY_TO:
-	case SEARCH_MESSAGE_ID:
+		*have_headers = TRUE;
+		buffer_append(headers, &date_hdr, sizeof(const char *));
+		break;
 	case SEARCH_HEADER:
+	case SEARCH_HEADER_ADDRESS:
+		buffer_append(headers, &arg->hdr_field_name,
+			      sizeof(const char *));
 		*have_headers = TRUE;
 		break;
 	case SEARCH_BODY:
@@ -138,12 +141,25 @@
 	}
 }
 
-void mail_search_args_analyze(struct mail_search_arg *args, int *have_headers,
-			      int *have_body, int *have_text)
+const char *const *
+mail_search_args_analyze(struct mail_search_arg *args,
+			 int *have_headers, int *have_body)
 {
-	*have_headers = *have_body = *have_text = FALSE;
+	const char *null = NULL;
+	buffer_t *headers;
+	int have_text;
 
-	for (; args != NULL; args = args->next)
-		search_arg_analyze(args, have_headers, have_body, have_text);
-}
+	*have_headers = *have_body = have_text = FALSE;
 
+	headers = buffer_create_dynamic(data_stack_pool, 128, (size_t)-1);
+	for (; args != NULL; args = args->next) {
+		search_arg_analyze(args, headers, have_headers,
+				   have_body, &have_text);
+	}
+
+	if (!have_headers || have_text)
+		return NULL;
+
+	buffer_append(headers, &null, sizeof(const char *));
+	return buffer_get_data(headers, NULL);
+}

Index: mail-search.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/mail-search.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- mail-search.h	1 Feb 2003 11:24:17 -0000	1.9
+++ mail-search.h	6 Aug 2003 20:15:32 -0000	1.10
@@ -32,20 +32,12 @@
 	SEARCH_LARGER,
 
 	/* headers */
-	SEARCH_FROM,
-	SEARCH_TO,
-	SEARCH_CC,
-	SEARCH_BCC,
-	SEARCH_SUBJECT,
 	SEARCH_HEADER,
+	SEARCH_HEADER_ADDRESS,
 
 	/* body */
 	SEARCH_BODY,
-	SEARCH_TEXT,
-
-	/* our shortcuts for headers */
-        SEARCH_IN_REPLY_TO,
-        SEARCH_MESSAGE_ID
+	SEARCH_TEXT
 };
 
 struct mail_search_arg {
@@ -58,7 +50,7 @@
 	} value;
 
         void *context;
-	const char *hdr_field_name; /* for SEARCH_HEADER */
+	const char *hdr_field_name; /* for SEARCH_HEADER* */
 	unsigned int not:1;
 
 	int result; /* -1 = unknown, 0 = unmatched, 1 = matched */
@@ -82,9 +74,11 @@
 			     mail_search_foreach_callback_t callback,
 			     void *context);
 
-/* Fills have_headers, have_body and have_text based on if such search
-   argument exists that needs to be checked. */
-void mail_search_args_analyze(struct mail_search_arg *args, int *have_headers,
-			      int *have_body, int *have_text);
+/* Fills have_headers and have_body based on if such search argument exists
+   that needs to be checked. Returns the headers that we're searching for, or
+   NULL if we're searching for TEXT. */
+const char *const *
+mail_search_args_analyze(struct mail_search_arg *args,
+			 int *have_headers, int *have_body);
 
 #endif

Index: mail-storage.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/mail-storage.h,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- mail-storage.h	27 Jul 2003 03:12:13 -0000	1.54
+++ mail-storage.h	6 Aug 2003 20:15:32 -0000	1.55
@@ -267,6 +267,7 @@
 	struct mail_fetch_context *
 		(*fetch_init)(struct mailbox *box,
 			      enum mail_fetch_field wanted_fields,
+			      const char *const *wanted_headers,
 			      const char *messageset, int uidset);
 	/* Deinitialize fetch request. all_found is set to TRUE if all of the
 	   fetched messages were found (ie. not just deleted). */
@@ -377,6 +378,10 @@
 
 	/* Get value for single header field */
 	const char *(*get_header)(struct mail *mail, const char *field);
+	/* Returns partial headers which contain _at least_ the given fields,
+	   but it may contain others as well. */
+	struct istream *(*get_headers)(struct mail *mail,
+				       const char *const minimum_fields[]);
 
 	/* Returns the parsed address for given header field. */
 	const struct message_address *(*get_address)(struct mail *mail,

Index: proxy-mailbox.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/proxy-mailbox.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- proxy-mailbox.c	26 Jul 2003 18:23:10 -0000	1.1
+++ proxy-mailbox.c	6 Aug 2003 20:15:32 -0000	1.2
@@ -56,11 +56,13 @@
 
 static struct mail_fetch_context *
 _fetch_init(struct mailbox *box, enum mail_fetch_field wanted_fields,
+	    const char *const *wanted_headers,
 	    const char *messageset, int uidset)
 {
 	struct proxy_mailbox *p = (struct proxy_mailbox *) box;
 
-	return p->box->fetch_init(p->box, wanted_fields, messageset, uidset);
+	return p->box->fetch_init(p->box, wanted_fields, wanted_headers,
+				  messageset, uidset);
 }
 
 static struct mail *_fetch_uid(struct mailbox *box, unsigned int uid,



More information about the dovecot-cvs mailing list