FILE *db_file) {
char raw_line[BUFFER_SIZE];
char current_mail_filename[BUFFER_SIZE];
- unsigned int current_position_in_mail;
+ unsigned long int current_position_in_mail;
char *name, *value;
regex_t regexp;
int already_written;
name = raw_line;
value = segment_next_field(raw_line);
- /* printf("LINE [%s] %s", name, value); */
-
if(strcmp("mail", name) == 0) {
char *position_in_file_string = value;
char *mail_filename = segment_next_field(value);
- current_position_in_mail = atoi(position_in_file_string);
+ current_position_in_mail = atol(position_in_file_string);
strcpy(current_mail_filename, mail_filename);
remove_eof(current_mail_filename);
- /* printf("READING [%s]\n", current_mail_filename); */
already_written = 0;
- } else if(!already_written) {
- if(strcmp(search_name, name) == 0 && regexec(®exp, value, 0, 0, 0) == 0) {
+ }
+
+ else if(!already_written) {
+ if(strcmp(search_name, name) == 0 && regexec(®exp, value, 0, 0, 0) == 0) {
FILE *mail_file;
- /* printf("%s:%u\n", current_mail_filename, current_position_in_mail); */
mail_file = fopen(current_mail_filename, "r");
if(!mail_file) {
fprintf(stderr, "mymail: Can not open `%s'.\n", current_mail_filename);
}
}
}
+
+ regfree(®exp);
}
char raw_line[BUFFER_SIZE];
FILE *file;
int in_header, new_header;
- unsigned int position_in_file;
+ unsigned long int position_in_file;
file = fopen(input_filename, "r");
if(strncmp(raw_line, "From ", 5) == 0) {
if(in_header) {
fprintf(stderr,
- "Got a 'From ' in the header in %s:%u.\n",
+ "Got a 'From ' in the header in %s:%lu.\n",
input_filename, position_in_file);
fprintf(stderr, "%s", raw_line);
exit(EXIT_FAILURE);
int f;
regmatch_t matches;
if(new_header) {
- fprintf(db_file, "mail %u %s\n", position_in_file, input_filename);
+ fprintf(db_file, "mail %lu %s\n", position_in_file, input_filename);
new_header = 0;
}
for(f = 0; f < nb_fields_to_parse; f++) {
int ignore_entry(const char *name) {
return
- strcmp(name, ".") == 0 ||
- strcmp(name, "..") == 0 ||
+ /* strcmp(name, ".") == 0 || */
+ /* strcmp(name, "..") == 0 || */
(name[0] == '.' && name[1] != '/');
}
dir_name,
strerror(errno));
exit(EXIT_FAILURE);
- } else {
}
- if(S_ISLNK(sb.st_mode)) {
- return;
- }
+ /* if(S_ISLNK(sb.st_mode)) { */
+ /* return; */
+ /* } */
dir = opendir(dir_name);
}
closedir(dir);
} else {
- if(S_ISREG(sb.st_mode)) {
- /* printf("Processing regular file '%s'.\n", dir_name); */
+ /* if(S_ISREG(sb.st_mode)) { */
read_file(dir_name, nb_fields_to_parse, fields_to_parse, db_file);
- }
+ /* } */
}
}
}
}
+ free(db_filename);
+
exit(EXIT_SUCCESS);
}