+ if(nb_body_conditions == nb_fulfilled_body_conditions) {
+ FILE *mail_file;
+
+ mail_file = fopen(current_mail_filename, "r");
+
+ if(!mail_file) {
+ fprintf(stderr,
+ "mymail: Cannot open mbox '%s' for mail extraction.\n",
+ current_mail_filename);
+ exit(EXIT_FAILURE);
+ }
+
+ fseek(mail_file, current_position_in_mail, SEEK_SET);
+
+ if(fgets(raw_mbox_line, BUFFER_SIZE, mail_file)) {
+ last_mbox_line_was_empty = 1;
+ fprintf(output_file, "%s", raw_mbox_line);
+ while(1) {
+ if(!fgets(raw_mbox_line, BUFFER_SIZE, mail_file) ||
+ (last_mbox_line_was_empty && strncmp(raw_mbox_line, "From ", 5) == 0))
+ break;
+ last_mbox_line_was_empty = (raw_mbox_line[0] == '\n');
+ fprintf(output_file, "%s", raw_mbox_line);
+ }
+ }
+
+ fclose(mail_file);
+ }
+ }