123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973 |
- #!/usr/bin/env perl
- #***************************************************************************
- # _ _ ____ _
- # Project ___| | | | _ \| |
- # / __| | | | |_) | |
- # | (__| |_| | _ <| |___
- # \___|\___/|_| \_\_____|
- #
- # Copyright (C) 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 https://curl.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.
- #
- # SPDX-License-Identifier: curl
- #
- ###########################################################################
- =begin comment
- This script generates the manpage.
- Example: gen.pl <command> [files] > curl.1
- Dev notes:
- We open *input* files in :crlf translation (a no-op on many platforms) in
- case we have CRLF line endings in Windows but a perl that defaults to LF.
- Unfortunately it seems some perls like msysgit cannot handle a global input-only
- :crlf so it has to be specified on each file open for text input.
- =end comment
- =cut
- my %optshort;
- my %optlong;
- my %helplong;
- my %arglong;
- my %redirlong;
- my %protolong;
- my %catlong;
- use POSIX qw(strftime);
- my @ts;
- if (defined($ENV{SOURCE_DATE_EPOCH})) {
- @ts = localtime($ENV{SOURCE_DATE_EPOCH});
- } else {
- @ts = localtime;
- }
- my $date = strftime "%B %d %Y", @ts;
- my $year = strftime "%Y", @ts;
- my $version = "unknown";
- my $globals;
- open(INC, "<../../include/curl/curlver.h");
- while(<INC>) {
- if($_ =~ /^#define LIBCURL_VERSION \"([0-9.]*)/) {
- $version = $1;
- last;
- }
- }
- close(INC);
- # get the long name version, return the man page string
- sub manpageify {
- my ($k)=@_;
- my $l;
- my $klong = $k;
- # quote "bare" minuses in the long name
- $klong =~ s/-/\\-/g;
- if($optlong{$k} ne "") {
- # both short + long
- $l = "\\fI-".$optlong{$k}.", \\-\\-$klong\\fP";
- }
- else {
- # only long
- $l = "\\fI\\-\\-$klong\\fP";
- }
- return $l;
- }
- sub printdesc {
- my @desc = @_;
- my $exam = 0;
- for my $d (@desc) {
- print $d;
- }
- }
- sub seealso {
- my($standalone, $data)=@_;
- if($standalone) {
- return sprintf
- ".SH \"SEE ALSO\"\n$data\n";
- }
- else {
- return "See also $data. ";
- }
- }
- sub overrides {
- my ($standalone, $data)=@_;
- if($standalone) {
- return ".SH \"OVERRIDES\"\n$data\n";
- }
- else {
- return $data;
- }
- }
- sub protocols {
- my ($standalone, $data)=@_;
- if($standalone) {
- return ".SH \"PROTOCOLS\"\n$data\n";
- }
- else {
- return "($data) ";
- }
- }
- sub too_old {
- my ($version)=@_;
- my $a = 999999;
- if($version =~ /^(\d+)\.(\d+)\.(\d+)/) {
- $a = $1 * 1000 + $2 * 10 + $3;
- }
- elsif($version =~ /^(\d+)\.(\d+)/) {
- $a = $1 * 1000 + $2 * 10;
- }
- if($a < 7500) {
- # we consider everything before 7.50.0 to be too old to mention
- # specific changes for
- return 1;
- }
- return 0;
- }
- sub added {
- my ($standalone, $data)=@_;
- if(too_old($data)) {
- # do not mention ancient additions
- return "";
- }
- if($standalone) {
- return ".SH \"ADDED\"\nAdded in curl version $data\n";
- }
- else {
- return "Added in $data. ";
- }
- }
- sub render {
- my ($fh, $f, $line) = @_;
- my @desc;
- my $tablemode = 0;
- my $header = 0;
- # if $top is TRUE, it means a top-level page and not a command line option
- my $top = ($line == 1);
- my $quote;
- $start = 0;
- while(<$fh>) {
- my $d = $_;
- $line++;
- if($d =~ /^\.(SH|BR|IP|B)/) {
- print STDERR "$f:$line:1:ERROR: nroff instruction in input: \".$1\"\n";
- return 4;
- }
- if(/^ *<!--/) {
- # skip comments
- next;
- }
- if((!$start) && ($_ =~ /^[\r\n]*\z/)) {
- # skip leading blank lines
- next;
- }
- $start = 1;
- if(/^# (.*)/) {
- $header = 1;
- if($top != 1) {
- # ignored for command line options
- $blankline++;
- next;
- }
- push @desc, ".SH $1\n";
- next;
- }
- elsif(/^###/) {
- print STDERR "$f:$line:1:ERROR: ### header is not supported\n";
- exit 3;
- }
- elsif(/^## (.*)/) {
- my $word = $1;
- # if there are enclosing quotes, remove them first
- $word =~ s/[\"\'](.*)[\"\']\z/$1/;
- # remove backticks from headers
- $words =~ s/\`//g;
- # if there is a space, it needs quotes
- if($word =~ / /) {
- $word = "\"$word\"";
- }
- if($top == 1) {
- push @desc, ".IP $word\n";
- }
- else {
- if(!$tablemode) {
- push @desc, ".RS\n";
- $tablemode = 1;
- }
- push @desc, ".IP $word\n";
- }
- $header = 1;
- next;
- }
- elsif(/^##/) {
- if($top == 1) {
- print STDERR "$f:$line:1:ERROR: ## empty header top-level mode\n";
- exit 3;
- }
- if($tablemode) {
- # end of table
- push @desc, ".RE\n.IP\n";
- $tablmode = 0;
- }
- $header = 1;
- next;
- }
- elsif(/^\.(IP|RS|RE)/) {
- my ($cmd) = ($1);
- print STDERR "$f:$line:1:ERROR: $cmd detected, use ##-style\n";
- return 3;
- }
- elsif(/^[ \t]*\n/) {
- # count and ignore blank lines
- $blankline++;
- next;
- }
- elsif($d =~ /^ (.*)/) {
- my $word = $1;
- if(!$quote) {
- push @desc, ".nf\n";
- }
- $quote = 1;
- $d = "$word\n";
- }
- elsif($quote && ($d !~ /^ (.*)/)) {
- # end of quote
- push @desc, ".fi\n";
- $quote = 0;
- }
- $d =~ s/`%DATE`/$date/g;
- $d =~ s/`%VERSION`/$version/g;
- $d =~ s/`%GLOBALS`/$globals/g;
- # convert backticks to double quotes
- $d =~ s/\`/\"/g;
- if($d =~ /\(Added in ([0-9.]+)\)/i) {
- my $ver = $1;
- if(too_old($ver)) {
- $d =~ s/ *\(Added in $ver\)//gi;
- }
- }
- if(!$quote) {
- if($d =~ /^(.*) /) {
- printf STDERR "$f:$line:%d:ERROR: 2 spaces detected\n",
- length($1);
- return 3;
- }
- elsif($d =~ /[^\\][\<\>]/) {
- print STDERR "$f:$line:1:WARN: un-escaped < or > used\n";
- return 3;
- }
- }
- # convert backslash-'<' or '> to just the second character
- $d =~ s/\\([><])/$1/g;
- # convert single backslash to double-backslash
- $d =~ s/\\/\\\\/g;
- if(!$quote && $d =~ /--/) {
- # scan for options in longest-names first order
- for my $k (sort {length($b) <=> length($a)} keys %optlong) {
- # --tlsv1 is complicated since --tlsv1.2 etc are also
- # acceptable options!
- if(($k eq "tlsv1") && ($d =~ /--tlsv1\.[0-9]\\f/)) {
- next;
- }
- my $l = manpageify($k);
- $d =~ s/--$k([^a-z0-9-])/$l$1/g;
- }
- }
- # quote minuses in the output
- $d =~ s/([^\\])-/$1\\-/g;
- # replace single quotes
- $d =~ s/\'/\\(aq/g;
- # handle double quotes or periods first on the line
- $d =~ s/^([\.\"])/\\&$1/;
- # **bold**
- $d =~ s/\*\*(\S.*?)\*\*/\\fB$1\\fP/g;
- # *italics*
- $d =~ s/\*(\S.*?)\*/\\fI$1\\fP/g;
- # trim trailing spaces
- $d =~ s/[ \t]+\z//;
- push @desc, "\n" if($blankline && !$header);
- $blankline = 0;
- push @desc, $d;
- $header = 0;
- }
- if($tablemode) {
- # end of table
- push @desc, ".RE\n.IP\n";
- }
- return @desc;
- }
- sub single {
- my ($f, $standalone)=@_;
- my $fh;
- open($fh, "<:crlf", "$f") ||
- return 1;
- my $short;
- my $long;
- my $tags;
- my $added;
- my $protocols;
- my $arg;
- my $mutexed;
- my $requires;
- my $category;
- my @seealso;
- my $copyright;
- my $spdx;
- my @examples; # there can be more than one
- my $magic; # cmdline special option
- my $line;
- my $dline;
- my $multi;
- my $scope;
- my $experimental;
- my $start;
- my $list; # identifies the list, 1 example, 2 see-also
- while(<$fh>) {
- $line++;
- if(/^ *<!--/) {
- next;
- }
- if(!$start) {
- if(/^---/) {
- $start = 1;
- }
- next;
- }
- if(/^Short: *(.)/i) {
- $short=$1;
- }
- elsif(/^Long: *(.*)/i) {
- $long=$1;
- }
- elsif(/^Added: *(.*)/i) {
- $added=$1;
- }
- elsif(/^Tags: *(.*)/i) {
- $tags=$1;
- }
- elsif(/^Arg: *(.*)/i) {
- $arg=$1;
- }
- elsif(/^Magic: *(.*)/i) {
- $magic=$1;
- }
- elsif(/^Mutexed: *(.*)/i) {
- $mutexed=$1;
- }
- elsif(/^Protocols: *(.*)/i) {
- $protocols=$1;
- }
- elsif(/^See-also: +(.+)/i) {
- if($seealso) {
- print STDERR "ERROR: duplicated See-also in $f\n";
- return 1;
- }
- push @seealso, $1;
- }
- elsif(/^See-also:/i) {
- $list=2;
- }
- elsif(/^ *- (.*)/i && ($list == 2)) {
- push @seealso, $1;
- }
- elsif(/^Requires: *(.*)/i) {
- $requires=$1;
- }
- elsif(/^Category: *(.*)/i) {
- $category=$1;
- }
- elsif(/^Example: +(.+)/i) {
- push @examples, $1;
- }
- elsif(/^Example:/i) {
- # '1' is the example list
- $list = 1;
- }
- elsif(/^ *- (.*)/i && ($list == 1)) {
- push @examples, $1;
- }
- elsif(/^Multi: *(.*)/i) {
- $multi=$1;
- }
- elsif(/^Scope: *(.*)/i) {
- $scope=$1;
- }
- elsif(/^Experimental: yes/i) {
- $experimental=1;
- }
- elsif(/^C: (.*)/i) {
- $copyright=$1;
- }
- elsif(/^SPDX-License-Identifier: (.*)/i) {
- $spdx=$1;
- }
- elsif(/^Help: *(.*)/i) {
- ;
- }
- elsif(/^---/) {
- $start++;
- if(!$long) {
- print STDERR "ERROR: no 'Long:' in $f\n";
- return 1;
- }
- if(!$category) {
- print STDERR "ERROR: no 'Category:' in $f\n";
- return 2;
- }
- if(!$examples[0]) {
- print STDERR "$f:$line:1:ERROR: no 'Example:' present\n";
- return 2;
- }
- if(!$added) {
- print STDERR "$f:$line:1:ERROR: no 'Added:' version present\n";
- return 2;
- }
- if(!$seealso[0]) {
- print STDERR "$f:$line:1:ERROR: no 'See-also:' field present\n";
- return 2;
- }
- if(!$copyright) {
- print STDERR "$f:$line:1:ERROR: no 'C:' field present\n";
- return 2;
- }
- if(!$spdx) {
- print STDERR "$f:$line:1:ERROR: no 'SPDX-License-Identifier:' field present\n";
- return 2;
- }
- last;
- }
- else {
- chomp;
- print STDERR "$f:$line:1:WARN: unrecognized line in $f, ignoring:\n:'$_';"
- }
- }
- if($start < 2) {
- print STDERR "$f:1:1:ERROR: no proper meta-data header\n";
- return 2;
- }
- my @desc = render($fh, $f, $line);
- close($fh);
- if($tablemode) {
- # end of table
- push @desc, ".RE\n.IP\n";
- }
- my $opt;
- if(defined($short) && $long) {
- $opt = "-$short, --$long";
- }
- elsif($short && !$long) {
- $opt = "-$short";
- }
- elsif($long && !$short) {
- $opt = "--$long";
- }
- if($arg) {
- $opt .= " $arg";
- }
- # quote "bare" minuses in opt
- $opt =~ s/-/\\-/g;
- if($standalone) {
- print ".TH curl 1 \"30 Nov 2016\" \"curl 7.52.0\" \"curl manual\"\n";
- print ".SH OPTION\n";
- print "curl $opt\n";
- }
- else {
- print ".IP \"$opt\"\n";
- }
- if($protocols) {
- print protocols($standalone, $protocols);
- }
- if($standalone) {
- print ".SH DESCRIPTION\n";
- }
- if($experimental) {
- print "**WARNING**: this option is experimental. Do not use in production.\n\n";
- }
- printdesc(@desc);
- undef @desc;
- if($scope) {
- if($scope eq "global") {
- print "\nThis option is global and does not need to be specified for each use of --next.\n";
- }
- else {
- print STDERR "$f:$line:1:ERROR: unrecognized scope: '$scope'\n";
- return 2;
- }
- }
- my @extra;
- if($multi eq "single") {
- push @extra, "\nIf --$long is provided several times, the last set ".
- "value is used.\n";
- }
- elsif($multi eq "append") {
- push @extra, "\n--$long can be used several times in a command line\n";
- }
- elsif($multi eq "boolean") {
- my $rev = "no-$long";
- # for options that start with "no-" the reverse is then without
- # the no- prefix
- if($long =~ /^no-/) {
- $rev = $long;
- $rev =~ s/^no-//;
- }
- push @extra,
- "\nProviding --$long multiple times has no extra effect.\n".
- "Disable it again with \\-\\-$rev.\n";
- }
- elsif($multi eq "mutex") {
- push @extra,
- "\nProviding --$long multiple times has no extra effect.\n";
- }
- elsif($multi eq "custom") {
- ; # left for the text to describe
- }
- else {
- print STDERR "$f:$line:1:ERROR: unrecognized Multi: '$multi'\n";
- return 2;
- }
- printdesc(@extra);
- my @foot;
- my $mstr;
- my $and = 0;
- my $num = scalar(@seealso);
- if($num > 2) {
- # use commas up to this point
- $and = $num - 1;
- }
- my $i = 0;
- for my $k (@seealso) {
- if(!$helplong{$k}) {
- print STDERR "$f:$line:1:WARN: see-also a non-existing option: $k\n";
- }
- my $l = manpageify($k);
- my $sep = " and";
- if($and && ($i < $and)) {
- $sep = ",";
- }
- $mstr .= sprintf "%s$l", $mstr?"$sep ":"";
- $i++;
- }
- push @foot, seealso($standalone, $mstr);
- if($requires) {
- my $l = manpageify($long);
- push @foot, "$l requires that the underlying libcurl".
- " was built to support $requires. ";
- }
- if($mutexed) {
- my @m=split(/ /, $mutexed);
- my $mstr;
- for my $k (@m) {
- if(!$helplong{$k}) {
- print STDERR "WARN: $f mutexes a non-existing option: $k\n";
- }
- my $l = manpageify($k);
- $mstr .= sprintf "%s$l", $mstr?" and ":"";
- }
- push @foot, overrides($standalone,
- "This option is mutually exclusive to $mstr. ");
- }
- if($examples[0]) {
- my $s ="";
- $s="s" if($examples[1]);
- print "\nExample$s:\n.nf\n";
- foreach my $e (@examples) {
- $e =~ s!\$URL!https://example.com!g;
- #$e =~ s/-/\\-/g;
- #$e =~ s/\'/\\(aq/g;
- # convert single backslahes to doubles
- $e =~ s/\\/\\\\/g;
- print " curl $e\n";
- }
- print ".fi\n";
- }
- if($added) {
- push @foot, added($standalone, $added);
- }
- if($foot[0]) {
- print "\n";
- my $f = join("", @foot);
- $f =~ s/ +\z//; # remove trailing space
- print "$f\n";
- }
- return 0;
- }
- sub getshortlong {
- my ($f)=@_;
- open(F, "<:crlf", "$f");
- my $short;
- my $long;
- my $help;
- my $arg;
- my $protocols;
- my $category;
- my $start = 0;
- while(<F>) {
- if(!$start) {
- if(/^---/) {
- $start = 1;
- }
- next;
- }
- if(/^Short: (.)/i) {
- $short=$1;
- }
- elsif(/^Long: (.*)/i) {
- $long=$1;
- }
- elsif(/^Help: (.*)/i) {
- $help=$1;
- }
- elsif(/^Arg: (.*)/i) {
- $arg=$1;
- }
- elsif(/^Protocols: (.*)/i) {
- $protocols=$1;
- }
- elsif(/^Category: (.*)/i) {
- $category=$1;
- }
- elsif(/^---/) {
- last;
- }
- }
- close(F);
- if($short) {
- $optshort{$short}=$long;
- }
- if($long) {
- $optlong{$long}=$short;
- $helplong{$long}=$help;
- $arglong{$long}=$arg;
- $protolong{$long}=$protocols;
- $catlong{$long}=$category;
- }
- }
- sub indexoptions {
- my (@files) = @_;
- foreach my $f (@files) {
- getshortlong($f);
- }
- }
- sub header {
- my ($f)=@_;
- my $fh;
- open($fh, "<:crlf", "$f");
- my @d = render($fh, $f, 1);
- close($fh);
- printdesc(@d);
- }
- sub listhelp {
- print <<HEAD
- /***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \\| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \\___|\\___/|_| \\_\\_____|
- *
- * Copyright (C) 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 https://curl.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.
- *
- * SPDX-License-Identifier: curl
- *
- ***************************************************************************/
- #include "tool_setup.h"
- #include "tool_help.h"
- /*
- * DO NOT edit tool_listhelp.c manually.
- * This source file is generated with the following command in an autotools
- * build:
- *
- * "make listhelp"
- */
- const struct helptxt helptext[] = {
- HEAD
- ;
- foreach my $f (sort keys %helplong) {
- my $long = $f;
- my $short = $optlong{$long};
- my @categories = split ' ', $catlong{$long};
- my $bitmask = ' ';
- my $opt;
- if(defined($short) && $long) {
- $opt = "-$short, --$long";
- }
- elsif($long && !$short) {
- $opt = " --$long";
- }
- for my $i (0 .. $#categories) {
- $bitmask .= 'CURLHELP_' . uc $categories[$i];
- # If not last element, append |
- if($i < $#categories) {
- $bitmask .= ' | ';
- }
- }
- $bitmask =~ s/(?=.{76}).{1,76}\|/$&\n /g;
- my $arg = $arglong{$long};
- if($arg) {
- $opt .= " $arg";
- }
- my $desc = $helplong{$f};
- $desc =~ s/\"/\\\"/g; # escape double quotes
- my $line = sprintf " {\"%s\",\n \"%s\",\n %s},\n", $opt, $desc, $bitmask;
- if(length($opt) > 78) {
- print STDERR "WARN: the --$long name is too long\n";
- }
- elsif(length($desc) > 78) {
- print STDERR "WARN: the --$long description is too long\n";
- }
- print $line;
- }
- print <<FOOT
- { NULL, NULL, CURLHELP_HIDDEN }
- };
- FOOT
- ;
- }
- sub listcats {
- my %allcats;
- foreach my $f (sort keys %helplong) {
- my @categories = split ' ', $catlong{$f};
- foreach (@categories) {
- $allcats{$_} = undef;
- }
- }
- my @categories;
- foreach my $key (keys %allcats) {
- push @categories, $key;
- }
- @categories = sort @categories;
- unshift @categories, 'hidden';
- for my $i (0..$#categories) {
- print '#define ' . 'CURLHELP_' . uc($categories[$i]) . ' ' . "1u << " . $i . "u\n";
- }
- }
- sub listglobals {
- my (@files) = @_;
- my @globalopts;
- # Find all global options and output them
- foreach my $f (sort @files) {
- open(F, "<:crlf", "$f") ||
- next;
- my $long;
- my $start = 0;
- while(<F>) {
- if(/^---/) {
- if(!$start) {
- $start = 1;
- next;
- }
- else {
- last;
- }
- }
- if(/^Long: *(.*)/i) {
- $long=$1;
- }
- elsif(/^Scope: global/i) {
- push @globalopts, $long;
- last;
- }
- }
- close(F);
- }
- return $ret if($ret);
- for my $e (0 .. $#globalopts) {
- $globals .= sprintf "%s--%s", $e?($globalopts[$e+1] ? ", " : " and "):"",
- $globalopts[$e],;
- }
- }
- sub noext {
- my $in = $_[0];
- $in =~ s/\.d//;
- return $in;
- }
- sub sortnames {
- return noext($a) cmp noext($b);
- }
- sub mainpage {
- my (@files) = @_;
- my $ret;
- my $fh;
- open($fh, "<:crlf", "mainpage.idx") ||
- return 1;
- print <<HEADER
- .\\" **************************************************************************
- .\\" * _ _ ____ _
- .\\" * Project ___| | | | _ \\| |
- .\\" * / __| | | | |_) | |
- .\\" * | (__| |_| | _ <| |___
- .\\" * \\___|\\___/|_| \\_\\_____|
- .\\" *
- .\\" * Copyright (C) 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 https://curl.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.
- .\\" *
- .\\" * SPDX-License-Identifier: curl
- .\\" *
- .\\" **************************************************************************
- .\\"
- .\\" DO NOT EDIT. Generated by the curl project gen.pl man page generator.
- .\\"
- .TH curl 1 "$date" "curl $version" "curl Manual"
- HEADER
- ;
- while(<$fh>) {
- my $f = $_;
- chomp $f;
- if($f =~ /^#/) {
- # stardard comment
- next;
- }
- if(/^%options/) {
- # output docs for all options
- foreach my $f (sort sortnames @files) {
- $ret += single($f, 0);
- }
- }
- else {
- # render the file
- header($f);
- }
- }
- close($fh);
- exit $ret if($ret);
- }
- sub showonly {
- my ($f) = @_;
- if(single($f, 1)) {
- print STDERR "$f: failed\n";
- }
- }
- sub showprotocols {
- my %prots;
- foreach my $f (keys %optlong) {
- my @p = split(/ /, $protolong{$f});
- for my $p (@p) {
- $prots{$p}++;
- }
- }
- for(sort keys %prots) {
- printf "$_ (%d options)\n", $prots{$_};
- }
- }
- sub getargs {
- my ($f, @s) = @_;
- if($f eq "mainpage") {
- listglobals(@s);
- mainpage(@s);
- return;
- }
- elsif($f eq "listhelp") {
- listhelp();
- return;
- }
- elsif($f eq "single") {
- showonly($s[0]);
- return;
- }
- elsif($f eq "protos") {
- showprotocols();
- return;
- }
- elsif($f eq "listcats") {
- listcats();
- return;
- }
- print "Usage: gen.pl <mainpage/listhelp/single FILE/protos/listcats> [files]\n";
- }
- #------------------------------------------------------------------------
- my $cmd = shift @ARGV;
- my @files = @ARGV; # the rest are the files
- # learn all existing options
- indexoptions(@files);
- getargs($cmd, @files);
|