~ubuntu-branches/ubuntu/trusty/lxr-cvs/trusty

« back to all changes in this revision

Viewing changes to ident

  • Committer: Bazaar Package Importer
  • Author(s): Giacomo Catenazzi
  • Date: 2004-01-27 20:34:44 UTC
  • Revision ID: james.westby@ubuntu.com-20040127203444-kb8xobdp8j1z8owi
Tags: upstream-0.9.2
ImportĀ upstreamĀ versionĀ 0.9.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
# $Id: ident,v 1.15 2002/03/18 14:55:43 mbox Exp $
 
3
 
 
4
# ident --      Look up identifiers
 
5
#
 
6
#       Arne Georg Gleditsch <argggh@ifi.uio.no>
 
7
#       Per Kristian Gjermshus <pergj@ifi.uio.no>
 
8
#
 
9
#
 
10
# This program is free software; you can redistribute it and/or modify
 
11
# it under the terms of the GNU General Public License as published by
 
12
# the Free Software Foundation; either version 2 of the License, or
 
13
# (at your option) any later version.
 
14
#
 
15
# This program is distributed in the hope that it will be useful,
 
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
# GNU General Public License for more details.
 
19
 
20
# You should have received a copy of the GNU General Public License
 
21
# along with this program; if not, write to the Free Software
 
22
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
23
 
 
24
######################################################################
 
25
 
 
26
$CVSID = '$Id: ident,v 1.15 2002/03/18 14:55:43 mbox Exp $ ';
 
27
 
 
28
use strict;
 
29
use lib do { $0 =~ m{(.*)/} ? "$1/lib" : "lib" };
 
30
 
 
31
use LXR::Common qw(:html);
 
32
use Local;
 
33
 
 
34
 
 
35
sub varinputs {
 
36
    my $ret = '';
 
37
    foreach ($config->allvariables) {
 
38
        if ($config->variable($_) ne $config->vardefault($_)) {
 
39
            $ret .= "<input type=\"hidden\" name=\"$_\" value=\"" .
 
40
              $config->variable($_) . "\">\n";
 
41
        }
 
42
    }
 
43
    return $ret;
 
44
}
 
45
 
 
46
sub refexpand {
 
47
    my $templ = shift;
 
48
    my $ret = '';
 
49
 
 
50
    my @refs = $index->getindex($identifier, $release);
 
51
 
 
52
    my $def;
 
53
    foreach my $def (@refs) {
 
54
        my ($file, $line, $type, $rel) = @$def;
 
55
        $rel &&= "(member of ".idref($rel, "search-member", $rel).")";
 
56
        $ret .= expandtemplate($templ,
 
57
                               (file => sub { $file },
 
58
                                line => sub { $line },
 
59
                                type => sub { $type },
 
60
                                rel  => sub { $rel },
 
61
                                fileref  => sub {
 
62
                                    fileref("$file, line $line", 
 
63
                                            "search-decl",
 
64
                                            $file, $line);
 
65
                                }
 
66
                               ));
 
67
        
 
68
#       print("<span class=\"search-li1\"> $type_names{$type} in ".
 
69
#             fileref("$file, line $line", "search-decl",
 
70
#                     $file, $line).
 
71
#             " $rel</span>\n");
 
72
    }
 
73
    
 
74
    return $ret;
 
75
}
 
76
 
 
77
sub usesexpand {
 
78
    my $templ = shift;
 
79
    my $ret = '';
 
80
 
 
81
    my @uses = $index->getreference($identifier, $release);
 
82
    foreach my $ref (sort { $$a[0] cmp $$b[0] } @uses) {
 
83
        my ($file, $line) = @$ref;
 
84
        $ret .= expandtemplate($templ,
 
85
                               (
 
86
                                file => sub { $file },
 
87
                                line => sub { $line },
 
88
                                fileref => sub {
 
89
                                    fileref("$file, line $line", "search-ref",
 
90
                                            $file, $line);
 
91
                                }
 
92
                               ));
 
93
    }
 
94
    
 
95
    return $ret;
 
96
}
 
97
 
 
98
sub printident {
 
99
    my $dir = shift;
 
100
    my ($templ, $templ_refs);
 
101
    
 
102
    #$templ = "<ul>\n\$files{\n<li>\$iconlink \$namelink\n}</ul>\n";
 
103
    if ($config->htmlident) {
 
104
                unless (open(TEMPL, $config->htmlident)) {
 
105
                        warning("Template ".$config->htmlident." does not exist.");
 
106
                } else {
 
107
                        local($/) = undef;
 
108
                        $templ = <TEMPL>;
 
109
                        close(TEMPL);
 
110
                }
 
111
    } else {
 
112
                die "Ident template not configured";
 
113
        }
 
114
        
 
115
        
 
116
        if ($config->htmlident_refs) {
 
117
                unless (open(TEMPL, $config->htmlident_refs)) {
 
118
                        warning("Template ".$config->htmlident_refs." does not exist.");
 
119
                } else {
 
120
                        local($/) = undef;
 
121
                        $templ_refs = <TEMPL>;
 
122
                        close(TEMPL);
 
123
                }
 
124
    } else {
 
125
                die "Ident refs template not configured";
 
126
        }
 
127
        
 
128
    
 
129
    # print the description of the current directory
 
130
    #dirdesc($dir);
 
131
    
 
132
    # print the listing itself
 
133
    print(expandtemplate($templ,
 
134
                                                 (variables => \&varinputs,
 
135
                                                  identifier => sub { return $identifier },
 
136
                                                  refs => sub { refexpand(@_) },
 
137
                                                 )));
 
138
        print(expandtemplate($templ_refs,
 
139
                                                 (uses => sub { usesexpand(@_) },
 
140
                                                 )));
 
141
}
 
142
 
 
143
 
 
144
httpinit;
 
145
 
 
146
makeheader('ident');
 
147
printident;
 
148
makefooter('ident');
 
149
httpclean;
 
150