cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Max number of args to curl_formadd()

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 22 Nov 2002 14:25:56 +0100 (MET)

On Fri, 22 Nov 2002, Yet Another Geek wrote:

> Still trying to get the curl_formadd() function implemented across
> FreePascal/Delphi/Kylix.
>
> Delphi and Kylix understand something called a "varargs" directive that
> allows the function to be called just as it would be in "C".
>
> But FreePascal takes a slightly different approach, so I need to declare
> overloaded versions for each possible number of arguments.

Ouch. Seems like a rather crude hack.

> As far as i can tell, the criteria is something like this:
>
> 1. The first two arguments are always pointers to
> Curl_httppost pointers.
>
> 2. Between the second and last arguments is *some*
> number of pairs of arguments, always in the form
> of a flag followed by a value. ( Is this correct? )
>
> 3, The last argument is always the "CURLFORM_END"
> flag.

This is 100% correct.

> So the question is, just how many possible flag/value pairs can there be?
> Maybe six? Or maybe five thousand?

Somewhere in between. I don't think you can do it with less than two
flag/value pairs, but you can probably think of some combination with quite a
few of them.

> There appears to be nineteen flags, but some of them, like
> CURLFORM_OBSOLETE and CURLFORM_LASTENTRY would never be used, while others,
> like CURLFORM_COPYCONTENTS and CURLFORM_PTRCONTENTS would be mutually
> exclusive.

Right. But it's more to it than that, because one single form 'part' may in
fact contain multiple files, which means that CURLFORM_FILE can actually be
used any number of times!

(This is very rare though.)

> Would there ever be a situation where someone might need more?

It is possible to come up with an example that uses more, yes.

I'd suggest that you make it cover commont amounts of arguments, and then if
users find problems with this, you add more combinations later on.

Or just fix FreePascal. It's an insanely stupid limitation! ;-)

-- 
 Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs.
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2002-11-22