1 #include <lib9.h> 2 #include <regexp.h> 3 4 struct x 5 { 6 char *re; 7 char *s; 8 Reprog *p; 9 }; 10 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 { "^(coma|research|pipe|pyxis|inet|hunny|gauss)!(.*)$", "/mail/lib/qmail '\s' 'net!\\1' '\\2'", 0 }, 20 { "^.*$", "/mail/lib/qmail '\s' 'net!research' '&'", 0 }, 21 { 0, 0, 0 }, 22 }; 23 24 25 26 main(int ac, char **av) 27 { 28 Resub rs[10]; 29 char dst[128]; 30 int n; 31 struct x *tp; 32 33 for(tp = t; tp->re; tp++) 34 tp->p = regcomp(tp->re); 35 36 37 for(tp = t; tp->re; tp++){ 38 print("%s VIA %s", av[1], tp->re); 39 if(regexec(tp->p, av[1], rs, 10)){ 40 regsub(tp->s, dst, rs, 10); 41 print(" sub %s -> %s", tp->s, dst); 42 } 43 print("\n"); 44 } 45 exits(0); 46 } 47