[dovecot-cvs] dovecot/src/lib-mail istream-header-filter.c, 1.35, 1.36 istream-header-filter.h, 1.8, 1.9 message-body-search.c, 1.28, 1.29 message-content-parser.c, 1.14, 1.15 message-content-parser.h, 1.8, 1.9 message-decoder.c, 1.4, 1.5 message-header-decode.c, 1.6, 1.7 message-header-decode.h, 1.4, 1.5 message-header-parser.c, 1.3, 1.4 message-header-parser.h, 1.2, 1.3 message-parser.c, 1.75, 1.76 message-parser.h, 1.34, 1.35

tss at dovecot.org tss at dovecot.org
Fri Dec 15 16:55:45 UTC 2006


Update of /var/lib/cvs/dovecot/src/lib-mail
In directory talvi:/tmp/cvs-serv346/lib-mail

Modified Files:
	istream-header-filter.c istream-header-filter.h 
	message-body-search.c message-content-parser.c 
	message-content-parser.h message-decoder.c 
	message-header-decode.c message-header-decode.h 
	message-header-parser.c message-header-parser.h 
	message-parser.c message-parser.h 
Log Message:
Added context parameter type safety checks for most callback APIs.



Index: istream-header-filter.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/istream-header-filter.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- istream-header-filter.c	18 Nov 2006 14:06:36 -0000	1.35
+++ istream-header-filter.c	15 Dec 2006 16:55:41 -0000	1.36
@@ -35,6 +35,8 @@
 	unsigned int hide_body:1;
 };
 
+header_filter_callback *null_header_filter_callback = NULL;
+
 static void _close(struct _iostream *stream __attr_unused__)
 {
 }
@@ -305,6 +307,7 @@
 	return &stream->statbuf;
 }
 
+#undef i_stream_create_header_filter
 struct istream *
 i_stream_create_header_filter(struct istream *input,
                               enum header_filter_flags flags,

Index: istream-header-filter.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/istream-header-filter.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- istream-header-filter.h	13 Jan 2006 20:26:16 -0000	1.8
+++ istream-header-filter.h	15 Dec 2006 16:55:41 -0000	1.9
@@ -18,6 +18,8 @@
 typedef void header_filter_callback(struct message_header_line *hdr,
 				    bool *matched, void *context);
 
+extern header_filter_callback *null_header_filter_callback;
+
 /* NOTE: headers list must be sorted. */
 struct istream *
 i_stream_create_header_filter(struct istream *input,
@@ -25,5 +27,10 @@
 			      const char *const *headers,
 			      unsigned int headers_count,
 			      header_filter_callback *callback, void *context);
+#define i_stream_create_header_filter(input, flags, headers, headers_count, \
+				      callback, context) \
+	CONTEXT_CALLBACK3(i_stream_create_header_filter, \
+			  header_filter_callback, callback, context, \
+			  input, flags, headers, headers_count)
 
 #endif

Index: message-body-search.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/message-body-search.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- message-body-search.c	28 Jun 2006 13:10:44 -0000	1.28
+++ message-body-search.c	15 Dec 2006 16:55:41 -0000	1.29
@@ -149,9 +149,9 @@
 				continue;
 			}
 			message_content_parse_header(hdr->full_value,
-						     hdr->full_value_len,
-						     parse_content_encoding,
-						     NULL, ctx);
+				hdr->full_value_len,
+				parse_content_encoding,
+				null_parse_content_param_callback, ctx);
 		}
 	}
 	i_assert(ret != 0);

Index: message-content-parser.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/message-content-parser.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- message-content-parser.c	15 Oct 2006 12:23:17 -0000	1.14
+++ message-content-parser.c	15 Dec 2006 16:55:41 -0000	1.15
@@ -5,6 +5,10 @@
 #include "rfc822-parser.h"
 #include "message-content-parser.h"
 
+parse_content_callback_t *null_parse_content_callback = NULL;
+parse_content_param_callback_t *null_parse_content_param_callback = NULL;
+
+#undef message_content_parse_header
 void message_content_parse_header(const unsigned char *data, size_t size,
 				  parse_content_callback_t *callback,
 				  parse_content_param_callback_t *param_cb,

Index: message-content-parser.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/message-content-parser.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- message-content-parser.h	13 Jan 2006 20:26:16 -0000	1.8
+++ message-content-parser.h	15 Dec 2006 16:55:41 -0000	1.9
@@ -10,9 +10,20 @@
 					    size_t value_len,
 					    bool value_quoted, void *context);
 
+extern parse_content_callback_t *null_parse_content_callback;
+extern parse_content_param_callback_t *null_parse_content_param_callback;
+
 void message_content_parse_header(const unsigned char *data, size_t size,
 				  parse_content_callback_t *callback,
 				  parse_content_param_callback_t *param_cb,
 				  void *context);
+#ifdef CONTEXT_TYPE_SAFETY
+#  define message_content_parse_header(data, size, callback, param_cb, context)\
+	({(void)(1 ? 0 : callback(0, 0, context)); \
+	  (void)(1 ? 0 : param_cb(0, 0, 0, 0, 0, context)); \
+	  message_content_parse_header(data, size, \
+		(parse_content_callback_t *)callback, \
+		(parse_content_param_callback_t *)param_cb, context); })
+#endif
 
 #endif

Index: message-decoder.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/message-decoder.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- message-decoder.c	9 Dec 2006 23:22:08 -0000	1.4
+++ message-decoder.c	15 Dec 2006 16:55:41 -0000	1.5
@@ -148,7 +148,7 @@
 	    strcasecmp(hdr->name, "Content-Type") == 0) {
 		message_content_parse_header(hdr->full_value,
 					     hdr->full_value_len,
-					     NULL,
+					     null_parse_content_callback,
 					     parse_content_type_param, ctx);
 	}
 	if (hdr->name_len == 25 &&
@@ -156,7 +156,8 @@
 		message_content_parse_header(hdr->full_value,
 					     hdr->full_value_len,
 					     parse_content_encoding,
-					     NULL, ctx);
+					     null_parse_content_param_callback,
+					     ctx);
 	}
 
 	buffer_set_used_size(ctx->buf, 0);

Index: message-header-decode.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/message-header-decode.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- message-header-decode.c	13 Jan 2006 20:26:16 -0000	1.6
+++ message-header-decode.c	15 Dec 2006 16:55:41 -0000	1.7
@@ -84,6 +84,7 @@
 	return ret;
 }
 
+#undef message_header_decode
 void message_header_decode(const unsigned char *data, size_t size,
 			   message_header_decode_callback_t *callback,
 			   void *context)

Index: message-header-decode.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/message-header-decode.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- message-header-decode.h	13 Jan 2006 20:26:16 -0000	1.4
+++ message-header-decode.h	15 Dec 2006 16:55:41 -0000	1.5
@@ -12,5 +12,9 @@
 void message_header_decode(const unsigned char *data, size_t size,
 			   message_header_decode_callback_t *callback,
 			   void *context);
+#define message_header_decode(data, size, callback, context) \
+	CONTEXT_CALLBACK4(message_header_decode, \
+			  message_header_decode_callback_t, \
+			  callback, context, data, size)
 
 #endif

Index: message-header-parser.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/message-header-parser.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- message-header-parser.c	24 Oct 2006 21:47:30 -0000	1.3
+++ message-header-parser.c	15 Dec 2006 16:55:41 -0000	1.4
@@ -361,6 +361,7 @@
 	return ctx->has_nuls;
 }
 
+#undef message_parse_header
 void message_parse_header(struct istream *input, struct message_size *hdr_size,
 			  message_header_callback_t *callback, void *context)
 {

Index: message-header-parser.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/message-header-parser.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- message-header-parser.h	17 Jun 2006 17:10:38 -0000	1.2
+++ message-header-parser.h	15 Dec 2006 16:55:42 -0000	1.3
@@ -55,5 +55,8 @@
 /* Read and parse the header from the given stream. */
 void message_parse_header(struct istream *input, struct message_size *hdr_size,
 			  message_header_callback_t *callback, void *context);
+#define message_parse_header(input, hdr_size, callback, context) \
+	CONTEXT_CALLBACK2(message_parse_header, message_header_callback_t, \
+			  callback, context, input, hdr_size)
 
 #endif

Index: message-parser.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/message-parser.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -d -r1.75 -r1.76
--- message-parser.c	15 Oct 2006 12:13:08 -0000	1.75
+++ message-parser.c	15 Dec 2006 16:55:42 -0000	1.76
@@ -40,6 +40,8 @@
 	unsigned int part_seen_content_type:1;
 };
 
+message_part_header_callback_t *null_message_part_header_callback = NULL;
+
 static int parse_next_header_init(struct message_parser_ctx *ctx,
 				  struct message_block *block_r);
 static int parse_next_body_to_boundary(struct message_parser_ctx *ctx,
@@ -565,6 +567,7 @@
 	return ret;
 }
 
+#undef message_parser_parse_header
 void message_parser_parse_header(struct message_parser_ctx *ctx,
 				 struct message_size *hdr_size,
 				 message_part_header_callback_t *callback,
@@ -589,6 +592,7 @@
         *hdr_size = ctx->part->header_size;
 }
 
+#undef message_parser_parse_body
 void message_parser_parse_body(struct message_parser_ctx *ctx,
 			       message_part_header_callback_t *hdr_callback,
 			       void *context)
@@ -635,6 +639,7 @@
 	}
 }
 
+#undef message_parse_from_parts
 void message_parse_from_parts(struct message_part *part, struct istream *input,
 			      message_part_header_callback_t *callback,
 			      void *context)

Index: message-parser.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/message-parser.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- message-parser.h	16 Sep 2006 13:47:48 -0000	1.34
+++ message-parser.h	15 Dec 2006 16:55:42 -0000	1.35
@@ -55,6 +55,8 @@
 					    struct message_header_line *hdr,
 					    void *context);
 
+extern message_part_header_callback_t *null_message_part_header_callback;
+
 /* Initialize message parser. part_spool specifies where struct message_parts
    are allocated from. */
 struct message_parser_ctx *
@@ -72,17 +74,29 @@
 				 struct message_size *hdr_size,
 				 message_part_header_callback_t *callback,
 				 void *context);
+#define message_parser_parse_header(ctx, hdr_size, callback, context) \
+	CONTEXT_CALLBACK3(message_parser_parse_header, \
+			  message_part_header_callback_t, \
+			  callback, context, ctx, hdr_size)
 /* Read and parse body. If message is a MIME multipart or message/rfc822
    message, hdr_callback is called for all headers. body_callback is called
    for the body content. */
 void message_parser_parse_body(struct message_parser_ctx *ctx,
 			       message_part_header_callback_t *hdr_callback,
 			       void *context);
+#define message_parser_parse_body(ctx, callback, context) \
+	CONTEXT_CALLBACK3(message_parser_parse_body, \
+			  message_part_header_callback_t, \
+			  callback, context, ctx)
 
 /* callback is called for each field in message header. */
 void message_parse_from_parts(struct message_part *part, struct istream *input,
 			      message_part_header_callback_t *callback,
 			      void *context);
+#define message_parse_from_parts(part, input, callback, context) \
+	CONTEXT_CALLBACK3(message_parse_from_parts, \
+			  message_part_header_callback_t, \
+			  callback, context, part, input)
 
 /* Update the physical_size of all parts. If use_crlf is TRUE, they're set
    to same as virtual_size. If use_crlf is FALSE, they're set to



More information about the dovecot-cvs mailing list