cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: [PHP-DEV] Work is beginning on cURL and PHP again

From: Cris Bailiff <c.bailiff+curl_at_awayweb.com>
Date: Tue, 22 Oct 2002 11:12:30 +1000

On Tue, 22 Oct 2002 06:28 am, Sterling Hughes wrote:
> On Mon, 2002-10-21 at 22:15, Jon Parise wrote:
> > On Mon, Oct 21, 2002 at 10:12:55PM +0200, Sterling Hughes wrote:
> > > * Autogenerating much of the interface between cURL and PHP, allowing
> > > PHP to support multiple versions of the underlying cURL library
> >
> > By what mechanism do you plan on implementing this?
>
> Well, currently i plan on using a Perl script to read the curl.h
> definition file, and generate the code for all options that don't meet
> the following criterium:

You might find the Makefile.PL in the perl-curl interface (perl-Curl-easy) a
useful starting point. It basically does this for all the options and
constants.

http://curl.haxx.se/libcurl/perl

> 1) There is a definition in for the constant in the file
> php4/ext/curl/objects.def, in the form of something like:
>
> CURLOPT_OPTNAME: {
> // code goes here
> }
>
> 2) the type of the constant is OBJECTPOINT
>
> (the words "type" and "constant" are used loosely here :)

Yes, pretty similar to the perl interface. It just has a big switch() to pull
out all the options that need special handling (callbacks and lists mainly),
and then dumps the rest through to curl_easy_setopt.

> Then for constants that are definied in both curl/objects.def and
> curl.h, i'll add the code for them into curl.c.

If you've any ideas for improving the parsing of curl.h (either by running the
real C pre-processor, or feeling enthusiastic enough to do more emulation in
perl), this would improve the 'special case' stuff I've had to hard-code in
perl because of certain #ifdef and #if 0 cases in curl.h which make straight
pattern matching insufficient.

> Any other constants
> will get simply get the "undefined constant" warning with E_ALL and cURL
> will complain that the constant doesn't exist when curl_setopt() is
> used, at least this is the current plan for auto-generation.

Seems to work OK for the perl interface. At least, nothing to fatal has gone
wrong so far...

> I'm also debating just having a standard (generated from the latest
> stable cURL version) file, in case Perl is not present on the users
> system (but if Perl isn't present on your system - that's pretty bad :)

I guess this is a common windows case, but by definition I haven't faced that
problem yet!

Cris

-------------------------------------------------------
This sf.net emial is sponsored by: Influence the future of
Java(TM) technology. Join the Java Community Process(SM) (JCP(SM))
program now. http://ad.doubleclick.net/clk;4699841;7576301;v?
http://www.sun.com/javavote
Received on 2002-10-22