cURL / Mailing Lists / curl-library / Single Mail

curl-library

curl_easy_init_options (Was: Re: ARES configuration)

From: codemastr <codemstr_at_ptd.net>
Date: Fri, 4 Mar 2005 14:14:20 -0500

> That's a very good idea. Possibly in the style of ares_init_options() (see
> http://daniel.haxx.se/projects/c-ares/ares_init.html). We just need to
> make sure we can extend the struct in future versions without breaking
> existing/older apps/libraries.

Microsoft (and I'm sure others) have a pretty simple solution for this that
they use in many of the WinAPI calls. Basically, you have the user specify
the size of the structure:

struct curl_options copt;

copt.struct_size = sizeof(struct curl_options);

Then in libcurl, it decides how to treat curl_options based on the value of
struct_size (note: struct_size would be the first member of the struct). So
if you later added another option, thereby increasing the size of
curl_options, you have two structs internally curl_options_v1 and
curl_options (v2). If copt.struct_size == sizeof(curl_options_v1), you cast
it to that, otherwise you interpret it as v2 and so on. It's pretty simple
to implement and it should make changes in size completely backwards
compatible.

Dominick Meglio
Received on 2005-03-04