[dovecot-cvs] dovecot/src/lib-imap Makefile.am,1.4,1.5 imap-envelope.c,1.14,1.15 imap-envelope.h,1.3,1.4

cras at procontrol.fi cras at procontrol.fi
Tue Dec 17 06:28:43 EET 2002


Update of /home/cvs/dovecot/src/lib-imap
In directory danu:/tmp/cvs-serv32695/src/lib-imap

Modified Files:
	Makefile.am imap-envelope.c imap-envelope.h 
Log Message:
Full not-too-well-tested support for SORT extension. Required a few
library interface changes.



Index: Makefile.am
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/Makefile.am,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Makefile.am	30 Sep 2002 21:18:12 -0000	1.4
+++ Makefile.am	17 Dec 2002 04:28:41 -0000	1.5
@@ -2,9 +2,11 @@
 
 INCLUDES = \
 	-I$(top_srcdir)/src/lib \
+	-I$(top_srcdir)/src/lib-charset \
 	-I$(top_srcdir)/src/lib-mail
 
 libimap_a_SOURCES = \
+	imap-base-subject.c \
 	imap-bodystructure.c \
 	imap-date.c \
 	imap-envelope.c \
@@ -15,6 +17,7 @@
 	imap-util.c
 
 noinst_HEADERS = \
+	imap-base-subject.h \
 	imap-bodystructure.h \
 	imap-date.h \
 	imap-envelope.h \

Index: imap-envelope.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-envelope.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- imap-envelope.c	9 Dec 2002 15:25:20 -0000	1.14
+++ imap-envelope.c	17 Dec 2002 04:28:41 -0000	1.15
@@ -210,21 +210,44 @@
 	return str->str;
 }
 
+static const char *imap_envelope_parse_first_mailbox(ImapArg *arg)
+{
+	/* ((name route mailbox domain) ...) */
+	if (arg->type != IMAP_ARG_LIST)
+		return NULL;
+
+	if (arg->data.list->size == 0)
+		return "";
+
+	arg = arg->data.list->args;
+	if (arg->type != IMAP_ARG_LIST || arg->data.list->size != 4)
+		return NULL;
+
+	return t_strdup(arg->data.list->args[2].data.str);
+}
+
 static const char *
 imap_envelope_parse_arg(ImapArg *arg, ImapEnvelopeField field,
-			const char *envelope)
+			const char *envelope, ImapEnvelopeResult result)
 {
-	const char *value;
+	const char *value = NULL;
 
 	if (arg->type == IMAP_ARG_NIL)
 		return "";
 
-	if (field >= IMAP_ENVELOPE_FROM && field <= IMAP_ENVELOPE_BCC)
-		value = imap_envelope_parse_address(arg);
-	else if (arg->type == IMAP_ARG_STRING || arg->type == IMAP_ARG_ATOM)
-		value = t_strdup(arg->data.str);
-	else
-		value = NULL;
+	switch (result) {
+	case IMAP_ENVELOPE_RESULT_STRING:
+		if (field >= IMAP_ENVELOPE_FROM && field <= IMAP_ENVELOPE_BCC)
+			value = imap_envelope_parse_address(arg);
+		else if (arg->type == IMAP_ARG_STRING || arg->type == IMAP_ARG_ATOM)
+			value = t_strdup(arg->data.str);
+		break;
+	case IMAP_ENVELOPE_RESULT_FIRST_MAILBOX:
+		i_assert(field >= IMAP_ENVELOPE_FROM &&
+			 field <= IMAP_ENVELOPE_BCC);
+		value = imap_envelope_parse_first_mailbox(arg);
+		break;
+	}
 
 	if (value == NULL) {
 		i_error("Invalid field %u in IMAP envelope: %s",
@@ -234,7 +257,8 @@
 	return value;
 }
 
-const char *imap_envelope_parse(const char *envelope, ImapEnvelopeField field)
+const char *imap_envelope_parse(const char *envelope, ImapEnvelopeField field,
+				ImapEnvelopeResult result)
 {
 	IStream *input;
 	ImapParser *parser;
@@ -251,7 +275,8 @@
 	(void)i_stream_read(input);
 	ret = imap_parser_read_args(parser, field+1, 0, &args);
 	if (ret > (int)field) {
-		value = imap_envelope_parse_arg(&args[field], field, envelope);
+		value = imap_envelope_parse_arg(&args[field], field,
+						envelope, result);
 	} else {
 		i_error("Error parsing IMAP envelope: %s", envelope);
 		value = NULL;

Index: imap-envelope.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-envelope.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- imap-envelope.h	11 Oct 2002 22:33:54 -0000	1.3
+++ imap-envelope.h	17 Dec 2002 04:28:41 -0000	1.4
@@ -19,6 +19,11 @@
 	IMAP_ENVELOPE_FIELDS
 } ImapEnvelopeField;
 
+typedef enum {
+	IMAP_ENVELOPE_RESULT_STRING,
+	IMAP_ENVELOPE_RESULT_FIRST_MAILBOX
+} ImapEnvelopeResult;
+
 /* Update envelope data based from given header field */
 void imap_envelope_parse_header(Pool pool, MessagePartEnvelopeData **data,
 				const char *name,
@@ -32,6 +37,7 @@
 
 /* Parse envelope and return specified field unquoted, or NULL if error
    occured. NILs are returned as "". */
-const char *imap_envelope_parse(const char *envelope, ImapEnvelopeField field);
+const char *imap_envelope_parse(const char *envelope, ImapEnvelopeField field,
+				ImapEnvelopeResult result);
 
 #endif




More information about the dovecot-cvs mailing list