/* Copyright (c) 2007-2009 Dovecot authors, see the included COPYING file */
#include "lib.h"
-#include "array.h"
-#include "str.h"
#include "maildir/maildir-storage.h"
#include "maildir/maildir-uidlist.h"
#include "maildir/maildir-filename.h"
case DBOX_METADATA_OLDV1_EXPUNGED:
case DBOX_METADATA_OLDV1_FLAGS:
case DBOX_METADATA_OLDV1_KEYWORDS:
+ case DBOX_METADATA_OLDV1_SPACE:
case DBOX_METADATA_EXT_REF:
- case DBOX_METADATA_SPACE:
break;
}
return value;
}
+
+bool dbox_maildir_uid_get_fname(struct dbox_mailbox *mbox, uint32_t uid,
+ const char **fname_r)
+{
+ enum maildir_uidlist_rec_flag flags;
+
+ *fname_r = maildir_uidlist_lookup(mbox->maildir_uidlist, uid, &flags);
+ return *fname_r != NULL;
+}
const char *dbox_file_maildir_metadata_get(struct dbox_file *file,
enum dbox_metadata_key key);
+bool dbox_maildir_uid_get_fname(struct dbox_mailbox *mbox, uint32_t uid,
+ const char **fname_r);
#endif
#include "mkdir-parents.h"
#include "fdatasync-path.h"
#include "str.h"
-#include "maildir/maildir-uidlist.h"
#include "dbox-storage.h"
#include "dbox-file.h"
#include "dbox-file-maildir.h"
#include <unistd.h>
#include <fcntl.h>
-enum mail_flags dbox_mail_flags_map[DBOX_METADATA_FLAGS_COUNT] = {
- MAIL_ANSWERED,
- MAIL_FLAGGED,
- MAIL_DELETED,
- MAIL_SEEN,
- MAIL_DRAFT
-};
-
-char dbox_mail_flag_chars[DBOX_METADATA_FLAGS_COUNT] = {
- 'A', 'F', 'D', 'S', 'T'
-};
-
static int dbox_file_metadata_skip_header(struct dbox_file *file);
static char *dbox_generate_tmp_filename(void)
}
}
-static bool
-dbox_maildir_uid_get_fname(struct dbox_mailbox *mbox, uint32_t uid,
- const char **fname_r)
-{
- enum maildir_uidlist_rec_flag flags;
-
- *fname_r = maildir_uidlist_lookup(mbox->maildir_uidlist, uid, &flags);
- return *fname_r != NULL;
-}
-
static char *
dbox_file_uid_get_fname(struct dbox_mailbox *mbox, uint32_t uid,
bool *maildir_file_r)
return file->current_path;
}
-static int
-dbox_file_get_maildir_data(struct dbox_file *file, uoff_t *physical_size_r)
-{
- struct stat st;
-
- i_assert(file->uid != 0);
-
- if (fstat(file->fd, &st) < 0) {
- dbox_file_set_syscall_error(file, "fstat");
- return -1;
- }
-
- *physical_size_r = st.st_size;
- return 1;
-}
-
static int
dbox_file_read_mail_header(struct dbox_file *file, uoff_t *physical_size_r)
{
struct dbox_message_header hdr;
+ struct stat st;
const unsigned char *data;
size_t size;
int ret;
- if (file->maildir_file)
- return dbox_file_get_maildir_data(file, physical_size_r);
+ if (file->maildir_file) {
+ if (fstat(file->fd, &st) < 0) {
+ dbox_file_set_syscall_error(file, "fstat");
+ return -1;
+ }
+ *physical_size_r = st.st_size;
+ return 1;
+ }
ret = i_stream_read_data(file->input, &data, &size,
file->msg_header_size - 1);
/* skip over the actual metadata */
while ((line = i_stream_read_next_line(file->input)) != NULL) {
- if (*line == DBOX_METADATA_SPACE) {
+ if (*line == DBOX_METADATA_OLDV1_SPACE) {
/* end of metadata */
break;
}
if ((line = i_stream_read_next_line(file->input)) == NULL)
break;
- if (*line == DBOX_METADATA_SPACE || *line == '\0') {
+ if (*line == DBOX_METADATA_OLDV1_SPACE || *line == '\0') {
/* end of metadata */
*expunged_r = FALSE;
break;
<metadata>
Metadata block begins with DBOX_MAGIC_POST, followed by zero or more lines
- in format <key character><value><LF>. The block ends with a line containing
- zero or more spaces. The spaces can be used for writing more headers.
+ in format <key character><value><LF>. The block ends with an empty line.
Unknown metadata should be ignored, but preserved when copying.
There should be no duplicates for the current metadata, but future
DBOX_HEADER_CREATE_STAMP = 'C'
};
-enum dbox_metadata_flags {
- DBOX_METADATA_FLAGS_ANSWERED = 0,
- DBOX_METADATA_FLAGS_FLAGGED,
- DBOX_METADATA_FLAGS_DELETED,
- DBOX_METADATA_FLAGS_SEEN,
- DBOX_METADATA_FLAGS_DRAFT,
-
- DBOX_METADATA_FLAGS_COUNT
-};
-
enum dbox_metadata_key {
- /* metadata used by old Dovecot versions */
- DBOX_METADATA_OLDV1_EXPUNGED = 'E',
- DBOX_METADATA_OLDV1_FLAGS = 'F',
- DBOX_METADATA_OLDV1_KEYWORDS = 'K',
-
/* Globally unique identifier for the message. Preserved when
copying. */
DBOX_METADATA_GUID = 'G',
1*(<start offset> <byte count> <ref>) */
DBOX_METADATA_EXT_REF = 'X',
- /* End of metadata block. The spaces can be used for writing more
- metadata. */
- DBOX_METADATA_SPACE = ' '
+ /* metadata used by old Dovecot versions */
+ DBOX_METADATA_OLDV1_EXPUNGED = 'E',
+ DBOX_METADATA_OLDV1_FLAGS = 'F',
+ DBOX_METADATA_OLDV1_KEYWORDS = 'K',
+ DBOX_METADATA_OLDV1_SPACE = ' '
};
enum dbox_message_type {
unsigned int deleted:1;
};
-extern enum mail_flags dbox_mail_flags_map[DBOX_METADATA_FLAGS_COUNT];
-extern char dbox_mail_flag_chars[DBOX_METADATA_FLAGS_COUNT];
-
struct dbox_file *
dbox_file_init_single(struct dbox_mailbox *mbox, uint32_t uid);
struct dbox_file *