Added default_search_field, set to "participant".
authorFrancois Fleuret <francois@fleuret.org>
Wed, 6 Feb 2013 08:09:23 +0000 (09:09 +0100)
committerFrancois Fleuret <francois@fleuret.org>
Wed, 6 Feb 2013 08:09:23 +0000 (09:09 +0100)
mymail.c

index 0e9009a..3c810a1 100644 (file)
--- 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",