source: rtems/doc/tools/src2html1.4a/src2html.cgi @ 52461c5

4.104.114.84.95
Last change on this file since 52461c5 was 52461c5, checked in by Joel Sherrill <joel.sherrill@…>, on Apr 14, 1998 at 4:03:45 PM

New files

  • Property mode set to 100644
File size: 3.1 KB
Line 
1#!/usr/local/bin/perl
2#
3# src2html.cgi -- A search script to file symbols in a src2html tree.
4# You need to install this in your httpd script directory AND set the
5# httpd web root below.
6#
7# We need the cgi-lib.pl package to be available to Perl
8require 'cgi-lib.pl';
9#
10## We MUST know the root of the httpd server, so we can find the ctags
11##
12#
13$Http_root= "/usr/pub/pub/www";
14
15                                                # Parse input -> %in
16&ReadParse;                                     # and print first 2 lines
17
18@keys= keys(%in);                       # We only expect one name/val pair
19if ($#keys != 0) {                      # Otherwise, return an error document
20    print <<"query_error";
21Content-type: text/html
22
23    <header><title>Query Error</title></header><body>
24    <h1>Query Error</h1>
25    The document you used to query this source tree has an error in it.
26    You should email the maintainer of the source tree with a copy of the
27    document with the query form in it.
28    </body>
29query_error
30    exit(1);
31}
32                                        # Given the name, determine which tree
33$Htmltree= "$Http_root/$keys[0]"; 
34$Htmltree=~ s/\/[^\/]*$//;              # Location of the Html tree root
35$Srctree= "/$keys[0]";                  # URL of the actual source
36$Ctags= "$Htmltree/ctags";              # Location of the ctags files
37
38@symbol= split(/\s+/, $in{$keys[0]});   # Get one symbol to search for
39
40if ($#symbol != 0) {                    # Hmm, <> 1 symbol, return an error
41    print <<"symbol_error";
42Content-type: text/html
43
44    <header><title>$Htmltree Search Error</title></header><body>
45    <h1>$Htmltree Search Error</h1>
46    Hmm, you either sent in no symbols to me to search, or a number of
47    symbols to find, separated by whitespace.<p>
48    The search function can only handle regexp expressions with no
49    whitespace. Try resubmitting your query.
50    </body>
51symbol_error
52    exit(1);
53}
54                                        # Let's go to work, egrep the ctags
55
56# Naftali Schwartz (nschwart@SLINKY.CS.NYU.EDU) reports that using the ^
57# on the following line stops the script from working under SunOS 4.1.3.
58# Sounds like ctags-new doesn't start the symbol in the 1st column.
59open(IN, "cat $Ctags/* | egrep ^$symbol[0] |") || die "$0: egrep failed\n";
60$cnt=0;
61while(<IN>) {
62    ($sym, $line, $file, $com)= split(/\s+/);
63    $Sym[$cnt]=$sym; $Line[$cnt]= $line; $File[$cnt]= $file; $cnt++;
64}
65close(IN);
66                                        # How many did we get? Zero, no symbol
67if ($cnt == 0) {
68    print <<"symbol_missing";
69Content-type: text/html
70
71    <header><title>$Htmltree Search Error</title></header><body>
72    <h1>$Htmltree Search Error</h1>
73    The symbol $symbol[0] does not appear in the source tree.
74    </body>
75symbol_missing
76    exit(1);
77}
78
79if ($cnt == 1) {                        # Exactly one, return ptr to that doc
80    print "Location: $Srctree/$File[0]";
81
82# I used to use the commented out line under NCSA httpd because the other
83# line didn't work. You may need to try things out on your server.
84    print ".html\#$Sym[0]\n\n";
85#   print ".html\n\n";
86    exit(0);
87}
88                                        # Else return a list of choices
89print <<"many_found";
90Content-type: text/html
91
92<header><title>$Htmltree Search</title></header><body>
93<h1>$Htmltree Search</h1><ul>
94many_found
95for ($i = 0; $i < $cnt; $i++) {
96    print "<li><a href= \"$Srctree/$File[$i]";
97    print ".html#$Sym[$i]\">$Sym[$i]</a> $File[$i]:$Line[$i]\n";
98}
99print "</ul></body>\n";
100exit(0);
Note: See TracBrowser for help on using the repository browser.