X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=mymail.c;h=b0744be4165d837d11b3810b3589b7ad529f2149;hb=b9768330a0a489db900b5b36cff1ec0dda2acacf;hp=347f2a4be148611e356bf5993f4b0743a77ddc0d;hpb=cc6ebaf22de26379f347bccad740d4d2d28f780e;p=mymail.git diff --git a/mymail.c b/mymail.c index 347f2a4..b0744be 100644 --- a/mymail.c +++ b/mymail.c @@ -84,6 +84,10 @@ enum { ID_PARTICIPANT, ID_BODY, ID_TIME_INTERVAL, + /* + ID_MAIL_ID, + ID_REFERENCES, + */ MAX_ID }; @@ -96,7 +100,11 @@ static char *field_keys[] = { "date", "part", "body", - "interval" + "interval", + /* + "mailid", + "references" + */ }; /********************************************************************/ @@ -153,6 +161,22 @@ static struct parsable_field fields_to_parse[] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + /* + { + ID_MAIL_ID, + REG_ICASE, + "^message-id: ", + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + }, + + { + ID_REFERENCES, + REG_ICASE, + "^\\(in-reply-to\\|references\\): ", + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + }, + */ + }; /********************************************************************/ @@ -506,6 +530,12 @@ int search_in_db(const char *db_filename, while(nb_extracted_mails < global_nb_mails_max && fgets(raw_db_line, BUFFER_SIZE, db_file)) { + + /* Removes the CR */ + char *s = raw_db_line; + while(*s && *s != '\n') { s++; } + *s = '\0'; + db_value = parse_token(db_key_string, TOKEN_BUFFER_SIZE, ' ', raw_db_line); if(strcmp("mail", db_key_string) == 0) { @@ -521,7 +551,7 @@ int search_in_db(const char *db_filename, for(n = 0; n < nb_search_conditions; n++) { hits[n] = 0; } db_value = parse_token(position_in_file_string, TOKEN_BUFFER_SIZE, ' ', db_value); - db_value = parse_token(current_mail_filename, PATH_MAX+1, '\n', db_value); + strncpy(current_mail_filename, db_value, PATH_MAX + 1); current_position_in_mail = atol(position_in_file_string); } @@ -1146,6 +1176,16 @@ int main(int argc, char **argv) { } } + if(error) { + print_usage(stderr); + exit(EXIT_FAILURE); + } + + if(show_help) { + print_usage(stdout); + exit(EXIT_SUCCESS); + } + /* Set all the values that may defined in the arguments, through environment variables, or hard-coded */ @@ -1169,18 +1209,6 @@ int main(int argc, char **argv) { "MYMAIL_MBOX_PATTERN", 0); - /* Start the processing */ - - if(error) { - print_usage(stderr); - exit(EXIT_FAILURE); - } - - if(show_help) { - print_usage(stdout); - exit(EXIT_SUCCESS); - } - /* mbox indexing */ if(action_index) {