use strict;
use warnings;
my $root=$ARGV[0] || ".";
my $buildroot=$ARGV[1] || ".";
my $syms = "$root/docs/libcurl/symbols-in-versions";
my $curlh = "$root/include/curl/curl.h";
my $errors=0;
my %alias = (
'CURLINFO_DATA_IN' => 'none',
'CURLINFO_DATA_OUT' => 'none',
'CURLINFO_END' => 'none',
'CURLINFO_HEADER_IN' => 'none',
'CURLINFO_HEADER_OUT' => 'none',
'CURLINFO_LASTONE' => 'none',
'CURLINFO_NONE' => 'none',
'CURLINFO_SSL_DATA_IN' => 'none',
'CURLINFO_SSL_DATA_OUT' => 'none',
'CURLINFO_TEXT' => 'none'
);
sub scanmanpage {
my ($file, @words) = @_;
open(M, "<$file");
my @m = <M>;
close(M);
foreach my $m (@words) {
my @g = grep(/^\.IP $m/, @m);
if(!$g[0]) {
print STDERR "Missing mention of $m in $file\n";
$errors++;
}
}
}
open(R, "<$curlh") ||
die "no curl.h";
while(<R>) {
if(/^\ $alias{$1}=$3;
}
}
close(R);
my @curlopt;
my @curlinfo;
my @curlmopt;
open(R, "<$syms") ||
die "no input file";
while(<R>) {
chomp;
my $l= $_;
if($l =~ /(CURL(OPT|INFO|MOPT)_\w+) *([0-9.]*) *([0-9.-]*) *([0-9.]*)/) {
my ($opt, $type, $add, $dep, $rem) = ($1, $2, $3, $4, $5);
if($alias{$opt}) {
}
elsif($rem) {
}
else {
if($type eq "OPT") {
push @curlopt, $opt,
}
elsif($type eq "INFO") {
push @curlinfo, $opt,
}
elsif($type eq "MOPT") {
push @curlmopt, $opt,
}
if(! -f "$root/docs/libcurl/opts/$opt.3") {
print STDERR "Missing $opt.3\n";
$errors++;
}
}
}
}
close(R);
scanmanpage("$root/docs/libcurl/curl_easy_setopt.3", @curlopt);
scanmanpage("$root/docs/libcurl/curl_easy_getinfo.3", @curlinfo);
scanmanpage("$root/docs/libcurl/curl_multi_setopt.3", @curlmopt);
my %opts = (
'--no-alpn' => 1,
'--no-npn' => 1,
'-N, --no-buffer' => 1,
'--no-sessionid' => 1,
'--no-keepalive' => 1,
'--alpn' => 6,
'--npn' => 6,
'--eprt' => 6,
'--epsv' => 6,
'--keepalive' => 6,
'-N, --buffer' => 6,
'--sessionid' => 6,
'--krb4' => 6,
'--ftp-ssl' => 6,
'--ftp-ssl-reqd' => 6,
'--test-event' => 6,
'--wdebug' => 6,
);
open(R, "<$root/src/tool_getparam.c") ||
die "no input file";
my $list;
my @getparam;
while(<R>) {
chomp;
my $l= $_;
if(/struct LongShort aliases/) {
$list=1;
}
elsif($list) {
if( /^ \{([^,]*), *([^ ]*)/) {
my ($s, $l)=($1, $2);
my $sh;
my $lo;
my $title;
if($l =~ /\"(.*)\"/) {
$lo = $1;
$title="--$lo";
}
if($s =~ /\"(.)\"/) {
$sh = $1;
$title="-$sh, $title";
}
push @getparam, $title;
$opts{$title} |= 1;
}
}
}
close(R);
open(R, "<$buildroot/docs/curl.1") || open(R, "<$root/docs/curl.1") ||
die "no input file";
my @manpage; while(<R>) {
chomp;
my $l= $_;
if(/^\.IP \"(-[^\"]*)\"/) {
my $str = $1;
my $combo;
if($str =~ /^-(.), --([a-z0-9.-]*)/) {
$combo = "-$1, --$2";
}
elsif($str =~ /^--([a-z0-9.-]*)/) {
$combo = "--$1";
}
if($combo) {
push @manpage, $combo;
$opts{$combo} |= 2;
}
}
}
close(R);
open(R, "<$root/src/tool_help.c") ||
die "no input file";
my @toolhelp; while(<R>) {
chomp;
my $l= $_;
if(/^ \{\" *(.*)/) {
my $str=$1;
my $combo;
if($str =~ /^-(.), --([a-z0-9.-]*)/) {
$combo = "-$1, --$2";
}
elsif($str =~ /^--([a-z0-9.-]*)/) {
$combo = "--$1";
}
if($combo) {
push @toolhelp, $combo;
$opts{$combo} |= 4;
}
}
}
close(R);
foreach my $o (keys %opts) {
my $where = $opts{$o};
if($where != 7) {
$errors++;
my $exists;
my $missing;
if($where & 1) {
$exists=" tool_getparam.c";
}
else {
$missing=" tool_getparam.c";
}
if($where & 2) {
$exists.= " curl.1";
}
else {
$missing.= " curl.1";
}
if($where & 4) {
$exists .= " tool_help.c";
}
else {
$missing .= " tool_help.c";
}
print STDERR "$o is not in$missing (but in$exists)\n";
}
}
exit $errors;