cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: List available curl options

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Mon, 15 Dec 2014 21:50:46 +0100

On Mon, Dec 15, 2014 at 12:27:24PM -0800, Jeroen Ooms wrote:
> On Mon, Dec 15, 2014 at 3:34 AM, Gisle Vanem <gvanem_at_yahoo.no> wrote:
> > Jeroen Ooms wrote:
> >
> >> #define MAKE_OPTION(a) {#a, CURLOPT_##a}
> >>
> >> typedef struct {
> >> char name[40];
> >> int val;
> >> } keyval;
> >>
> >> keyval curl_options[] = {
> >> MAKE_OPTION(MUTE),
> >> MAKE_OPTION(ACCEPT_ENCODING),
> >> ... etc
> >> };
> >>
> >> But currently this fails when calling MAKE_OPTION with an undefined
> >> symbol.
> >> Is there any easy way that I can use the LIBCURL_HAS macro or a variant
> >> such
> >> that MAKE_OPTION will set (int val) to e.g. null or -9999999 or so, when
> >> the symbol
> >> does not exist in the version of libcurl that is being linked?
> >
> >
> > I've not followed this thread, but can't you use some
> > external tools to create the list. Like:
> > grep "^ CINIT(" ../include/curl/curl.h | cut -f1 -d, | sed
> > 's/CINIT(/CURLOPT_/'
>
> I am not sure this is the most elegant way. It would break if a future
> version of curl.h would use a different macro than CINIT.
>
> Also I would prefer a method method that can also be used to list
> available CURLINFO_ symbols.

If the goal is to simply #ifdef code depending on which options are available,
then why wouldn't a simple AC_COMPILE_IFELSE workd? e.g. something like this
(untested):

AC_DEFUN([CHECK_CURL_OPT],
 AC_COMPILE_IFELSE(
  AC_LANG_PROGRAM([#include <curl/curl.h>],[CURLoption o = ($1);]),
  AC_DEFINE([HAVE_]$1))
)

CHECK_CURL_OPT(CURLOPT_DNS_INTERFACE)
CHECK_CURL_OPT(CURLOPT_SSL_ENABLE_ALPN)

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-12-15