Patrick Monnerat wrote:

> I tried it on Fedora 23 64-bit: it works providing you make/run it from a 
> direct 
> subdirectory of curl sources. I had to "buildconf" + "configure" to make it 
> run.

I simply assumed that. Not sure what "buildconf" + "configure" would do.
Here is another try with a man-file check added.

-- 
--gv
#
# A Gnu-makefile to generate a file (curl_options.c) with all
# current 'CURLOPT_x' values.
#
# NB! must be invoked from libcurl's './lib' directory.
#
# By G. Vanem <gva...@yahoo.no> 2014.
#

empty :=
space := $(empty) $(empty) $(empty)

OPTIONS  = grep '^  CINIT(' ../include/curl/curl.h | cut -f1 -d, | sed 
's/CINIT(/CURLOPT_/'
OPTIONS := $(shell $(OPTIONS))

CC     = gcc
CFLAGS = -Wall -I../include

define CURLOPT_TOP
  /*
   * This file has been generated by $(realpath $(MAKEFILE_LIST)) at
   * $(shell date +%d-%B-%Y).
   * DO NOT EDIT!
   */
  #include <curl/curl.h>

  struct key_val {
     unsigned    val;
     const char *name;
     const char *man3_page;
   };

  #if defined(_WIN32)
    #include <io.h>
    #define FILE_EXIST(fname)  (access(fname,0) == 0)
  #else
    #include <unistd.h>
    #define FILE_EXIST(fname)  (chmod(fname,0) != -1)
  #endif

  #define ADD_OPT(opt)  { opt, #opt, "../docs/libcurl/opts/" #opt ".3" }

  static const struct key_val options[] = {
endef

define CURLOPT_BOTTOM
  };

  const char *decode_opt (unsigned opt)
  {
    static char ret[100];
    const char *type = "long";  /* CURLOPTTYPE_LONG == 0 */

    if (opt >= CURLOPTTYPE_OFF_T) {
      opt -= CURLOPTTYPE_OFF_T;
      type = "off_t";
    }
    else if (opt >= CURLOPTTYPE_FUNCTIONPOINT) {
      opt -= CURLOPTTYPE_FUNCTIONPOINT;
      type = "function";
    }
    else if (opt >= CURLOPTTYPE_OBJECTPOINT) {
      opt -= CURLOPTTYPE_OBJECTPOINT;
      type = "object/string";
    }
    snprintf (ret, sizeof(ret), "%3u: %s", opt, type);
    return (ret);
  }

  int man3_page_exist (const struct key_val *o)
  {
    if (!o->man3_page)
       return (0);
    if (!strncmp(o->name,"CURLOPT_OBSOLETE",16)) /* Ignore these */
       return (1);
    return FILE_EXIST (o->man3_page);
  }

  int main (void)
  {
    const struct key_val *o = options;
    int   i;

    puts ("Idx  CURLOPT_x                              value: arg type      raw 
value\n"
          
"==========================================================================");
    for (i = 0; i < sizeof(options) / sizeof(options[0]); i++, o++)
        printf ("%3d: %-35.35s -> %-20s %5u   %s\n",
                i, o->name, decode_opt(o->val), o->val,
                man3_page_exist(o) ? "" : "missing .3 file!");
    return (0);
  }
endef

all: check_libdir curl_options

curl_options.c: $(MAKEFILE_LIST)
        $(file > $@,$(CURLOPT_TOP))
        $(foreach o, $(sort $(OPTIONS)), \
          $(file >> $@, $(space) ADD_OPT ($(o)), ) )
        $(file >> $@,$(CURLOPT_BOTTOM))
        @echo '$(words $(OPTIONS)) options generated for $@.'

curl_options: curl_options.c
        $(CC) $(CFLAGS) -o $@ $<

check_libdir:
ifeq ($(wildcard curl_setup.h),)
        $(error Must be invoked from libcurl's './lib' directory.)
endif

clean:
        rm -f curl_options.*
-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:  https://curl.haxx.se/mail/etiquette.html

Reply via email to