From: Francois Fleuret Date: Sat, 23 Mar 2013 16:37:02 +0000 (+0100) Subject: Cosmetics, renamed some db-related variables properly. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=3844ef01e27dbebdff078cd3c52d44b564367d2e;p=mymail.git Cosmetics, renamed some db-related variables properly. --- diff --git a/mymail.c b/mymail.c index c07e8a8..9c085de 100644 --- a/mymail.c +++ b/mymail.c @@ -249,8 +249,8 @@ int is_a_leading_from_line(char *mbox_line) { regexec(&global_leading_from_line_regexp, mbox_line, 0, 0, 0) == 0; } -int mbox_line_match_search(struct search_condition *condition, - int mbox_id, const char *mbox_value) { +int db_line_match_search(struct search_condition *condition, + int mbox_id, const char *mbox_value) { return ( @@ -317,7 +317,7 @@ void update_body_hits(char *mail_filename, int position_in_mail, } void extract_mail(const char *mail_filename, unsigned long int position_in_mail, - FILE *output_file) { + FILE *output_file) { char raw_mbox_line[BUFFER_SIZE]; FILE *mail_file; @@ -389,20 +389,20 @@ int check_full_mail_match(char *current_mail_filename, /* We use the mail leading line time by default, and if we should and can, we update with the Date: field */ -void update_time(int mbox_id, const char *mbox_value, time_t *t) { +void update_time(int db_id, const char *db_value, time_t *t) { const char *c; struct tm tm; - if(mbox_id == ID_LEADING_LINE) { - c = mbox_value; + if(db_id == ID_LEADING_LINE) { + c = db_value; while(*c && *c != ' ') c++; while(*c && *c == ' ') c++; strptime(c, "%a %b %e %k:%M:%S %Y", &tm); *t = mktime(&tm); } else { if(!global_use_leading_time) { - if(mbox_id == ID_DATE) { - if(strptime(mbox_value, "%a, %d %b %Y %k:%M:%S", &tm) || - strptime(mbox_value, "%d %b %Y %k:%M:%S", &tm)) { + if(db_id == ID_DATE) { + if(strptime(db_value, "%a, %d %b %Y %k:%M:%S", &tm) || + strptime(db_value, "%d %b %Y %k:%M:%S", &tm)) { *t = mktime(&tm); } } @@ -418,11 +418,11 @@ int search_in_db(const char *db_filename, FILE *db_file; char raw_db_line[BUFFER_SIZE]; char current_mail_filename[PATH_MAX + 1]; - char mbox_key[TOKEN_BUFFER_SIZE]; + char db_key[TOKEN_BUFFER_SIZE]; char position_in_file_string[TOKEN_BUFFER_SIZE]; unsigned long int current_position_in_mail; - const char *mbox_value; - int mbox_id; + const char *db_value; + int db_id; int hits[MAX_NB_SEARCH_CONDITIONS]; int nb_body_conditions, need_time; int nb_extracted_mails; @@ -477,9 +477,9 @@ int search_in_db(const char *db_filename, strcpy(current_mail_filename, ""); while(fgets(raw_db_line, BUFFER_SIZE, db_file)) { - mbox_value = parse_token(mbox_key, TOKEN_BUFFER_SIZE, ' ', raw_db_line); + db_value = parse_token(db_key, TOKEN_BUFFER_SIZE, ' ', raw_db_line); - if(strcmp("mail", mbox_key) == 0) { + if(strcmp("mail", db_key) == 0) { if(current_mail_filename[0]) { if(check_full_mail_match(current_mail_filename, mail_time, @@ -491,26 +491,26 @@ int search_in_db(const char *db_filename, } for(n = 0; n < nb_search_conditions; n++) { hits[n] = 0; } - mbox_value = parse_token(position_in_file_string, TOKEN_BUFFER_SIZE, ' ', mbox_value); - mbox_value = parse_token(current_mail_filename, PATH_MAX+1, '\n', mbox_value); + 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); current_position_in_mail = atol(position_in_file_string); } else { - mbox_id = -1; - for(m = 0; (m < MAX_ID) && mbox_id == -1; m++) { - if(strncmp(field_keys[m], mbox_key, strlen(mbox_key)) == 0) { - mbox_id = m; + db_id = -1; + for(m = 0; (m < MAX_ID) && db_id == -1; m++) { + if(strncmp(field_keys[m], db_key, strlen(db_key)) == 0) { + db_id = m; } } for(n = 0; n < nb_search_conditions; n++) { - hits[n] |= mbox_line_match_search(&search_conditions[n], - mbox_id, mbox_value); + hits[n] |= db_line_match_search(&search_conditions[n], + db_id, db_value); } if(need_time) { - update_time(mbox_id, mbox_value, &mail_time); + update_time(db_id, db_value, &mail_time); } } } @@ -811,7 +811,7 @@ void init_condition(struct search_condition *condition, const char *full_string, condition->field_id = -1; - /* Recently */ + /* Time condition */ for(k = 0; k < sizeof(time_criteria) / sizeof(struct time_criterion); k++) { if(strcmp(time_criteria[k].label, search_field) == 0) {