OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [doc/] [tools/] [src2html1.4a/] [src2html.cgi] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
#!/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
8
require '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
19
if ($#keys != 0) {                      # Otherwise, return an error document
20
    print <<"query_error";
21
Content-type: text/html
22
 
23
    
Query Error
24
    

Query Error

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
    
29
query_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
 
40
if ($#symbol != 0) {                    # Hmm, <> 1 symbol, return an error
41
    print <<"symbol_error";
42
Content-type: text/html
43
 
44
    
$Htmltree Search Error
45
    

$Htmltree Search Error

46
    Hmm, you either sent in no symbols to me to search, or a number of
47
    symbols to find, separated by whitespace.

48
    The search function can only handle regexp expressions with no
49
    whitespace. Try resubmitting your query.
50
    
51
symbol_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.
59
open(IN, "cat $Ctags/* | egrep ^$symbol[0] |") || die "$0: egrep failed\n";
60
$cnt=0;
61
while() {
62
    ($sym, $line, $file, $com)= split(/\s+/);
63
    $Sym[$cnt]=$sym; $Line[$cnt]= $line; $File[$cnt]= $file; $cnt++;
64
}
65
close(IN);
66
                                        # How many did we get? Zero, no symbol
67
if ($cnt == 0) {
68
    print <<"symbol_missing";
69
Content-type: text/html
70
 
71
    
$Htmltree Search Error
72
    

$Htmltree Search Error

73
    The symbol $symbol[0] does not appear in the source tree.
74
    
75
symbol_missing
76
    exit(1);
77
}
78
 
79
if ($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
89
print <<"many_found";
90
Content-type: text/html
91
 
92
$Htmltree Search
93

$Htmltree Search

94
many_found
95
for ($i = 0; $i < $cnt; $i++) {
96
    print "
  • 97
        print ".html#$Sym[$i]\">$Sym[$i] $File[$i]:$Line[$i]\n";
    98
    }
    99
    print "\n";
    100
    exit(0);

    powered by: WebSVN 2.1.0

    © copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.