1#!/usr/bin/env perl 2# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3# 4# SPDX-License-Identifier: curl 5# 6# Given: a libcurl curldown man page 7# Outputs: the same file, minus the SYNOPSIS and the EXAMPLE sections 8# 9 10my $f = $ARGV[0]; 11 12open(F, "<$f") or die; 13 14my @out; 15my $ignore = 0; 16while(<F>) { 17 if($_ =~ /^# (SYNOPSIS|EXAMPLE)/) { 18 $ignore = 1; 19 } 20 elsif($ignore && ($_ =~ /^# [A-Z]/)) { 21 $ignore = 0; 22 } 23 elsif(!$ignore) { 24 # **bold** 25 $_ =~ s/\*\*(\S.*?)\*\*//g; 26 # *italics* 27 $_ =~ s/\*(\S.*?)\*//g; 28 29 $_ =~ s/CURL(M|SH|U|H)code//g; 30 $_ =~ s/CURL_[A-Z0-9_]*//g; 31 $_ =~ s/CURLALTSVC_[A-Z0-9_]*//g; 32 $_ =~ s/CURLAUTH_[A-Z0-9_]*//g; 33 $_ =~ s/CURLE_[A-Z0-9_]*//g; 34 $_ =~ s/CURLFORM_[A-Z0-9_]*//g; 35 $_ =~ s/CURLFTP_[A-Z0-9_]*//g; 36 $_ =~ s/CURLFTPAUTH_[A-Z0-9_]*//g; 37 $_ =~ s/CURLFTPMETHOD_[A-Z0-9_]*//g; 38 $_ =~ s/CURLFTPSSL_[A-Z0-9_]*//g; 39 $_ =~ s/CURLGSSAPI_[A-Z0-9_]*//g; 40 $_ =~ s/CURLHEADER_[A-Z0-9_]*//g; 41 $_ =~ s/CURLINFO_[A-Z0-9_]*//g; 42 $_ =~ s/CURLM_[A-Z0-9_]*//g; 43 $_ =~ s/CURLMIMEOPT_[A-Z0-9_]*//g; 44 $_ =~ s/CURLMOPT_[A-Z0-9_]*//g; 45 $_ =~ s/CURLOPT_[A-Z0-9_]*//g; 46 $_ =~ s/CURLPIPE_[A-Z0-9_]*//g; 47 $_ =~ s/CURLPROTO_[A-Z0-9_]*//g; 48 $_ =~ s/CURLPROXY_[A-Z0-9_]*//g; 49 $_ =~ s/CURLPX_[A-Z0-9_]*//g; 50 $_ =~ s/CURLSHE_[A-Z0-9_]*//g; 51 $_ =~ s/CURLSHOPT_[A-Z0-9_]*//g; 52 $_ =~ s/CURLSSLOPT_[A-Z0-9_]*//g; 53 $_ =~ s/CURLSSH_[A-Z0-9_]*//g; 54 $_ =~ s/CURLSSLBACKEND_[A-Z0-9_]*//g; 55 $_ =~ s/CURLU_[A-Z0-9_]*//g; 56 $_ =~ s/CURLUPART_[A-Z0-9_]*//g; 57 #$_ =~ s/\bCURLU\b//g; # stand-alone CURLU 58 $_ =~ s/CURLUE_[A-Z0-9_]*//g; 59 $_ =~ s/CURLHE_[A-Z0-9_]*//g; 60 $_ =~ s/CURLWS_[A-Z0-9_]*//g; 61 $_ =~ s/CURLKH[A-Z0-9_]*//g; 62 $_ =~ s/CURLUPART_[A-Z0-9_]*//g; 63 $_ =~ s/CURLUSESSL_[A-Z0-9_]*//g; 64 $_ =~ s/CURLPAUSE_[A-Z0-9_]*//g; 65 $_ =~ s/CURLHSTS_[A-Z0-9_]*//g; 66 $_ =~ s/curl_global_([a-z_]*)//g; 67 $_ =~ s/curl_(strequal|strnequal|formadd|waitfd|formget|getdate|formfree)//g; 68 $_ =~ s/curl_easy_([a-z]*)//g; 69 $_ =~ s/curl_multi_([a-z_]*)//g; 70 $_ =~ s/curl_mime_(subparts|addpart|filedata|data_cb)//g; 71 $_ =~ s/curl_ws_(send|recv|meta)//g; 72 $_ =~ s/curl_url_(dup)//g; 73 $_ =~ s/curl_pushheader_by(name|num)//g; 74 $_ =~ s/libcurl-(env|ws)//g; 75 $_ =~ s/libcurl\\-(env|ws)//g; 76 $_ =~ s/(^|\W)((tftp|https|http|ftp):\/\/[a-z0-9\-._~%:\/?\#\[\]\@!\$&'()*+,;=\\]+)//gi; 77 push @out, $_; 78 } 79} 80close(F); 81 82open(O, ">$f") or die; 83for my $l (@out) { 84 print O $l; 85} 86close(O); 87