From: Francois Fleuret Date: Wed, 6 Feb 2013 08:09:23 +0000 (+0100) Subject: Added default_search_field, set to "participant". X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=7edf0cc9d64e71d1ca91dd34dbe03c12380c9466;p=mymail.git Added default_search_field, set to "participant". --- diff --git a/mymail.c b/mymail.c index 0e9009a..3c810a1 100644 --- a/mymail.c +++ b/mymail.c @@ -59,6 +59,7 @@ regex_t leading_from_line_regexp; int paranoid; int quiet; +char *default_search_field = "p"; /********************************************************************/ @@ -688,11 +689,12 @@ static struct option long_options[] = { /*********************************************************************/ -void init_condition(struct search_condition *condition, char *string) { +void init_condition(struct search_condition *condition, char *full_string) { char full_search_field[TOKEN_BUFFER_SIZE], *search_field; int m; + char *string; - string = parse_token(full_search_field, TOKEN_BUFFER_SIZE, ' ', string); + string = parse_token(full_search_field, TOKEN_BUFFER_SIZE, ' ', full_string); search_field = full_search_field; if(search_field[0] == '!') { @@ -784,6 +786,18 @@ void init_condition(struct search_condition *condition, char *string) { } } + if(condition->field_id == -1) { + if(default_search_field) { + for(m = 0; (m < MAX_ID) && condition->field_id == -1; m++) { + if(strncmp(field_names[m], + default_search_field, strlen(default_search_field)) == 0) { + condition->field_id = m; + } + } + string = full_string; + } + } + if(condition->field_id == -1) { fprintf(stderr, "mymail: Syntax error in field name \"%s\".\n",