diff --git a/mairix.h b/mairix.h index ea3b56c..6c61dc3 100644 --- a/mairix.h +++ b/mairix.h @@ -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 */ diff --git a/mbox.c b/mbox.c index f8bed26..6444286 100644 --- a/mbox.c +++ b/mbox.c @@ -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); @@ -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; in_mboxen; i++) { diff --git a/rfc822.c b/rfc822.c index 6839828..04a7209 100644 --- a/rfc822.c +++ b/rfc822.c @@ -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 */ @@ -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; @@ -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); } /*}}}*/ @@ -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; @@ -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 { @@ -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; @@ -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) { @@ -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; @@ -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", @@ -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 */ @@ -993,7 +993,7 @@ 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; @@ -1001,7 +1001,7 @@ struct rfc822 *data_to_rfc822(struct msg_src *src, 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); @@ -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: @@ -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; @@ -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)); @@ -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; @@ -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; @@ -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; @@ -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; diff --git a/search.c b/search.c index f8e70f0..df105a0 100644 --- a/search.c +++ b/search.c @@ -81,7 +81,7 @@ static void mark_hits_in_table2(struct read_db *db, struct toktable2_db *tt, int Curnow - I haven't looked at any related source (webglimpse, agrep etc) in writing this. */ -static void build_match_vector(char *substring, unsigned long *a, unsigned long *hit)/*{{{*/ +static void build_match_vector(char *substring, unsigned long long *a, unsigned long long *hit)/*{{{*/ { int len; char *p; @@ -100,12 +100,12 @@ static void build_match_vector(char *substring, unsigned long *a, unsigned long return; } /*}}}*/ -static int substring_match_0(unsigned long *a, unsigned long hit, int left_anchor, char *token)/*{{{*/ +static int substring_match_0(unsigned long long *a, unsigned long long hit, int left_anchor, char *token)/*{{{*/ { int got_hit=0; char *p; - unsigned long r0; - unsigned long anchor, anchor1; + unsigned long long r0; + unsigned long long anchor, anchor1; r0 = ~0; got_hit = 0; @@ -123,12 +123,12 @@ static int substring_match_0(unsigned long *a, unsigned long hit, int left_ancho return got_hit; } /*}}}*/ -static int substring_match_1(unsigned long *a, unsigned long hit, int left_anchor, char *token)/*{{{*/ +static int substring_match_1(unsigned long long *a, unsigned long long hit, int left_anchor, char *token)/*{{{*/ { int got_hit=0; char *p; - unsigned long r0, r1, nr0; - unsigned long anchor, anchor1; + unsigned long long r0, r1, nr0; + unsigned long long anchor, anchor1; r0 = ~0; r1 = r0<<1; @@ -149,12 +149,12 @@ static int substring_match_1(unsigned long *a, unsigned long hit, int left_ancho return got_hit; } /*}}}*/ -static int substring_match_2(unsigned long *a, unsigned long hit, int left_anchor, char *token)/*{{{*/ +static int substring_match_2(unsigned long long *a, unsigned long long hit, int left_anchor, char *token)/*{{{*/ { int got_hit=0; char *p; - unsigned long r0, r1, r2, nr0, nr1; - unsigned long anchor, anchor1; + unsigned long long r0, r1, r2, nr0, nr1; + unsigned long long anchor, anchor1; r0 = ~0; r1 = r0<<1; @@ -178,12 +178,12 @@ static int substring_match_2(unsigned long *a, unsigned long hit, int left_ancho return got_hit; } /*}}}*/ -static int substring_match_3(unsigned long *a, unsigned long hit, int left_anchor, char *token)/*{{{*/ +static int substring_match_3(unsigned long long *a, unsigned long long hit, int left_anchor, char *token)/*{{{*/ { int got_hit=0; char *p; - unsigned long r0, r1, r2, r3, nr0, nr1, nr2; - unsigned long anchor, anchor1; + unsigned long long r0, r1, r2, r3, nr0, nr1, nr2; + unsigned long long anchor, anchor1; r0 = ~0; r1 = r0<<1; @@ -210,12 +210,12 @@ static int substring_match_3(unsigned long *a, unsigned long hit, int left_ancho return got_hit; } /*}}}*/ -static int substring_match_general(unsigned long *a, unsigned long hit, int left_anchor, char *token, int max_errors, unsigned long *r, unsigned long *nr)/*{{{*/ +static int substring_match_general(unsigned long long *a, unsigned long long hit, int left_anchor, char *token, int max_errors, unsigned long long *r, unsigned long long *nr)/*{{{*/ { int got_hit=0; char *p; int j; - unsigned long anchor, anchor1; + unsigned long long anchor, anchor1; r[0] = ~0; anchor = 0; @@ -251,9 +251,9 @@ static void match_substring_in_table(struct read_db *db, struct toktable_db *tt, { int i, got_hit; - unsigned long a[256]; - unsigned long *r=NULL, *nr=NULL; - unsigned long hit; + unsigned long long a[256]; + unsigned long long *r=NULL, *nr=NULL; + unsigned long long hit; char *token; build_match_vector(substring, a, &hit); @@ -296,9 +296,9 @@ static void match_substring_in_table2(struct read_db *db, struct toktable2_db *t { int i, got_hit; - unsigned long a[256]; - unsigned long *r=NULL, *nr=NULL; - unsigned long hit; + unsigned long long a[256]; + unsigned long long *r=NULL, *nr=NULL; + unsigned long long hit; char *token; build_match_vector(substring, a, &hit); @@ -341,9 +341,9 @@ static void match_substring_in_paths(struct read_db *db, char *substring, int ma { int i; - unsigned long a[256]; - unsigned long *r=NULL, *nr=NULL; - unsigned long hit; + unsigned long long a[256]; + unsigned long long *r=NULL, *nr=NULL; + unsigned long long hit; build_match_vector(substring, a, &hit); @@ -682,7 +682,7 @@ static void mbox_terminate(const unsigned char *data, int len, FILE *out)/*{{{*/ static void append_file_to_mbox(const char *path, FILE *out)/*{{{*/ { unsigned char *data; - int len; + size_t len; create_ro_mapping(path, &data, &len); if (data) { fprintf(out, "From mairix@mairix Mon Jan 1 12:34:56 1970\n"); @@ -719,7 +719,7 @@ static int had_failed_checksum; static void get_validated_mbox_msg(struct read_db *db, int msg_index,/*{{{*/ int *mbox_index, - unsigned char **mbox_data, int *mbox_len, + unsigned char **mbox_data, size_t *mbox_len, unsigned char **msg_data, int *msg_len) { /* msg_data==NULL if checksum mismatches */ @@ -759,7 +759,8 @@ static void append_mboxmsg_to_mbox(struct read_db *db, int msg_index, FILE *out) { /* Need to common up code with try_copy_to_path */ unsigned char *mbox_start, *msg_start; - int mbox_len, msg_len; + size_t mbox_len; + int msg_len; int mbox_index; get_validated_mbox_msg(db, msg_index, &mbox_index, &mbox_start, &mbox_len, &msg_start, &msg_len); @@ -780,7 +781,8 @@ static void append_mboxmsg_to_mbox(struct read_db *db, int msg_index, FILE *out) static void try_copy_to_path(struct read_db *db, int msg_index, char *target_path)/*{{{*/ { unsigned char *data; - int mbox_len, msg_len; + size_t mbox_len; + int msg_len; int mbi; FILE *out; unsigned char *start; @@ -1286,7 +1288,8 @@ static int do_search(struct read_db *db, char **args, char *output_path, int sho unsigned int mbix, msgix; int start, len, after_end; unsigned char *mbox_start, *msg_start; - int mbox_len, msg_len; + size_t mbox_len; + int msg_len; int mbox_index; start = db->mtime_table[i];