#!/usr/bin/perl
#***************************************************************************
#                                  _   _ ____  _
#  Project                     ___| | | |  _ \| |
#                             / __| | | | |_) | |
#                            | (__| |_| |  _ <| |___
#                             \___|\___/|_| \_\_____|
#
# Copyright (C) 2011 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://curl.haxx.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
###########################################################################
#
# This generates a list of all known CURLOPT_ options that haven't been
# deprecated.
#
# This script assumes first run the symbols.pl script to generate the defines
# and the LIBCURL_HAS() macro so that this list will work even if you build
# with older libcurl headers present.
#
open F, "<symbols-in-versions";

print <<EOS

#include <curl/curl.h>

struct curloptarg {
    char *name;
    int value;
};

struct curloptarg list[] = {
EOS
    ;

while(<F>) {
    if(/^(CURLOPT_[^ ]*)[ \t]*(.*)/) {
        my ($sym, $vers)=($1, $2);

        my $intr;
        my $rm="";
        my $dep;

        # is there removed info?
        if($vers =~ /([\d.]+)[ \t-]+([\d.-]+)[ \t]+([\d.]+)/) {
            ($intr, $dep, $rm)=($1, $2, $3);
        }
        # is it a dep-only line?
        elsif($vers =~ /([\d.]+)[ \t-]+([\d.]+)/) {
            ($intr, $dep)=($1, $2);
        }
        else {
            $intr = $vers;
        }

        if(!$rm) {
        print <<EOS
#if LIBCURL_HAS($sym)
  { "${sym}", ${sym} },
#endif
EOS
;
        }

    }
}

print <<EOS
};

EOS
    ;
