[dovecot-cvs] dovecot/src/lib-mail message-address.c,1.1,1.2 message-address.h,1.1,1.2 message-body-search.c,1.9,1.10 message-body-search.h,1.4,1.5 message-date.c,1.5,1.6 message-date.h,1.1,1.2 message-parser.h,1.16,1.17 message-send.c,1.14,1.15 Message-Id: <20030120145253.E1EF4238CB@danu.procontrol.fi>
cras at procontrol.fi
cras at procontrol.fi
Mon Jan 20 16:52:53 EET 2003
- Previous message: [dovecot-cvs] dovecot/src/imap imap-fetch-body-section.c,NONE,1.1 imap-fetch.c,NONE,1.1 imap-fetch.h,NONE,1.1 imap-search.c,NONE,1.1 imap-search.h,NONE,1.1 imap-sort.c,NONE,1.1 imap-sort.h,NONE,1.1 imap-thread.c,NONE,1.1 imap-thread.h,NONE,1.1 Makefile.am,1.10,1.11 Message-Id: <20030120145253.72E4723837@danu.procontrol.fi>
- Next message: [dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-copy.c,1.18,1.19 maildir-save.c,1.14,1.15 maildir-storage.c,1.22,1.23 maildir-storage.h,1.10,1.11
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/dovecot/src/lib-mail
In directory danu:/tmp/cvs-serv7093/lib-mail
Modified Files:
message-address.c message-address.h message-body-search.c
message-body-search.h message-date.c message-date.h
message-parser.h message-send.c message-send.h message-size.h
message-tokenize.h
Log Message:
mail-storage.h interface changes, affects pretty much everything.
FETCH, SEARCH, SORT and THREAD handling were pretty much moved from
lib-storage/ to imap/ so adding non-index storages would be much easier now.
Also POP3 server can now be easily implemented with lib-storage.
Not too well tested, and at least one major problem: partial fetching is
_slow_.
Index: message-address.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-address.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- message-address.c 5 Jan 2003 13:09:52 -0000 1.1
+++ message-address.c 20 Jan 2003 14:52:51 -0000 1.2
@@ -19,7 +19,8 @@
}
struct message_address *
-message_address_parse(pool_t pool, const unsigned char *data, size_t size)
+message_address_parse(pool_t pool, const unsigned char *data, size_t size,
+ unsigned int max_addresses)
{
static const enum message_token stop_tokens_init[] =
{ ',', '@', '<', ':', TOKEN_LAST };
@@ -74,8 +75,11 @@
ingroup = FALSE; len = 0;
stop_tokens = stop_tokens_init;
+ if (max_addresses == 0)
+ max_addresses = (unsigned int)-1;
+
next_phrase = mailbox; stop = FALSE;
- while (!stop) {
+ while (!stop && max_addresses > 0) {
if (next_phrase == name && str_len(name) > 0) {
/* continuing previously started name,
separate it from us with space */
@@ -101,6 +105,7 @@
if (str_len(mailbox) > 0 || str_len(domain) > 0 ||
str_len(route) > 0 || str_len(name) > 0) {
addr = new_address(pool, &next_addr);
+ max_addresses--;
addr->mailbox = p_strdup(pool, str_c(mailbox));
addr->domain = str_len(domain) == 0 ? NULL :
p_strdup(pool, str_c(domain));
@@ -115,6 +120,7 @@
/* end of group - add end of group marker */
ingroup = FALSE;
(void)new_address(pool, &next_addr);
+ max_addresses--;
}
if (token == TOKEN_LAST) {
@@ -187,6 +193,7 @@
case ':':
/* beginning of group */
addr = new_address(pool, &next_addr);
+ max_addresses--;
addr->name = p_strdup(pool, str_c(mailbox));
str_truncate(mailbox, 0);
@@ -210,3 +217,61 @@
return first_addr;
}
+void message_address_write(string_t *str, const struct message_address *addr)
+{
+ int first = TRUE, in_group = FALSE;
+
+ /* a) mailbox at domain
+ b) name <@route:mailbox at domain>
+ c) group: .. ; */
+
+ while (addr != NULL) {
+ if (first)
+ first = FALSE;
+ else
+ str_append(str, ", ");
+
+ if (addr->mailbox == NULL && addr->domain == NULL) {
+ if (!in_group) {
+ if (addr->name != NULL)
+ str_append(str, addr->name);
+ str_append(str, ": ");
+ first = TRUE;
+ } else {
+ i_assert(addr->name == NULL);
+
+ /* cut out the ", " */
+ str_truncate(str, str_len(str)-2);
+ str_append_c(str, ';');
+ }
+
+ in_group = !in_group;
+ } else if ((addr->name == NULL || *addr->name == '\0') &&
+ addr->route == NULL) {
+ i_assert(addr->mailbox != NULL);
+ i_assert(addr->domain != NULL);
+
+ str_append(str, addr->mailbox);
+ str_append_c(str, '@');
+ str_append(str, addr->domain);
+ } else {
+ i_assert(addr->mailbox != NULL);
+ i_assert(addr->domain != NULL);
+
+ if (addr->name != NULL) {
+ str_append(str, addr->name);
+ str_append_c(str, ' ');
+ }
+ str_append_c(str, '<');
+ if (addr->route != NULL) {
+ str_append_c(str, '@');
+ str_append(str, addr->route);
+ str_append_c(str, ':');
+ }
+ str_append(str, addr->mailbox);
+ str_append_c(str, '@');
+ str_append(str, addr->domain);
+ str_append_c(str, '>');
+ }
+ }
+}
Index: message-address.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-address.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- message-address.h 5 Jan 2003 13:09:52 -0000 1.1
+++ message-address.h 20 Jan 2003 14:52:51 -0000 1.2
@@ -1,13 +1,22 @@
#ifndef __MESSAGE_ADDRESS_H
#define __MESSAGE_ADDRESS_H
+/* group: ... ; will be stored like:
+ {name = "group", NULL, NULL, NULL}, ..., {NULL, NULL, NULL, NULL}
+*/
struct message_address {
struct message_address *next;
const char *name, *route, *mailbox, *domain;
};
+/* data and size are passed directly to message_tokenize_init(), so (size_t)-1
+ can be given if data is \0 terminated. If there's more than max_addresses,
+ the rest are skipped. Setting max_addresses to 0 disables this. */
struct message_address *
-message_address_parse(pool_t pool, const unsigned char *data, size_t size);
+message_address_parse(pool_t pool, const unsigned char *data, size_t size,
+ unsigned int max_addresses);
+
+void message_address_write(string_t *str, const struct message_address *addr);
#endif
Index: message-body-search.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-body-search.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- message-body-search.c 5 Jan 2003 13:09:52 -0000 1.9
+++ message-body-search.c 20 Jan 2003 14:52:51 -0000 1.10
@@ -255,7 +255,7 @@
static int message_search_body(struct part_search_context *ctx,
struct istream *input,
- struct message_part *part)
+ const struct message_part *part)
{
const unsigned char *data;
buffer_t *decodebuf;
@@ -368,7 +368,7 @@
static int message_body_search_ctx(struct body_search_context *ctx,
struct istream *input,
- struct message_part *part)
+ const struct message_part *part)
{
struct part_search_context part_ctx;
int found;
@@ -410,7 +410,7 @@
int message_body_search(const char *key, const char *charset,
int *unknown_charset, struct istream *input,
- struct message_part *part, int search_header)
+ const struct message_part *part, int search_header)
{
struct body_search_context ctx;
Index: message-body-search.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-body-search.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- message-body-search.h 5 Jan 2003 13:09:52 -0000 1.4
+++ message-body-search.h 20 Jan 2003 14:52:51 -0000 1.5
@@ -9,6 +9,6 @@
specific charset but is compared to message data without any translation. */
int message_body_search(const char *key, const char *charset,
int *unknown_charset, struct istream *input,
- struct message_part *part, int search_header);
+ const struct message_part *part, int search_header);
#endif
Index: message-date.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-date.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- message-date.c 13 Jan 2003 20:00:38 -0000 1.5
+++ message-date.c 20 Jan 2003 14:52:51 -0000 1.6
@@ -213,7 +213,8 @@
return TRUE;
}
-int message_date_parse(const char *data, time_t *time, int *timezone_offset)
+int message_date_parse(const unsigned char *data, size_t size,
+ time_t *time, int *timezone_offset)
{
struct message_tokenizer *ctx;
int ret;
@@ -221,8 +222,7 @@
if (data == NULL || *data == '\0')
return FALSE;
- ctx = message_tokenize_init((const unsigned char *) data, (size_t)-1,
- NULL, NULL);
+ ctx = message_tokenize_init(data, size, NULL, NULL);
ret = mail_date_parse_tokens(ctx, time, timezone_offset);
message_tokenize_deinit(ctx);
Index: message-date.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-date.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- message-date.h 5 Jan 2003 13:09:52 -0000 1.1
+++ message-date.h 20 Jan 2003 14:52:51 -0000 1.2
@@ -3,7 +3,8 @@
/* Parses RFC2822 date/time string. timezone_offset is filled with the
timezone's difference to UTC in minutes. */
-int message_date_parse(const char *data, time_t *time, int *timezone_offset);
+int message_date_parse(const unsigned char *data, size_t size,
+ time_t *time, int *timezone_offset);
/* Create RFC2822 date/time string from given time in local timezone. */
const char *message_date_create(time_t time);
Index: message-parser.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-parser.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- message-parser.h 11 Jan 2003 19:55:56 -0000 1.16
+++ message-parser.h 20 Jan 2003 14:52:51 -0000 1.17
@@ -1,6 +1,8 @@
#ifndef __MESSAGE_PARSER_H
#define __MESSAGE_PARSER_H
+#include "message-size.h"
+
#define IS_LWSP(c) \
((c) == ' ' || (c) == '\t')
@@ -14,12 +16,6 @@
/* content-transfer-encoding: binary */
MESSAGE_PART_FLAG_BINARY = 0x10
-};
-
-struct message_size {
- uoff_t physical_size;
- uoff_t virtual_size;
- unsigned int lines;
};
struct message_part {
Index: message-send.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-send.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- message-send.c 5 Jan 2003 13:09:52 -0000 1.14
+++ message-send.c 20 Jan 2003 14:52:51 -0000 1.15
@@ -8,7 +8,7 @@
#include "message-size.h"
int message_send(struct ostream *output, struct istream *input,
- struct message_size *msg_size,
+ const struct message_size *msg_size,
uoff_t virtual_skip, uoff_t max_virtual_size)
{
const unsigned char *msg;
Index: message-send.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-send.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- message-send.h 5 Jan 2003 13:09:52 -0000 1.7
+++ message-send.h 20 Jan 2003 14:52:51 -0000 1.8
@@ -8,7 +8,7 @@
use (uoff_t)-1. Remember that if input begins with LF, CR is inserted
before it unless virtual_skip = 1. Returns TRUE if successful. */
int message_send(struct ostream *output, struct istream *input,
- struct message_size *msg_size,
+ const struct message_size *msg_size,
uoff_t virtual_skip, uoff_t max_virtual_size);
#endif
Index: message-size.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-size.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- message-size.h 5 Jan 2003 13:09:52 -0000 1.8
+++ message-size.h 20 Jan 2003 14:52:51 -0000 1.9
@@ -1,7 +1,11 @@
#ifndef __MESSAGE_SIZE_H
#define __MESSAGE_SIZE_H
-struct message_size;
+struct message_size {
+ uoff_t physical_size;
+ uoff_t virtual_size;
+ unsigned int lines;
+};
/* Calculate size of message header. Leave the input point to first
character in body. */
Index: message-tokenize.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-tokenize.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- message-tokenize.h 11 Jan 2003 19:55:56 -0000 1.3
+++ message-tokenize.h 20 Jan 2003 14:52:51 -0000 1.4
@@ -34,9 +34,9 @@
char missing_char,
void *context);
-/* Tokenize the string. Returns NULL if string is empty. Memory for
- returned array is allocated from data stack. You don't have to use
- the tokens_count, since last token is always 0. */
+/* Initialize message tokenizer. data is parsed until \0 is found, or size
+ bytes has been parsed, so it's possible to give (size_t)-1 as size
+ if the string is \0 terminated. */
struct message_tokenizer *
message_tokenize_init(const unsigned char *data, size_t size,
message_tokenize_error_callback_t error_cb,
- Previous message: [dovecot-cvs] dovecot/src/imap imap-fetch-body-section.c,NONE,1.1 imap-fetch.c,NONE,1.1 imap-fetch.h,NONE,1.1 imap-search.c,NONE,1.1 imap-search.h,NONE,1.1 imap-sort.c,NONE,1.1 imap-sort.h,NONE,1.1 imap-thread.c,NONE,1.1 imap-thread.h,NONE,1.1 Makefile.am,1.10,1.11 Message-Id: <20030120145253.72E4723837@danu.procontrol.fi>
- Next message: [dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-copy.c,1.18,1.19 maildir-save.c,1.14,1.15 maildir-storage.c,1.22,1.23 maildir-storage.h,1.10,1.11
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list