3 # Display a single manual page
5 require './man-lib.pl';
7 &ui_print_header(undef, $text{'man_title'}, "");
9 if (&has_command($config{'man2html_path'})) {
10 $ocmd = $in{'sec'} ? $config{'list_cmd_sect'}
11 : $config{'list_cmd'};
14 $ocmd = $in{'sec'} ? $config{'man_cmd_sect'}
17 if ($config{'strip_letters'}) {
18 $in{'sec'} =~ s/^(\d+).*$/$1/;
20 &set_manpath($in{'opts'});
22 # Try various man commands, like :
23 # man -s 3x Foo, man -s 3x foo, man -s 3 Foo, man -s 3 foo
24 @sects = ( $in{'sec'} );
25 if ($in{'sec'} =~ /^(\d+)[^0-9]+$/) {
28 SECT: foreach $sec (@sects) {
29 foreach $page ($in{'page'}, lc($in{'page'})) {
30 $qpage = quotemeta($page);
31 $qsec = quotemeta($sec);
33 $cmd =~ s/PAGE/$qpage/;
34 $cmd =~ s/SECTION/$qsec/;
35 $out = &backquote_command("$cmd 2>&1", 1);
36 if ($out !~ /^.*no manual entry/i && $out !~ /^.*no entry/i &&
37 $out !~ /^.*nothing appropriate/i) {
45 print "<p><b>",&text('man_noentry', "<tt>$in{'page'}</tt>"),
49 if (&has_command($config{'man2html_path'})) {
51 @lines = split(/\r?\n/, $out);
52 $out = $lines[$#lines];
53 if ($out =~ /\(<--\s+(.*)\)/) {
54 # Output has cached file and original path
58 if( $out =~ /^.*\.gz/i ) {
61 elsif ($out =~ /^.*\.(bz2|bz)/i) {
67 $qout = quotemeta($out);
68 $manout = &backquote_command("$config{'man2html_path'} -v 2>&1", 1);
69 if ($manout =~ /Version:\s+([0-9\.]+)/i && $1 >= 3) {
70 # New version uses a different syntax!
71 $cmd .= " $qout | nroff -mman | $config{'man2html_path'} --cgiurl \"view_man.cgi?page=\\\${title}&sec=\\\${section}&opts=$in{'opts'}\" --bare";
72 $out = &backquote_command("$cmd 2>&1", 1);
75 # Old version of man2html
76 $cmd .= " $qout | $config{'man2html_path'} -H \"\" -M \"view_man.cgi\"";
77 $out = &backquote_command("$cmd 2>&1", 1);
78 $out =~ s/^.*Content-type:.*\n//i;
79 $out =~ s/http:\/\///ig;
80 $out =~ s/\?/\?sec=/ig;
81 $out =~ s/\+/&opts=$in{'opts'}&page=/ig;
82 $out =~ s/<HTML>.*<BODY>//isg;
83 $out =~ s/<\/HTML>//ig;
84 $out =~ s/<\/BODY>//ig;
85 $out =~ s/<A HREF="file:[^"]+">([^<]+)<\/a>/$1/ig;
86 $out =~ s/<A HREF="view_man.cgi">/<A HREF=\"\">/i;
88 &show_view_table(&text('man_header', $in{'page'}, $in{'sec'}),
92 $out =~ s/^(man:\s*)?(re)?formatting.*//i;
93 &show_view_table(&text('man_header', $in{'page'}, $in{'sec'}),
94 "<pre>".&html_escape($out)."</pre>");
98 &ui_print_footer("", $text{'index_return'});