rendered paste body#*****************************************************************************
#* _ _ ____ _
#* Project ___| | | | _ \| |
#* / __| | | | |_) | |
#* | (__| |_| | _ <| |___
#* \___|\___/|_| \_\_____|
#*
#* $Id: perl_interface.c,v 1.0 2007/08/10 13:45:11 Voldor Exp $
#*****************************************************************************
#!/usr/bin/perl -w
#perl -MInline=Force,NoClean,Info hello.pl // Debugging
#perl hello.pl // Run it
#pp -M FindBin -M Inline -o hello.pl hello // Compile stand-alone exe, remember _Inline dir
use Inline C => Config =>
ENABLE => AUTOWRAP => #Use curl functions
AUTO_INCLUDE => '#include "curl/curl.h"' => #Curl library
LIBS => "-lcurl"; #Curl flag
use Inline C => <<'END';
char* hello_inline(char* host) {
CURL *curl;
CURLcode res;
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, host);
curl_easy_setopt(curl, CURLOPT_HEADER, 1);
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
curl_easy_setopt(curl, CURLOPT_AUTOREFERER, 1);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
END
if (@ARGV < 1) {
print("Usage: $0 <url>\n");
print("Example: ./$0 www.google.com\n");
exit(1);
}
my $host = shift; #Take input
hello_inline($host); #Run c code