diff options
author | Brendan Cully <brendan@kublai.com> | 2005-09-24 19:45:22 +0000 |
---|---|---|
committer | Brendan Cully <brendan@kublai.com> | 2005-09-24 19:45:22 +0000 |
commit | f2baaf411baf41e5ac0233302166e4de9ea1d4e8 (patch) | |
tree | 878f3c35350e10bf2f7baa08ffaecacb3f6d4d34 | |
parent | 3313ff832a97ad3f710ca331ff5cc69002b54ae9 (diff) |
Use fseeko/ftello when available while opening mbox/mmdf. Closes: #2084.
-rw-r--r-- | configure.in | 10 | ||||
-rw-r--r-- | mbox.c | 28 | ||||
-rw-r--r-- | mutt.h | 2 |
3 files changed, 25 insertions, 15 deletions
diff --git a/configure.in b/configure.in index 5d9c57c0..bd516358 100644 --- a/configure.in +++ b/configure.in @@ -41,6 +41,7 @@ AC_C_INLINE AC_C_CONST AC_SYS_LARGEFILE +AC_FUNC_FSEEKO AC_PATH_PROG(DBX, dbx, no) AC_PATH_PROG(GDB, gdb, no) @@ -82,6 +83,15 @@ AH_TEMPLATE([ICONV_NONTRANS], [Define as 1 if iconv() only converts exactly and we should treat all return values other than (size_t)(-1) as equivalent.]) +AH_BOTTOM([/* fseeko portability defines */ +#ifdef HAVE_FSEEKO +# define LOFF_T off_t +#else +# define LOFF_T long +# define fseeko fseek +# define ftello ftell +#endif +]) MUTT_C99_INTTYPES ac_aux_path_sendmail=/usr/sbin:/usr/lib @@ -85,7 +85,7 @@ int mmdf_parse_mailbox (CONTEXT *ctx) int count = 0, oldmsgcount = ctx->msgcount; int lines; time_t t, tz; - long loc, tmploc; + LOFF_T loc, tmploc; HEADER *hdr; struct stat sb; #ifdef NFS_ATTRIBUTE_HACK @@ -122,7 +122,7 @@ int mmdf_parse_mailbox (CONTEXT *ctx) if (mutt_strcmp (buf, MMDF_SEP) == 0) { - loc = ftell (ctx->fp); + loc = ftello (ctx->fp); count++; if (!ctx->quiet && ReadInc && ((count % ReadInc == 0) || count == 1)) @@ -159,7 +159,7 @@ int mmdf_parse_mailbox (CONTEXT *ctx) hdr->env = mutt_read_rfc822_header (ctx->fp, hdr, 0, 0); - loc = ftell (ctx->fp); + loc = ftello (ctx->fp); if (hdr->content->length > 0 && hdr->lines > 0) { @@ -186,7 +186,7 @@ int mmdf_parse_mailbox (CONTEXT *ctx) { lines = -1; do { - loc = ftell (ctx->fp); + loc = ftello (ctx->fp); if (fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL) break; lines++; @@ -231,7 +231,7 @@ int mbox_parse_mailbox (CONTEXT *ctx) HEADER *curhdr; time_t t, tz; int count = 0, lines = 0; - long loc; + LOFF_T loc; #ifdef NFS_ATTRIBUTE_HACK struct utimbuf newtime; #endif @@ -262,7 +262,7 @@ int mbox_parse_mailbox (CONTEXT *ctx) date received */ tz = mutt_local_tz (0); - loc = ftell (ctx->fp); + loc = ftello (ctx->fp); while (fgets (buf, sizeof (buf), ctx->fp) != NULL) { if (is_from (buf, return_path, sizeof (return_path), &t)) @@ -304,9 +304,9 @@ int mbox_parse_mailbox (CONTEXT *ctx) */ if (curhdr->content->length > 0) { - long tmploc; + LOFF_T tmploc; - loc = ftell (ctx->fp); + loc = ftello (ctx->fp); tmploc = loc + curhdr->content->length + 1; if (0 < tmploc && tmploc < ctx->size) @@ -315,13 +315,13 @@ int mbox_parse_mailbox (CONTEXT *ctx) * check to see if the content-length looks valid. we expect to * to see a valid message separator at this point in the stream */ - if (fseek (ctx->fp, tmploc, SEEK_SET) != 0 || + if (fseeko (ctx->fp, tmploc, SEEK_SET) != 0 || fgets (buf, sizeof (buf), ctx->fp) == NULL || mutt_strncmp ("From ", buf, 5) != 0) { dprint (1, (debugfile, "mbox_parse_mailbox: bad content-length in message %d (cl=%ld)\n", curhdr->index, curhdr->content->length)); dprint (1, (debugfile, "\tLINE: %s", buf)); - if (fseek (ctx->fp, loc, SEEK_SET) != 0) /* nope, return the previous position */ + if (fseeko (ctx->fp, loc, SEEK_SET) != 0) /* nope, return the previous position */ { dprint (1, (debugfile, "mbox_parse_mailbox: fseek() failed\n")); } @@ -346,7 +346,7 @@ int mbox_parse_mailbox (CONTEXT *ctx) int cl = curhdr->content->length; /* count the number of lines in this message */ - if (fseek (ctx->fp, loc, SEEK_SET) != 0) + if (fseeko (ctx->fp, loc, SEEK_SET) != 0) dprint (1, (debugfile, "mbox_parse_mailbox: fseek() failed\n")); while (cl-- > 0) { @@ -356,7 +356,7 @@ int mbox_parse_mailbox (CONTEXT *ctx) } /* return to the offset of the next message separator */ - if (fseek (ctx->fp, tmploc, SEEK_SET) != 0) + if (fseeko (ctx->fp, tmploc, SEEK_SET) != 0) dprint (1, (debugfile, "mbox_parse_mailbox: fseek() failed\n")); } } @@ -374,7 +374,7 @@ int mbox_parse_mailbox (CONTEXT *ctx) else lines++; - loc = ftell (ctx->fp); + loc = ftello (ctx->fp); } /* @@ -387,7 +387,7 @@ int mbox_parse_mailbox (CONTEXT *ctx) { if (PREV->content->length < 0) { - PREV->content->length = ftell (ctx->fp) - PREV->content->offset - 1; + PREV->content->length = ftello (ctx->fp) - PREV->content->offset - 1; if (PREV->content->length < 0) PREV->content->length = 0; } @@ -627,7 +627,7 @@ typedef struct body * attachment */ long offset; /* offset where the actual data begins */ - long length; /* length (in bytes) of attachment */ + LOFF_T length; /* length (in bytes) of attachment */ char *filename; /* when sending a message, this is the file * to which this structure refers */ |