"Fossies" - the Fresh Open Source Software Archive

Member "rman-3.2/contrib/rman.pl" (26 Jul 2003, 6596 Bytes) of package /linux/www/old/rman-3.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "rman.pl" see the Fossies "Dox" file reference documentation.

    1 #!/usr/local/bin/perl
    2 # Copyright 1994 Alexander Gagin (gagin@cvxct0.jinr.dubna.su)
    3 # http://www.jinr.dubna.su/~gagin
    4 # CGI form interface to RosettaMan program, which is available as
    5 # ftp://ftp.cs.berkeley.edu:/ucb/people/phelps/tcltk/rman.tar.Z
    6 # The most recent version of this program available as
    7 # http://thsun1.jinr.dubna.su/~gagin/rman.pl
    8 #
    9 # $Id: rman.pl,v 1.3 1994/08/18 10:30:27 gagin Exp $
   10 #---------------------------------------------------------------------
   11 #   Copyright conditions:
   12 # Permission to copy, distribute and use this software as part of any 
   13 # educational, research and non-profit organization's WWW-server, 
   14 # without fee, and without a written agreement is hereby granted, 
   15 # provided that the above copyright notice and this paragraph appear 
   16 # in all copies.
   17 # This software comes with no warranty, express or implied, but with 
   18 # the hope that someone may find it useful.
   19 # Comments, improvements and suggestions are welcomed.
   20 #---------------------------------------------------------------------
   21 # Request form: rman.pl?topic=SOMETOPIC&section=SECTION[&keyword=on]
   22 # SOMETOPIC is man topic
   23 # For SunOS and Linux SECTION is one of follows:
   24 #               all         or  nothing, or anything,
   25 #                           doesn't containing
   26 #                           "&keyword=on" text
   27 #               user+commands   or  1
   28 #               system+calls    or  2
   29 #               subroutines     or  3
   30 #               devices     or  4
   31 #               file+formats    or  5
   32 #               games       or  6
   33 #               miscellanious   or  7
   34 #               sys.+admin.     or  8
   35 # If &keyword=on absent, I assume no keywprd search. If it present,
   36 # SECTION don't make any sense. 
   37 # Program was "Quick'n'Dirty", so here can be unefficient and stupid 
   38 # code.
   39 # Program was developed for NCSA httpd 1.3, working on SunOS 4.1.1
   40 #---------------------------------------------------------------------
   41 $ENV{'MANPATH'}='/usr/man:/usr/share/man:/usr/local/man:/usr/local/gnu/man';
   42 $ENV{'PATH'}='/usr/bin:/usr/local/bin:/usr/local/gnu/bin';
   43 # Stuff to change 
   44 # path to man program
   45 $man='/usr/bin/man';
   46 # path to RosettaMan program. "-b" is not nessesary
   47 $rman='/usr/local/bin/rman -b -f html';
   48 # URL to this program
   49 $rmanpl='http://forrest.cso.uiuc.edu/cgi-bin/rman.cgi';
   50 # First part of title. Will be smth like "Man page on man(1)"
   51 $manon='Man page on';
   52 # if man produced number of lines less then follows, 
   53 # I assume that request failed
   54 #$emptyman=5;
   55 $emptyman=0;
   56 # tail of every produced html document
   57 $tail="<HR><A HREF=http://forrest.cso.uiuc.edu/>Back</a> to Forrest's homepage.
   58 <p><A HREF=http://forrest.cso.uiuc.edu/hp_project/>Back</a> to HP Special 
   59 Project Page\n <p> <a href=http://forrest.cso.uiuc.edu/scripts/rman.cgi.txt>See the code</a> for this page";
   60 # temporary file prefix
   61 $tmp='/tmp/rman.pl_tmp';
   62 # end changable things
   63 #----------------------------------------------------------------------
   64 $form='
   65 <center><h1>HP-UX 10.10 Man Page Gateway</h1></center> <hr> <h1>Select which man page you want to see:</h1> <FORM METHOD="GET"> Search for
   66 <INPUT SIZE=10 NAME="topic"> in
   67 <SELECT NAME="section"> <OPTION> all
   68 <OPTION>user commands 1
   69 <OPTION>system admin. 1m
   70 <OPTION>system calls 2
   71 <OPTION>library functions 3
   72 <OPTION>file formats 4
   73 <OPTION>miscellaneous 5
   74 <OPTION>devices 7
   75 <OPTION>glossary 9
   76 </SELECT> section(s).
   77 <P><INPUT TYPE="checkbox" NAME="keyword">Search only for keyword
   78 (section will be ignored then)
   79 <P><INPUT TYPE="submit" VALUE="Do search"> <INPUT TYPE="reset" VALUE="Clear Form"> </FORM> ';
   80 $type="Content-type: text/html\n\n";
   81 $string=$ENV{QUERY_STRING};
   82 if($string eq ""){print $type;
   83                   print "<title>Which man page do you want to see?</title>\n";
   84                   print $form;
   85                   print $tail;
   86           exit;}
   87 if($string =~ /topic=(\S*)&section=(\S*)/)
   88  {
   89  $topic=$1;
   90  if ($topic eq "")
   91     {
   92     print $type;
   93     print "<title>Topic for man search needed</title>\n";
   94     print "<strong>Request failed:</strong> <code>Topic for man search needed</code><hr>\n";
   95     print $form;
   96     print $tail;
   97     exit;
   98     }
   99  if ($2=~/(\S*)&keyword=on/)
  100     {
  101     open(TMPHTML,"$man -k $topic 2>/dev/null |") || die "can't open pipe \"$man -k $topic |\": $!\n";
  102     print $type;
  103     print "<title>Keyword search results for $topic</title>\n";
  104     print "<h1>Keyword search results for $topic</h1>\n";
  105         while(<TMPHTML>)
  106         {
  107         if (/^(.+) \((\S+)\)\s+- (.+)$/) {@topics=split(/, /,$1); 
  108                                           $section=$2; 
  109                                           print "<h2>$3:</h2>\n";
  110                                           print "<UL>\n";
  111                                           for $topic (@topics)
  112                                                 {
  113                                                  print "<li><A HREF=\"$rmanpl?topic=$topic&section=$section\">$topic($section)</a>\n";
  114                                                 }                                  
  115                           print "</UL>\n";
  116                          }
  117         }
  118     print "<hr>\n";
  119     print $tail;
  120     exit;
  121     }
  122  if ($2 eq "user+commands+1"){$section=1;}
  123  elsif ($2 eq "1"){$section=1;}
  124  #elsif ($2 eq "system+admin.+1m"){$section='1m';}
  125  #elsif ($2 eq "1m"){$section=1m;}
  126  elsif ($2 eq "system+calls+2"){$section=2;}
  127  elsif ($2 eq "2"){$section=2;}
  128  elsif ($2 eq "library+functions+3"){$section=3;}
  129  elsif ($2 eq "3"){$section=3;}
  130  elsif ($2 eq "file+formats+4"){$section=4;}
  131  elsif ($2 eq "4"){$section=4;}
  132  elsif ($2 eq "miscellaneous+5"){$section=5;}
  133  elsif ($2 eq "5"){$section=5;} 
  134  elsif ($2 eq "devices+7"){$section=7;}
  135  elsif ($2 eq "7"){$section=7;}
  136  elsif ($2 eq "glossary+9"){$section=9;}
  137  elsif ($2 eq "9"){$section=9;}
  138  else {$string=$topic;}
  139  if(defined($section)){$string="$section $topic";}
  140  }
  141 for ($i=0;-e "$tmp$i";$i++){;}
  142 system("$man $string 2>/dev/null 1> $tmp$i");
  143 open(TMPHTML,"<$tmp$i") || die "$rmanpl: can't open $tmp$i: $!\n";
  144 $counter=0;
  145 while(<TMPHTML>){$counter++;}
  146 close TMPHTML;
  147 if ($counter < $emptyman) 
  148     {print $type;
  149     print"<strong>Request failed:</strong>\n<code>";
  150     open(TMPHTML,"<$tmp$i") || die "$rmanpl: can't open $tmp$i: $!\n";
  151     while(<TMPHTML>){print;}
  152     print "</code><hr>\n";
  153     print $form; 
  154     print $tail;
  155     unlink "$tmp$i";
  156     exit;}
  157 for ($j=0;-e "$tmp$j";$j++){;}
  158 if (defined($section))
  159    {system("$rman -r \"$rmanpl?topic=%s&section=%s\" -l \"$manon $topic($section)\"< $tmp$i > $tmp$j");}
  160    else {system("$rman -r \"$rmanpl?topic=%s&section=%s\" -l \"$manon $string\"< $tmp$i > $tmp$j");}
  161 print $type; 
  162 open(TMPHTML,"<$tmp$j") || die "$rmanpl: can't open $tmp$j: $!\n";
  163 while(<TMPHTML>){print;}
  164 print "<hr>\n";
  165 print $tail;
  166 unlink "$tmp$i";
  167 unlink "$tmp$j";