]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
cleanup: message saving code isn't index-specific
authorTimo Sirainen <tss@iki.fi>
Wed, 7 May 2003 12:06:47 +0000 (15:06 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 7 May 2003 12:06:47 +0000 (15:06 +0300)
--HG--
branch : HEAD

src/lib-storage/Makefile.am
src/lib-storage/index/Makefile.am
src/lib-storage/index/index-storage.h
src/lib-storage/index/maildir/maildir-save.c
src/lib-storage/index/mbox/mbox-save.c
src/lib-storage/mail-save.c [moved from src/lib-storage/index/index-save.c with 91% similarity]
src/lib-storage/mail-save.h [new file with mode: 0644]

index 0183a87d832ba63c87a1dfce022ea670f765463c..56049bc4e06d7118892bd68c34627682163fe2f7 100644 (file)
@@ -8,9 +8,11 @@ INCLUDES = \
        -I$(top_srcdir)/src/lib-imap
 
 libstorage_a_SOURCES = \
+       mail-save.c \
        mail-search.c \
        mail-storage.c
 
 noinst_HEADERS = \
+       mail-save.h \
        mail-search.h \
        mail-storage.h
index 22fda89bc6ed3a1e7262a5be092c20436bd582c3..ba465a91da5a78fa3ad2ced12ca26c05511afd62 100644 (file)
@@ -16,7 +16,6 @@ libstorage_index_a_SOURCES = \
        index-mail.c \
        index-mailbox-check.c \
        index-messageset.c \
-       index-save.c \
        index-search.c \
        index-status.c \
        index-storage.c \
index b4d37a0c924a4400986c9cbe5f874d72f2f9044a..10fd8277d2a21beb72c5cc978ab07cb05e814a72 100644 (file)
@@ -5,12 +5,6 @@
 #include "mail-index.h"
 #include "index-mail.h"
 
-typedef int write_func_t(struct ostream *, const void *, size_t);
-
-/* Return -1 = failure, 0 = don't write the header, 1 = write it */
-typedef int header_callback_t(const char *name,
-                             write_func_t *write_func, void *context);
-
 struct index_autosync_file {
        struct index_autosync_file *next;
 
@@ -74,10 +68,6 @@ int index_expunge_mail(struct index_mailbox *ibox,
                       struct mail_index_record *rec,
                       unsigned int seq, int notify);
 
-int index_storage_save(struct mail_storage *storage, const char *path,
-                      struct istream *input, struct ostream *output,
-                      header_callback_t *header_callback, void *context);
-
 void index_mailbox_check_add(struct index_mailbox *ibox, const char *path);
 void index_mailbox_check_remove_all(struct index_mailbox *ibox);
 
index a9fcdf28eafe29cc28942bf245518056d51eecdd..1f517bade7d0d8eb6ff64353d080f2f28f0b8361 100644 (file)
@@ -5,8 +5,10 @@
 #include "ostream.h"
 #include "maildir-index.h"
 #include "maildir-storage.h"
+#include "mail-save.h"
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <utime.h>
@@ -48,8 +50,8 @@ maildir_read_into_tmp(struct index_mailbox *ibox, const char *dir,
                                      IO_PRIORITY_DEFAULT, FALSE);
        o_stream_set_blocking(output, 60000, NULL, NULL);
 
-       if (!index_storage_save(ibox->box.storage, path, input, output,
-                               NULL, NULL))
+       if (!mail_storage_save(ibox->box.storage, path, input, output,
+                               getenv("MAIL_SAVE_CRLF") != NULL, NULL, NULL))
                fname = NULL;
 
        o_stream_unref(output);
index f1a149413416ae51ea7ec3579aad22391222fdd8..3804301b0cea7f778b32ae6e4d9b8215b25a7966 100644 (file)
@@ -8,6 +8,7 @@
 #include "mbox-index.h"
 #include "mbox-lock.h"
 #include "mbox-storage.h"
+#include "mail-save.h"
 
 #include <stdlib.h>
 #include <unistd.h>
@@ -286,9 +287,11 @@ int mbox_storage_save_next(struct mail_save_context *ctx,
 
        t_push();
        if (!write_from_line(ctx, received_date) ||
-           !index_storage_save(ctx->ibox->box.storage,
-                               ctx->ibox->index->mailbox_path,
-                               data, ctx->output, save_header_callback, ctx) ||
+           !mail_storage_save(ctx->ibox->box.storage,
+                              ctx->ibox->index->mailbox_path,
+                              data, ctx->output,
+                              getenv("MAIL_SAVE_CRLF") != NULL,
+                              save_header_callback, ctx) ||
            !mbox_fix_header(ctx) ||
            !mbox_append_lf(ctx)) {
                /* failed, truncate file back to original size.
similarity index 91%
rename from src/lib-storage/index/index-save.c
rename to src/lib-storage/mail-save.c
index 3806d4297dd49853d9d77bbd4134593d963d59ec..b3199555fd25d12dee25f036f174918219681af3 100644 (file)
@@ -3,11 +3,9 @@
 #include "lib.h"
 #include "istream.h"
 #include "ostream.h"
-#include "write-full.h"
-#include "index-storage.h"
-
-#include <stdlib.h>
-#include <unistd.h>
+#include "message-parser.h"
+#include "mail-storage.h"
+#include "mail-save.h"
 
 static int write_with_crlf(struct ostream *output, const void *v_data,
                           size_t size)
@@ -132,9 +130,9 @@ static int save_headers(struct istream *input, struct ostream *output,
        return !failed;
 }
 
-int index_storage_save(struct mail_storage *storage, const char *path,
-                      struct istream *input, struct ostream *output,
-                      header_callback_t *header_callback, void *context)
+int mail_storage_save(struct mail_storage *storage, const char *path,
+                     struct istream *input, struct ostream *output, int crlf,
+                     header_callback_t *header_callback, void *context)
 {
         write_func_t *write_func;
        const unsigned char *data;
@@ -142,7 +140,7 @@ int index_storage_save(struct mail_storage *storage, const char *path,
        ssize_t ret;
        int failed;
 
-       write_func = getenv("MAIL_SAVE_CRLF") ? write_with_crlf : write_with_lf;
+       write_func = crlf ? write_with_crlf : write_with_lf;
 
        if (header_callback != NULL) {
                if (!save_headers(input, output, header_callback,
diff --git a/src/lib-storage/mail-save.h b/src/lib-storage/mail-save.h
new file mode 100644 (file)
index 0000000..91a46ec
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef __MAIL_SAVE_H
+#define __MAIL_SAVE_H
+
+typedef int write_func_t(struct ostream *, const void *, size_t);
+
+/* Return -1 = failure, 0 = don't write the header, 1 = write it */
+typedef int header_callback_t(const char *name,
+                             write_func_t *write_func, void *context);
+
+int mail_storage_save(struct mail_storage *storage, const char *path,
+                     struct istream *input, struct ostream *output, int crlf,
+                     header_callback_t *header_callback, void *context);
+
+#endif