Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for large mailboxes #16

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mairix.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,9 @@ enum data_to_rfc822_error {
DTR8_BAD_HEADERS, /* corrupt headers */
DTR8_BAD_ATTACHMENT /* corrupt attachment (e.g. no body part) */
};
struct rfc822 *data_to_rfc822(struct msg_src *src, char *data, int length, enum data_to_rfc822_error *error);
void create_ro_mapping(const char *filename, unsigned char **data, int *len);
void free_ro_mapping(unsigned char *data, int len);
struct rfc822 *data_to_rfc822(struct msg_src *src, char *data, size_t length, enum data_to_rfc822_error *error);
void create_ro_mapping(const char *filename, unsigned char **data, size_t *len);
void free_ro_mapping(unsigned char *data, size_t len);
char *format_msg_src(struct msg_src *src);

/* In tok.c */
Expand Down
4 changes: 2 additions & 2 deletions mbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ void build_mbox_lists(struct database *db, const char *folder_base, /*{{{*/
mb->n_old_msgs_valid = mb->n_msgs;
} else {
unsigned char *va;
int len;
size_t len;
create_ro_mapping(mb->path, &va, &len);
if (va) {
rescan_mbox(mb, (char *) va, len);
Expand Down Expand Up @@ -853,7 +853,7 @@ int add_mbox_messages(struct database *db)/*{{{*/
int any_new = 0;
int N;
unsigned char *va;
int valen;
size_t valen;
enum data_to_rfc822_error error;

for (i=0; i<db->n_mboxen; i++) {
Expand Down
60 changes: 30 additions & 30 deletions rfc822.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ static int audit_header(struct line *header)/*{{{*/
* following lines have leading spaces or single word followed by colon
* */
struct line *x;
int first=1;
int count=1;
long long first=1;
long long count=1;
for (x=header->next; x!=header; x=x->next) {
int has_leading_space=0;
int is_blank;
int has_word_colon=0;
long long has_leading_space=0;
long long is_blank;
long long has_word_colon=0;

if (1 || first) {
/* Ignore any UUCP or mbox style From line at the start */
Expand All @@ -172,7 +172,7 @@ static int audit_header(struct line *header)/*{{{*/
is_blank = !(x->text[0]);
if (!is_blank) {
char *p;
int saw_char = 0;
long long saw_char = 0;
has_leading_space = isspace(x->text[0] & 0xff);
has_word_colon = 0; /* default */
p = x->text;
Expand Down Expand Up @@ -212,7 +212,7 @@ static int audit_header(struct line *header)/*{{{*/
}/*}}}*/
static int match_string(const char *ref, const char *candidate)/*{{{*/
{
int len = strlen(ref);
size_t len = strlen(ref);
return !strncasecmp(ref, candidate, len);
}
/*}}}*/
Expand Down Expand Up @@ -448,7 +448,7 @@ static char *looking_at_ws_then_newline(char *start)/*{{{*/
}
/*}}}*/

static char *unencode_data(struct msg_src *src, char *input, int input_len, const char *enc, int *output_len)/*{{{*/
static char *unencode_data(struct msg_src *src, char *input, long long input_len, const char *enc, long long *output_len)/*{{{*/
{
enum encoding_type encoding;
char *result, *end_result;
Expand Down Expand Up @@ -613,10 +613,10 @@ char *format_msg_src(struct msg_src *src)/*{{{*/
return result;
}
/*}}}*/
static int split_and_splice_header(struct msg_src *src, char *data, struct line *header, char **body_start)/*{{{*/
static long long split_and_splice_header(struct msg_src *src, char *data, struct line *header, char **body_start)/*{{{*/
{
char *sol, *eol;
int blank_line;
long long blank_line;
header->next = header->prev = header;
sol = data;
do {
Expand All @@ -629,7 +629,7 @@ static int split_and_splice_header(struct msg_src *src, char *data, struct line
}
if (*eol == '\n') {
if (!blank_line) {
int line_length = eol - sol;
long long line_length = eol - sol;
char *line_text = new_array(char, 1 + line_length);
struct line *new_header;

Expand Down Expand Up @@ -663,20 +663,20 @@ static int split_and_splice_header(struct msg_src *src, char *data, struct line
/*}}}*/

/* Forward prototypes */
static void do_multipart(struct msg_src *src, char *input, int input_len,
static void do_multipart(struct msg_src *src, char *input, long long input_len,
const char *boundary, struct attachment *atts,
enum data_to_rfc822_error *error);

/*{{{ do_body() */
static void do_body(struct msg_src *src,
char *body_start, int body_len,
char *body_start, long long body_len,
struct nvp *ct_nvp, struct nvp *cte_nvp,
struct nvp *cd_nvp,
struct attachment *atts,
enum data_to_rfc822_error *error)
{
char *decoded_body;
int decoded_body_len;
long long decoded_body_len;
const char *content_transfer_encoding;
content_transfer_encoding = NULL;
if (cte_nvp) {
Expand Down Expand Up @@ -770,7 +770,7 @@ static void do_attachment(struct msg_src *src,
/* decode attachment and add to attachment list */
struct line header, *x, *nx;
char *body_start;
int body_len;
long long body_len;

struct nvp *ct_nvp, *cte_nvp, *cd_nvp, *nvp;

Expand Down Expand Up @@ -834,15 +834,15 @@ static void do_attachment(struct msg_src *src,
/*}}}*/
/*{{{ do_multipart() */
static void do_multipart(struct msg_src *src,
char *input, int input_len,
char *input, long long input_len,
const char *boundary,
struct attachment *atts,
enum data_to_rfc822_error *error)
{
char *b0, *b1, *be, *bx;
char *line_after_b0, *start_b1_search_from;
int boundary_len;
int looking_at_end_boundary;
long long boundary_len;
long long looking_at_end_boundary;

if (!boundary) {
fprintf(stderr, "Can't process multipart message %s with no boundary string\n",
Expand All @@ -858,7 +858,7 @@ static void do_multipart(struct msg_src *src,
be = input + input_len;

do {
int boundary_ok;
long long boundary_ok;
start_b1_search_from = line_after_b0;
do {
/* reject boundaries that aren't a whole line */
Expand Down Expand Up @@ -993,15 +993,15 @@ static void scan_status_flags(const char *s, struct headers *hdrs)/*{{{*/

/*{{{ data_to_rfc822() */
struct rfc822 *data_to_rfc822(struct msg_src *src,
char *data, int length,
char *data, size_t length,
enum data_to_rfc822_error *error)
{
struct rfc822 *result;
char *body_start;
struct line header;
struct line *x, *nx;
struct nvp *ct_nvp, *cte_nvp, *cd_nvp, *nvp;
int body_len;
long long body_len;

if (error) *error = DTR8_OK; /* default */
result = new(struct rfc822);
Expand Down Expand Up @@ -1176,7 +1176,7 @@ static void xx_zclose(struct zFile *zf) {/*{{{*/
free(zf);
}
/*}}}*/
static int xx_zread(struct zFile *zf, void *buf, int len) {/*{{{*/
static long long xx_zread(struct zFile *zf, void *buf, long long len) {/*{{{*/
switch (zf->type) {
#ifdef USE_GZIP_MBOX
case COMPRESSION_GZIP:
Expand Down Expand Up @@ -1204,16 +1204,16 @@ struct ro_mapping {
unsigned char *map;
size_t len;
};
static int ro_cache_init = 0;
static long long ro_cache_init = 0;
static struct ro_mapping ro_mapping_cache[ROCACHE_SIZE];

/* find a temp file in the mapping cache. If nothing is found lasti is
* set to the next slot to use for insertion. You have to check that slot
* to see if it is currently in use
*/
static struct ro_mapping *find_ro_cache(const char *filename, int *lasti)
static struct ro_mapping *find_ro_cache(const char *filename, long long *lasti)
{
int i = 0;
long long i = 0;
struct ro_mapping *ro = NULL;
if (lasti)
*lasti = 0;
Expand All @@ -1239,7 +1239,7 @@ static struct ro_mapping *find_ro_cache(const char *filename, int *lasti)
*/
static struct ro_mapping *add_ro_cache(const char *filename, int fd, size_t len)
{
int i = 0;
long long i = 0;
struct ro_mapping *ro = NULL;
if (!ro_cache_init) {
memset(&ro_mapping_cache, 0, sizeof(ro_mapping_cache));
Expand Down Expand Up @@ -1268,7 +1268,7 @@ static struct ro_mapping *add_ro_cache(const char *filename, int fd, size_t len)
}
#endif /* USE_GZIP_MBOX || USE_BZIP_MBOX */

void create_ro_mapping(const char *filename, unsigned char **data, int *len)/*{{{*/
void create_ro_mapping(const char *filename, unsigned char **data, size_t *len)/*{{{*/
{
struct stat sb;
int fd;
Expand Down Expand Up @@ -1323,7 +1323,7 @@ void create_ro_mapping(const char *filename, unsigned char **data, int *len)/*{{
*len = cur_read;
if (cur_read >= SIZE_STEP) {
while(1) {
int ret;
long long ret;
cur_read = xx_zread(zf, p, SIZE_STEP);
if (cur_read <= 0)
break;
Expand Down Expand Up @@ -1389,7 +1389,7 @@ void create_ro_mapping(const char *filename, unsigned char **data, int *len)/*{{
data_alloc_type = ALLOC_MMAP;
}
/*}}}*/
void free_ro_mapping(unsigned char *data, int len)/*{{{*/
void free_ro_mapping(unsigned char *data, size_t len)/*{{{*/
{
int r;

Expand Down Expand Up @@ -1417,7 +1417,7 @@ static struct msg_src *setup_msg_src(char *filename)/*{{{*/
/*}}}*/
struct rfc822 *make_rfc822(char *filename)/*{{{*/
{
int len;
size_t len;
unsigned char *data;
struct rfc822 *result;

Expand Down
Loading