Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/ruby17 -w
- begin
- require 'rubygems'
- rescue LoadError
- $: << 'lib'
- end
- require 'inline'
- class Parser
- inline do |builder|
- builder.add_compile_flags %q(-O3)
- # builder.add_link_flags %q(-lstdc++)
- builder.include "<string.h>"
- builder.c "
- char *parseGet(char *url)
- {
- char *q = memchr(url, '?', strlen(url));
- if(q != NULL)
- return q+1;
- else
- return 0;
- }
- "
- end
- end
- def get_fields (url)
- #exemple 2 call
- t = Parser.new()
- array=t.parseGet(url).split(/[\&\=]/)
- hash = Hash[*array.flatten]
- @ret=hash
- end
- hash=get_fields("http://teste.com/index.jsp?var=2&test=3&var2=ball")
- puts hash.inspect
Add Comment
Please, Sign In to add comment