Skip to content

Instantly share code, notes, and snippets.

@perplexes
Created August 12, 2010 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perplexes/520065 to your computer and use it in GitHub Desktop.
Save perplexes/520065 to your computer and use it in GitHub Desktop.
%%{
machine gearman;
alphtype int;
action req_magic {
puts "req_magic"
}
action get_size {
puts "get_size"
}
action test_size { puts "match size"; true }
size = (0..255){4} %get_size;
data = (any when test_size)*;
req_head = 0 'REQ';
res_head = 0 'RES';
req_magic = 0{3} (1|2|3|4|7|9|12|13|14|15|16|18|21|22|23|24|25|26|28|29|30|32|33|34|35|36) %req_magic;
res_magic = 0{3} (6|8|10|11|12|13|14|17|19|20|25|27|28|29|31);
req_packet = req_head req_magic size data;
res_packet = res_head res_magic size data;
packet = req_packet | res_packet;
main := |*
packet => {
puts "packet"
};
*|;
}%%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment