Blob


1 #include "lib9.h"
2 #include <regexp9.h>
4 struct x
5 {
6 char *re;
7 char *s;
8 Reprog *p;
9 };
11 struct x t[] = {
12 { "^[^!@]+$", "/bin/upas/aliasmail '&'", 0 },
13 { "^local!(.*)$", "/mail/box/\\1/mbox", 0 },
14 { "^plan9!(.*)$", "\\1", 0 },
15 { "^helix!(.*)$", "\\1", 0 },
16 { "^([^!]+)@([^!@]+)$", "\\2!\\1", 0 },
17 { "^(uk\\.[^!]*)(!.*)$", "/bin/upas/uk2uk '\\1' '\\2'", 0 },
18 { "^[^!]*\\.[^!]*!.*$", "inet!&", 0 },
19 { "^\xE2\x98\xBA$", "smiley", 0 },
20 { "^(coma|research|pipe|pyxis|inet|hunny|gauss)!(.*)$", "/mail/lib/qmail '\\s' 'net!\\1' '\\2'", 0 },
21 { "^.*$", "/mail/lib/qmail '\\s' 'net!research' '&'", 0 },
22 { 0, 0, 0 },
23 };
25 int
26 main(int ac, char **av)
27 {
28 Resub rs[10];
29 char dst[128];
30 struct x *tp;
32 for(tp = t; tp->re; tp++)
33 tp->p = regcomp(tp->re);
35 for(tp = t; tp->re; tp++){
36 print("%s VIA %s", av[1], tp->re);
37 memset(rs, 0, sizeof rs);
38 if(regexec(tp->p, av[1], rs, 10)){
39 regsub(tp->s, dst, sizeof dst, rs, 10);
40 print(" sub %s -> %s", tp->s, dst);
41 }
42 print("\n");
43 }
44 exit(0);
45 }