-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.c
50 lines (44 loc) · 1.04 KB
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "regexp9.h"
struct x
{
char *re;
char *s;
Reprog *p;
};
struct x t[] = {
{ "^[^!@]+$", "/bin/upas/aliasmail '&'", 0 },
{ "^local!(.*)$", "/mail/box/\\1/mbox", 0 },
{ "^plan9!(.*)$", "\\1", 0 },
{ "^helix!(.*)$", "\\1", 0 },
{ "^([^!]+)@([^!@]+)$", "\\2!\\1", 0 },
{ "^(uk\\.[^!]*)(!.*)$", "/bin/upas/uk2uk '\\1' '\\2'", 0 },
{ "^[^!]*\\.[^!]*!.*$", "inet!&", 0 },
{ "^\xE2\x98\xBA$", "smiley", 0 },
{ "^(coma|research|pipe|pyxis|inet|hunny|gauss)!(.*)$", "/mail/lib/qmail '\\s' 'net!\\1' '\\2'", 0 },
{ "^.*$", "/mail/lib/qmail '\\s' 'net!research' '&'", 0 },
{ 0, 0, 0 },
};
int
main(int ac, char **av)
{
Resub rs[10];
char dst[128];
struct x *tp;
if(ac != 2)
exit(1);
for(tp = t; tp->re; tp++)
tp->p = regcomp(tp->re);
for(tp = t; tp->re; tp++){
printf("%s VIA %s", av[1], tp->re);
memset(rs, 0, sizeof rs);
if(regexec(tp->p, av[1], rs, 10)){
regsub(tp->s, dst, sizeof dst, rs, 10);
printf(" sub %s -> %s", tp->s, dst);
}
printf("\n");
}
exit(0);
}