Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Advertising

Perl Interface to Curl C API
Friday, August 10th, 2007 at 6:59:20am MDT 

  1. #*****************************************************************************
  2. #*                                  _   _ ____  _
  3. #*  Project                     ___| | | |  _ \| |
  4. #*                             / __| | | | |_) | |
  5. #*                            | (__| |_| |  _ <| |___
  6. #*                             \___|\___/|_| \_\_____|
  7. #*
  8. #* $Id: perl_interface.pl,v 1.0 2007/08/10 13:45:11 Voldor Exp $
  9. #*****************************************************************************
  10. #!/usr/bin/perl -w
  11. #perl -MInline=Force,NoClean,Info perl_interface.pl // Debugging
  12. #perl perl_interface.pl // Run it
  13. #pp -M FindBin -M Inline -o perl_interface.pl perl_interface =>
  14. #Compile stand-alone exe, remember _Inline dir - not use comments or ___EOF___
  15.  
  16. use Inline C => Config =>
  17. ENABLE => AUTOWRAP =>   #Use curl functions
  18. AUTO_INCLUDE => '#include "curl/curl.h"' =>   #Curl library
  19. LIBS => "-lcurl";   #Curl flag
  20. use Inline C => <<'END';
  21.  
  22. char* curl_inline(char* host) {
  23.           CURL *curl;
  24.       CURLcode res;
  25.       curl = curl_easy_init();
  26.       curl_easy_setopt(curl, CURLOPT_URL, host);
  27.       curl_easy_setopt(curl, CURLOPT_HEADER, 1);
  28.       curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
  29.       curl_easy_setopt(curl, CURLOPT_AUTOREFERER, 1);
  30.       curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
  31.     res = curl_easy_perform(curl);
  32.     curl_easy_cleanup(curl);
  33. }
  34. END
  35.  
  36. if (@ARGV < 1) {
  37.                     print("Usage: $0 <url>\n");
  38.                     print("Example: ./$0 www.google.com\n");
  39.                     exit(1);
  40.                     }
  41.                     
  42. my $host = shift; #Take input
  43.  
  44. curl_inline($host); #Run c code

Paste Details

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right