equal
deleted
inserted
replaced
|
1 /* vim: set noet nosta sw=4 ts=4 ft=ragel : */ |
|
2 |
|
3 #include "volta.h" |
|
4 |
|
5 /* state machine data */ |
|
6 %%{ |
|
7 machine redirector; |
|
8 |
|
9 action yay { |
|
10 printf( "YAH\n" ); |
|
11 } |
|
12 |
|
13 # http://, ftp://, https://, etc |
|
14 proto = alpha{3,5} . '://'; |
|
15 |
|
16 # http://mahlon:password@example.com or http://mahlon@example.com |
|
17 # username optional password |
|
18 creds = ( alnum | [+._\-] )+ . ( ':' . any+ )? . '@'; |
|
19 |
|
20 main := ( proto . creds ) | proto @yay '\n'; |
|
21 }%% |
|
22 %% write data; |
|
23 |
|
24 int |
|
25 parse( char *p ) |
|
26 { |
|
27 /* initial machine state */ |
|
28 short int cs = 0; |
|
29 |
|
30 /* the client request object */ |
|
31 request c_request; |
|
32 request *cp_request = &c_request; |
|
33 |
|
34 /* |
|
35 char ip[ INET_ADDRSTRLEN ]; |
|
36 inet_pton( AF_INET, "127.0.0.1", &cp_request->ip ); |
|
37 inet_ntop( AF_INET, &cp_request->ip, ip, INET_ADDRSTRLEN ); |
|
38 */ |
|
39 |
|
40 /* initalize state machine with current line */ |
|
41 char *pe = p + strlen(p) + 1; |
|
42 |
|
43 /* enter state machine */ |
|
44 %% write init; |
|
45 %% write exec; |
|
46 |
|
47 /* reset the request */ |
|
48 /* c_request = reset_request; */ |
|
49 return( 0 ); |
|
50 } |
|
51 |