--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/parser.rl Fri Aug 26 14:40:51 2011 -0700
@@ -0,0 +1,51 @@
+/* vim: set noet nosta sw=4 ts=4 ft=ragel : */
+
+#include "volta.h"
+
+/* state machine data */
+%%{
+ machine redirector;
+
+ action yay {
+ printf( "YAH\n" );
+ }
+
+ # http://, ftp://, https://, etc
+ proto = alpha{3,5} . '://';
+
+ # http://mahlon:password@example.com or http://mahlon@example.com
+ # username optional password
+ creds = ( alnum | [+._\-] )+ . ( ':' . any+ )? . '@';
+
+ main := ( proto . creds ) | proto @yay '\n';
+}%%
+%% write data;
+
+int
+parse( char *p )
+{
+ /* initial machine state */
+ short int cs = 0;
+
+ /* the client request object */
+ request c_request;
+ request *cp_request = &c_request;
+
+ /*
+ char ip[ INET_ADDRSTRLEN ];
+ inet_pton( AF_INET, "127.0.0.1", &cp_request->ip );
+ inet_ntop( AF_INET, &cp_request->ip, ip, INET_ADDRSTRLEN );
+ */
+
+ /* initalize state machine with current line */
+ char *pe = p + strlen(p) + 1;
+
+ /* enter state machine */
+ %% write init;
+ %% write exec;
+
+ /* reset the request */
+ /* c_request = reset_request; */
+ return( 0 );
+}
+