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