summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--attach.c2
-rw-r--r--buffy.c10
-rw-r--r--commands.c2
-rw-r--r--copy.c4
-rw-r--r--init.c3
-rw-r--r--mbox.c54
-rw-r--r--mx.c2
-rw-r--r--mx.h2
-rw-r--r--sendlib.c2
9 files changed, 59 insertions, 22 deletions
diff --git a/attach.c b/attach.c
index b6a613e7..029fdac5 100644
--- a/attach.c
+++ b/attach.c
@@ -631,7 +631,7 @@ int mutt_save_attachment (FILE *fp, BODY *m, char *path, int flags, HEADER *hdr)
mx_close_mailbox(&ctx);
return -1;
}
- if (ctx.magic == M_MBOX || ctx.magic == M_MMDF)
+ if (ctx.magic == M_MBOX || ctx.magic == M_MMDF || ctx.magic == M_KENDRA)
chflags = CH_FROM;
chflags |= (ctx.magic == M_MAILDIR ? CH_NOSTATUS : CH_UPDATE);
if ((r = _mutt_copy_message (msg->fp, fp, hn, hn->content, 0, chflags)) == 0)
diff --git a/buffy.c b/buffy.c
index 0a2ccce9..09955835 100644
--- a/buffy.c
+++ b/buffy.c
@@ -46,10 +46,11 @@ static short BuffyNotify = 0; /* # of unnotified new boxes */
int fseek_last_message (FILE * f)
{
long int pos;
- char buffer[BUFSIZ + 7]; /* 7 for "\n\nFrom " */
+ char buffer[BUFSIZ + 9]; /* 7 for "\n\nFrom " */
int bytes_read;
int i; /* Index into `buffer' for scanning. */
- memset (buffer, 0, BUFSIZ+7);
+
+ memset (buffer, 0, sizeof(buffer));
fseek (f, 0, SEEK_END);
pos = ftell (f);
@@ -63,7 +64,7 @@ int fseek_last_message (FILE * f)
while ((pos -= bytes_read) >= 0)
{
/* we save in the buffer at the end the first 7 chars from the last read */
- strncpy (buffer + BUFSIZ, buffer, 7);
+ strncpy (buffer + BUFSIZ, buffer, 5+2); /* 2 == 2 * strlen(CRLF) */
fseek (f, pos, SEEK_SET);
bytes_read = fread (buffer, sizeof (char), bytes_read, f);
if (bytes_read == -1)
@@ -113,7 +114,7 @@ int test_new_folder (const char *path)
typ = mx_get_magic (path);
- if (typ != M_MBOX && typ != M_MMDF)
+ if (typ != M_MBOX && typ != M_MMDF && typ != M_KENDRA)
return 0;
f = fopen (path, "rb");
@@ -277,6 +278,7 @@ int mutt_buffy_check (int force)
{
case M_MBOX:
case M_MMDF:
+ case M_KENDRA:
if (STAT_CHECK)
{
diff --git a/commands.c b/commands.c
index c7a08923..eb9c9949 100644
--- a/commands.c
+++ b/commands.c
@@ -657,7 +657,7 @@ int mutt_save_message (HEADER *h, int delete, int decode, int decrypt, int *redr
}
}
- need_buffy_cleanup = (ctx.magic == M_MBOX || ctx.magic == M_MMDF);
+ need_buffy_cleanup = (ctx.magic == M_MBOX || ctx.magic == M_MMDF || ctx.magic == M_KENDRA);
mx_close_mailbox (&ctx);
diff --git a/copy.c b/copy.c
index 4e2b61b5..f04de422 100644
--- a/copy.c
+++ b/copy.c
@@ -515,9 +515,9 @@ _mutt_append_message (CONTEXT *dest, FILE *fpin, CONTEXT *src, HEADER *hdr,
MESSAGE *msg;
int r;
- if ((msg = mx_open_new_message (dest, hdr, (src->magic == M_MBOX || src->magic == M_MMDF) ? 0 : M_ADD_FROM)) == NULL)
+ if ((msg = mx_open_new_message (dest, hdr, (src->magic == M_MBOX || src->magic == M_MMDF || src->magic == M_KENDRA) ? 0 : M_ADD_FROM)) == NULL)
return -1;
- if (dest->magic == M_MBOX || dest->magic == M_MMDF)
+ if (dest->magic == M_MBOX || dest->magic == M_MMDF || dest->magic == M_KENDRA)
chflags |= CH_FROM;
chflags |= (dest->magic == M_MAILDIR ? CH_NOSTATUS : CH_UPDATE);
r = _mutt_copy_message (msg->fp, fpin, hdr, body, flags, chflags);
diff --git a/init.c b/init.c
index 87c3bf4b..601fd758 100644
--- a/init.c
+++ b/init.c
@@ -907,6 +907,9 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err)
case M_MMDF:
p = "MMDF";
break;
+ case M_KENDRA:
+ p = "KENDRA";
+ break;
case M_MH:
p = "MH";
break;
diff --git a/mbox.c b/mbox.c
index 8bf1686b..37aea877 100644
--- a/mbox.c
+++ b/mbox.c
@@ -19,6 +19,10 @@ static const char rcsid[]="$Id$";
/* This file contains code to parse ``mbox'' and ``mmdf'' style mailboxes */
+/* OS/2's "kendra" mail folder format is also supported. It's a slightly
+ * modified version of MMDF.
+ */
+
#include "mutt.h"
#include "mailbox.h"
#include "mx.h"
@@ -106,12 +110,13 @@ int mmdf_parse_mailbox (CONTEXT *ctx)
tz = mutt_local_tz ();
buf[sizeof (buf) - 1] = 0;
+
FOREVER
{
if (fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL)
break;
- if (strcmp (buf, MMDF_SEP) == 0)
+ if (strcmp (buf, ctx->magic == M_MMDF ? MMDF_SEP : KENDRA_SEP) == 0)
{
loc = ftell (ctx->fp);
@@ -154,7 +159,7 @@ int mmdf_parse_mailbox (CONTEXT *ctx)
{
if (fseek (ctx->fp, tmploc, SEEK_SET) != 0 ||
fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL ||
- strcmp (MMDF_SEP, buf) != 0)
+ strcmp (ctx->magic == M_MMDF ? MMDF_SEP : KENDRA_SEP, buf) != 0)
{
if (fseek (ctx->fp, loc, SEEK_SET) != 0)
dprint (1, (debugfile, "mmdf_parse_mailbox: fseek() failed\n"));
@@ -175,7 +180,7 @@ int mmdf_parse_mailbox (CONTEXT *ctx)
if (fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL)
break;
lines++;
- } while (strcmp (buf, MMDF_SEP) != 0);
+ } while (strcmp (buf, ctx->magic == M_MMDF ? MMDF_SEP : KENDRA_SEP) != 0);
hdr->lines = lines;
hdr->content->length = loc - hdr->content->offset;
@@ -188,6 +193,8 @@ int mmdf_parse_mailbox (CONTEXT *ctx)
hdr->env->from = rfc822_cpy_adr (hdr->env->return_path);
mx_update_context (ctx);
+ if(ctx->magic == M_KENDRA && feof(ctx->fp))
+ break;
}
else
{
@@ -402,7 +409,7 @@ int mbox_open_mailbox (CONTEXT *ctx)
if (ctx->magic == M_MBOX)
rc = mbox_parse_mailbox (ctx);
- else if (ctx->magic == M_MMDF)
+ else if (ctx->magic == M_MMDF || ctx->magic == M_KENDRA)
rc = mmdf_parse_mailbox (ctx);
else
rc = -1;
@@ -586,7 +593,8 @@ int mbox_check_mailbox (CONTEXT *ctx, int *index_hint)
if (fgets (buffer, sizeof (buffer), ctx->fp) != NULL)
{
if ((ctx->magic == M_MBOX && strncmp ("From ", buffer, 5) == 0) ||
- (ctx->magic == M_MMDF && strcmp (MMDF_SEP, buffer) == 0))
+ (ctx->magic == M_MMDF && strcmp (MMDF_SEP, buffer) == 0) ||
+ (ctx->magic == M_KENDRA && strcmp(KENDRA_SEP, buffer) == 0))
{
if (fseek (ctx->fp, ctx->size, SEEK_SET) != 0)
dprint (1, (debugfile, "mbox_check_mailbox: fseek() failed\n"));
@@ -650,7 +658,7 @@ int mbox_check_mailbox (CONTEXT *ctx, int *index_hint)
int mbox_sync_mailbox (CONTEXT *ctx)
{
char tempfile[_POSIX_PATH_MAX];
- char buf[16];
+ char buf[32];
int i, j, save_sort = SORT_ORDER;
int need_sort = 0; /* flag to resort mailbox if new mail arrives */
int first; /* first message to be written */
@@ -732,15 +740,19 @@ int mbox_sync_mailbox (CONTEXT *ctx)
goto bail;
}
+ /* save the index of the first changed/deleted message */
+ first = i;
+ /* where to start overwriting */
+ offset = ctx->hdrs[i]->offset;
- first = i; /* save the index of the first changed/deleted message */
- offset = ctx->hdrs[i]->offset; /* where to start overwriting */
/* the offset stored in the header does not include the MMDF_SEP, so make
* sure we seek to the correct location
*/
if (ctx->magic == M_MMDF)
offset -= strlen (MMDF_SEP);
-
+ else if (ctx->magic == M_KENDRA)
+ offset -= strlen(KENDRA_SEP);
+
/* allocate space for the new offsets */
newOffset = safe_calloc (ctx->msgcount - first, sizeof (struct m_update_t));
@@ -758,6 +770,11 @@ int mbox_sync_mailbox (CONTEXT *ctx)
if (fputs (MMDF_SEP, fp) == EOF)
goto bail;
}
+ else if (ctx->magic == M_KENDRA)
+ {
+ if (fputs (KENDRA_SEP, fp) == EOF)
+ goto bail;
+ }
/* save the new offset for this message. we add `offset' because the
* temporary file only contains saved message which are located after
@@ -777,11 +794,20 @@ int mbox_sync_mailbox (CONTEXT *ctx)
newOffset[i - first].body = ftell (fp) - ctx->hdrs[i]->content->length + offset;
mutt_free_body (&ctx->hdrs[i]->content->parts);
- if (fputs (ctx->magic == M_MMDF ? MMDF_SEP : "\n", fp) == EOF)
- goto bail;
+ switch(ctx->magic)
+ {
+ case M_MMDF:
+ if(fputs(MMDF_SEP, fp) == EOF) goto bail;
+ break;
+ case M_KENDRA:
+ if(fputs(KENDRA_SEP, fp) == EOF) goto bail;
+ break;
+ default:
+ if(fputs("\n", fp) == EOF) goto bail;
+ }
}
}
-
+
if (fclose (fp) != 0)
{
fp = NULL;
@@ -811,7 +837,8 @@ int mbox_sync_mailbox (CONTEXT *ctx)
/* do a sanity check to make sure the mailbox looks ok */
fgets (buf, sizeof (buf), ctx->fp) == NULL ||
(ctx->magic == M_MBOX && strncmp ("From ", buf, 5) != 0) ||
- (ctx->magic == M_MMDF && strcmp (MMDF_SEP, buf) != 0))
+ (ctx->magic == M_MMDF && strcmp (MMDF_SEP, buf) != 0) ||
+ (ctx->magic == M_KENDRA && strcmp (KENDRA_SEP, buf) != 0))
{
dprint (1, (debugfile, "mbox_sync_mailbox: message not in expected position."));
dprint (1, (debugfile, "\tLINE: %s\n", buf));
@@ -1001,6 +1028,7 @@ int mutt_reopen_mailbox (CONTEXT *ctx, int *index_hint)
{
case M_MBOX:
case M_MMDF:
+ case M_KENDRA:
if (fseek (ctx->fp, 0, SEEK_SET) != 0)
{
dprint (1, (debugfile, "mutt_reopen_mailbox: fseek() failed\n"));
diff --git a/mx.c b/mx.c
index b1ed5c01..44698121 100644
--- a/mx.c
+++ b/mx.c
@@ -392,6 +392,8 @@ int mx_set_magic (const char *s)
DefaultMagic = M_MH;
else if (strcasecmp (s, "maildir") == 0)
DefaultMagic = M_MAILDIR;
+ else if (strcasecmp (s, "kendra") == 0)
+ DefaultMagic = M_KENDRA;
else
return (-1);
diff --git a/mx.h b/mx.h
index 6501744c..b97a985f 100644
--- a/mx.h
+++ b/mx.h
@@ -27,6 +27,7 @@ enum
{
M_MBOX = 1,
M_MMDF,
+ M_KENDRA,
M_MH,
M_MAILDIR
#ifdef USE_IMAP
@@ -37,6 +38,7 @@ enum
WHERE short DefaultMagic INITVAL (M_MBOX);
#define MMDF_SEP "\001\001\001\001\n"
+#define KENDRA_SEP "\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\n"
#define MAXLOCKATTEMPT 5
int mbox_sync_mailbox (CONTEXT *);
diff --git a/sendlib.c b/sendlib.c
index 4f7a1dd5..11170c3e 100644
--- a/sendlib.c
+++ b/sendlib.c
@@ -1911,7 +1911,7 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post,
/* We need to add a Content-Length field to avoid problems where a line in
* the message body begins with "From "
*/
- if (f.magic == M_MMDF || f.magic == M_MBOX)
+ if (f.magic == M_MMDF || f.magic == M_MBOX || f.magic == M_KENDRA)
{
mutt_mktemp (tempfile);
if ((tempfp = safe_fopen (tempfile, "w+")) == NULL)