[dovecot-cvs] dovecot/src/lib-imap imap-base-subject.c,1.2,1.3 imap-base-subject.h,1.1,1.2 imap-bodystructure.c,1.27,1.28 imap-bodystructure.h,1.5,1.6 imap-envelope.c,1.20,1.21 imap-envelope.h,1.7,1.8 imap-match.c,1.3,1.4 imap-match.h,1.3,1.4 Message-Id: <20030105130954.EB40E238C5@danu.procontrol.fi>

cras at procontrol.fi cras at procontrol.fi
Sun Jan 5 15:09:54 EET 2003


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

Modified Files:
	imap-base-subject.c imap-base-subject.h imap-bodystructure.c 
	imap-bodystructure.h imap-envelope.c imap-envelope.h 
	imap-match.c imap-match.h imap-message-cache.c 
	imap-message-cache.h imap-parser.c imap-parser.h imap-quote.c 
	imap-quote.h imap-util.c imap-util.h 
Log Message:
Naming style changes, finally got tired of most of the typedefs. Also the
previous enum -> macro change reverted so that we don't use the highest bit
anymore, that's incompatible with old indexes so they will be rebuilt.



Index: imap-base-subject.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-base-subject.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- imap-base-subject.c	4 Jan 2003 17:26:30 -0000	1.2
+++ imap-base-subject.c	5 Jan 2003 13:09:52 -0000	1.3
@@ -9,7 +9,7 @@
 static int header_decode(const unsigned char *data, size_t size,
 			 const char *charset, void *context)
 {
-	Buffer *buf = context;
+	buffer_t *buf = context;
 	const char *utf8_str;
 	unsigned char *buf_data;
 	size_t i, used_size;
@@ -19,7 +19,8 @@
 		buffer_append(buf, data, size);
 	} else {
 		t_push();
-		utf8_str = charset_to_utf8_string(charset, NULL, data, size, &size);
+		utf8_str = charset_to_utf8_string(charset, NULL, data,
+						  size, &size);
 		if (utf8_str == NULL)
 			size = 0;
 		else
@@ -40,7 +41,7 @@
 	return TRUE;
 }
 
-static void pack_whitespace(Buffer *buf)
+static void pack_whitespace(buffer_t *buf)
 {
 	char *data, *dest;
 	int last_lwsp;
@@ -78,7 +79,7 @@
 	buffer_set_used_size(buf, (size_t) (dest - data)+1);
 }
 
-static void remove_subj_trailers(Buffer *buf)
+static void remove_subj_trailers(buffer_t *buf)
 {
 	const char *data;
 	size_t orig_size, size;
@@ -125,7 +126,7 @@
 	return TRUE;
 }
 
-static int remove_subj_leader(Buffer *buf)
+static int remove_subj_leader(buffer_t *buf)
 {
 	const char *data, *orig_data;
 	int ret = FALSE;
@@ -175,7 +176,7 @@
 	return TRUE;
 }
 
-static int remove_blob_when_nonempty(Buffer *buf)
+static int remove_blob_when_nonempty(buffer_t *buf)
 {
 	const char *data, *orig_data;
 
@@ -189,7 +190,7 @@
 	return FALSE;
 }
 
-static int remove_subj_fwd_hdr(Buffer *buf)
+static int remove_subj_fwd_hdr(buffer_t *buf)
 {
 	const char *data;
 	size_t size;
@@ -212,9 +213,9 @@
 	return TRUE;
 }
 
-const char *imap_get_base_subject_cased(Pool pool, const char *subject)
+const char *imap_get_base_subject_cased(pool_t pool, const char *subject)
 {
-	Buffer *buf;
+	buffer_t *buf;
 	size_t subject_len;
 	int found;
 

Index: imap-base-subject.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-base-subject.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- imap-base-subject.h	17 Dec 2002 04:33:38 -0000	1.1
+++ imap-base-subject.h	5 Jan 2003 13:09:52 -0000	1.2
@@ -4,6 +4,6 @@
 /* Returns the base subject of the given string, according to
    draft-ietf-imapext-sort-10. String is returned so that it's suitable for
    strcmp() comparing with another base subject. */
-const char *imap_get_base_subject_cased(Pool pool, const char *subject);
+const char *imap_get_base_subject_cased(pool_t pool, const char *subject);
 
 #endif

Index: imap-bodystructure.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-bodystructure.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- imap-bodystructure.c	4 Jan 2003 17:26:30 -0000	1.27
+++ imap-bodystructure.c	5 Jan 2003 13:09:52 -0000	1.28
@@ -3,9 +3,9 @@
 #include "lib.h"
 #include "istream.h"
 #include "str.h"
-#include "rfc822-tokenize.h"
 #include "message-parser.h"
 #include "message-content-parser.h"
+#include "message-tokenize.h"
 #include "imap-parser.h"
 #include "imap-quote.h"
 #include "imap-envelope.h"
@@ -14,9 +14,9 @@
 #define EMPTY_BODYSTRUCTURE \
         "(\"text\" \"plain\" (\"charset\" \"us-ascii\") NIL NIL \"7bit\" 0 0)"
 
-typedef struct {
-	Pool pool;
-	String *str;
+struct message_part_body_data {
+	pool_t pool;
+	string_t *str;
 	char *content_type, *content_subtype;
 	char *content_type_params;
 	char *content_transfer_encoding;
@@ -27,16 +27,16 @@
 	char *content_md5;
 	char *content_language;
 
-	MessagePartEnvelopeData *envelope;
-} MessagePartBodyData;
+	struct message_part_envelope_data *envelope;
+};
 
-static void part_write_bodystructure(MessagePart *part, String *str,
-				     int extended);
+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)
 {
-        MessagePartBodyData *data = context;
+        struct message_part_body_data *data = context;
 	size_t i;
 
 	for (i = 0; i < value_len; i++) {
@@ -62,7 +62,7 @@
 				   int value_quoted __attr_unused__,
 				   void *context)
 {
-        MessagePartBodyData *data = context;
+        struct message_part_body_data *data = context;
 
 	if (str_len(data->str) != 0)
 		str_append_c(data->str, ' ');
@@ -79,7 +79,7 @@
 static void parse_content_transfer_encoding(const unsigned char *value,
 					    size_t value_len, void *context)
 {
-        MessagePartBodyData *data = context;
+        struct message_part_body_data *data = context;
 
 	data->content_transfer_encoding =
 		imap_quote_value(data->pool, value, value_len);
@@ -88,29 +88,29 @@
 static void parse_content_disposition(const unsigned char *value,
 				      size_t value_len, void *context)
 {
-        MessagePartBodyData *data = context;
+        struct message_part_body_data *data = context;
 
 	data->content_disposition =
 		imap_quote_value(data->pool, value, value_len);
 }
 
 static void parse_content_language(const unsigned char *value, size_t value_len,
-				   MessagePartBodyData *data)
+				   struct message_part_body_data *data)
 {
-	Rfc822TokenizeContext *ctx;
-        Rfc822Token token;
-	String *str;
+	struct message_tokenizer *tok;
+        enum message_token token;
+	string_t *str;
 	int quoted;
 
 	/* Content-Language: en-US, az-arabic (comments allowed) */
 
-	ctx = rfc822_tokenize_init(value, value_len, NULL, NULL);
+	tok = message_tokenize_init(value, value_len, NULL, NULL);
 
 	t_push();
 	str = t_str_new(256);
 
 	quoted = FALSE;
-	while ((token = rfc822_tokenize_next(ctx)) != TOKEN_LAST) {
+	while ((token = message_tokenize_next(tok)) != TOKEN_LAST) {
 		if (token == ',') {
 			/* list separator */
 			if (quoted) {
@@ -131,8 +131,8 @@
 			if (!IS_TOKEN_STRING(token))
 				str_append_c(str, token);
 			else {
-				value = rfc822_tokenize_get_value(ctx,
-								  &value_len);
+				value = message_tokenize_get_value(tok,
+								   &value_len);
 				str_append_n(str, value, value_len);
 			}
 		}
@@ -145,16 +145,16 @@
 
 	t_pop();
 
-	rfc822_tokenize_deinit(ctx);
+	message_tokenize_deinit(tok);
 }
 
-static void parse_header(MessagePart *part,
+static void parse_header(struct message_part *part,
 			 const unsigned char *name, size_t name_len,
 			 const unsigned char *value, size_t value_len,
 			 void *context)
 {
-	Pool pool = context;
-	MessagePartBodyData *part_data;
+	pool_t pool = context;
+	struct message_part_body_data *part_data;
 	int parent_rfc822;
 
 	parent_rfc822 = part->parent != NULL &&
@@ -166,7 +166,7 @@
 	if (part->context == NULL) {
 		/* initialize message part data */
 		part->context = part_data =
-			p_new(pool, MessagePartBodyData, 1);
+			p_new(pool, struct message_part_body_data, 1);
 		part_data->pool = pool;
 	}
 	part_data = part->context;
@@ -245,8 +245,8 @@
 	t_pop();
 }
 
-static void part_parse_headers(MessagePart *part, IStream *input,
-			       uoff_t start_offset, Pool pool)
+static void part_parse_headers(struct message_part *part, struct istream *input,
+			       uoff_t start_offset, pool_t pool)
 {
 	while (part != NULL) {
 		/* note that we want to parse the header of all
@@ -266,14 +266,14 @@
 	}
 }
 
-static void part_write_body_multipart(MessagePart *part, String *str,
-				      int extended)
+static void part_write_body_multipart(struct message_part *part,
+				      string_t *str, int extended)
 {
-	MessagePartBodyData *data = part->context;
+	struct message_part_body_data *data = part->context;
 
 	if (data == NULL) {
 		/* there was no content headers, use an empty structure */
-		data = t_new(MessagePartBodyData, 1);
+		data = t_new(struct message_part_body_data, 1);
 	}
 
 	if (part->children != NULL)
@@ -332,13 +332,14 @@
 	}
 }
 
-static void part_write_body(MessagePart *part, String *str, int extended)
+static void part_write_body(struct message_part *part,
+			    string_t *str, int extended)
 {
-	MessagePartBodyData *data = part->context;
+	struct message_part_body_data *data = part->context;
 
 	if (data == NULL) {
 		/* there was no content headers, use an empty structure */
-		data = t_new(MessagePartBodyData, 1);
+		data = t_new(struct message_part_body_data, 1);
 	}
 
 	/* "content type" "subtype" */
@@ -367,7 +368,7 @@
 		str_printfa(str, " %u", part->body_size.lines);
 	} else if (part->flags & MESSAGE_PART_FLAG_MESSAGE_RFC822) {
 		/* message/rfc822 contains envelope + body + line count */
-		MessagePartBodyData *child_data;
+		struct message_part_body_data *child_data;
 
 		i_assert(part->children != NULL);
 		i_assert(part->children->next == NULL);
@@ -428,8 +429,8 @@
 	}
 }
 
-static void part_write_bodystructure(MessagePart *part, String *str,
-				     int extended)
+static void part_write_bodystructure(struct message_part *part,
+				     string_t *str, int extended)
 {
 	i_assert(part->parent != NULL || part->next == NULL);
 
@@ -449,17 +450,18 @@
 	}
 }
 
-static const char *part_get_bodystructure(MessagePart *part, int extended)
+static const char *part_get_bodystructure(struct message_part *part,
+					  int extended)
 {
-	String *str;
+	string_t *str;
 
 	str = t_str_new(2048);
 	part_write_bodystructure(part, str, extended);
 	return str_c(str);
 }
 
-const char *imap_part_get_bodystructure(Pool pool, MessagePart **part,
-					IStream *input, int extended)
+const char *imap_part_get_bodystructure(pool_t pool, struct message_part **part,
+					struct istream *input, int extended)
 {
 	uoff_t start_offset;
 
@@ -473,7 +475,7 @@
 	return part_get_bodystructure(*part, extended);
 }
 
-static int imap_write_list(const ImapArg *args, String *str)
+static int imap_write_list(const struct imap_arg *args, string_t *str)
 {
 	/* don't do any typechecking, just write it out */
 	str_append_c(str, '(');
@@ -506,10 +508,11 @@
 	return TRUE;
 }
 
-static int imap_parse_bodystructure_args(const ImapArg *args, String *str)
+static int imap_parse_bodystructure_args(const struct imap_arg *args,
+					 string_t *str)
 {
-	ImapArg *subargs;
-	ImapArgList *list;
+	struct imap_arg *subargs;
+	struct imap_arg_list *list;
 	int i, multipart, text, message_rfc822;
 
 	multipart = FALSE;
@@ -620,10 +623,10 @@
 
 const char *imap_body_parse_from_bodystructure(const char *bodystructure)
 {
-	IStream *input;
-	ImapParser *parser;
-	ImapArg *args;
-	String *str;
+	struct istream *input;
+	struct imap_parser *parser;
+	struct imap_arg *args;
+	string_t *str;
 	const char *value;
 	size_t len;
 	int ret;

Index: imap-bodystructure.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-bodystructure.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- imap-bodystructure.h	6 Dec 2002 01:09:22 -0000	1.5
+++ imap-bodystructure.h	5 Jan 2003 13:09:52 -0000	1.6
@@ -1,10 +1,12 @@
 #ifndef __IMAP_BODYSTRUCTURE_H
 #define __IMAP_BODYSTRUCTURE_H
 
+struct message_part;
+
 /* If *part is non-NULL, it's used as base for building the body structure.
-   Otherwise it's set to the root MessagePart and parsed. */
-const char *imap_part_get_bodystructure(Pool pool, MessagePart **part,
-					IStream *input, int extended);
+   Otherwise it's set to the root message_part and parsed. */
+const char *imap_part_get_bodystructure(pool_t pool, struct message_part **part,
+					struct istream *input, int extended);
 
 /* Return BODY part from BODYSTRUCTURE */
 const char *imap_body_parse_from_bodystructure(const char *bodystructure);

Index: imap-envelope.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-envelope.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- imap-envelope.c	4 Jan 2003 17:26:30 -0000	1.20
+++ imap-envelope.c	5 Jan 2003 13:09:52 -0000	1.21
@@ -3,89 +3,82 @@
 #include "lib.h"
 #include "istream.h"
 #include "str.h"
-#include "rfc822-address.h"
+#include "message-address.h"
 #include "imap-parser.h"
 #include "imap-envelope.h"
 #include "imap-quote.h"
 
-struct _MessagePartEnvelopeData {
-	Pool pool;
+struct message_part_envelope_data {
+	pool_t pool;
 
 	char *date, *subject;
-	Rfc822Address *from, *sender, *reply_to;
-	Rfc822Address *to, *cc, *bcc;
+	struct message_address *from, *sender, *reply_to;
+	struct message_address *to, *cc, *bcc;
 
 	char *in_reply_to, *message_id;
 };
 
-static Rfc822Address *parse_address(Pool pool, const unsigned char *value,
-				    size_t value_len)
-{
-	return rfc822_address_parse(pool, value, value_len);
-}
-
-void imap_envelope_parse_header(Pool pool, MessagePartEnvelopeData **data,
+void imap_envelope_parse_header(pool_t pool,
+				struct message_part_envelope_data **data,
 				const unsigned char *name, size_t name_len,
 				const unsigned char *value, size_t value_len)
 {
+	struct message_part_envelope_data *d;
+
 	if (*data == NULL) {
-		*data = p_new(pool, MessagePartEnvelopeData, 1);
+		*data = p_new(pool, struct message_part_envelope_data, 1);
 		(*data)->pool = pool;
 	}
+	d = *data;
 
 	t_push();
 
 	switch (name_len) {
 	case 2:
-		if (memcasecmp(name, "To", 2) == 0 && (*data)->to == NULL)
-			(*data)->to = parse_address(pool, value, value_len);
-		else if (memcasecmp(name, "Cc", 2) == 0 && (*data)->cc == NULL)
-			(*data)->cc = parse_address(pool, value, value_len);
+		if (memcasecmp(name, "To", 2) == 0 && d->to == NULL)
+			d->to = message_address_parse(pool, value, value_len);
+		else if (memcasecmp(name, "Cc", 2) == 0 && d->cc == NULL)
+			d->cc = message_address_parse(pool, value, value_len);
 		break;
 	case 3:
-		if (memcasecmp(name, "Bcc", 3) == 0 && (*data)->bcc == NULL)
-			(*data)->bcc = parse_address(pool, value, value_len);
+		if (memcasecmp(name, "Bcc", 3) == 0 && d->bcc == NULL)
+			d->bcc = message_address_parse(pool, value, value_len);
 		break;
 	case 4:
-		if (memcasecmp(name, "From", 4) == 0 && (*data)->from == NULL)
-			(*data)->from = parse_address(pool, value, value_len);
-		else if (memcasecmp(name, "Date", 4) == 0 &&
-			 (*data)->date == NULL) {
-			(*data)->date = imap_quote_value(pool, value,
-							 value_len);
-		}
+		if (memcasecmp(name, "From", 4) == 0 && d->from == NULL)
+			d->from = message_address_parse(pool, value, value_len);
+		else if (memcasecmp(name, "Date", 4) == 0 && d->date == NULL)
+			d->date = imap_quote_value(pool, value, value_len);
 		break;
 	case 6:
-		if (memcasecmp(name, "Sender", 6) == 0 &&
-		    (*data)->sender == NULL)
-			(*data)->sender = parse_address(pool, value, value_len);
+		if (memcasecmp(name, "Sender", 6) == 0 && d->sender == NULL) {
+			d->sender = message_address_parse(pool, value,
+							  value_len);
+		}
 		break;
 	case 7:
-		if (memcasecmp(name, "Subject", 7) == 0 &&
-		    (*data)->subject == NULL) {
-			(*data)->subject = imap_quote_value(pool, value,
-							    value_len);
-		}
+		if (memcasecmp(name, "Subject", 7) == 0 && d->subject == NULL)
+			d->subject = imap_quote_value(pool, value, value_len);
 		break;
 	case 8:
 		if (memcasecmp(name, "Reply-To", 8) == 0 &&
-		    (*data)->reply_to == NULL) {
-			(*data)->reply_to = parse_address(pool, value,
-							  value_len);
+		    d->reply_to == NULL) {
+			d->reply_to =
+				message_address_parse(pool, value, value_len);
 		}
 		break;
 	case 10:
 		if (memcasecmp(name, "Message-Id", 10) == 0 &&
-		    (*data)->message_id == NULL) {
-			(*data)->message_id = imap_quote_value(pool, value,
-							       value_len);
+		    d->message_id == NULL) {
+			d->message_id =
+				imap_quote_value(pool, value, value_len);
 		}
 		break;
 	case 11:
 		if (memcasecmp(name, "In-Reply-To", 11) == 0 &&
-		    (*data)->in_reply_to == NULL) {
-			(*data)->in_reply_to = imap_quote_value(pool, value,
-								value_len);
+		    d->in_reply_to == NULL) {
+			d->in_reply_to =
+				imap_quote_value(pool, value, value_len);
 		}
 		break;
 	}
@@ -93,7 +86,7 @@
 	t_pop();
 }
 
-static void imap_write_address(String *str, Rfc822Address *addr)
+static void imap_write_address(string_t *str, struct message_address *addr)
 {
 	if (addr == NULL) {
 		str_append(str, "NIL");
@@ -117,8 +110,8 @@
 	str_append_c(str, ')');
 }
 
-void imap_envelope_write_part_data(MessagePartEnvelopeData *data,
-				   String *str)
+void imap_envelope_write_part_data(struct message_part_envelope_data *data,
+				   string_t *str)
 {
 	str_append(str, NVL(data->date, "NIL"));
 	str_append_c(str, ' ');
@@ -143,18 +136,20 @@
 	str_append(str, NVL(data->message_id, "NIL"));
 }
 
-const char *imap_envelope_get_part_data(MessagePartEnvelopeData *data)
+const char *
+imap_envelope_get_part_data(struct message_part_envelope_data *data)
 {
-	String *str;
+	string_t *str;
 
 	str = t_str_new(2048);
         imap_envelope_write_part_data(data, str);
 	return str_c(str);
 }
 
-static int imap_address_arg_append(ImapArg *arg, String *str, int *in_group)
+static int imap_address_arg_append(struct imap_arg *arg, string_t *str,
+				   int *in_group)
 {
-	ImapArgList *list;
+	struct imap_arg_list *list;
 	const char *args[4];
 	int i;
 
@@ -220,10 +215,10 @@
 	return TRUE;
 }
 
-static const char *imap_envelope_parse_address(ImapArg *arg)
+static const char *imap_envelope_parse_address(struct imap_arg *arg)
 {
-	ImapArgList *list;
-	String *str;
+	struct imap_arg_list *list;
+	string_t *str;
 	size_t i;
 	int in_group;
 
@@ -242,9 +237,9 @@
 	return str_c(str);
 }
 
-static const char *imap_envelope_parse_first_mailbox(ImapArg *arg)
+static const char *imap_envelope_parse_first_mailbox(struct imap_arg *arg)
 {
-	ImapArgList *list;
+	struct imap_arg_list *list;
 
 	/* ((name route mailbox domain) ...) */
 	if (arg->type != IMAP_ARG_LIST)
@@ -265,9 +260,10 @@
 	return t_strdup(imap_arg_string(&list->args[2]));
 }
 
-static int imap_envelope_parse_arg(ImapArg *arg, ImapEnvelopeField field,
+static int imap_envelope_parse_arg(struct imap_arg *arg,
+				   enum imap_envelope_field field,
 				   const char *envelope,
-				   ImapEnvelopeResult result_type,
+				   enum imap_envelope_result_type result_type,
 				   const char **result)
 {
 	const char *value = NULL;
@@ -278,13 +274,13 @@
 	}
 
 	switch (result_type) {
-	case IMAP_ENVELOPE_RESULT_STRING:
+	case IMAP_ENVELOPE_RESULT_TYPE_STRING:
 		if (field >= IMAP_ENVELOPE_FROM && field <= IMAP_ENVELOPE_BCC)
 			value = imap_envelope_parse_address(arg);
 		else
 			value = t_strdup(imap_arg_string(arg));
 		break;
-	case IMAP_ENVELOPE_RESULT_FIRST_MAILBOX:
+	case IMAP_ENVELOPE_RESULT_TYPE_FIRST_MAILBOX:
 		i_assert(field >= IMAP_ENVELOPE_FROM &&
 			 field <= IMAP_ENVELOPE_BCC);
 		value = imap_envelope_parse_first_mailbox(arg);
@@ -301,12 +297,13 @@
 	}
 }
 
-int imap_envelope_parse(const char *envelope, ImapEnvelopeField field,
-			ImapEnvelopeResult result_type, const char **result)
+int imap_envelope_parse(const char *envelope, enum imap_envelope_field field,
+			enum imap_envelope_result_type result_type,
+			const char **result)
 {
-	IStream *input;
-	ImapParser *parser;
-	ImapArg *args;
+	struct istream *input;
+	struct imap_parser *parser;
+	struct imap_arg *args;
 	int ret;
 
 	i_assert(field < IMAP_ENVELOPE_FIELDS);

Index: imap-envelope.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-envelope.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- imap-envelope.h	4 Jan 2003 17:26:30 -0000	1.7
+++ imap-envelope.h	5 Jan 2003 13:09:52 -0000	1.8
@@ -1,9 +1,7 @@
 #ifndef __IMAP_ENVELOPE_H
 #define __IMAP_ENVELOPE_H
 
-typedef struct _MessagePartEnvelopeData MessagePartEnvelopeData;
-
-typedef enum {
+enum imap_envelope_field {
 	/* NOTE: in the same order as listed in ENVELOPE */
 	IMAP_ENVELOPE_DATE = 0,
 	IMAP_ENVELOPE_SUBJECT,
@@ -17,27 +15,32 @@
 	IMAP_ENVELOPE_MESSAGE_ID,
 
 	IMAP_ENVELOPE_FIELDS
-} ImapEnvelopeField;
+};
 
-typedef enum {
-	IMAP_ENVELOPE_RESULT_STRING,
-	IMAP_ENVELOPE_RESULT_FIRST_MAILBOX
-} ImapEnvelopeResult;
+enum imap_envelope_result_type {
+	IMAP_ENVELOPE_RESULT_TYPE_STRING,
+	IMAP_ENVELOPE_RESULT_TYPE_FIRST_MAILBOX
+};
+
+struct message_part_envelope_data;
 
 /* Update envelope data based from given header field */
-void imap_envelope_parse_header(Pool pool, MessagePartEnvelopeData **data,
+void imap_envelope_parse_header(pool_t pool,
+				struct message_part_envelope_data **data,
 				const unsigned char *name, size_t name_len,
 				const unsigned char *value, size_t value_len);
 
 /* Write envelope to given string */
-void imap_envelope_write_part_data(MessagePartEnvelopeData *data,
-				   String *str);
+void imap_envelope_write_part_data(struct message_part_envelope_data *data,
+				   string_t *str);
 /* Return envelope. */
-const char *imap_envelope_get_part_data(MessagePartEnvelopeData *data);
+const char *
+imap_envelope_get_part_data(struct message_part_envelope_data *data);
 
 /* Parse envelope and store specified field to result. NIL is stored as NULL.
    Returns TRUE if successful. */
-int imap_envelope_parse(const char *envelope, ImapEnvelopeField field,
-			ImapEnvelopeResult result_type, const char **result);
+int imap_envelope_parse(const char *envelope, enum imap_envelope_field field,
+			enum imap_envelope_result_type result_type,
+			const char **result);
 
 #endif

Index: imap-match.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-match.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- imap-match.c	18 Dec 2002 15:15:41 -0000	1.3
+++ imap-match.c	5 Jan 2003 13:09:52 -0000	1.4
@@ -9,7 +9,7 @@
 
 #include <ctype.h>
 
-struct _ImapMatchGlob {
+struct imap_match_glob {
 	int inboxcase;
 	const char *inboxcase_end;
 
@@ -21,14 +21,15 @@
 static const char inbox[] = "INBOX";
 #define INBOXLEN (sizeof(inbox) - 1)
 
-ImapMatchGlob *imap_match_init(const char *mask, int inboxcase, char separator)
+struct imap_match_glob *imap_match_init(const char *mask, int inboxcase,
+					char separator)
 {
-	ImapMatchGlob *glob;
+	struct imap_match_glob *glob;
 	const char *p, *inboxp;
 	char *dst;
 
 	/* +1 from struct */
-	glob = t_malloc(sizeof(ImapMatchGlob) + strlen(mask));
+	glob = t_malloc(sizeof(struct imap_match_glob) + strlen(mask));
 	glob->sep_char = separator;
 
 	/* @UNSAFE: compress the mask */
@@ -85,7 +86,7 @@
 	return glob;
 }
 
-static inline int cmp_chr(const ImapMatchGlob *glob,
+static inline int cmp_chr(const struct imap_match_glob *glob,
 			  const char *data, char maskchr)
 {
 	return *data == maskchr ||
@@ -93,7 +94,7 @@
 		 i_toupper(*data) == i_toupper(maskchr));
 }
 
-static int match_sub(const ImapMatchGlob *glob, const char **data_p,
+static int match_sub(const struct imap_match_glob *glob, const char **data_p,
 		     const char **mask_p)
 {
 	const char *mask, *data;
@@ -149,7 +150,7 @@
 	return 1;
 }
 
-int imap_match(ImapMatchGlob *glob, const char *data)
+int imap_match(struct imap_match_glob *glob, const char *data)
 {
 	const char *mask;
 	int ret;

Index: imap-match.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-match.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- imap-match.h	18 Dec 2002 15:15:41 -0000	1.3
+++ imap-match.h	5 Jan 2003 13:09:52 -0000	1.4
@@ -1,14 +1,15 @@
 #ifndef __IMAP_MATCH_H
 #define __IMAP_MATCH_H
 
-typedef struct _ImapMatchGlob ImapMatchGlob;
+struct imap_match_glob;
 
 /* If inboxcase is TRUE, the "INBOX" string at the beginning of line is
    compared case-insensitively */
-ImapMatchGlob *imap_match_init(const char *mask, int inboxcase, char separator);
+struct imap_match_glob *imap_match_init(const char *mask, int inboxcase,
+					char separator);
 
 /* Returns 1 if matched, 0 if it didn't match, but could match with additional
    hierarchies, -1 if definitely didn't match */
-int imap_match(ImapMatchGlob *glob, const char *data);
+int imap_match(struct imap_match_glob *glob, const char *data);
 
 #endif

Index: imap-message-cache.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-message-cache.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- imap-message-cache.c	4 Jan 2003 17:26:30 -0000	1.31
+++ imap-message-cache.c	5 Jan 2003 13:09:52 -0000	1.32
@@ -19,18 +19,16 @@
 
 #define DEFAULT_MESSAGE_POOL_SIZE 4096
 
-typedef struct _CachedMessage CachedMessage;
-
-struct _CachedMessage {
-	CachedMessage *next;
+struct cached_message {
+	struct cached_message *next;
 
-	Pool pool;
+	pool_t pool;
 	unsigned int uid;
 
-	MessagePart *part;
-	MessageSize *hdr_size;
-	MessageSize *body_size;
-	MessageSize *partial_size;
+	struct message_part *part;
+	struct message_size *hdr_size;
+	struct message_size *body_size;
+	struct message_size *partial_size;
 
 	time_t internal_date;
 	uoff_t full_virtual_size;
@@ -39,38 +37,39 @@
 	char *cached_bodystructure;
 	char *cached_envelope;
 
-	MessagePartEnvelopeData *envelope;
+	struct message_part_envelope_data *envelope;
 };
 
-struct _ImapMessageCache {
-	ImapMessageCacheIface *iface;
+struct imap_message_cache {
+	struct imap_message_cache_iface *iface;
 
-	CachedMessage *messages;
+	struct cached_message *messages;
 	int messages_count;
 
-	CachedMessage *open_msg;
-	IStream *open_stream;
+	struct cached_message *open_msg;
+	struct istream *open_stream;
 
 	void *context;
 };
 
-ImapMessageCache *imap_msgcache_alloc(ImapMessageCacheIface *iface)
+struct imap_message_cache *
+imap_msgcache_alloc(struct imap_message_cache_iface *iface)
 {
-	ImapMessageCache *cache;
+	struct imap_message_cache *cache;
 
-	cache = i_new(ImapMessageCache, 1);
+	cache = i_new(struct imap_message_cache, 1);
 	cache->iface = iface;
 	return cache;
 }
 
-static void cached_message_free(CachedMessage *msg)
+static void cached_message_free(struct cached_message *msg)
 {
 	pool_unref(msg->pool);
 }
 
-void imap_msgcache_clear(ImapMessageCache *cache)
+void imap_msgcache_clear(struct imap_message_cache *cache)
 {
-	CachedMessage *next;
+	struct cached_message *next;
 
 	imap_msgcache_close(cache);
 
@@ -81,16 +80,17 @@
 	}
 }
 
-void imap_msgcache_free(ImapMessageCache *cache)
+void imap_msgcache_free(struct imap_message_cache *cache)
 {
 	imap_msgcache_clear(cache);
 	i_free(cache);
 }
 
-static CachedMessage *cache_new(ImapMessageCache *cache, unsigned int uid)
+static struct cached_message *
+cache_new(struct imap_message_cache *cache, unsigned int uid)
 {
-	CachedMessage *msg, **msgp;
-	Pool pool;
+	struct cached_message *msg, **msgp;
+	pool_t pool;
 
 	if (cache->messages_count < MAX_CACHED_MESSAGES)
 		cache->messages_count++;
@@ -104,10 +104,10 @@
 		*msgp = NULL;
 	}
 
-	pool = pool_alloconly_create("CachedMessage",
+	pool = pool_alloconly_create("cached_message",
 				     DEFAULT_MESSAGE_POOL_SIZE);
 
-	msg = p_new(pool, CachedMessage, 1);
+	msg = p_new(pool, struct cached_message, 1);
 	msg->pool = pool;
 	msg->uid = uid;
 	msg->internal_date = (time_t)-1;
@@ -118,10 +118,10 @@
 	return msg;
 }
 
-static CachedMessage *cache_open_or_create(ImapMessageCache *cache,
-					   unsigned int uid)
+static struct cached_message *
+cache_open_or_create(struct imap_message_cache *cache, unsigned int uid)
 {
-	CachedMessage **pos, *msg;
+	struct cached_message **pos, *msg;
 
 	pos = &cache->messages;
 	for (; *pos != NULL; pos = &(*pos)->next) {
@@ -146,12 +146,12 @@
 	return msg;
 }
 
-static void parse_envelope_header(MessagePart *part,
+static void parse_envelope_header(struct message_part *part,
 				  const unsigned char *name, size_t name_len,
 				  const unsigned char *value, size_t value_len,
 				  void *context)
 {
-	CachedMessage *msg = context;
+	struct cached_message *msg = context;
 
 	if (part == NULL || part->parent == NULL) {
 		/* parse envelope headers if we're at the root message part */
@@ -160,7 +160,8 @@
 	}
 }
 
-static int imap_msgcache_get_stream(ImapMessageCache *cache, uoff_t offset)
+static int imap_msgcache_get_stream(struct imap_message_cache *cache,
+				    uoff_t offset)
 {
 	if (cache->open_stream == NULL)
 		cache->open_stream = cache->iface->open_mail(cache->context);
@@ -181,7 +182,7 @@
 	return TRUE;
 }
 
-static void msg_get_part(ImapMessageCache *cache)
+static void msg_get_part(struct imap_message_cache *cache)
 {
 	if (cache->open_msg->part == NULL) {
 		cache->open_msg->part =
@@ -191,9 +192,10 @@
 }
 
 /* Caches the fields for given message if possible */
-static int cache_fields(ImapMessageCache *cache, ImapCacheField fields)
+static int cache_fields(struct imap_message_cache *cache,
+			enum imap_cache_field fields)
 {
-        CachedMessage *msg;
+        struct cached_message *msg;
 	const char *value;
 	int failed;
 
@@ -257,8 +259,9 @@
 				/* envelope isn't parsed yet, do it. header
 				   size is calculated anyway so save it */
 				if (msg->hdr_size == NULL) {
-					msg->hdr_size = p_new(msg->pool,
-							      MessageSize, 1);
+					msg->hdr_size =
+						p_new(msg->pool,
+						      struct message_size, 1);
 				}
 
 				message_parse_header(NULL, cache->open_stream,
@@ -283,7 +286,7 @@
 	if ((fields & IMAP_CACHE_MESSAGE_BODY_SIZE) && msg->body_size == NULL) {
 		/* we don't have body size. and since we're already going
 		   to scan the whole message body, we might as well build
-		   the MessagePart. FIXME: this slows down things when it's
+		   the message_part. FIXME: this slows down things when it's
 		   not needed, do we really want to? */
                 fields |= IMAP_CACHE_MESSAGE_PART;
 	}
@@ -314,9 +317,11 @@
 	if ((fields & IMAP_CACHE_MESSAGE_BODY_SIZE) && msg->body_size == NULL) {
 		i_assert(msg->part != NULL);
 
-		msg->body_size = p_new(msg->pool, MessageSize, 1);
-		if (msg->hdr_size == NULL)
-			msg->hdr_size = p_new(msg->pool, MessageSize, 1);
+		msg->body_size = p_new(msg->pool, struct message_size, 1);
+		if (msg->hdr_size == NULL) {
+			msg->hdr_size = p_new(msg->pool,
+					      struct message_size, 1);
+		}
 
 		*msg->hdr_size = msg->part->header_size;
 		*msg->body_size = msg->part->body_size;
@@ -325,14 +330,14 @@
 	if ((fields & IMAP_CACHE_MESSAGE_HDR_SIZE) && msg->hdr_size == NULL) {
 		msg_get_part(cache);
 
-		msg->hdr_size = p_new(msg->pool, MessageSize, 1);
+		msg->hdr_size = p_new(msg->pool, struct message_size, 1);
 		if (msg->part != NULL) {
 			/* easy, get it from root part */
 			*msg->hdr_size = msg->part->header_size;
 
 			if (msg->body_size == NULL) {
 				msg->body_size = p_new(msg->pool,
-						       MessageSize, 1);
+						       struct message_size, 1);
 				*msg->body_size = msg->part->body_size;
 			}
 		} else {
@@ -375,12 +380,12 @@
 	return !failed;
 }
 
-int imap_msgcache_open(ImapMessageCache *cache, unsigned int uid,
-		       ImapCacheField fields,
+int imap_msgcache_open(struct imap_message_cache *cache, unsigned int uid,
+		       enum imap_cache_field fields,
 		       uoff_t vp_header_size, uoff_t vp_body_size,
 		       uoff_t full_virtual_size, void *context)
 {
-	CachedMessage *msg;
+	struct cached_message *msg;
 
 	msg = cache_open_or_create(cache, uid);
 	if (cache->open_msg != msg) {
@@ -392,14 +397,14 @@
 
 	if (vp_header_size != (uoff_t)-1 && msg->hdr_size == NULL) {
 		/* physical size == virtual size */
-		msg->hdr_size = p_new(msg->pool, MessageSize, 1);
+		msg->hdr_size = p_new(msg->pool, struct message_size, 1);
 		msg->hdr_size->physical_size = msg->hdr_size->virtual_size =
 			vp_header_size;
 	}
 
 	if (vp_body_size != (uoff_t)-1 && msg->body_size == NULL) {
 		/* physical size == virtual size */
-		msg->body_size = p_new(msg->pool, MessageSize, 1);
+		msg->body_size = p_new(msg->pool, struct message_size, 1);
 		msg->body_size->physical_size = msg->body_size->virtual_size =
 			vp_body_size;
 	}
@@ -409,7 +414,7 @@
 	return cache_fields(cache, fields);
 }
 
-void imap_msgcache_close(ImapMessageCache *cache)
+void imap_msgcache_close(struct imap_message_cache *cache)
 {
 	if (cache->open_stream != NULL) {
 		i_stream_unref(cache->open_stream);
@@ -420,9 +425,10 @@
 	cache->context = NULL;
 }
 
-const char *imap_msgcache_get(ImapMessageCache *cache, ImapCacheField field)
+const char *imap_msgcache_get(struct imap_message_cache *cache,
+			      enum imap_cache_field field)
 {
-	CachedMessage *msg;
+	struct cached_message *msg;
 
 	i_assert(cache->open_msg != NULL);
 
@@ -447,31 +453,33 @@
 	return NULL;
 }
 
-MessagePart *imap_msgcache_get_parts(ImapMessageCache *cache)
+struct message_part *imap_msgcache_get_parts(struct imap_message_cache *cache)
 {
 	if (cache->open_msg->part == NULL)
 		cache_fields(cache, IMAP_CACHE_MESSAGE_PART);
 	return cache->open_msg->part;
 }
 
-uoff_t imap_msgcache_get_virtual_size(ImapMessageCache *cache)
+uoff_t imap_msgcache_get_virtual_size(struct imap_message_cache *cache)
 {
 	if (cache->open_msg->full_virtual_size == (uoff_t)-1)
 		cache_fields(cache, IMAP_CACHE_VIRTUAL_SIZE);
 	return cache->open_msg->full_virtual_size;
 }
 
-time_t imap_msgcache_get_internal_date(ImapMessageCache *cache)
+time_t imap_msgcache_get_internal_date(struct imap_message_cache *cache)
 {
 	if (cache->open_msg->internal_date == (time_t)-1)
 		cache_fields(cache, IMAP_CACHE_INTERNALDATE);
 	return cache->open_msg->internal_date;
 }
 
-int imap_msgcache_get_rfc822(ImapMessageCache *cache, IStream **stream,
-			     MessageSize *hdr_size, MessageSize *body_size)
+int imap_msgcache_get_rfc822(struct imap_message_cache *cache,
+			     struct istream **stream,
+			     struct message_size *hdr_size,
+			     struct message_size *body_size)
 {
-	CachedMessage *msg;
+	struct cached_message *msg;
 	uoff_t offset;
 
 	i_assert(cache->open_msg != NULL);
@@ -506,17 +514,17 @@
 	return TRUE;
 }
 
-static uoff_t get_partial_size(IStream *stream,
+static uoff_t get_partial_size(struct istream *stream,
 			       uoff_t virtual_skip, uoff_t max_virtual_size,
-			       MessageSize *partial, MessageSize *dest,
-			       int *cr_skipped)
+			       struct message_size *partial,
+			       struct message_size *dest, int *cr_skipped)
 {
 	uoff_t physical_skip;
 	int last_cr;
 
 	/* see if we can use the existing partial */
 	if (partial->virtual_size > virtual_skip)
-		memset(partial, 0, sizeof(MessageSize));
+		memset(partial, 0, sizeof(struct message_size));
 	else {
 		i_stream_skip(stream, partial->physical_size);
 		virtual_skip -= partial->virtual_size;
@@ -550,19 +558,19 @@
 	return physical_skip;
 }
 
-int imap_msgcache_get_rfc822_partial(ImapMessageCache *cache,
+int imap_msgcache_get_rfc822_partial(struct imap_message_cache *cache,
 				     uoff_t virtual_skip,
 				     uoff_t max_virtual_size,
-				     int get_header, MessageSize *size,
-                                     IStream **stream, int *cr_skipped)
+				     int get_header, struct message_size *size,
+                                     struct istream **stream, int *cr_skipped)
 {
-	CachedMessage *msg;
+	struct cached_message *msg;
 	uoff_t physical_skip, full_size;
 	int size_got;
 
 	i_assert(cache->open_msg != NULL);
 
-	memset(size, 0, sizeof(MessageSize));
+	memset(size, 0, sizeof(struct message_size));
 	*stream = NULL;
 	*cr_skipped = FALSE;
 
@@ -588,7 +596,7 @@
 			full_size += msg->hdr_size->virtual_size;
 
 		if (max_virtual_size >= full_size) {
-			memcpy(size, msg->body_size, sizeof(MessageSize));
+			memcpy(size, msg->body_size, sizeof(*size));
 			if (get_header)
 				message_size_add(size, msg->hdr_size);
 			size_got = TRUE;
@@ -601,8 +609,10 @@
 		if (!imap_msgcache_get_stream(cache, 0))
 			return FALSE;
 
-		if (msg->partial_size == NULL)
-			msg->partial_size = p_new(msg->pool, MessageSize, 1);
+		if (msg->partial_size == NULL) {
+			msg->partial_size =
+				p_new(msg->pool, struct message_size, 1);
+		}
 		if (!get_header)
 			virtual_skip += msg->hdr_size->virtual_size;
 
@@ -620,7 +630,8 @@
 	return TRUE;
 }
 
-int imap_msgcache_get_data(ImapMessageCache *cache, IStream **stream)
+int imap_msgcache_get_data(struct imap_message_cache *cache,
+			   struct istream **stream)
 {
 	i_assert(cache->open_msg != NULL);
 

Index: imap-message-cache.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-message-cache.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- imap-message-cache.h	6 Dec 2002 01:09:22 -0000	1.13
+++ imap-message-cache.h	5 Jan 2003 13:09:52 -0000	1.14
@@ -1,6 +1,9 @@
 #ifndef __IMAP_MESSAGE_CACHE_H
 #define __IMAP_MESSAGE_CACHE_H
 
+struct message_part;
+struct message_size;
+
 /* IMAP message cache. Caches are mailbox-specific and must be cleared
    if UID validity changes. Also if message data may have changed,
    imap_msgcache_close() must be called.
@@ -9,9 +12,7 @@
    when client fetches the message in parts.
 */
 
-#include "message-parser.h"
-
-typedef enum {
+enum imap_cache_field {
 	IMAP_CACHE_BODY			= 0x0001,
 	IMAP_CACHE_BODYSTRUCTURE	= 0x0002,
 	IMAP_CACHE_ENVELOPE		= 0x0004,
@@ -22,72 +23,78 @@
 	IMAP_CACHE_MESSAGE_PART		= 0x0400,
 	IMAP_CACHE_MESSAGE_HDR_SIZE	= 0x0800,
 	IMAP_CACHE_MESSAGE_BODY_SIZE	= 0x0100
-} ImapCacheField;
+};
 
-typedef struct {
+struct imap_message_cache_iface {
 	/* Open mail for reading. */
-	IStream *(*open_mail)(void *context);
+	struct istream *(*open_mail)(void *context);
 	/* Rewind stream to beginning, possibly closing the old stream
 	   if it can't directly be rewinded. */
-	IStream *(*stream_rewind)(IStream *stream, void *context);
+	struct istream *(*stream_rewind)(struct istream *stream, void *context);
 
 	/* Returns field if it's already cached, or NULL. */
-	const char *(*get_cached_field)(ImapCacheField field, void *context);
-	/* Returns MessagePart if it's already cached, or NULL. */
-	MessagePart *(*get_cached_parts)(Pool pool, void *context);
+	const char *(*get_cached_field)(enum imap_cache_field field,
+					void *context);
+	/* Returns message_part if it's already cached, or NULL. */
+	struct message_part *(*get_cached_parts)(pool_t pool, void *context);
 
 	/* Returns message's internal date, or (time_t)-1 if error. */
 	time_t (*get_internal_date)(void *context);
-} ImapMessageCacheIface;
+};
 
-typedef struct _ImapMessageCache ImapMessageCache;
+struct imap_message_cache;
 
-ImapMessageCache *imap_msgcache_alloc(ImapMessageCacheIface *iface);
-void imap_msgcache_clear(ImapMessageCache *cache);
-void imap_msgcache_free(ImapMessageCache *cache);
+struct imap_message_cache *
+imap_msgcache_alloc(struct imap_message_cache_iface *iface);
+void imap_msgcache_clear(struct imap_message_cache *cache);
+void imap_msgcache_free(struct imap_message_cache *cache);
 
 /* Open the specified message. Set vp_*_size if both physical and virtual
    sizes are same, otherwise (uoff_t)-1. If full_virtual_size isn't known,
    set it to (uoff_t)-1. Returns TRUE if all specified fields were cached.
    Even if FALSE is returned, it's possible to use the cached data,
    imap_msgcache_get() just returns NULL for those that weren't. */
-int imap_msgcache_open(ImapMessageCache *cache, unsigned int uid,
-		       ImapCacheField fields,
+int imap_msgcache_open(struct imap_message_cache *cache, unsigned int uid,
+		       enum imap_cache_field fields,
 		       uoff_t vp_header_size, uoff_t vp_body_size,
 		       uoff_t full_virtual_size, void *context);
 
 /* Close the IOStream for opened message. */
-void imap_msgcache_close(ImapMessageCache *cache);
+void imap_msgcache_close(struct imap_message_cache *cache);
 
 /* Returns the field from cache, or NULL if it's not cached. */
-const char *imap_msgcache_get(ImapMessageCache *cache, ImapCacheField field);
+const char *imap_msgcache_get(struct imap_message_cache *cache,
+			      enum imap_cache_field field);
 
-/* Returns the root MessagePart for message, or NULL if failed. */
-MessagePart *imap_msgcache_get_parts(ImapMessageCache *cache);
+/* Returns the root message_part for message, or NULL if failed. */
+struct message_part *imap_msgcache_get_parts(struct imap_message_cache *cache);
 
 /* Returns the virtual size of message, or (uoff_t)-1 if failed. */
-uoff_t imap_msgcache_get_virtual_size(ImapMessageCache *cache);
+uoff_t imap_msgcache_get_virtual_size(struct imap_message_cache *cache);
 
 /* Returns the internal date of message, or (time_t)-1 if failed. */
-time_t imap_msgcache_get_internal_date(ImapMessageCache *cache);
+time_t imap_msgcache_get_internal_date(struct imap_message_cache *cache);
 
 /* Returns TRUE if successful. If stream is not NULL, it's set to point to
    beginning of message, or to beginning of message body if hdr_size is NULL. */
-int imap_msgcache_get_rfc822(ImapMessageCache *cache, IStream **stream,
-			     MessageSize *hdr_size, MessageSize *body_size);
+int imap_msgcache_get_rfc822(struct imap_message_cache *cache,
+			     struct istream **stream,
+			     struct message_size *hdr_size,
+			     struct message_size *body_size);
 
 /* Returns TRUE if successful. *stream is set to point to the first non-skipped
    character. size is set to specify the actual message size in
    virtual_skip..max_virtual_size range. cr_skipped is set to TRUE if first
    character in stream is LF, and we should NOT treat it as CR+LF. */
-int imap_msgcache_get_rfc822_partial(ImapMessageCache *cache,
+int imap_msgcache_get_rfc822_partial(struct imap_message_cache *cache,
 				     uoff_t virtual_skip,
 				     uoff_t max_virtual_size,
-				     int get_header, MessageSize *size,
-				     IStream **stream, int *cr_skipped);
+				     int get_header, struct message_size *size,
+				     struct istream **stream, int *cr_skipped);
 
 /* Returns TRUE if successful. *stream is set to point to beginning of
    message. */
-int imap_msgcache_get_data(ImapMessageCache *cache, IStream **stream);
+int imap_msgcache_get_data(struct imap_message_cache *cache,
+			   struct istream **stream);
 
 #endif

Index: imap-parser.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-parser.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- imap-parser.c	4 Jan 2003 17:26:30 -0000	1.30
+++ imap-parser.c	5 Jan 2003 13:09:52 -0000	1.31
@@ -11,29 +11,29 @@
 
 #define LIST_ALLOC_SIZE 7
 
-typedef enum {
+enum arg_parse_type {
 	ARG_PARSE_NONE = 0,
 	ARG_PARSE_ATOM,
 	ARG_PARSE_STRING,
 	ARG_PARSE_LITERAL,
 	ARG_PARSE_LITERAL_DATA
-} ArgParseType;
+};
 
-struct _ImapParser {
+struct imap_parser {
 	/* permanent */
-	Pool pool;
-	IStream *input;
-	OStream *output;
+	pool_t pool;
+	struct istream *input;
+	struct ostream *output;
 	size_t max_literal_size, max_elements;
-        ImapParserFlags flags;
+        enum imap_parser_flags flags;
 
 	/* reset by imap_parser_reset(): */
-        ImapArgList *root_list;
-        ImapArgList *cur_list;
-	ImapArg *list_arg;
+        struct imap_arg_list *root_list;
+        struct imap_arg_list *cur_list;
+	struct imap_arg *list_arg;
 	size_t element_count;
 
-	ArgParseType cur_type;
+	enum arg_parse_type cur_type;
 	size_t cur_pos; /* parser position in input buffer */
 
 	int str_first_escape; /* ARG_PARSE_STRING: index to first '\' */
@@ -48,10 +48,12 @@
 
 #define LIST_REALLOC(parser, old_list, size) \
 	p_realloc((parser)->pool, old_list, \
-		  sizeof(ImapArgList) + sizeof(ImapArg) * ((size)-1))
+		  sizeof(struct imap_arg_list) + \
+		  sizeof(struct imap_arg) * ((size)-1))
 
-static void imap_args_realloc(ImapParser *parser, size_t size)
+static void imap_args_realloc(struct imap_parser *parser, size_t size)
 {
+	/* @UNSAFE */
 	parser->cur_list = LIST_REALLOC(parser, parser->cur_list, size);
 	parser->cur_list->alloc = size;
 
@@ -61,12 +63,13 @@
 		parser->list_arg->_data.list = parser->cur_list;
 }
 
-ImapParser *imap_parser_create(IStream *input, OStream *output,
-			       size_t max_literal_size, size_t max_elements)
+struct imap_parser *
+imap_parser_create(struct istream *input, struct ostream *output,
+		   size_t max_literal_size, size_t max_elements)
 {
-	ImapParser *parser;
+	struct imap_parser *parser;
 
-	parser = i_new(ImapParser, 1);
+	parser = i_new(struct imap_parser, 1);
         parser->pool = pool_alloconly_create("IMAP parser", 8192);
 	parser->input = input;
 	parser->output = output;
@@ -77,13 +80,13 @@
 	return parser;
 }
 
-void imap_parser_destroy(ImapParser *parser)
+void imap_parser_destroy(struct imap_parser *parser)
 {
 	pool_unref(parser->pool);
 	i_free(parser);
 }
 
-void imap_parser_reset(ImapParser *parser)
+void imap_parser_reset(struct imap_parser *parser)
 {
 	p_clear(parser->pool);
 
@@ -107,13 +110,13 @@
 	imap_args_realloc(parser, LIST_ALLOC_SIZE);
 }
 
-const char *imap_parser_get_error(ImapParser *parser)
+const char *imap_parser_get_error(struct imap_parser *parser)
 {
 	return parser->error;
 }
 
 /* skip over everything parsed so far, plus the following whitespace */
-static int imap_parser_skip_to_next(ImapParser *parser,
+static int imap_parser_skip_to_next(struct imap_parser *parser,
 				    const unsigned char **data,
 				    size_t *data_size)
 {
@@ -132,9 +135,9 @@
 	return *data_size > 0;
 }
 
-static ImapArg *imap_arg_create(ImapParser *parser)
+static struct imap_arg *imap_arg_create(struct imap_parser *parser)
 {
-	ImapArg *arg;
+	struct imap_arg *arg;
 
 	i_assert(parser->cur_list != NULL);
 
@@ -150,7 +153,7 @@
 	return arg;
 }
 
-static void imap_parser_open_list(ImapParser *parser)
+static void imap_parser_open_list(struct imap_parser *parser)
 {
 	parser->list_arg = imap_arg_create(parser);
 
@@ -163,9 +166,9 @@
 	parser->cur_type = ARG_PARSE_NONE;
 }
 
-static int imap_parser_close_list(ImapParser *parser)
+static int imap_parser_close_list(struct imap_parser *parser)
 {
-	ImapArg *arg;
+	struct imap_arg *arg;
 
 	if (parser->list_arg == NULL) {
 		/* we're not inside list */
@@ -188,10 +191,10 @@
 	return TRUE;
 }
 
-static void imap_parser_save_arg(ImapParser *parser, const unsigned char *data,
-				 size_t size)
+static void imap_parser_save_arg(struct imap_parser *parser,
+				 const unsigned char *data, size_t size)
 {
-	ImapArg *arg;
+	struct imap_arg *arg;
 
 	arg = imap_arg_create(parser);
 
@@ -239,8 +242,8 @@
 	parser->cur_type = ARG_PARSE_NONE;
 }
 
-static int imap_parser_read_atom(ImapParser *parser, const unsigned char *data,
-				 size_t data_size)
+static int imap_parser_read_atom(struct imap_parser *parser,
+				 const unsigned char *data, size_t data_size)
 {
 	size_t i;
 
@@ -276,7 +279,7 @@
 	return parser->cur_type == ARG_PARSE_NONE;
 }
 
-static int imap_parser_read_string(ImapParser *parser,
+static int imap_parser_read_string(struct imap_parser *parser,
 				   const unsigned char *data, size_t data_size)
 {
 	size_t i;
@@ -318,7 +321,7 @@
 	return parser->cur_type == ARG_PARSE_NONE;
 }
 
-static int imap_parser_literal_end(ImapParser *parser)
+static int imap_parser_literal_end(struct imap_parser *parser)
 {
 	if ((parser->flags & IMAP_PARSE_FLAG_LITERAL_SIZE) == 0) {
 		if (parser->literal_size > parser->max_literal_size) {
@@ -340,7 +343,7 @@
 	return TRUE;
 }
 
-static int imap_parser_read_literal(ImapParser *parser,
+static int imap_parser_read_literal(struct imap_parser *parser,
 				    const unsigned char *data,
 				    size_t data_size)
 {
@@ -372,7 +375,7 @@
 	return FALSE;
 }
 
-static int imap_parser_read_literal_data(ImapParser *parser,
+static int imap_parser_read_literal_data(struct imap_parser *parser,
 					 const unsigned char *data,
 					 size_t data_size)
 {
@@ -420,7 +423,7 @@
 
 /* Returns TRUE if argument was fully processed. Also returns TRUE if
    an argument inside a list was processed. */
-static int imap_parser_read_arg(ImapParser *parser)
+static int imap_parser_read_arg(struct imap_parser *parser)
 {
 	const unsigned char *data;
 	size_t data_size;
@@ -507,8 +510,8 @@
         ((parser)->cur_type != ARG_PARSE_NONE || \
 	 (parser)->cur_list != parser->root_list)
 
-int imap_parser_read_args(ImapParser *parser, unsigned int count,
-			  ImapParserFlags flags, ImapArg **args)
+int imap_parser_read_args(struct imap_parser *parser, unsigned int count,
+			  enum imap_parser_flags flags, struct imap_arg **args)
 {
 	parser->flags = flags;
 
@@ -551,7 +554,7 @@
 	}
 }
 
-const char *imap_parser_read_word(ImapParser *parser)
+const char *imap_parser_read_word(struct imap_parser *parser)
 {
 	const unsigned char *data;
 	size_t i, data_size;
@@ -571,7 +574,7 @@
 	}
 }
 
-const char *imap_parser_read_line(ImapParser *parser)
+const char *imap_parser_read_line(struct imap_parser *parser)
 {
 	const unsigned char *data;
 	size_t i, data_size;
@@ -591,7 +594,7 @@
 	}
 }
 
-const char *imap_arg_string(ImapArg *arg)
+const char *imap_arg_string(struct imap_arg *arg)
 {
 	switch (arg->type) {
 	case IMAP_ARG_NIL:
@@ -606,20 +609,20 @@
 	}
 }
 
-char *_imap_arg_str_error(const ImapArg *arg)
+char *_imap_arg_str_error(const struct imap_arg *arg)
 {
-	i_panic("Tried to access ImapArg type %d as string", arg->type);
+	i_panic("Tried to access imap_arg type %d as string", arg->type);
 	return NULL;
 }
 
-uoff_t _imap_arg_literal_size_error(const ImapArg *arg)
+uoff_t _imap_arg_literal_size_error(const struct imap_arg *arg)
 {
-	i_panic("Tried to access ImapArg type %d as literal size", arg->type);
+	i_panic("Tried to access imap_arg type %d as literal size", arg->type);
 	return 0;
 }
 
-ImapArgList *_imap_arg_list_error(const ImapArg *arg)
+struct imap_arg_list *_imap_arg_list_error(const struct imap_arg *arg)
 {
-	i_panic("Tried to access ImapArg type %d as list", arg->type);
+	i_panic("Tried to access imap_arg type %d as list", arg->type);
 	return NULL;
 }

Index: imap-parser.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-parser.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- imap-parser.h	2 Jan 2003 08:13:24 -0000	1.8
+++ imap-parser.h	5 Jan 2003 13:09:52 -0000	1.9
@@ -1,7 +1,7 @@
 #ifndef __IMAP_PARSER_H
 #define __IMAP_PARSER_H
 
-typedef enum {
+enum imap_parser_flags {
 	/* Set this flag if you wish to read only size of literal argument
 	   and not convert literal into string. Useful when you need to deal
 	   with large literal sizes. The literal must be the last read
@@ -9,9 +9,9 @@
 	IMAP_PARSE_FLAG_LITERAL_SIZE	= 0x01,
 	/* Don't remove '\' chars from string arguments */
 	IMAP_PARSE_FLAG_NO_UNESCAPE	= 0x02,
-} ImapParserFlags;
+};
 
-typedef enum {
+enum imap_arg_type {
 	IMAP_ARG_NIL = 0,
 	IMAP_ARG_ATOM,
 	IMAP_ARG_STRING,
@@ -19,20 +19,18 @@
 	IMAP_ARG_LIST,
 
 	IMAP_ARG_EOL /* end of argument list */
-} ImapArgType;
+};
 
-typedef struct _ImapParser ImapParser;
-typedef struct _ImapArg ImapArg;
-typedef struct _ImapArgList ImapArgList;
+struct imap_parser;
 
-struct _ImapArg {
-	ImapArgType type;
-        ImapArg *parent; /* always of type IMAP_ARG_LIST */
+struct imap_arg {
+	enum imap_arg_type type;
+        struct imap_arg *parent; /* always of type IMAP_ARG_LIST */
 
 	union {
 		char *str;
 		uoff_t literal_size;
-		ImapArgList *list;
+		struct imap_arg_list *list;
 	} _data;
 };
 
@@ -49,9 +47,9 @@
 	((arg)->type == IMAP_ARG_LIST ? \
 	 (arg)->_data.list : _imap_arg_list_error(arg))
 
-struct _ImapArgList {
+struct imap_arg_list {
 	size_t size, alloc;
-	ImapArg args[1]; /* variable size */
+	struct imap_arg args[1]; /* variable size */
 };
 
 /* Create new IMAP argument parser. There's no limit in argument sizes, only
@@ -60,15 +58,16 @@
    unset). max_elements sets the number of elements we allow entirely so that
    user can't give huge lists or lists inside lists. output is used for sending
    command continuation requests for literals. */
-ImapParser *imap_parser_create(IStream *input, OStream *output,
-			       size_t max_literal_size, size_t max_elements);
-void imap_parser_destroy(ImapParser *parser);
+struct imap_parser *
+imap_parser_create(struct istream *input, struct ostream *output,
+		   size_t max_literal_size, size_t max_elements);
+void imap_parser_destroy(struct imap_parser *parser);
 
 /* Reset the parser to initial state. */
-void imap_parser_reset(ImapParser *parser);
+void imap_parser_reset(struct imap_parser *parser);
 
 /* Return the last error in parser. */
-const char *imap_parser_get_error(ImapParser *parser);
+const char *imap_parser_get_error(struct imap_parser *parser);
 
 /* Read a number of arguments. This function doesn't call i_stream_read(), you
    need to do that. Returns number of arguments read (may be less than count
@@ -78,22 +77,22 @@
    0 or larger. If all arguments weren't read, they're set to NIL. count
    can be set to 0 to read all arguments in the line. Last element in
    args[size] is always of type IMAP_ARG_EOL. */
-int imap_parser_read_args(ImapParser *parser, unsigned int count,
-			  ImapParserFlags flags, ImapArg **args);
+int imap_parser_read_args(struct imap_parser *parser, unsigned int count,
+			  enum imap_parser_flags flags, struct imap_arg **args);
 
 /* Read one word - used for reading tag and command name.
    Returns NULL if more data is needed. */
-const char *imap_parser_read_word(ImapParser *parser);
+const char *imap_parser_read_word(struct imap_parser *parser);
 
 /* Read the rest of the line. Returns NULL if more data is needed. */
-const char *imap_parser_read_line(ImapParser *parser);
+const char *imap_parser_read_line(struct imap_parser *parser);
 
 /* Returns the imap argument as string. NIL returns "" and list returns NULL. */
-const char *imap_arg_string(ImapArg *arg);
+const char *imap_arg_string(struct imap_arg *arg);
 
 /* Error functions */
-char *_imap_arg_str_error(const ImapArg *arg);
-uoff_t _imap_arg_literal_size_error(const ImapArg *arg);
-ImapArgList *_imap_arg_list_error(const ImapArg *arg);
+char *_imap_arg_str_error(const struct imap_arg *arg);
+uoff_t _imap_arg_literal_size_error(const struct imap_arg *arg);
+struct imap_arg_list *_imap_arg_list_error(const struct imap_arg *arg);
 
 #endif

Index: imap-quote.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-quote.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- imap-quote.c	4 Jan 2003 17:26:30 -0000	1.4
+++ imap-quote.c	5 Jan 2003 13:09:52 -0000	1.5
@@ -78,7 +78,7 @@
 	return i;
 }
 
-static void append_quoted_qp(String *str, const unsigned char *value,
+static void append_quoted_qp(string_t *str, const unsigned char *value,
 			     size_t len)
 {
 	size_t i;
@@ -105,7 +105,7 @@
 	}
 }
 
-static void append_quoted(String *str, const unsigned char *value, size_t len)
+static void append_quoted(string_t *str, const unsigned char *value, size_t len)
 {
 	size_t i;
 
@@ -117,9 +117,9 @@
 }
 
 /* does two things: 1) escape '\' and '"' characters, 2) 8bit text -> QP */
-static String *get_quoted_str(const unsigned char *value, size_t value_len)
+static string_t *get_quoted_str(const unsigned char *value, size_t value_len)
 {
-	String *str;
+	string_t *str;
 	size_t token_len;
 	int qp, need_qp, quoted;
 
@@ -170,9 +170,10 @@
 				     strlen(value)));
 }
 
-char *imap_quote_value(Pool pool, const unsigned char *value, size_t value_len)
+char *imap_quote_value(pool_t pool, const unsigned char *value,
+		       size_t value_len)
 {
-	String *str;
+	string_t *str;
 
 	str = get_quoted_str(value, value_len);
 	return p_strndup(pool, str_data(str), str_len(str));

Index: imap-quote.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-quote.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- imap-quote.h	4 Jan 2003 17:26:30 -0000	1.2
+++ imap-quote.h	5 Jan 2003 13:09:52 -0000	1.3
@@ -5,6 +5,7 @@
 const char *imap_quote_str_nil(const char *value);
 
 /* Return value quoted and allocated from specified pool. */
-char *imap_quote_value(Pool pool, const unsigned char *value, size_t value_len);
+char *imap_quote_value(pool_t pool, const unsigned char *value,
+		       size_t value_len);
 
 #endif

Index: imap-util.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-util.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- imap-util.c	3 Jan 2003 15:57:12 -0000	1.7
+++ imap-util.c	5 Jan 2003 13:09:52 -0000	1.8
@@ -4,10 +4,10 @@
 #include "str.h"
 #include "imap-util.h"
 
-const char *imap_write_flags(MailFlags flags, const char *custom_flags[],
+const char *imap_write_flags(enum mail_flags flags, const char *custom_flags[],
 			     unsigned int custom_flags_count)
 {
-	String *str;
+	string_t *str;
 	const char *sysflags, *name;
 	unsigned int i;
 

Index: imap-util.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-util.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- imap-util.h	4 Jan 2003 17:26:30 -0000	1.4
+++ imap-util.h	5 Jan 2003 13:09:52 -0000	1.5
@@ -1,7 +1,7 @@
 #ifndef __IMAP_UTIL_H
 #define __IMAP_UTIL_H
 
-typedef enum {
+enum mail_flags {
 	MAIL_ANSWERED		= 0x0000001,
 	MAIL_FLAGGED		= 0x0000002,
 	MAIL_DELETED		= 0x0000004,
@@ -14,7 +14,7 @@
 
 	MAIL_SYSTEM_FLAGS_MASK	= 0x000003f,
 	MAIL_CUSTOM_FLAGS_MASK	= 0xfffffc0
-} MailFlags;
+};
 
 /* growing number of flags isn't very easy. biggest problem is that they're
    stored into unsigned int, which is 32bit almost everywhere. another thing
@@ -30,7 +30,7 @@
 
 /* Return flags as a space separated string. custom_flags[] is a list of
    names for custom flags, flags having NULL or "" entry are ignored. */
-const char *imap_write_flags(MailFlags flags, const char *custom_flags[],
+const char *imap_write_flags(enum mail_flags flags, const char *custom_flags[],
 			     unsigned int custom_flags_count);
 
 #endif




More information about the dovecot-cvs mailing list