dovecot-2.2-pigeonhole: lib-sieve: Moved utility source modules ...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Sat Dec 21 22:32:25 EET 2013


details:   http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/559621e9e633
changeset: 1824:559621e9e633
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Sat Dec 21 21:10:13 2013 +0100
description:
lib-sieve: Moved utility source modules to sub-directory.
In the future, much of these can be moved to Dovecot.

diffstat:

 configure.ac                                            |     1 +
 src/lib-sieve/Makefile.am                               |    21 +-
 src/lib-sieve/edit-mail.c                               |  1924 ---------------
 src/lib-sieve/edit-mail.h                               |    49 -
 src/lib-sieve/plugins/editheader/Makefile.am            |     3 +-
 src/lib-sieve/plugins/enotify/mailto/Makefile.am        |     1 +
 src/lib-sieve/plugins/ihave/Makefile.am                 |     2 +-
 src/lib-sieve/plugins/metadata/Makefile.am              |     5 +-
 src/lib-sieve/plugins/notify/Makefile.am                |     1 +
 src/lib-sieve/plugins/subaddress/Makefile.am            |     2 +-
 src/lib-sieve/plugins/vacation/Makefile.am              |     3 +-
 src/lib-sieve/plugins/vnd.dovecot/debug/Makefile.am     |     2 +-
 src/lib-sieve/plugins/vnd.dovecot/duplicate/Makefile.am |     2 +-
 src/lib-sieve/rfc2822.c                                 |   236 -
 src/lib-sieve/rfc2822.h                                 |    45 -
 src/lib-sieve/util/Makefile.am                          |    19 +
 src/lib-sieve/util/edit-mail.c                          |  1924 +++++++++++++++
 src/lib-sieve/util/edit-mail.h                          |    49 +
 src/lib-sieve/util/rfc2822.c                            |   236 +
 src/lib-sieve/util/rfc2822.h                            |    45 +
 20 files changed, 2300 insertions(+), 2270 deletions(-)

diffs (truncated from 4738 to 300 lines):

diff -r 8612191c5069 -r 559621e9e633 configure.ac
--- a/configure.ac	Sat Dec 21 15:09:32 2013 +0100
+++ b/configure.ac	Sat Dec 21 21:10:13 2013 +0100
@@ -100,6 +100,7 @@
 doc/rfc/Makefile
 src/Makefile
 src/lib-sieve/Makefile
+src/lib-sieve/util/Makefile
 src/lib-sieve/plugins/Makefile
 src/lib-sieve/plugins/vacation/Makefile
 src/lib-sieve/plugins/subaddress/Makefile
diff -r 8612191c5069 -r 559621e9e633 src/lib-sieve/Makefile.am
--- a/src/lib-sieve/Makefile.am	Sat Dec 21 15:09:32 2013 +0100
+++ b/src/lib-sieve/Makefile.am	Sat Dec 21 21:10:13 2013 +0100
@@ -1,4 +1,4 @@
-SUBDIRS = plugins
+SUBDIRS = util plugins
 
 dovecot_pkglib_LTLIBRARIES = libdovecot-sieve.la
 
@@ -6,6 +6,7 @@
 	$(LIBDOVECOT_INCLUDE) \
 	$(LIBDOVECOT_LDA_INCLUDE) \
 	$(LIBDOVECOT_SERVICE_INCLUDE) \
+	-I$(top_srcdir)/src/lib-sieve/util \
 	-DMODULEDIR=\""$(dovecot_moduledir)"\"
 
 tests = \
@@ -71,12 +72,20 @@
 	$(extdir)/vnd.dovecot/duplicate/libsieve_ext_duplicate.la \
 	$(unfinished_plugins)
 
-libdovecot_sieve_la_DEPENDENCIES = $(plugins) $(LIBDOVECOT_LDA_DEPS) $(LIBDOVECOT_STORAGE_DEPS) $(LIBDOVECOT_DEPS)
-libdovecot_sieve_la_LIBADD = $(plugins) $(LIBDOVECOT_LDA) $(LIBDOVECOT_STORAGE) $(LIBDOVECOT)
+libdovecot_sieve_la_DEPENDENCIES = \
+	$(plugins) \
+	$(top_builddir)/src/lib-sieve/util/libsieve_util.la \
+	$(LIBDOVECOT_LDA_DEPS) \
+	$(LIBDOVECOT_STORAGE_DEPS) \
+	$(LIBDOVECOT_DEPS)
+libdovecot_sieve_la_LIBADD = \
+	$(plugins) \
+	$(top_builddir)/src/lib-sieve/util/libsieve_util.la \
+	$(LIBDOVECOT_LDA) \
+	$(LIBDOVECOT_STORAGE) \
+	$(LIBDOVECOT)
 
 libdovecot_sieve_la_SOURCES = \
-	rfc2822.c \
-	edit-mail.c \
 	sieve-settings.c \
 	sieve-message.c \
 	sieve-smtp.c \
@@ -118,8 +127,6 @@
 	sieve.c
 
 headers = \
-	rfc2822.h \
-	edit-mail.h \
 	sieve-config.h \
 	sieve-types.h \
 	sieve-common.h \
diff -r 8612191c5069 -r 559621e9e633 src/lib-sieve/edit-mail.c
--- a/src/lib-sieve/edit-mail.c	Sat Dec 21 15:09:32 2013 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1924 +0,0 @@
-/* Copyright (c) 2002-2013 Pigeonhole authors, see the included COPYING file
- */
-
-#include "lib.h"
-#include "array.h"
-#include "str.h"
-#include "mempool.h"
-#include "llist.h"
-#include "istream-private.h"
-#include "master-service.h"
-#include "master-service-settings.h"
-#include "message-parser.h"
-#include "message-header-encode.h"
-#include "message-header-decode.h"
-#include "mail-user.h"
-#include "mail-storage-private.h"
-#include "index-mail.h"
-#include "raw-storage.h"
-
-#include "rfc2822.h"
-
-#include "edit-mail.h"
-
-/*
- * Forward declarations
- */
-
-struct _header_field_index;
-struct _header_field;
-struct _header_index;
-struct _header;
-
-static struct mail_vfuncs edit_mail_vfuncs;
-
-struct edit_mail_istream;
-struct istream *edit_mail_istream_create(struct edit_mail *edmail);
-
-static struct _header_index *edit_mail_header_clone
-	(struct edit_mail *edmail, struct _header *header);
-
-/*
- * Raw storage
- */
-
-static struct mail_user *edit_mail_user = NULL;
-static unsigned int edit_mail_refcount = 0;
-
-static struct mail_user *edit_mail_raw_storage_get(struct mail_user *mail_user)
-{
-	if ( edit_mail_user == NULL ) {
-		void **sets = master_service_settings_get_others(master_service);
-
-		edit_mail_user = raw_storage_create_from_set(mail_user->set_info, sets[0]);
-	}
-
-	edit_mail_refcount++;
-
-	return edit_mail_user;
-}
-
-static void edit_mail_raw_storage_drop(void)
-{
-	i_assert(edit_mail_refcount > 0);
-
-	if ( --edit_mail_refcount != 0)
-		return;
-
-	mail_user_unref(&edit_mail_user);
-	edit_mail_user = NULL;
-}
-
-/*
- * Headers
- */
-
-struct _header_field {
-	struct _header *header;
-
-	unsigned int refcount;
-
-	char *data;
-	size_t size;
-	size_t virtual_size;
-	uoff_t offset;
-	unsigned int lines;
-
-	uoff_t body_offset;
-
-	char *utf8_value;
-};
-
-struct _header_field_index {
-	struct _header_field_index *prev, *next;
-
-	struct _header_field *field;
-	struct _header_index *header;
-};
-
-struct _header {
-	unsigned int refcount;
-
-	char *name;
-};
-
-struct _header_index {
-	struct _header_index *prev, *next;
-
-	struct _header *header;
-
-	struct _header_field_index *first, *last;
-
-	unsigned int count;
-};
-
-static inline struct _header *_header_create(const char *name)
-{
-	struct _header *header;
-
-	header = i_new(struct _header, 1);
-	header->name = i_strdup(name);
-	header->refcount = 1;
-
-	return header;
-}
-
-static inline void _header_ref(struct _header *header)
-{
-	header->refcount++;
-}
-
-static inline void _header_unref(struct _header *header)
-{
-	i_assert( header->refcount > 0 );
-	if ( --header->refcount != 0 )
-		return;
-
-	i_free(header->name);
-	i_free(header);
-}
-
-static inline struct _header_field *_header_field_create(struct _header *header)
-{
-	struct _header_field *hfield;
-
-	hfield = i_new(struct _header_field, 1);
-	hfield->refcount = 1;
-	hfield->header = header;
-	if ( header != NULL )
-		_header_ref(header);
-
-	return hfield;
-}
-
-static inline void _header_field_ref(struct _header_field *hfield)
-{
-	hfield->refcount++;
-}
-
-static inline void _header_field_unref(struct _header_field *hfield)
-{
-	i_assert( hfield->refcount > 0 );
-	if ( --hfield->refcount != 0 )
-		return;
-
-	if ( hfield->header != NULL )
-		_header_unref(hfield->header);
-
-	if ( hfield->data != NULL )
-		i_free(hfield->data);
-	if ( hfield->utf8_value != NULL )
-		i_free(hfield->utf8_value);
-	i_free(hfield);
-}
-
-/*
- * Edit mail object
- */
-
-struct edit_mail {
-	struct mail_private mail;
-	struct mail_private *wrapped;
-
-	struct edit_mail *parent;
-	unsigned int refcount;
-
-	struct istream *wrapped_stream;
-	struct istream *stream;
-
-	struct _header_index *headers_head, *headers_tail;
-	struct _header_field_index *header_fields_head, *header_fields_tail;
-	struct message_size hdr_size, body_size;
-
-	struct message_size wrapped_hdr_size, wrapped_body_size;
-
-	struct _header_field_index *header_fields_appended;
-	struct message_size appended_hdr_size;
-
-	unsigned int modified:1;
-	unsigned int snapshot_modified:1;
-	unsigned int crlf:1;
-	unsigned int eoh_crlf:1;
-	unsigned int headers_parsed:1;
-	unsigned int destroying_stream:1;
-};
-
-struct edit_mail *edit_mail_wrap(struct mail *mail)
-{
-	struct mail_private *mailp = (struct mail_private *) mail;
-	struct edit_mail *edmail;
-	struct mail_user *raw_mail_user;
-	struct mailbox *raw_box = NULL;
-	struct mailbox_transaction_context *raw_trans;
-	struct message_size hdr_size, body_size;
-	struct istream *wrapped_stream;
-	uoff_t size_diff;
-	pool_t pool;
-
-	if ( mail_get_stream(mail, &hdr_size, &body_size, &wrapped_stream) < 0 ) {
-		return NULL;
-	}
-
-	/* Create dummy raw mailbox for our wrapper */
-
-	raw_mail_user = edit_mail_raw_storage_get(mail->box->storage->user);
-
-	if ( raw_mailbox_alloc_stream(raw_mail_user, wrapped_stream, (time_t)-1,
-		"editor at example.com", &raw_box) < 0 ) {
-		i_error("edit-mail: failed to open raw box: %s",
-				mailbox_get_last_error(raw_box, NULL));
-		mailbox_free(&raw_box);
-		edit_mail_raw_storage_drop();
-		return NULL;
-	}
-


More information about the dovecot-cvs mailing list