[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-file.c, 1.9, 1.10 mbox-lock.c, 1.15, 1.16 mbox-save.c, 1.80, 1.81 mbox-storage.c, 1.117, 1.118 mbox-storage.h, 1.37, 1.38 mbox-sync-rewrite.c, 1.46, 1.47 mbox-sync.c, 1.146, 1.147

cras at dovecot.org cras at dovecot.org
Fri Apr 8 17:32:54 EEST 2005


Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv25906/lib-storage/index/mbox

Modified Files:
	mbox-file.c mbox-lock.c mbox-save.c mbox-storage.c 
	mbox-storage.h mbox-sync-rewrite.c mbox-sync.c 
Log Message:
Created mbox_storage and maildir_storage.



Index: mbox-file.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-file.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- mbox-file.c	8 Apr 2005 13:13:48 -0000	1.9
+++ mbox-file.c	8 Apr 2005 14:32:52 -0000	1.10
@@ -134,7 +134,7 @@
 	}
 
 	if (data == NULL) {
-		mail_storage_set_critical(&mbox->storage->storage,
+		mail_storage_set_critical(STORAGE(mbox->storage),
 			"Cached message offset lost for seq %u in mbox file %s",
 			seq, mbox->path);
 		mail_index_mark_corrupted(mbox->ibox.index);
@@ -144,7 +144,7 @@
 	offset = *((const uint64_t *)data);
 	if (istream_raw_mbox_seek(mbox->mbox_stream, offset) < 0) {
 		if (offset == 0) {
-			mail_storage_set_error(&mbox->storage->storage,
+			mail_storage_set_error(STORAGE(mbox->storage),
 				"Mailbox isn't a valid mbox file");
 			return -1;
 		}
@@ -152,7 +152,7 @@
 		if (mbox->mbox_sync_dirty)
 			return 0;
 
-		mail_storage_set_critical(&mbox->storage->storage,
+		mail_storage_set_critical(STORAGE(mbox->storage),
 			"Cached message offset %s is invalid for mbox file %s",
 			dec2str(offset), mbox->path);
 		mail_index_mark_corrupted(mbox->ibox.index);

Index: mbox-lock.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-lock.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- mbox-lock.c	8 Apr 2005 13:13:48 -0000	1.15
+++ mbox-lock.c	8 Apr 2005 14:32:52 -0000	1.16
@@ -259,7 +259,7 @@
 		return -1;
 	}
 	if (ret == 0) {
-		mail_storage_set_error(&mbox->storage->storage,
+		mail_storage_set_error(STORAGE(mbox->storage),
 				       "Timeout while waiting for lock");
 		return 0;
 	}
@@ -485,7 +485,7 @@
 		if (!drop_locks)
 			(void)mbox_unlock_files(&ctx);
 		if (ret == 0) {
-			mail_storage_set_error(&mbox->storage->storage,
+			mail_storage_set_error(STORAGE(mbox->storage),
 				"Timeout while waiting for lock");
 		}
 		return ret;

Index: mbox-save.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-save.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- mbox-save.c	8 Apr 2005 13:13:48 -0000	1.80
+++ mbox-save.c	8 Apr 2005 14:32:52 -0000	1.81
@@ -51,7 +51,7 @@
 static void write_error(struct mbox_save_context *ctx, int error)
 {
 	if (ENOSPACE(error)) {
-		mail_storage_set_error(&ctx->mbox->storage->storage,
+		mail_storage_set_error(STORAGE(ctx->mbox->storage),
 				       "Not enough disk space");
 	} else {
 		errno = error;
@@ -127,8 +127,9 @@
 
 	t_push();
 	if (from_envelope == NULL) {
-		from_envelope = t_strconcat(ctx->mbox->storage->user,
-					    "@", my_hostdomain, NULL);
+		from_envelope =
+			t_strconcat(INDEX_STORAGE(ctx->mbox->storage)->user,
+				    "@", my_hostdomain, NULL);
 	}
 
 	/* save in local timezone, no matter what it was given with */
@@ -263,7 +264,7 @@
 	int ret;
 
 	if (ctx->mbox->mbox_readonly || ctx->mbox->ibox.readonly) {
-		mail_storage_set_error(&ctx->mbox->storage->storage,
+		mail_storage_set_error(STORAGE(ctx->mbox->storage),
 				       "Read-only mbox");
 		return -1;
 	}
@@ -397,7 +398,7 @@
 						      save_header_callback,
 						      ctx);
 		ctx->body_output =
-			(ctx->mbox->storage->storage.flags &
+			(STORAGE(mbox->storage)->flags &
 			 MAIL_STORAGE_FLAG_SAVE_CRLF) != 0 ?
 			o_stream_create_crlf(default_pool, ctx->output) :
 			o_stream_create_lf(default_pool, ctx->output);
@@ -513,10 +514,10 @@
 	if (ctx->failed) {
 		errno = ctx->output->stream_errno;
 		if (ENOSPACE(errno)) {
-			mail_storage_set_error(&ctx->mbox->storage->storage,
+			mail_storage_set_error(STORAGE(ctx->mbox->storage),
 					       "Not enough disk space");
 		} else if (errno != 0) {
-			mail_storage_set_critical(&ctx->mbox->storage->storage,
+			mail_storage_set_critical(STORAGE(ctx->mbox->storage),
 				"write(%s) failed: %m", ctx->mbox->path);
 		}
 		return -1;

Index: mbox-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.c,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -d -r1.117 -r1.118
--- mbox-storage.c	8 Apr 2005 13:13:48 -0000	1.117
+++ mbox-storage.c	8 Apr 2005 14:32:52 -0000	1.118
@@ -41,7 +41,7 @@
 {
 	i_assert(function != NULL);
 
-	mail_storage_set_critical(&mbox->storage->storage,
+	mail_storage_set_critical(STORAGE(mbox->storage),
 		"%s failed with mbox file %s: %m", function, mbox->path);
 	return -1;
 }
@@ -247,7 +247,8 @@
 	    enum mail_storage_lock_method lock_method)
 {
 	int debug = (flags & MAIL_STORAGE_FLAG_DEBUG) != 0;
-	struct index_storage *storage;
+	struct mbox_storage *storage;
+	struct index_storage *istorage;
 	const char *root_dir, *inbox_file, *index_dir, *p;
 	struct stat st;
 	int autodetect;
@@ -330,17 +331,18 @@
 	}
 
 	pool = pool_alloconly_create("storage", 256);
-	storage = p_new(pool, struct index_storage, 1);
-	storage->storage = mbox_storage;
-	storage->storage.pool = pool;
+	storage = p_new(pool, struct mbox_storage, 1);
+	istorage = INDEX_STORAGE(storage);
+	istorage->storage = mbox_storage;
+	istorage->storage.pool = pool;
 
-	storage->dir = p_strdup(pool, home_expand(root_dir));
-	storage->inbox_path = p_strdup(pool, home_expand(inbox_file));
-	storage->index_dir = p_strdup(pool, home_expand(index_dir));
-	storage->user = p_strdup(pool, user);
-	storage->callbacks = p_new(pool, struct mail_storage_callbacks, 1);
-	index_storage_init(storage, flags, lock_method);
-	return &storage->storage;
+	istorage->dir = p_strdup(pool, home_expand(root_dir));
+	istorage->inbox_path = p_strdup(pool, home_expand(inbox_file));
+	istorage->index_dir = p_strdup(pool, home_expand(index_dir));
+	istorage->user = p_strdup(pool, user);
+	istorage->callbacks = p_new(pool, struct mail_storage_callbacks, 1);
+	index_storage_init(istorage, flags, lock_method);
+	return &storage->storage.storage;
 }
 
 static void mbox_free(struct mail_storage *_storage)
@@ -481,7 +483,7 @@
 }
 
 static struct mbox_mailbox *
-mbox_alloc(struct index_storage *storage, struct mail_index *index,
+mbox_alloc(struct mbox_storage *storage, struct mail_index *index,
 	   const char *name, enum mailbox_open_flags flags)
 {
 	struct mbox_mailbox *mbox;
@@ -491,7 +493,7 @@
 	mbox = p_new(pool, struct mbox_mailbox, 1);
 	mbox->ibox.box = mbox_mailbox;
 	mbox->ibox.box.pool = pool;
-	mbox->ibox.storage = storage;
+	mbox->ibox.storage = INDEX_STORAGE(storage);
 	mbox->ibox.mail_vfuncs = &mbox_mail_vfuncs;
 	mbox->ibox.is_recent = mbox_mail_is_recent;
 
@@ -511,15 +513,16 @@
 	mbox->mbox_do_dirty_syncs = mbox->mbox_very_dirty_syncs ||
 		getenv("MBOX_DIRTY_SYNCS") != NULL;
 
-	if ((storage->storage.flags & MAIL_STORAGE_FLAG_KEEP_HEADER_MD5) != 0)
+	if ((STORAGE(storage)->flags & MAIL_STORAGE_FLAG_KEEP_HEADER_MD5) != 0)
 		mbox->mbox_save_md5 = TRUE;
 	return mbox;
 }
 
 static struct mailbox *
-mbox_open(struct index_storage *storage, const char *name,
+mbox_open(struct mbox_storage *storage, const char *name,
 	  enum mailbox_open_flags flags)
 {
+	struct index_storage *istorage = INDEX_STORAGE(storage);
 	struct mbox_mailbox *mbox;
 	struct mail_index *index;
 	const char *path, *index_dir;
@@ -528,14 +531,14 @@
 		/* name = "INBOX"
 		   path = "<inbox_file>/INBOX"
 		   index_dir = "/mail/.imap/INBOX" */
-		path = storage->inbox_path;
-		index_dir = mbox_get_index_dir(storage, "INBOX");
+		path = istorage->inbox_path;
+		index_dir = mbox_get_index_dir(istorage, "INBOX");
 	} else {
 		/* name = "foo/bar"
 		   path = "/mail/foo/bar"
 		   index_dir = "/mail/foo/.imap/bar" */
-		path = mbox_get_path(storage, name);
-		index_dir = mbox_get_index_dir(storage, name);
+		path = mbox_get_path(istorage, name);
+		index_dir = mbox_get_index_dir(istorage, name);
 	}
 
 	index = index_storage_alloc(index_dir, path, MBOX_INDEX_PREFIX);
@@ -558,7 +561,7 @@
 }
 
 static struct mailbox *
-mbox_mailbox_open_stream(struct index_storage *storage, const char *name,
+mbox_mailbox_open_stream(struct mbox_storage *storage, const char *name,
 			 struct istream *input, enum mailbox_open_flags flags)
 {
 	struct mail_index *index;
@@ -583,7 +586,8 @@
 mbox_mailbox_open(struct mail_storage *_storage, const char *name,
 		  struct istream *input, enum mailbox_open_flags flags)
 {
-	struct index_storage *storage = (struct index_storage *)_storage;
+	struct mbox_storage *storage = (struct mbox_storage *)_storage;
+	struct index_storage *istorage = INDEX_STORAGE(storage);
 	const char *path;
 	struct stat st;
 
@@ -594,7 +598,7 @@
 
 	if (strcmp(name, "INBOX") == 0) {
 		/* make sure INBOX exists */
-		if (verify_inbox(storage) < 0)
+		if (verify_inbox(istorage) < 0)
 			return NULL;
 		return mbox_open(storage, "INBOX", flags);
 	}
@@ -604,7 +608,7 @@
 		return NULL;
 	}
 
-	path = mbox_get_path(storage, name);
+	path = mbox_get_path(istorage, name);
 	if (stat(path, &st) == 0) {
 		if (S_ISDIR(st.st_mode)) {
 			mail_storage_set_error(_storage,
@@ -613,7 +617,7 @@
 		}
 
 		/* exists - make sure the required directories are also there */
-		if (create_mbox_index_dirs(storage, name) < 0)
+		if (create_mbox_index_dirs(istorage, name) < 0)
 			return NULL;
 
 		return mbox_open(storage, name, flags);
@@ -622,7 +626,7 @@
 	if (ENOTFOUND(errno)) {
 		mail_storage_set_error(_storage, "Mailbox doesn't exist: %s",
 				       name);
-	} else if (!mbox_handle_errors(storage)) {
+	} else if (!mbox_handle_errors(istorage)) {
 		mail_storage_set_critical(_storage, "stat(%s) failed: %m",
 					  path);
 	}

Index: mbox-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.h,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- mbox-storage.h	8 Apr 2005 13:13:48 -0000	1.37
+++ mbox-storage.h	8 Apr 2005 14:32:52 -0000	1.38
@@ -11,9 +11,18 @@
 
 #include "index-storage.h"
 
+#define STORAGE(mbox_storage) \
+	(&(mbox_storage)->storage.storage)
+#define INDEX_STORAGE(mbox_storage) \
+	(&(mbox_storage)->storage)
+
+struct mbox_storage {
+	struct index_storage storage;
+};
+
 struct mbox_mailbox {
 	struct index_mailbox ibox;
-	struct index_storage *storage;
+	struct mbox_storage *storage;
 
 	const char *path;
 

Index: mbox-sync-rewrite.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync-rewrite.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- mbox-sync-rewrite.c	8 Apr 2005 13:13:48 -0000	1.46
+++ mbox-sync-rewrite.c	8 Apr 2005 14:32:52 -0000	1.47
@@ -36,7 +36,7 @@
         if (ret == (off_t)size)
 		ret = 0;
 	else if (ret >= 0) {
-		mail_storage_set_critical(&sync_ctx->mbox->storage->storage,
+		mail_storage_set_critical(STORAGE(sync_ctx->mbox->storage),
 			"mbox_move(%"PRIuUOFF_T", %"PRIuUOFF_T", %"PRIuUOFF_T
 			") moved only %"PRIuUOFF_T" bytes in mbox file %s",
 			dest, source, size, (uoff_t)ret, sync_ctx->mbox->path);

Index: mbox-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync.c,v
retrieving revision 1.146
retrieving revision 1.147
diff -u -d -r1.146 -r1.147
--- mbox-sync.c	8 Apr 2005 13:13:48 -0000	1.146
+++ mbox-sync.c	8 Apr 2005 14:32:52 -0000	1.147
@@ -65,7 +65,7 @@
 int mbox_sync_seek(struct mbox_sync_context *sync_ctx, uoff_t from_offset)
 {
 	if (istream_raw_mbox_seek(sync_ctx->input, from_offset) < 0) {
-		mail_storage_set_critical(&sync_ctx->mbox->storage->storage,
+		mail_storage_set_critical(STORAGE(sync_ctx->mbox->storage),
 			"Unexpectedly lost From-line at offset %"PRIuUOFF_T
 			" from mbox file %s", from_offset,
 			sync_ctx->mbox->path);
@@ -271,14 +271,14 @@
 
 	if (ret == 0 && uid < sync_ctx->hdr->next_uid) {
 		/* this UID was already in index and it was expunged */
-		mail_storage_set_critical(&sync_ctx->mbox->storage->storage,
+		mail_storage_set_critical(STORAGE(sync_ctx->mbox->storage),
 			"mbox sync: Expunged message reappeared in mailbox %s "
 			"(UID %u < %u)", sync_ctx->mbox->path, uid,
 			sync_ctx->hdr->next_uid);
 		ret = 0; rec = NULL;
 	} else if (rec != NULL && rec->uid != uid) {
 		/* new UID in the middle of the mailbox - shouldn't happen */
-		mail_storage_set_critical(&sync_ctx->mbox->storage->storage,
+		mail_storage_set_critical(STORAGE(sync_ctx->mbox->storage),
 			"mbox sync: UID inserted in the middle of mailbox %s "
 			"(%u > %u)", sync_ctx->mbox->path, rec->uid, uid);
 		ret = 0; rec = NULL;
@@ -537,7 +537,7 @@
 	}
 
 	if (uid_last != sync_ctx->base_uid_last) {
-		mail_storage_set_critical(&sync_ctx->mbox->storage->storage,
+		mail_storage_set_critical(STORAGE(sync_ctx->mbox->storage),
 			"X-IMAPbase uid-last unexpectedly lost in mbox file %s",
 			sync_ctx->mbox->path);
 		return -1;
@@ -775,7 +775,7 @@
 
 	if (seq == 0) {
 		if (istream_raw_mbox_seek(mbox->mbox_stream, 0) < 0) {
-			mail_storage_set_error(&mbox->storage->storage,
+			mail_storage_set_error(STORAGE(mbox->storage),
 				"Mailbox isn't a valid mbox file");
 			return -1;
 		}
@@ -791,7 +791,7 @@
 			if (istream_raw_mbox_seek(mbox->mbox_stream,
 						  old_offset) < 0) {
 				mail_storage_set_critical(
-					&mbox->storage->storage,
+					STORAGE(mbox->storage),
 					"Error seeking back to original "
 					"offset %s in mbox file %s",
 					dec2str(old_offset), mbox->path);
@@ -849,7 +849,7 @@
 		if (istream_raw_mbox_seek(sync_ctx->mbox->mbox_stream,
 					  st->st_size) < 0) {
 			mail_storage_set_critical(
-				&sync_ctx->mbox->storage->storage,
+				STORAGE(sync_ctx->mbox->storage),
 				"Error seeking to end of mbox file %s",
 				sync_ctx->mbox->path);
 			return -1;
@@ -935,7 +935,7 @@
 		    sync_ctx->base_uid_validity !=
 		    sync_ctx->hdr->uid_validity) {
 			mail_storage_set_critical(
-				&sync_ctx->mbox->storage->storage,
+				STORAGE(sync_ctx->mbox->storage),
 				"UIDVALIDITY changed (%u -> %u) "
 				"in mbox file %s",
 				sync_ctx->hdr->uid_validity,



More information about the dovecot-cvs mailing list