void *p = malloc(n);
if(!p && n != 0) {
fprintf(stderr,
- "selector: cannot allocate memory: %s\n", strerror(errno));
+ "mymail: cannot allocate memory: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
return p;
return result;
} else {
fprintf(stderr,
- "mymail: Cannot open file '%s' (%s) with mode \"%s\".\n",
- path, comment, mode);
+ "mymail: Cannot open file '%s' (%s) with mode \"%s\": %s\n",
+ path, comment, mode,
+ strerror(errno));
exit(EXIT_FAILURE);
}
}
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) {
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);
}