1 Making mairix work with mbox files over 2GB.
3 https://github.com/rc0/mairix/pull/19
5 diff --git a/mairix.h b/mairix.h
6 index 2480492..cb25824 100644
9 @@ -327,9 +327,9 @@ enum data_to_rfc822_error {
10 DTR8_BAD_HEADERS, /* corrupt headers */
11 DTR8_BAD_ATTACHMENT /* corrupt attachment (e.g. no body part) */
13 -struct rfc822 *data_to_rfc822(struct msg_src *src, char *data, int length, enum data_to_rfc822_error *error);
14 -void create_ro_mapping(const char *filename, unsigned char **data, int *len);
15 -void free_ro_mapping(unsigned char *data, int len);
16 +struct rfc822 *data_to_rfc822(struct msg_src *src, char *data, size_t length, enum data_to_rfc822_error *error);
17 +void create_ro_mapping(const char *filename, unsigned char **data, size_t *len);
18 +void free_ro_mapping(unsigned char *data, size_t len);
19 char *format_msg_src(struct msg_src *src);
22 diff --git a/mbox.c b/mbox.c
23 index ebbfa78..396e27d 100644
26 @@ -816,7 +816,7 @@ void build_mbox_lists(struct database *db, const char *folder_base, /*{{{*/
27 mb->n_old_msgs_valid = mb->n_msgs;
32 create_ro_mapping(mb->path, &va, &len);
34 rescan_mbox(mb, (char *) va, len);
35 @@ -852,7 +852,7 @@ int add_mbox_messages(struct database *db)/*{{{*/
41 enum data_to_rfc822_error error;
43 for (i=0; i<db->n_mboxen; i++) {
44 diff --git a/reader.c b/reader.c
45 index 71ac5bd..18f0108 100644
48 @@ -81,7 +81,8 @@ static void read_toktable2_db(char *data, struct toktable2_db *toktable, int sta
50 struct read_db *open_db(char *filename)/*{{{*/
57 struct read_db *result;
58 diff --git a/reader.h b/reader.h
59 index 9b5dfa3..d709cc4 100644
62 @@ -138,7 +138,7 @@ struct toktable2_db {/*{{{*/
63 struct read_db {/*{{{*/
64 /* Raw file parameters, needed later for munmap */
69 /* Pathname information */
71 diff --git a/rfc822.c b/rfc822.c
72 index b411f85..9c8e1a4 100644
75 @@ -990,7 +990,7 @@ static void scan_status_flags(const char *s, struct headers *hdrs)/*{{{*/
77 /*{{{ data_to_rfc822() */
78 struct rfc822 *data_to_rfc822(struct msg_src *src,
79 - char *data, int length,
80 + char *data, size_t length,
81 enum data_to_rfc822_error *error)
83 struct rfc822 *result;
84 @@ -1265,7 +1265,7 @@ static struct ro_mapping *add_ro_cache(const char *filename, int fd, size_t len)
86 #endif /* USE_GZIP_MBOX || USE_BZIP_MBOX */
88 -void create_ro_mapping(const char *filename, unsigned char **data, int *len)/*{{{*/
89 +void create_ro_mapping(const char *filename, unsigned char **data, size_t *len)/*{{{*/
93 @@ -1386,7 +1386,7 @@ comp_error:
94 data_alloc_type = ALLOC_MMAP;
97 -void free_ro_mapping(unsigned char *data, int len)/*{{{*/
98 +void free_ro_mapping(unsigned char *data, size_t len)/*{{{*/
102 @@ -1414,7 +1414,7 @@ static struct msg_src *setup_msg_src(char *filename)/*{{{*/
104 struct rfc822 *make_rfc822(char *filename)/*{{{*/
109 struct rfc822 *result;
111 diff --git a/search.c b/search.c
112 index 18b51ee..97967bc 100644
115 @@ -681,7 +681,7 @@ static void mbox_terminate(const unsigned char *data, int len, FILE *out)/*{{{*/
116 static void append_file_to_mbox(const char *path, FILE *out)/*{{{*/
121 create_ro_mapping(path, &data, &len);
123 fprintf(out, "From mairix@mairix Mon Jan 1 12:34:56 1970\n");
124 @@ -698,8 +698,8 @@ static int had_failed_checksum;
126 static void get_validated_mbox_msg(struct read_db *db, int msg_index,/*{{{*/
128 - unsigned char **mbox_data, int *mbox_len,
129 - unsigned char **msg_data, int *msg_len)
130 + unsigned char **mbox_data, size_t *mbox_len,
131 + unsigned char **msg_data, size_t *msg_len)
133 /* msg_data==NULL if checksum mismatches */
134 unsigned char *start;
135 @@ -738,7 +738,7 @@ static void append_mboxmsg_to_mbox(struct read_db *db, int msg_index, FILE *out)
137 /* Need to common up code with try_copy_to_path */
138 unsigned char *mbox_start, *msg_start;
139 - int mbox_len, msg_len;
140 + size_t mbox_len, msg_len;
143 get_validated_mbox_msg(db, msg_index, &mbox_index, &mbox_start, &mbox_len, &msg_start, &msg_len);
144 @@ -759,7 +759,7 @@ static void append_mboxmsg_to_mbox(struct read_db *db, int msg_index, FILE *out)
145 static void try_copy_to_path(struct read_db *db, int msg_index, char *target_path)/*{{{*/
148 - int mbox_len, msg_len;
149 + size_t mbox_len, msg_len;
152 unsigned char *start;
153 @@ -1214,7 +1214,7 @@ static int do_search(struct read_db *db, char **args, char *output_path, int sho
154 unsigned int mbix, msgix;
155 int start, len, after_end;
156 unsigned char *mbox_start, *msg_start;
157 - int mbox_len, msg_len;
158 + size_t mbox_len, msg_len;
161 start = db->mtime_table[i];