summary refs log tree commit diff
diff options
context:
space:
mode:
authorDuncaen <mail@duncano.de>2017-01-20 23:24:39 +0100
committerDuncaen <mail@duncano.de>2017-01-20 23:31:17 +0100
commit12e504fa42b43e031d070ca37395882a276ddbb0 (patch)
tree58363b116ea193b0bd7c4fa4d2ceee192f580070
parent0344e5a425afc11e988101156722a0e47722a1af (diff)
downloadmblaze-12e504fa42b43e031d070ca37395882a276ddbb0.tar.gz
mblaze-12e504fa42b43e031d070ca37395882a276ddbb0.tar.xz
mblaze-12e504fa42b43e031d070ca37395882a276ddbb0.zip
mpick: add msglist from address support
Fixes #9
-rw-r--r--mpick.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/mpick.c b/mpick.c
index 25c797e..7850a74 100644
--- a/mpick.c
+++ b/mpick.c
@@ -721,7 +721,27 @@ parse_msglist(char *s)
 
 			return e1;
 		} else {
-			expr = chain(parse_expr("from.addr == 's'"), EXPR_AND, expr);
+			char *disp, *addr;
+
+			d = blaze822_addr(s, &disp, &addr);
+			if (!disp && !addr)
+				parse_error("invalid address at '%.15s'", pos);
+
+			d = strdup((disp) ? disp : addr);
+
+			e1 = mkexpr(EXPR_REGEXI);
+			e1->a.prop = PROP_FROM;
+			e1->b.regex = malloc(sizeof (regex_t));
+			e1->extra = (disp) ? 0 : 1;
+
+			r = regcomp(e1->b.regex, d, REG_EXTENDED | REG_NOSUB | REG_ICASE);
+			if (r != 0) {
+				char msg[256];
+				regerror(r, e1->b.regex, msg, sizeof msg);
+				parse_error("invalid regex '%s': %s", d, msg);
+			}
+
+			return e1;
 		}
 	}
 	return 0;