[dovecot-cvs] dovecot/src/lib-imap imap-bodystructure.c, 1.46, 1.47 imap-bodystructure.h, 1.9, 1.10

cras at dovecot.org cras at dovecot.org
Thu Jul 8 23:26:17 EEST 2004


Update of /home/cvs/dovecot/src/lib-imap
In directory talvi:/tmp/cvs-serv1384/lib-imap

Modified Files:
	imap-bodystructure.c imap-bodystructure.h 
Log Message:
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
getting better..



Index: imap-bodystructure.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-bodystructure.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- imap-bodystructure.c	21 Sep 2003 16:21:37 -0000	1.46
+++ imap-bodystructure.c	8 Jul 2004 20:26:15 -0000	1.47
@@ -36,9 +36,6 @@
 	unsigned int charset_found:1;
 };
 
-static void part_write_bodystructure(struct message_part *part,
-				     string_t *str, int extended);
-
 static void parse_content_type(const unsigned char *value, size_t value_len,
 			       void *context)
 {
@@ -294,7 +291,7 @@
 	}
 
 	if (part->children != NULL)
-		part_write_bodystructure(part->children, str, extended);
+		imap_bodystructure_write(part->children, str, extended);
 	else {
 		/* no parts in multipart message,
 		   that's not allowed. write a single
@@ -416,7 +413,7 @@
 		imap_envelope_write_part_data(env_data, str);
 		str_append(str, ") ");
 
-		part_write_bodystructure(part->children, str, extended);
+		imap_bodystructure_write(part->children, str, extended);
 		str_printfa(str, " %u", part->body_size.lines);
 	}
 
@@ -459,37 +456,27 @@
 	}
 }
 
-static void part_write_bodystructure(struct message_part *part,
-				     string_t *str, int extended)
+void imap_bodystructure_write(struct message_part *part,
+			      string_t *dest, int extended)
 {
 	i_assert(part->parent != NULL || part->next == NULL);
 
 	while (part != NULL) {
 		if (part->parent != NULL)
-			str_append_c(str, '(');
+			str_append_c(dest, '(');
 
 		if (part->flags & MESSAGE_PART_FLAG_MULTIPART)
-			part_write_body_multipart(part, str, extended);
+			part_write_body_multipart(part, dest, extended);
 		else
-			part_write_body(part, str, extended);
+			part_write_body(part, dest, extended);
 
 		if (part->parent != NULL)
-			str_append_c(str, ')');
+			str_append_c(dest, ')');
 
 		part = part->next;
 	}
 }
 
-const char *imap_bodystructure_parse_finish(struct message_part *root,
-					    int extended)
-{
-	string_t *str;
-
-	str = t_str_new(2048);
-	part_write_bodystructure(root, str, extended);
-	return str_c(str);
-}
-
 static int str_append_imap_arg(string_t *str, const struct imap_arg *arg)
 {
 	switch (arg->type) {
@@ -645,35 +632,27 @@
 	return TRUE;
 }
 
-const char *imap_body_parse_from_bodystructure(const char *bodystructure)
+int imap_body_parse_from_bodystructure(const char *bodystructure,
+				       string_t *dest)
 {
 	struct istream *input;
 	struct imap_parser *parser;
 	struct imap_arg *args;
-	string_t *str;
-	const char *value;
-	size_t len;
 	int ret;
 
-	len = strlen(bodystructure);
-	str = t_str_new(len);
-
 	input = i_stream_create_from_data(pool_datastack_create(),
-					  bodystructure, len);
+					  bodystructure, strlen(bodystructure));
 	(void)i_stream_read(input);
 
 	parser = imap_parser_create(input, NULL, (size_t)-1);
 	ret = imap_parser_finish_line(parser, 0, IMAP_PARSE_FLAG_NO_UNESCAPE |
 				      IMAP_PARSE_FLAG_LITERAL_TYPE, &args);
-	if (ret <= 0 || !imap_parse_bodystructure_args(args, str))
-		value = NULL;
-	else
-		value = str_c(str);
+	ret = ret > 0 && imap_parse_bodystructure_args(args, dest);
 
-	if (value == NULL)
+	if (!ret)
 		i_error("Error parsing IMAP bodystructure: %s", bodystructure);
 
 	imap_parser_destroy(parser);
 	i_stream_unref(input);
-	return value;
+	return ret;
 }

Index: imap-bodystructure.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-bodystructure.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- imap-bodystructure.h	20 Aug 2003 02:51:30 -0000	1.9
+++ imap-bodystructure.h	8 Jul 2004 20:26:15 -0000	1.10
@@ -8,10 +8,11 @@
 void imap_bodystructure_parse_header(pool_t pool, struct message_part *part,
 				     struct message_header_line *hdr);
 
-const char *imap_bodystructure_parse_finish(struct message_part *root,
-					    int extended);
+void imap_bodystructure_write(struct message_part *part,
+			      string_t *dest, int extended);
 
 /* Return BODY part from BODYSTRUCTURE */
-const char *imap_body_parse_from_bodystructure(const char *bodystructure);
+int imap_body_parse_from_bodystructure(const char *bodystructure,
+				       string_t *dest);
 
 #endif



More information about the dovecot-cvs mailing list