2009-12-09 02:08:12 +01:00
|
|
|
#!/usr/bin/perl -w -I /home/msmud/libwww-perl-5.808/lib
|
2017-03-05 22:33:31 +01:00
|
|
|
|
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
2007-05-20 22:44:44 +02:00
|
|
|
# quick and dirty by :pragma
|
|
|
|
|
|
|
|
use LWP::Simple;
|
|
|
|
|
|
|
|
my ($result, $manpage, $section, $text, $name, $includes, $prototype, $conforms, $description);
|
|
|
|
|
|
|
|
if ($#ARGV < 0) {
|
|
|
|
print "Which command would you like information about?\n";
|
|
|
|
die;
|
|
|
|
}
|
|
|
|
|
|
|
|
$manpage = join("+", @ARGV);
|
2009-12-09 02:08:12 +01:00
|
|
|
$section = 8;
|
|
|
|
my $loop = 1;
|
2007-05-20 22:44:44 +02:00
|
|
|
|
|
|
|
if($manpage =~ m/([0-9]+)\+(.*)/) {
|
|
|
|
$section = $1;
|
|
|
|
$manpage = $2;
|
2009-12-09 02:08:12 +01:00
|
|
|
$loop = 0;
|
2007-05-20 22:44:44 +02:00
|
|
|
}
|
|
|
|
|
2009-12-09 02:08:12 +01:00
|
|
|
$manpage =~ s/\+.*$//;
|
|
|
|
|
|
|
|
my $get_text;
|
|
|
|
do {
|
|
|
|
# $text = get("http://www.freebsd.org/cgi/man.cgi?query=$manpage&sektion=$section&apropos=0&manpath=FreeBSD+6.2-RELEASE&format=ascii");
|
|
|
|
|
2014-04-07 07:12:00 +02:00
|
|
|
$get_text = get("http://www.freebsd.org/cgi/man.cgi?query=$manpage&sektion=$section&apropos=0&manpath=SuSE+Linux%2Fi386+11.3&format=ascii");
|
2009-12-09 02:08:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
$text = substr($get_text, 0, 5000);
|
|
|
|
# print '['.length($text).']'."\n";
|
|
|
|
|
|
|
|
if($text =~ m/Sorry, no data found/)
|
|
|
|
{
|
|
|
|
$section--;
|
|
|
|
|
|
|
|
if($section == 0 || $loop == 0) {
|
|
|
|
$section++;
|
|
|
|
if($section == 1 && $loop == 1) {
|
|
|
|
print "No information found for $manpage in any of the sections.\n";
|
|
|
|
} else {
|
|
|
|
print "No information found for $manpage in section $section.\n";
|
|
|
|
}
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
} else { $loop = 0; }
|
|
|
|
} while($loop);
|
2007-05-20 22:44:44 +02:00
|
|
|
|
|
|
|
$text =~ m/^\s+NAME/gsm;
|
|
|
|
if($text =~ m/(.*?)SYNOPSIS/gsi) {
|
|
|
|
$name = $1;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $i = 0;
|
|
|
|
while ($text =~ m/#include <(.*?)>/gsi) {
|
2009-12-09 02:08:12 +01:00
|
|
|
if(not $includes =~ /$1/) {
|
|
|
|
$includes .= ", " if($i > 0);
|
|
|
|
$includes .= "$1";
|
|
|
|
$i++;
|
|
|
|
}
|
2007-05-20 22:44:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$prototype = "$1 $2$manpage($3);"
|
|
|
|
if($text =~ m/SYNOPSIS.*^\s+(.*?)\s+(\*?)$manpage\s*\((.*?)\)\;?\n.*DESC/ms);
|
|
|
|
|
2009-12-09 02:08:12 +01:00
|
|
|
if($text =~ m/DESCRIPTION(.*?)$manpage(.*?)\./si) {
|
|
|
|
my $foo = $1;
|
|
|
|
my $bar = $2;
|
|
|
|
$foo =~ s/\r//g;
|
|
|
|
$foo =~ s/\n//g;
|
|
|
|
$foo =~ s/\s+/ /g;
|
|
|
|
$foo =~ s/^\s+//;
|
|
|
|
if($foo =~ /^NOTE/) {
|
2014-04-07 07:12:00 +02:00
|
|
|
$description = "$foo$manpage$bar";
|
2009-12-09 02:08:12 +01:00
|
|
|
} else {
|
2014-04-07 07:12:00 +02:00
|
|
|
$description = "$manpage$bar";
|
2009-12-09 02:08:12 +01:00
|
|
|
}
|
2007-05-20 22:44:44 +02:00
|
|
|
$description =~ s/\-\s+//g;
|
|
|
|
}
|
|
|
|
|
2009-12-09 02:08:12 +01:00
|
|
|
if ($get_text =~ m/^CONFORMING TO.*?^\s+The\s$manpage\s.*conforms to\s(.*?)$/ms) {
|
2007-05-20 22:44:44 +02:00
|
|
|
$conforms = $1;
|
2009-12-09 02:08:12 +01:00
|
|
|
} elsif ($get_text =~ m/^CONFORMING TO.*?^\s+The\s+$manpage\s+.*?is\s+compatible\s+with\s+(.*?)$/ms) {
|
2007-05-20 22:44:44 +02:00
|
|
|
$conforms = "$1 ...";
|
2009-12-09 02:08:12 +01:00
|
|
|
} elsif ($get_text =~ m/^CONFORMING TO.*?^\s+(.*?)\.\s/ms or
|
|
|
|
$get_text =~ m/^CONFORMING TO.*?^\s+(.*?)$/ms) {
|
2007-05-20 22:44:44 +02:00
|
|
|
$conforms = $1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$result = "";
|
2014-04-07 07:12:00 +02:00
|
|
|
$result .= "$name - " if (not defined $includes and defined $name);
|
2007-05-20 22:44:44 +02:00
|
|
|
$result .= "Includes: $includes - " if (defined $includes);
|
|
|
|
$result .= "$prototype - " if (defined $prototype);
|
2009-12-09 02:08:12 +01:00
|
|
|
|
2007-05-20 22:44:44 +02:00
|
|
|
$result .= $description;
|
|
|
|
|
2009-12-09 02:08:12 +01:00
|
|
|
if($section == 3) {
|
|
|
|
$result .= " - http://www.iso-9899.info/man?$manpage";
|
|
|
|
} else {
|
|
|
|
$result .= " - http://www.freebsd.org/cgi/man.cgi?sektion=$section&query=$manpage";
|
|
|
|
}
|
|
|
|
|
|
|
|
$result .= " - $conforms" if (defined $conforms);
|
|
|
|
|
2007-05-20 22:44:44 +02:00
|
|
|
$result =~ s/^\s+//g;
|
|
|
|
$result =~ s/\s+/ /g;
|
|
|
|
$result =~ s/ANSI - C/ANSI C/g;
|
2009-12-09 02:08:12 +01:00
|
|
|
$result =~ s/\(these.*?appeared in .*?\)//g;
|
|
|
|
$result =~ s/(\w)- /$1/g;
|
2007-05-20 22:44:44 +02:00
|
|
|
$result =~ s/\n//g;
|
|
|
|
$result =~ s/\r//g;
|
|
|
|
$result =~ s/\<A HREF.*?>//g;
|
|
|
|
$result =~ s/\<\/A>//g;
|
|
|
|
$result =~ s/"//g;
|
|
|
|
|
2009-12-09 02:08:12 +01:00
|
|
|
print "$result\n";
|
|
|
|
|