5 #include "libre9/re9.h"
15 static struct x t
[] = {
16 { "^[^!@]+$", "/bin/upas/aliasmail '\\0'", 0 },
17 { "^local!(.*)$", "/mail/box/\\1/mbox", 0 },
18 { "^plan9!(.*)$", "\\1", 0 },
19 { "^helix!(.*)$", "\\1", 0 },
20 { "^([^!]+)@([^!@]+)$", "\\2!\\1", 0 },
21 { "^(uk\\.[^!]*)(!.*)$", "/bin/upas/uk2uk '\\1' '\\2'", 0 },
22 { "^[^!]*\\.[^!]*!.*$", "inet!\\0", 0 },
23 { "^\xE2\x98\xBA$", "smiley", 0 },
24 { "^(coma|research|pipe|pyxis|inet|hunny|gauss)!(.*)$", "/mail/lib/qmail '\\s' 'net!\\1' '\\2'", 0 },
25 { "^.*$", "/mail/lib/qmail '\\s' 'net!research' '\\{0}'", 0 },
30 int main (int argc
, char *argv
[]) {
32 static char dst
[8192];
35 for (tp
= t
; tp
->re
; ++tp
) tp
->p
= re9_compile(tp
->re
, RE9_FLAG_NONUTF8
, NULL
);
37 for (int f
= 1; f
< argc
; ++f
) {
38 if (f
> 1) printf("===============================\n");
39 for (tp
= t
; tp
->re
; ++tp
) {
40 printf("<%s> VIA <%s>", argv
[f
], tp
->re
);
41 if (re9_execute(tp
->p
, RE9_FLAG_NONUTF8
, argv
[f
], rs
, 10)) {
42 int sz
= re9_sub(dst
, sizeof(dst
), tp
->s
, rs
, 10);
43 printf(" sub %s -> <%s> (%d)", tp
->s
, dst
, sz
);
49 for (tp
= t
; tp
->re
; ++tp
) re9_free(tp
->p
);