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_/'

The attached GNU-make file does this.

--
--gv



comma := ,
empty :=
space := $(empty) $(empty) $(empty)

LIST_OPTIONS = grep '^  CINIT(' ../include/curl/curl.h | cut -f1 -d, | sed 
's/CINIT(/CURLOPT_/'

define CURL_OPTIONS1
  #include <curl/curl.h>

  typedef struct {
     int  val;
     char name[40];
   } keyval;

  static const keyval options[] = {
endef

define CURL_OPTIONS2
   { 0, NULL }
  };

  int libcurl_has_option (int opt)
  {
    int i;
    for (i = 0; i < sizeof(options)/sizeof(options[0]); i++)
       if (opt == options[i].val)
         return (1);
    return (0);
  }
endef

all: curl_options.c

curl_options.c::
        $(file > $@, $(CURL_OPTIONS1))
        $(foreach o, $(shell $(LIST_OPTIONS)), $(file >> $@, $(space) { $(o) 
$(comma) "$(o)" } $(comma) ) )
        $(file >> $@, $(CURL_OPTIONS2))
        @echo '$@ done.'
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to