#include <time.h>
#define MYMAIL_DB_MAGIC_TOKEN "mymail_index_file"
-#define VERSION "0.9.6"
+#define VERSION "0.9.7"
#define MAX_NB_SEARCH_CONDITIONS 32
#define BUFFER_SIZE 65536
#define TOKEN_BUFFER_SIZE 1024
-#define LEADING_FROM_LINE_REGEXP_STRING "^From [^ ]* \\(Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\|Sun\\) \\(Jan\\|Feb\\|Mar\\|Apr\\|May\\|Jun\\|Jul\\|Aug\\|Sep\\|Oct\\|Nov\\|Dec\\) [ 123][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9][0-9][0-9]\n$"
+#define LEADING_FROM_LINE_REGEXP_STRING "^From .*\\(Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\|Sun\\) \\(Jan\\|Feb\\|Mar\\|Apr\\|May\\|Jun\\|Jul\\|Aug\\|Sep\\|Oct\\|Nov\\|Dec\\) [ 0123][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9][0-9][0-9]\n$"
/* Global variables! */
const char *parse_token(char *token_buffer, size_t token_buffer_size,
char separator, const char *string) {
char *u = token_buffer;
+
while(*string == separator) { string++; }
- while(u < token_buffer + token_buffer_size - 1 && *string &&
- *string != separator) {
+
+ while(u < token_buffer + token_buffer_size - 1 && *string && *string != separator) {
*(u++) = *(string++);
}
+
while(*string == separator) { string++; }
+
*u = '\0';
return string;
}
if(fgets(raw_mbox_line, BUFFER_SIZE, mail_file)) {
while(nb_body_hits < nb_body_conditions) {
- /* last_mbox_line_was_empty = (raw_mbox_line[0] == '\n'); */
- /* if(last_mbox_line_was_empty) { header = 0; } */
-
if(raw_mbox_line[0] == '\n') { header = 0; }
if(!header) {
char raw_mbox_line[BUFFER_SIZE];
FILE *mail_file;
+ /* printf("Extract\n"); */
+
mail_file = safe_fopen(mail_filename, "r", "mbox for mail extraction");
fseek(mail_file, position_in_mail, SEEK_SET);
fprintf(output_file, "%s", raw_mbox_line);
while(1) {
if(!fgets(raw_mbox_line, BUFFER_SIZE, mail_file) ||
- (is_a_leading_from_line(raw_mbox_line))
- )
+ is_a_leading_from_line(raw_mbox_line))
break;
fprintf(output_file, "%s", raw_mbox_line);
}
if(db_key == ID_LEADING_LINE) {
c = db_value;
while(*c && *c != ' ') c++; while(*c && *c == ' ') c++;
+ /* printf("From %s", db_value); */
strptime(c, "%a %b %e %k:%M:%S %Y", &tm);
*t = mktime(&tm);
} else {
if(db_key == ID_DATE) {
if(strptime(db_value, "%a, %d %b %Y %k:%M:%S", &tm) ||
strptime(db_value, "%d %b %Y %k:%M:%S", &tm)) {
+ /* printf("Date: %s", db_value); */
*t = mktime(&tm);
}
}
condition->time_stop = 0;
}
}
+
break;
}
}