diff options
Diffstat (limited to 'perl')
-rw-r--r-- | perl/Curl_easy/Changes | 92 | ||||
-rw-r--r-- | perl/Curl_easy/MANIFEST | 16 | ||||
-rw-r--r-- | perl/Curl_easy/Makefile.PL | 87 | ||||
-rw-r--r-- | perl/Curl_easy/Makefile.am | 3 | ||||
-rw-r--r-- | perl/Curl_easy/README | 40 | ||||
-rw-r--r-- | perl/Curl_easy/curlopt-constants.c | 125 | ||||
-rw-r--r-- | perl/Curl_easy/easy.pm | 288 | ||||
-rw-r--r-- | perl/Curl_easy/easy.xs | 672 |
8 files changed, 0 insertions, 1323 deletions
diff --git a/perl/Curl_easy/Changes b/perl/Curl_easy/Changes deleted file mode 100644 index af3d9cb40..000000000 --- a/perl/Curl_easy/Changes +++ /dev/null @@ -1,92 +0,0 @@ -Revision history for Perl extension Curl::easy. -Check out the file README for more info. - -1.1.8 Thu Sep 20 2001: - Cris Bailiff <c.bailiff@devsecure.com> - - Re-generate CURLOPT_ constants from curl.h and enhance makefile - to allow this to be repeated in future or for older versions of - libcurl. Constants up-to-date for libcurl-7.9(pre) - - Split tests into t/*.t to simplify each case - - Add test cases for new SSL switches. This needs ca-bundle.crt - (from mod_ssl) for verifying test cases. - -1.1.7 Thu Sep 13 2001: - Cris Bailiff <c.bailiff@devsecure.com> - - Documentation Update only - Explicitly state that Curl_easy - is released under the MIT-X/MPL dual licence. No code changes. - -1.1.6 Mon Sep 10 2001: - Cris Bailiff <c.bailiff@devsecure.com> - - Fix segfault due to changes in header callback behaviour - since curl-7.8.1-pre3 - -1.1.5 Fri Apr 20 2001: - Cris Bailiff <c.bailiff@devsecure.com> - - Add latest CURLOPT_ and CURLINFO_ constants to the constants list - -1.1.4 Fri Apr 20 2001: - Cris Bailiff <c.bailiff@devsecure.com> - - Fix case where curl_slists such as 'HTTPHEADERS' need to - be re-set over persistant requests - -1.1.3 Wed Apr 18 2001: - Cris Bailiff <c.bailiff@devsecure.com> - - Change/shorten module function names: Curl::easy::curl_easy_setopt - becomes Curl::easy::setopt etc. This requires minor changes to existing - scripts.... - - Added callback function support to pass arbitrary SV * (including - FILE globs) from perl through libcurl to the perl callback. - - Make callbacks still work with existing scripts which use STDIO - - Initial support for libcurl 7.7.2 HEADERFUNCTION callback feature - - Minor API cleanups/changes in the callback function signatures - - Added Curl::easy::version function to return curl version string - - Callback documentation added in easy.pm - - More tests in test.pl - -1.1.2 Mon Apr 16 2001: - Georg Horn <horn@koblenz-net.de> - - Added support for callback functions. This is for the curl_easy_setopt() - options WRITEFUNCTION, READFUNCTION, PROGRESSFUNCTION and PASSWDFUNCTION. - Still missing, but not really neccessary: Passing a FILE * pointer, - that is passed in from libcurl, on to the perl callback function. - - Various cleanups, fixes and enhancements to easy.xs and test.pl. - -1.1.1 Thu Apr 12 2001: - - Made more options of curl_easy_setopt() work: Options that require - a list of curl_slist structs to be passed in, like CURLOPT_HTTPHEADER, - are now working by passing a perl array containing the list elements. - As always, look at the test script test.pl for an example. - -1.1.0 Wed Apr 11 2001: - - tested against libcurl 7.7 - - Added new function Curl::easy::internal_setopt(). By calling - Curl::easy::internal_setopt(Curl::easy::USE_INTERNAL_VARS, 1); - the headers and content of the fetched page are no longer stored - into files (or written to stdout) but are stored into internal - Variables $Curl::easy::headers and $Curl::easy::content. - -1.0.2 Tue Oct 10 2000: - - runs with libcurl 7.4 - - modified curl_easy_getinfo(). It now calls curl_getinfo() that has - been added to libcurl in version 7.4. - -1.0.1 Tue Oct 10 2000: - - Added some missing features of curl_easy_setopt(): - - CURLOPT_ERRORBUFFER now works by passing the name of a perl - variable that shall be crated and the errormessage (if any) - be stored to. - - Passing filehandles (Options FILE, INFILE and WRITEHEADER) now works. - Have a look at test.pl to see how it works... - - - Added a new function, curl_easy_getinfo(), that for now always - returns the number of bytes that where written to disk during the last - download. If the curl_easy_getinfo() function is included in libcurl, - (as promised by Daniel ;-)) i will turn this into just a call to this - function. - -1.0 Thu Oct 5 2000: - - first released version - - runs with libcurl 7.3 - - some features of curl_easy_setopt() are still missing: - - passing function pointers doesn't work (options WRITEFUNCTION, - READFUNCTION and PROGRESSFUNCTION). - - passing FILE * pointers doesn't work (options FILE, INFILE and - WRITEHEADER). - - passing linked lists doesn't work (options HTTPHEADER and - HTTPPOST). - - setting the buffer where to store error messages in doesn't work - (option ERRORBUFFER). - diff --git a/perl/Curl_easy/MANIFEST b/perl/Curl_easy/MANIFEST deleted file mode 100644 index 82f8c20ce..000000000 --- a/perl/Curl_easy/MANIFEST +++ /dev/null @@ -1,16 +0,0 @@ -Changes -MANIFEST -Makefile.PL -README -easy.pm -easy.xs -curlopt-constants.c -t/00constants.t -t/01basic.t -t/02header-callback.t -t/03body-callback.t -t/04abort-test.t -t/05progress.t -t/06http-post.t -t/07ftp-upload.t -t/08ssl.t diff --git a/perl/Curl_easy/Makefile.PL b/perl/Curl_easy/Makefile.PL deleted file mode 100644 index 551808fa9..000000000 --- a/perl/Curl_easy/Makefile.PL +++ /dev/null @@ -1,87 +0,0 @@ -# Makefile.PL for Perl extension Curl::easy. -# Check out the file README for more info. - -use ExtUtils::MakeMaker; -# See lib/ExtUtils/MakeMaker.pm for details of how to influence -# the contents of the Makefile that is written. -WriteMakefile( - 'NAME' => 'Curl::easy', - 'VERSION_FROM' => 'easy.pm', # finds $VERSION - 'LIBS' => ['-lcurl '], # e.g., '-lm' - 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING' - 'INC' => '', # e.g., '-I/usr/include/other' - 'clean' => {FILES => "head.out body.out"} -); - -# -# This utility helper generates the constants function from curl.h -# -# It is normally only used by the maintainer, but if you're curl is older -# or missing some constants, you can delete curlopt-constants.c and re-run 'perl Makefile.PL' -# - -if (!open(CONSTANTS,"<curlopt-constants.c")) { - print "Rebuilding curlopt-constants.c for your libcurl version\n"; - close(CONSTANTS); - -# -# You may need to specify where to find curl.h on your platform -# These are guesses only -# -my $curl_h; -HEADER: foreach my $try (qw( - - curl.h - ../../include/curl.h - /usr/include/curl/curl.h - /usr/local/include/curl/curl.h - C:\\INCLUDE\\CURL\\CURL.H - - )) -{ - if (-e $try) { - $curl_h=$try; - last HEADER; - } -} - -if (!defined($curl_h)) { - die "Could not rebuild curlopt-constants.c - can't find curl.h\n"; -} - -print "Found curl.h in $curl_h\n"; -open (CURL_H,"<".$curl_h) or die "Can't open curl.h\n"; -my %types; -my %codes; -while(<CURL_H>) { - if ($_ =~ m/CINIT\(/ and $_ !~ m/#/) { - my ($option,$type,$code)=m/.*CINIT\((\w*)\s*,\s*(\w+)\s*,\s*(\d+).*/; - $types{$option}=$type; - $codes{$option}=$code; - } -} -close(CURL_H); - -# some things are ifdefed out... -foreach my $ifdef0 (qw(FLAGS PROGRESSMODE)) -{ - delete $types{$ifdef0}; delete $codes{$ifdef0}; -} - -open(CURL_XS,">curlopt-constants.c") or die "Can't write curlopt-constants.c\n"; -foreach my $next_initial ('A'..'Z') { - print CURL_XS " case '$next_initial':\n"; - my $count=0; - foreach my $option (sort keys %types) { - my $initial=substr($option,0,1); - if ($next_initial eq $initial) { - print CURL_XS " if (strEQ(name, \"$option\")) return CURLOPT_$option;\n"; - $count++; - } - } - if ($count) { - print CURL_XS " break;\n"; - } -} -close(CURL_XS); -} diff --git a/perl/Curl_easy/Makefile.am b/perl/Curl_easy/Makefile.am deleted file mode 100644 index 219bfa5e3..000000000 --- a/perl/Curl_easy/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -SUBDIRS = t - -EXTRA_DIST = Changes easy.pm easy.xs curlopt-constants.c Makefile.PL MANIFEST README diff --git a/perl/Curl_easy/README b/perl/Curl_easy/README deleted file mode 100644 index 88a741923..000000000 --- a/perl/Curl_easy/README +++ /dev/null @@ -1,40 +0,0 @@ -README for Perl extension Curl::easy. - -The perl module Curl::easy provides an interface to the cURL library "libcurl". -See http://curl.haxx.se/ for more information on cURL and libcurl. - -This module requires libcurl and the corresponding headerfiles to be -installed. You then may install this module via the usual way: - - perl Makefile.PL - make - make test - make install - -If you have an older version of libcurl, you can remove 'curlopt-constants.c' -and have it rebuilt by 'perl Makefile.PL'. - -You can also do this for a later version of libcurl, except currently -you will have to update the module EXPORTS list manually. - -The module provides the same functionality as libcurl provides to C programs, -please refer to the documentation of libcurl. Some examples may be found in -t/*.t. - -This software is distributed AS IS, WITHOUT WARRANTY OF ANY KIND, either -express or implied. Send praise, patches, money, beer and pizza to the author. -Send complaints to /dev/null. ;-) - -The original author of this software is Georg Horn <horn@koblenz-net.de> -Parts of the callback support, tests and documentation have been added by -Cris Bailiff <c.bailiff@devsecure.com> and Forrest Cahoon <forrest.cahoon@merrillcorp.com> - -The current maintainer is Cris Bailiff <c.bailiff@devsecure.com> - -The latest version can be downloaded from http://curl.haxx.se/libcurl/perl/ - -Copyright (C) 2000, Daniel Stenberg, , et al. -You may opt to use, copy, modify, merge, publish, distribute and/or sell -copies of the Software, and permit persons to whom the Software is -furnished to do so, under the terms of the MPL or the MIT/X-derivate -licenses. You may pick one of these licenses. diff --git a/perl/Curl_easy/curlopt-constants.c b/perl/Curl_easy/curlopt-constants.c deleted file mode 100644 index 4a317deab..000000000 --- a/perl/Curl_easy/curlopt-constants.c +++ /dev/null @@ -1,125 +0,0 @@ - case 'A': - if (strEQ(name, "AUTOREFERER")) return CURLOPT_AUTOREFERER; - break; - case 'B': - case 'C': - if (strEQ(name, "CAINFO")) return CURLOPT_CAINFO; - if (strEQ(name, "CLOSEFUNCTION")) return CURLOPT_CLOSEFUNCTION; - if (strEQ(name, "CLOSEPOLICY")) return CURLOPT_CLOSEPOLICY; - if (strEQ(name, "CONNECTTIMEOUT")) return CURLOPT_CONNECTTIMEOUT; - if (strEQ(name, "COOKIE")) return CURLOPT_COOKIE; - if (strEQ(name, "COOKIEFILE")) return CURLOPT_COOKIEFILE; - if (strEQ(name, "COOKIEJAR")) return CURLOPT_COOKIEJAR; - if (strEQ(name, "CRLF")) return CURLOPT_CRLF; - if (strEQ(name, "CUSTOMREQUEST")) return CURLOPT_CUSTOMREQUEST; - break; - case 'D': - case 'E': - if (strEQ(name, "EGDSOCKET")) return CURLOPT_EGDSOCKET; - if (strEQ(name, "ERRORBUFFER")) return CURLOPT_ERRORBUFFER; - break; - case 'F': - if (strEQ(name, "FAILONERROR")) return CURLOPT_FAILONERROR; - if (strEQ(name, "FILE")) return CURLOPT_FILE; - if (strEQ(name, "FILETIME")) return CURLOPT_FILETIME; - if (strEQ(name, "FOLLOWLOCATION")) return CURLOPT_FOLLOWLOCATION; - if (strEQ(name, "FORBID_REUSE")) return CURLOPT_FORBID_REUSE; - if (strEQ(name, "FRESH_CONNECT")) return CURLOPT_FRESH_CONNECT; - if (strEQ(name, "FTPAPPEND")) return CURLOPT_FTPAPPEND; - if (strEQ(name, "FTPASCII")) return CURLOPT_FTPASCII; - if (strEQ(name, "FTPLISTONLY")) return CURLOPT_FTPLISTONLY; - if (strEQ(name, "FTPPORT")) return CURLOPT_FTPPORT; - break; - case 'G': - case 'H': - if (strEQ(name, "HEADER")) return CURLOPT_HEADER; - if (strEQ(name, "HEADERFUNCTION")) return CURLOPT_HEADERFUNCTION; - if (strEQ(name, "HTTPGET")) return CURLOPT_HTTPGET; - if (strEQ(name, "HTTPHEADER")) return CURLOPT_HTTPHEADER; - if (strEQ(name, "HTTPPOST")) return CURLOPT_HTTPPOST; - if (strEQ(name, "HTTPPROXYTUNNEL")) return CURLOPT_HTTPPROXYTUNNEL; - if (strEQ(name, "HTTPREQUEST")) return CURLOPT_HTTPREQUEST; - break; - case 'I': - if (strEQ(name, "INFILE")) return CURLOPT_INFILE; - if (strEQ(name, "INFILESIZE")) return CURLOPT_INFILESIZE; - if (strEQ(name, "INTERFACE")) return CURLOPT_INTERFACE; - break; - case 'J': - case 'K': - if (strEQ(name, "KRB4LEVEL")) return CURLOPT_KRB4LEVEL; - break; - case 'L': - if (strEQ(name, "LOW_SPEED_LIMIT")) return CURLOPT_LOW_SPEED_LIMIT; - if (strEQ(name, "LOW_SPEED_TIME")) return CURLOPT_LOW_SPEED_TIME; - break; - case 'M': - if (strEQ(name, "MAXCONNECTS")) return CURLOPT_MAXCONNECTS; - if (strEQ(name, "MAXREDIRS")) return CURLOPT_MAXREDIRS; - if (strEQ(name, "MUTE")) return CURLOPT_MUTE; - break; - case 'N': - if (strEQ(name, "NETRC")) return CURLOPT_NETRC; - if (strEQ(name, "NOBODY")) return CURLOPT_NOBODY; - if (strEQ(name, "NOPROGRESS")) return CURLOPT_NOPROGRESS; - if (strEQ(name, "NOTHING")) return CURLOPT_NOTHING; - break; - case 'O': - case 'P': - if (strEQ(name, "PASSWDDATA")) return CURLOPT_PASSWDDATA; - if (strEQ(name, "PASSWDFUNCTION")) return CURLOPT_PASSWDFUNCTION; - if (strEQ(name, "PORT")) return CURLOPT_PORT; - if (strEQ(name, "POST")) return CURLOPT_POST; - if (strEQ(name, "POSTFIELDS")) return CURLOPT_POSTFIELDS; - if (strEQ(name, "POSTFIELDSIZE")) return CURLOPT_POSTFIELDSIZE; - if (strEQ(name, "POSTQUOTE")) return CURLOPT_POSTQUOTE; - if (strEQ(name, "PROGRESSDATA")) return CURLOPT_PROGRESSDATA; - if (strEQ(name, "PROGRESSFUNCTION")) return CURLOPT_PROGRESSFUNCTION; - if (strEQ(name, "PROXY")) return CURLOPT_PROXY; - if (strEQ(name, "PROXYPORT")) return CURLOPT_PROXYPORT; - if (strEQ(name, "PROXYUSERPWD")) return CURLOPT_PROXYUSERPWD; - if (strEQ(name, "PUT")) return CURLOPT_PUT; - break; - case 'Q': - if (strEQ(name, "QUOTE")) return CURLOPT_QUOTE; - break; - case 'R': - if (strEQ(name, "RANDOM_FILE")) return CURLOPT_RANDOM_FILE; - if (strEQ(name, "RANGE")) return CURLOPT_RANGE; - if (strEQ(name, "READFUNCTION")) return CURLOPT_READFUNCTION; - if (strEQ(name, "REFERER")) return CURLOPT_REFERER; - if (strEQ(name, "RESUME_FROM")) return CURLOPT_RESUME_FROM; - break; - case 'S': - if (strEQ(name, "SSLCERT")) return CURLOPT_SSLCERT; - if (strEQ(name, "SSLCERTPASSWD")) return CURLOPT_SSLCERTPASSWD; - if (strEQ(name, "SSLVERSION")) return CURLOPT_SSLVERSION; - if (strEQ(name, "SSL_CIPHER_LIST")) return CURLOPT_SSL_CIPHER_LIST; - if (strEQ(name, "SSL_VERIFYHOST")) return CURLOPT_SSL_VERIFYHOST; - if (strEQ(name, "SSL_VERIFYPEER")) return CURLOPT_SSL_VERIFYPEER; - if (strEQ(name, "STDERR")) return CURLOPT_STDERR; - break; - case 'T': - if (strEQ(name, "TELNETOPTIONS")) return CURLOPT_TELNETOPTIONS; - if (strEQ(name, "TIMECONDITION")) return CURLOPT_TIMECONDITION; - if (strEQ(name, "TIMEOUT")) return CURLOPT_TIMEOUT; - if (strEQ(name, "TIMEVALUE")) return CURLOPT_TIMEVALUE; - if (strEQ(name, "TRANSFERTEXT")) return CURLOPT_TRANSFERTEXT; - break; - case 'U': - if (strEQ(name, "UPLOAD")) return CURLOPT_UPLOAD; - if (strEQ(name, "URL")) return CURLOPT_URL; - if (strEQ(name, "USERAGENT")) return CURLOPT_USERAGENT; - if (strEQ(name, "USERPWD")) return CURLOPT_USERPWD; - break; - case 'V': - if (strEQ(name, "VERBOSE")) return CURLOPT_VERBOSE; - break; - case 'W': - if (strEQ(name, "WRITEFUNCTION")) return CURLOPT_WRITEFUNCTION; - if (strEQ(name, "WRITEHEADER")) return CURLOPT_WRITEHEADER; - if (strEQ(name, "WRITEINFO")) return CURLOPT_WRITEINFO; - break; - case 'X': - case 'Y': - case 'Z': diff --git a/perl/Curl_easy/easy.pm b/perl/Curl_easy/easy.pm deleted file mode 100644 index 2324ace1f..000000000 --- a/perl/Curl_easy/easy.pm +++ /dev/null @@ -1,288 +0,0 @@ -# Perl interface for libcurl. Check out the file README for more info. - -package Curl::easy; - -use strict; -use Carp; -use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD); - -require Exporter; -require DynaLoader; -require AutoLoader; - -@ISA = qw(Exporter DynaLoader); -# Items to export into callers namespace by default. Note: do not export -# names by default without a very good reason. Use EXPORT_OK instead. -# Do not simply export all your public functions/methods/constants. -@EXPORT = qw( -CURLOPT_AUTOREFERER -CURLOPT_CAINFO -CURLOPT_CLOSEFUNCTION -CURLOPT_CLOSEPOLICY -CURLOPT_CONNECTTIMEOUT -CURLOPT_COOKIE -CURLOPT_COOKIEFILE -CURLOPT_COOKIEJAR -CURLOPT_CRLF -CURLOPT_CUSTOMREQUEST -CURLOPT_EGDSOCKET -CURLOPT_ERRORBUFFER -CURLOPT_FAILONERROR -CURLOPT_FILE -CURLOPT_FILETIME -CURLOPT_FOLLOWLOCATION -CURLOPT_FORBID_REUSE -CURLOPT_FRESH_CONNECT -CURLOPT_FTPAPPEND -CURLOPT_FTPASCII -CURLOPT_FTPLISTONLY -CURLOPT_FTPPORT -CURLOPT_HEADER -CURLOPT_HEADERFUNCTION -CURLOPT_HTTPGET -CURLOPT_HTTPHEADER -CURLOPT_HTTPPOST -CURLOPT_HTTPPROXYTUNNEL -CURLOPT_HTTPREQUEST -CURLOPT_INFILE -CURLOPT_INFILESIZE -CURLOPT_INTERFACE -CURLOPT_KRB4LEVEL -CURLOPT_LOW_SPEED_LIMIT -CURLOPT_LOW_SPEED_TIME -CURLOPT_MAXCONNECTS -CURLOPT_MAXREDIRS -CURLOPT_MUTE -CURLOPT_NETRC -CURLOPT_NOBODY -CURLOPT_NOPROGRESS -CURLOPT_NOTHING -CURLOPT_PASSWDDATA -CURLOPT_PASSWDFUNCTION -CURLOPT_PORT -CURLOPT_POST -CURLOPT_POSTFIELDS -CURLOPT_POSTFIELDSIZE -CURLOPT_POSTQUOTE -CURLOPT_PROGRESSDATA -CURLOPT_PROGRESSFUNCTION -CURLOPT_PROXY -CURLOPT_PROXYPORT -CURLOPT_PROXYUSERPWD -CURLOPT_PUT -CURLOPT_QUOTE -CURLOPT_RANDOM_FILE -CURLOPT_RANGE -CURLOPT_READFUNCTION -CURLOPT_REFERER -CURLOPT_RESUME_FROM -CURLOPT_SSLCERT -CURLOPT_SSLCERTPASSWD -CURLOPT_SSLVERSION -CURLOPT_SSL_CIPHER_LIST -CURLOPT_SSL_VERIFYHOST -CURLOPT_SSL_VERIFYPEER -CURLOPT_STDERR -CURLOPT_TELNETOPTIONS -CURLOPT_TIMECONDITION -CURLOPT_TIMEOUT -CURLOPT_TIMEVALUE -CURLOPT_TRANSFERTEXT -CURLOPT_UPLOAD -CURLOPT_URL -CURLOPT_USERAGENT -CURLOPT_USERPWD -CURLOPT_VERBOSE -CURLOPT_WRITEFUNCTION -CURLOPT_WRITEHEADER -CURLOPT_WRITEINFO - -CURLINFO_EFFECTIVE_URL -CURLINFO_HTTP_CODE -CURLINFO_TOTAL_TIME -CURLINFO_NAMELOOKUP_TIME -CURLINFO_CONNECT_TIME -CURLINFO_PRETRANSFER_TIME -CURLINFO_SIZE_UPLOAD -CURLINFO_SIZE_DOWNLOAD -CURLINFO_SPEED_DOWNLOAD -CURLINFO_SPEED_UPLOAD -CURLINFO_HEADER_SIZE -CURLINFO_REQUEST_SIZE -CURLINFO_SSL_VERIFYRESULT -CURLINFO_FILETIME -CURLINFO_CONTENT_LENGTH_DOWNLOAD -CURLINFO_CONTENT_LENGTH_UPLOAD - -USE_INTERNAL_VARS -); - -$VERSION = '1.1.8'; - -$Curl::easy::headers = ""; -$Curl::easy::content = ""; - -sub AUTOLOAD { - # This AUTOLOAD is used to 'autoload' constants from the constant() - # XS function. - - (my $constname = $AUTOLOAD) =~ s/.*:://; - return constant($constname, 0); -} - -bootstrap Curl::easy $VERSION; - -# Preloaded methods go here. - -# Autoload methods go after =cut, and are processed by the autosplit program. - -1; -__END__ -# Below is the stub of documentation for your module. You better edit it! - -=pod - -=head1 NAME - -Curl::easy - Perl extension for libcurl - -=head1 SYNOPSIS - - use Curl::easy; - - $curl = Curl::easy::init(); - $CURLcode = Curl::easy::setopt($curl, CURLoption, Value); - $CURLcode = Curl::easy::perform($curl); - Curl::easy::cleanup($curl); - - Read curl_easy_setopt for details of most CURLoption values - -=head1 DESCRIPTION - - - -B<Curl::easy> provides an interface to the libcurl C library. See -http://curl.haxx.se/ for more information on cURL and libcurl. - -=head2 FILES and CALLBACKS - -Curl::easy supports the various options of curl_easy_setopt which require either a FILE * or -a callback function. - -The perl callback functions are handled through a C wrapper which takes care of converting -from C to perl variables and back again. This wrapper simplifies some C arguments to make -them behave in a more 'perl' like manner. In particular, the read and write callbacks do not -look just like the 'fread' and 'fwrite' C functions - perl variables do not need separate length -parameters, and perl functions can return a list of variables, instead of needing a pointer -to modify. The details are described below. - -=head2 FILE handles (GLOBS) - -Curl options which take a FILE, such as CURLOPT_FILE, CURLOPT_WRITEHEADER, CURLOPT_INFILE -can be passed a perl file handle: - - open BODY,">body.out"; - $CURLcode = Curl::easy::setopt($curl, CURLOPT_FILE, BODY); - -=head2 WRITE callback - -The CUROPT_WRITEFUNCTION option may be set which will cause libcurl to callback to -the given subroutine: - - sub chunk { my ($data,$pointer)=@_; ...; return length($data) } - $CURLcode = Curl::easy::setopt($curl, CURLOPT_WRITEFUNCTION, \&chunk ); - $CURLcode = Curl::easy::setopt($curl, CURLOPT_FILE, ); - -In this case, the subroutine will be passed whatever is defined by CURLOPT_FILE. This can be -a ref to a scalar, or a GLOB or anything else you like. - -The callback function must return the number of bytes 'handled' ( length($data) ) or the transfer -will abort. A transfer can be aborted by returning a 'length' of '-1'. - -The option CURLOPT_WRITEHEADER can be set to pass a different '$pointer' into the CURLOPT_WRITEFUNCTION -for header values. This lets you collect the headers and body separately: - - my $headers=""; - my $body=""; - sub chunk { my ($data,$pointer)=@_; ${$pointer}.=$data; return length($data) } - - $CURLcode = Curl::easy::setopt($curl, CURLOPT_WRITEFUNCTION, \&chunk ); - $CURLcode = Curl::easy::setopt($curl, CURLOPT_WRITEHEADER, \$header ); - $CURLcode = Curl::easy::setopt($curl, CURLOPT_FILE, \$body ); - -If you have libcurl > 7.7.1, then you could instead set CURLOPT_HEADERFUNCTION to a different callback, -and have the header collected that way. - -=head2 READ callback - -Curl::easy supports CURLOPT_READFUNCTION. This function should look something like this: - - sub read_callback { - my ($maxlength,$pointer)=@_; - - .... - - return $data; - } - -The subroutine must return an empty string "" at the end of the data. Note that this function -isn't told how much data to provide - $maxlength is just the maximum size of the buffer -provided by libcurl. If you are doing an HTTP POST or PUT for example, it is important that this -function only returns as much data as the 'Content-Length' header specifies, followed by a -an empty (0 length) buffer. - -=head2 PROGRESS callback - -Curl::easy supports CURLOPT_PROGRESSFUNCTION. This function should look something like this: - - sub prog_callb - { - my ($clientp,$dltotal,$dlnow,$ultotal,$ulnow)=@_; - .... - return 0; - } - -The function should return 0 normally, or -1 which will abort/cancel the transfer. $clientp is whatever -value/scalar is set using the CURLOPT_PROGRESSDATA option. - -=head2 PASSWD callback - -Curl::easy supports CURLOPT_PASSWDFUNCTION. This function should look something like this: - - sub passwd_callb - { - my ($clientp,$prompt,$buflen)=@_; - ... - return (0,$data); - } - -$clientp is whatever scalar is set using the CURLOPT_PASSWDDATA option. -$prompt is a text string which can be used to prompt for a password. -$buflen is the maximum accepted password reply. - -The function must return 0 (for 'OK') and the password data as a list. Return (-1,"") to -indicate an error. - -=head1 AUTHOR - -Georg Horn <horn@koblenz-net.de> - -Additional callback, pod and test work by Cris Bailiff <c.bailiff@devsecure.com> -and Forrest Cahoon <forrest.cahoon@merrillcorp.com> - -Currently maintained by Cris Bailiff <c.bailiff@devsecure.com> - -=head1 Copyright - -Copyright (C) 2000, Daniel Stenberg, , et al. - -You may opt to use, copy, modify, merge, publish, distribute and/or sell -copies of the Software, and permit persons to whom the Software is furnished -to do so, under the terms of the MPL or the MIT/X-derivate licenses. You may -pick one of these licenses. - -=head1 SEE ALSO - -http://curl.haxx.se/ - -=cut diff --git a/perl/Curl_easy/easy.xs b/perl/Curl_easy/easy.xs deleted file mode 100644 index f43d482cd..000000000 --- a/perl/Curl_easy/easy.xs +++ /dev/null @@ -1,672 +0,0 @@ -/* Perl interface for libcurl. Check out the file README for more info. */ -/* - -Copyright (C) 2000, Daniel Stenberg, , et al. -You may opt to use, copy, modify, merge, publish, distribute and/or -sell copies of the Software, and permit persons to whom the -Software is furnished to do so, under the terms of the MPL or -the MIT/X-derivate licenses. You may pick one of these licenses. -*/ - -#include "EXTERN.h" -#include "perl.h" -#include "XSUB.h" - -#include <curl/curl.h> -#include <curl/easy.h> - -#if (LIBCURL_VERSION_NUM<0x070702) -#define CURLOPT_HEADERFUNCTION 20079 -#define header_callback_func write_callback_func -#else -#define header_callback_func writeheader_callback_func -#endif - -/* Lists that can be set via curl_easy_setopt() */ - -static struct curl_slist *httpheader = NULL, *quote = NULL, *postquote = NULL; - - -/* Buffer and varname for option CURLOPT_ERRORBUFFER */ - -static char errbuf[CURL_ERROR_SIZE]; -static char *errbufvarname = NULL; - - -/* Callback functions */ - -static SV *read_callback = NULL, *write_callback = NULL, - *progress_callback = NULL, *passwd_callback = NULL, - *header_callback = NULL; - /* *closepolicy_callback = NULL; */ - - -/* For storing the content */ - -static char *contbuf = NULL, *bufptr = NULL; -static int bufsize = 32768, contlen = 0; - - -/* Internal options for this perl module */ - -#define USE_INTERNAL_VARS 0x01 - -static int internal_options = 0; - - -/* Setup these global vars */ - -static void init_globals(void) -{ - if (httpheader) curl_slist_free_all(httpheader); - if (quote) curl_slist_free_all(quote); - if (postquote) curl_slist_free_all(postquote); - httpheader = quote = postquote = NULL; - if (errbufvarname) free(errbufvarname); - errbufvarname = NULL; - if (contbuf == NULL) { - contbuf = malloc(bufsize + 1); - } - bufptr = contbuf; - *bufptr = '\0'; - contlen = 0; - internal_options = 0; -} - - -/* Register a callback function */ - -static void register_callback(SV **callback, SV *function) -{ - if (*callback == NULL) { - /* First time, create new SV */ - *callback = newSVsv(function); - } else { - /* Been there, done that. Just overwrite the SV */ - SvSetSV(*callback, function); - } -} - -/* generic fwrite callback, which decides which callback to call */ -static size_t -fwrite_wrapper (const void *ptr, - size_t size, - size_t nmemb, - void *stream, - void *call_function) -{ - dSP; - int count, status; - SV *sv; - - if (call_function) { - /* then we are doing a callback to perl */ - - ENTER; - SAVETMPS; - - PUSHMARK(SP); - - if (stream == stdout) { - sv = newSViv(0); /* FIXME: should cast stdout to GLOB somehow? */ - } else if (stream == NULL) { - sv = &PL_sv_undef; - } else { /* its already an SV */ - sv = stream; - } - - if (ptr != NULL) { - XPUSHs(sv_2mortal(newSVpvn((char *)ptr, (STRLEN)(size * nmemb)))); - } else { - XPUSHs(sv_2mortal(newSVpv("", 0))); - } - XPUSHs(sv_2mortal(newSVsv(sv))); /* CURLOPT_FILE SV* */ - PUTBACK; - - count = perl_call_sv((SV *) call_function, G_SCALAR); - - SPAGAIN; - if (count != 1) - croak("Big trouble, perl_call_sv(write_callback) didn't return status\n"); - - status = POPi; - - PUTBACK; - - FREETMPS; - LEAVE; - return status; - - } else { - /* default to a normal 'fwrite' */ - /* stream could be a FILE * or an SV * */ - /* or NULL since libcurl-7.8.1pre3 */ - FILE *f; - - if (stream == stdout || - stream == NULL) { /* the only possible FILE ? Think so */ - f = stream; - } else { /* its a GLOB */ - f = IoIFP(sv_2io(stream)); /* may barf if not a GLOB */ - } - - if (f) - return fwrite(ptr, size, nmemb, f); - else - return (size_t) size*nmemb; - } -} - -/* Write callback for calling a perl callback */ -size_t -write_callback_func( const void *ptr, size_t size, - size_t nmemb, void *stream) -{ - return fwrite_wrapper(ptr,size,nmemb,stream, - write_callback); -} - -/* header callback for calling a perl callback */ -size_t -writeheader_callback_func( const void *ptr, size_t size, - size_t nmemb, void *stream) -{ - return fwrite_wrapper(ptr,size,nmemb,stream, - header_callback); -} - -size_t -read_callback_func( void *ptr, size_t size, - size_t nmemb, void *stream) -{ - dSP ; - - int count; - SV *sv; - STRLEN len; - size_t maxlen,mylen; - char *p; - - maxlen = size*nmemb; - - if (read_callback) { - /* we are doing a callback to perl */ - - ENTER ; - SAVETMPS ; - - PUSHMARK(SP) ; - - if (stream == stdin) { - sv = newSViv(0); /* should cast stdin to GLOB somehow? */ - } else { /* its an SV */ - sv = stream; - } - - XPUSHs(sv_2mortal(newSViv(maxlen))); /* send how many bytes please */ - XPUSHs(sv_2mortal(newSVsv(sv))); /* CURLOPT_INFILE SV* */ - PUTBACK ; - - count = perl_call_sv(read_callback, G_SCALAR); - - SPAGAIN; - if (count != 1) - croak("Big trouble, perl_call_sv(read_callback) didn't return data\n"); - - sv = POPs; - p = SvPV(sv,len); - - /* only allowed to return the number of bytes asked for */ - mylen = len<maxlen ? len : maxlen; - memcpy(ptr,p,(size_t)mylen); - PUTBACK ; - - FREETMPS ; - LEAVE ; - return (size_t) (mylen/size); - } else { - /* default to a normal 'fread' */ - /* stream could be a FILE * or an SV * */ - FILE *f; - - if (stream == stdin) { /* the only possible FILE ? Think so*/ - f = stream; - } else { /* its a GLOB */ - f = IoIFP(sv_2io(stream)); /* may barf if not a GLOB */ - } - - return fread(ptr,size,nmemb,f); - } -} - -/* Porgress callback for calling a perl callback */ - -static int progress_callback_func(void *clientp, size_t dltotal, size_t dlnow, - size_t ultotal, size_t ulnow) -{ - dSP; - int count; - - ENTER; - SAVETMPS; - PUSHMARK(sp); - if (clientp != NULL) { - XPUSHs(sv_2mortal(newSVpv(clientp, 0))); - } else { - XPUSHs(sv_2mortal(newSVpv("", 0))); - } - XPUSHs(sv_2mortal(newSViv(dltotal))); - XPUSHs(sv_2mortal(newSViv(dlnow))); - XPUSHs(sv_2mortal(newSViv(ultotal))); - XPUSHs(sv_2mortal(newSViv(ulnow))); - PUTBACK; - count = perl_call_sv(progress_callback, G_SCALAR); - SPAGAIN; - if (count != 1) - croak("Big trouble, perl_call_sv(progress_callback) didn't return 1\n"); - count = POPi; - PUTBACK; - FREETMPS; - LEAVE; - return count; -} - - -/* Password callback for calling a perl callback */ - -static int passwd_callback_func(void *clientp, char *prompt, char *buffer, - int buflen) -{ - dSP; - int count; - SV *sv; - STRLEN len; - size_t mylen; - char *p; - - ENTER; - SAVETMPS; - PUSHMARK(sp); - if (clientp != NULL) { - XPUSHs(sv_2mortal(newSVsv(clientp))); - } else { - XPUSHs(sv_2mortal(newSVpv("", 0))); - } - XPUSHs(sv_2mortal(newSVpv(prompt, 0))); - XPUSHs(sv_2mortal(newSViv(buflen))); - PUTBACK; - count = perl_call_sv(passwd_callback, G_ARRAY); - SPAGAIN; - if (count != 2) - croak("Big trouble, perl_call_sv(passwd_callback) didn't return status + data\n"); - - sv = POPs; - count = POPi; - - p = SvPV(sv,len); - - /* only allowed to return the number of bytes asked for */ - mylen = len<(buflen-1) ? len : (buflen-1); - memcpy(buffer,p,mylen); - buffer[buflen]=0; /* ensure C string terminates */ - - PUTBACK; - FREETMPS; - LEAVE; - return count; -} - - -#if 0 -/* awaiting closepolicy prototype */ -int -closepolicy_callback_func(void *clientp) -{ - dSP; - int argc, status; - SV *pl_status; - - ENTER; - SAVETMPS; - - PUSHMARK(SP); - PUTBACK; - - argc = perl_call_sv(closepolicy_callback, G_SCALAR); - SPAGAIN; - - if (argc != 1) { - croak("Unexpected number of arguments returned from closefunction callback\n"); - } - pl_status = POPs; - status = SvTRUE(pl_status) ? 0 : 1; - - PUTBACK; - FREETMPS; - LEAVE; - - return status; -} -#endif - - - -/* Internal write callback. Only used if USE_INTERNAL_VARS was specified */ - -static size_t internal_write_callback(char *data, size_t size, size_t num, - FILE *fp) -{ - int i; - - size *= num; - if ((contlen + size) >= bufsize) { - bufsize *= 2; - contbuf = realloc(contbuf, bufsize + 1); - bufptr = contbuf + contlen; - } - contlen += size; - for (i = 0; i < size; i++) { - *bufptr++ = *data++; - } - *bufptr = '\0'; - return size; -} - - -static int -constant(char *name, int arg) -{ - errno = 0; - if (strncmp(name, "CURLINFO_", 9) == 0) { - name += 9; - switch (*name) { - case 'A': - case 'B': - case 'C': - if (strEQ(name, "CONNECT_TIME")) return CURLINFO_CONNECT_TIME; - if (strEQ(name, "CONTENT_LENGTH_DOWNLOAD")) return CURLINFO_CONTENT_LENGTH_DOWNLOAD; - if (strEQ(name, "CONTENT_LENGTH_UPLOAD")) return CURLINFO_CONTENT_LENGTH_UPLOAD; - break; - case 'D': - case 'E': - if (strEQ(name, "EFFECTIVE_URL")) return CURLINFO_EFFECTIVE_URL; - break; - case 'F': - if (strEQ(name, "FILETIME")) return CURLINFO_FILETIME; - break; - case 'G': - case 'H': - if (strEQ(name, "HEADER_SIZE")) return CURLINFO_HEADER_SIZE; - if (strEQ(name, "HTTP_CODE")) return CURLINFO_HTTP_CODE; - break; - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - if (strEQ(name, "NAMELOOKUP_TIME")) return CURLINFO_NAMELOOKUP_TIME; - break; - case 'O': - case 'P': - if (strEQ(name, "PRETRANSFER_TIME")) return CURLINFO_PRETRANSFER_TIME; - break; - case 'Q': - case 'R': - if (strEQ(name, "REQUEST_SIZE")) return CURLINFO_REQUEST_SIZE; - break; - case 'S': - if (strEQ(name, "SSL_VERIFYRESULT")) return CURLINFO_SSL_VERIFYRESULT; - break; - case 'T': - if (strEQ(name, "SIZE_DOWNLOAD")) return CURLINFO_SIZE_DOWNLOAD; - if (strEQ(name, "SIZE_UPLOAD")) return CURLINFO_SIZE_UPLOAD; - if (strEQ(name, "SPEED_DOWNLOAD")) return CURLINFO_SPEED_DOWNLOAD; - if (strEQ(name, "SPEED_UPLOAD")) return CURLINFO_SPEED_UPLOAD; - if (strEQ(name, "TOTAL_TIME")) return CURLINFO_TOTAL_TIME; - break; - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - break; - } - } - if (strncmp(name, "CURLOPT_", 8) == 0) { - name += 8; - switch (*name) { -#include "curlopt-constants.c" - } - } - if (strEQ(name, "USE_INTERNAL_VARS")) return USE_INTERNAL_VARS; - errno = EINVAL; - return 0; -} - - -MODULE = Curl::easy PACKAGE = Curl::easy PREFIX = curl_easy_ - -int -constant(name,arg) - char * name - int arg - - -void * -curl_easy_init() -CODE: - init_globals(); - RETVAL = curl_easy_init(); - curl_easy_setopt(RETVAL, CURLOPT_HEADERFUNCTION, header_callback_func); - curl_easy_setopt(RETVAL, CURLOPT_WRITEFUNCTION, write_callback_func); -OUTPUT: - RETVAL - -char * -curl_easy_version() -CODE: - RETVAL=curl_version(); -OUTPUT: - RETVAL - -int -curl_easy_setopt(curl, option, value) -void * curl -int option -SV * value -CODE: - if (option < CURLOPTTYPE_OBJECTPOINT) { - /* This is an option specifying an integer value: */ - RETVAL = curl_easy_setopt(curl, option, (long)SvIV(value)); - } else if (option == CURLOPT_FILE || option == CURLOPT_INFILE || - option == CURLOPT_WRITEHEADER || option == CURLOPT_PROGRESSDATA || - option == CURLOPT_PASSWDDATA) { - /* This is an option specifying an SV * value: */ - RETVAL = curl_easy_setopt(curl, option, newSVsv(ST(2))); - } else if (option == CURLOPT_ERRORBUFFER) { - /* Pass in variable name for storing error messages... */ - RETVAL = curl_easy_setopt(curl, option, errbuf); - if (errbufvarname) free(errbufvarname); - errbufvarname = strdup((char *)SvPV(value, PL_na)); - } else if (option == CURLOPT_WRITEFUNCTION || option == - CURLOPT_READFUNCTION || option == CURLOPT_PROGRESSFUNCTION || - option == CURLOPT_PASSWDFUNCTION || option == CURLOPT_HEADERFUNCTION) { - /* This is an option specifying a callback function */ - switch (option) { - case CURLOPT_WRITEFUNCTION: - register_callback(&write_callback, value); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback_func); - break; - case CURLOPT_READFUNCTION: - register_callback(&read_callback, value); - curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback_func); - break; - case CURLOPT_HEADERFUNCTION: - register_callback(&header_callback, value); - curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback_func); - case CURLOPT_PROGRESSFUNCTION: - register_callback(&progress_callback, value); - curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback_func); - break; - case CURLOPT_PASSWDFUNCTION: - register_callback(&passwd_callback, value); - curl_easy_setopt(curl, CURLOPT_PASSWDFUNCTION, passwd_callback_func); - break; - /* awaiting a prototype for the closepolicy function callback - case CURLOPT_CLOSEFUNCTION: - register_callback(&closepolicy_callback, value); - curl_easy_setopt(curl, CURLOPT_CLOSEFUNCTION, closepolicy_callback_func); - break; - */ - } - RETVAL = -1; - } else if (option == CURLOPT_HTTPHEADER || option == CURLOPT_QUOTE || - option == CURLOPT_POSTQUOTE) { - /* This is an option specifying a list of curl_slist structs: */ - AV *array = (AV *)SvRV(value); - struct curl_slist **slist = NULL; - /* We have to find out which list to use... */ - switch (option) { - case CURLOPT_HTTPHEADER: - slist = &httpheader; break; - case CURLOPT_QUOTE: - slist = "e; break; - case CURLOPT_POSTQUOTE: - slist = &postquote; break; - } - /* free any previous list */ - if (*slist) { - curl_slist_free_all(*slist); - *slist=NULL; - } - /* ...store the values into it... */ - for (;;) { - SV *sv = av_shift(array); - int len = 0; - char *str = SvPV(sv, len); - if (len == 0) break; - *slist = curl_slist_append(*slist, str); - } - /* ...and pass the list into curl_easy_setopt() */ - RETVAL = curl_easy_setopt(curl, option, *slist); - } else { - /* This is an option specifying a char * value: */ - RETVAL = curl_easy_setopt(curl, option, SvPV(value, PL_na)); - } -OUTPUT: - RETVAL - - -int -internal_setopt(option, value) -int option -int value -CODE: - if (value == 1) { - internal_options |= option; - } else { - internal_options &= !option; - } - RETVAL = 0; -OUTPUT: - RETVAL - - -int -curl_easy_perform(curl) -void * curl -CODE: - if (internal_options & USE_INTERNAL_VARS) { - /* Use internal callback which just stores the content into a buffer. */ - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, internal_write_callback); - curl_easy_setopt(curl, CURLOPT_HEADER, 1); - } - RETVAL = curl_easy_perform(curl); - if (RETVAL && errbufvarname) { - /* If an error occurred and a varname for error messages has been - specified, store the error message. */ - SV *sv = perl_get_sv(errbufvarname, TRUE | GV_ADDMULTI); - sv_setpv(sv, errbuf); - } - if (!RETVAL && (internal_options & USE_INTERNAL_VARS)) { - /* No error and internal variable for the content are to be used: - Split the data into headers and content and store them into - perl variables. */ - SV *head_sv = perl_get_sv("Curl::easy::headers", TRUE | GV_ADDMULTI); - SV *cont_sv = perl_get_sv("Curl::easy::content", TRUE | GV_ADDMULTI); - char *p = contbuf; - int nl = 0, found = 0; - while (p < bufptr) { - if (nl && (*p == '\n' || *p == '\r')) { - /* found empty line, end of headers */ - *p++ = '\0'; - sv_setpv(head_sv, contbuf); - while (*p == '\n' || *p == '\r') { - p++; - } - sv_setpv(cont_sv, p); - found = 1; - break; - } - nl = (*p == '\n'); - p++; - } - if (!found) { - sv_setpv(head_sv, ""); - sv_setpv(cont_sv, contbuf); - } - } -OUTPUT: - RETVAL - - -int -curl_easy_getinfo(curl, option, value) -void * curl -int option -double value -CODE: -#ifdef __GNUC__ - /* a(void) warnig about unnused variable */ - (void) value; -#endif - switch (option & CURLINFO_TYPEMASK) { - case CURLINFO_STRING: { - char * value = (char *)SvPV(ST(2), PL_na); - RETVAL = curl_easy_getinfo(curl, option, &value); - sv_setpv(ST(2), value); - break; - } - case CURLINFO_LONG: { - long value = (long)SvIV(ST(2)); - RETVAL = curl_easy_getinfo(curl, option, &value); - sv_setiv(ST(2), value); - break; - } - case CURLINFO_DOUBLE: { - double value = (double)SvNV(ST(2)); - RETVAL = curl_easy_getinfo(curl, option, &value); - sv_setnv(ST(2), value); - break; - } - default: { - RETVAL = CURLE_BAD_FUNCTION_ARGUMENT; - break; - } - } -OUTPUT: - RETVAL - - -int -curl_easy_cleanup(curl) -void * curl -CODE: - curl_easy_cleanup(curl); - init_globals(); - RETVAL = 0; -OUTPUT: - RETVAL - |