Cooler_

URLcrackC 2 array ruby 2 hash ruby

Aug 5th, 2012
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.66 KB | None | 0 0
  1. #!/usr/local/bin/ruby17 -w
  2.  
  3. begin
  4.   require 'rubygems'
  5. rescue LoadError
  6.   $: << 'lib'
  7. end
  8. require 'inline'
  9.  
  10. class Parser
  11.  
  12.   inline do |builder|
  13.     builder.add_compile_flags %q(-O3)
  14. #    builder.add_link_flags %q(-lstdc++)
  15.     builder.include "<string.h>"
  16.     builder.c "
  17. char *parseGet(char *url)
  18. {
  19. char *q = memchr(url, '?', strlen(url));
  20. if(q != NULL)
  21.  return q+1;
  22. else
  23.  return 0;
  24. }
  25. "
  26.   end
  27. end
  28.  
  29. def get_fields (url)
  30. #exemple 2 call
  31.  t = Parser.new()
  32.  array=t.parseGet(url).split(/[\&\=]/)
  33.  hash = Hash[*array.flatten]
  34.  @ret=hash
  35. end
  36.  
  37.  
  38.  hash=get_fields("http://teste.com/index.jsp?var=2&test=3&var2=ball")
  39.  puts hash.inspect
Add Comment
Please, Sign In to add comment