linux_xanmod: 5.11.14 -> 5.11.15
[NixPkgs.git] / pkgs / tools / text / mairix / mmap.patch
blob241083f2dde57445d55cc2f285781f7348514cc7
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
7 --- a/mairix.h
8 +++ b/mairix.h
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);
21 /* In tok.c */
22 diff --git a/mbox.c b/mbox.c
23 index ebbfa78..396e27d 100644
24 --- a/mbox.c
25 +++ b/mbox.c
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;
28 } else {
29 unsigned char *va;
30 - int len;
31 + size_t len;
32 create_ro_mapping(mb->path, &va, &len);
33 if (va) {
34 rescan_mbox(mb, (char *) va, len);
35 @@ -852,7 +852,7 @@ int add_mbox_messages(struct database *db)/*{{{*/
36 int any_new = 0;
37 int N;
38 unsigned char *va;
39 - int valen;
40 + size_t valen;
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
46 --- a/reader.c
47 +++ b/reader.c
48 @@ -81,7 +81,8 @@ static void read_toktable2_db(char *data, struct toktable2_db *toktable, int sta
49 /*}}}*/
50 struct read_db *open_db(char *filename)/*{{{*/
52 - int fd, len;
53 + int fd;
54 + size_t len;
55 char *data;
56 struct stat sb;
57 struct read_db *result;
58 diff --git a/reader.h b/reader.h
59 index 9b5dfa3..d709cc4 100644
60 --- a/reader.h
61 +++ b/reader.h
62 @@ -138,7 +138,7 @@ struct toktable2_db {/*{{{*/
63 struct read_db {/*{{{*/
64 /* Raw file parameters, needed later for munmap */
65 char *data;
66 - int len;
67 + size_t len;
69 /* Pathname information */
70 int n_msgs;
71 diff --git a/rfc822.c b/rfc822.c
72 index b411f85..9c8e1a4 100644
73 --- a/rfc822.c
74 +++ b/rfc822.c
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)/*{{{*/
91 struct stat sb;
92 int fd;
93 @@ -1386,7 +1386,7 @@ comp_error:
94 data_alloc_type = ALLOC_MMAP;
96 /*}}}*/
97 -void free_ro_mapping(unsigned char *data, int len)/*{{{*/
98 +void free_ro_mapping(unsigned char *data, size_t len)/*{{{*/
100 int r;
102 @@ -1414,7 +1414,7 @@ static struct msg_src *setup_msg_src(char *filename)/*{{{*/
103 /*}}}*/
104 struct rfc822 *make_rfc822(char *filename)/*{{{*/
106 - int len;
107 + size_t len;
108 unsigned char *data;
109 struct rfc822 *result;
111 diff --git a/search.c b/search.c
112 index 18b51ee..97967bc 100644
113 --- a/search.c
114 +++ b/search.c
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)/*{{{*/
118 unsigned char *data;
119 - int len;
120 + size_t len;
121 create_ro_mapping(path, &data, &len);
122 if (data) {
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,/*{{{*/
127 int *mbox_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;
141 int mbox_index;
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)/*{{{*/
147 unsigned char *data;
148 - int mbox_len, msg_len;
149 + size_t mbox_len, msg_len;
150 int mbi;
151 FILE *out;
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;
159 int mbox_index;
161 start = db->mtime_table[i];