add directory study
This commit is contained in:
339
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/COPYING
Normal file
339
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/COPYING
Normal file
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
577
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/Common.pm
Normal file
577
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/Common.pm
Normal file
@@ -0,0 +1,577 @@
|
||||
# $Id: Common.pm,v 1.6 1998/05/14 11:59:22 argggh Exp $
|
||||
|
||||
package LXR::Common;
|
||||
|
||||
use DB_File;
|
||||
|
||||
require Exporter;
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(&warning &fatal &abortall &fflush &urlargs
|
||||
&fileref &idref &htmlquote &freetextmarkup &markupfile
|
||||
&init &makeheader &makefooter &expandtemplate);
|
||||
|
||||
|
||||
$wwwdebug = 1;
|
||||
|
||||
$SIG{__WARN__} = 'warning';
|
||||
$SIG{__DIE__} = 'fatal';
|
||||
|
||||
|
||||
@cterm = ('atom', '\\\\.', '',
|
||||
'comment', '/\*', '\*/',
|
||||
'comment', '//', "\n",
|
||||
'string', '"', '"',
|
||||
'string', "'", "'",
|
||||
'include', '#include', "\n");
|
||||
|
||||
|
||||
sub warning {
|
||||
print(STDERR "[",scalar(localtime),"] warning: $_[0]\n");
|
||||
print("<h4 align=\"center\"><i>** Warning: $_[0]</i></h4>\n") if $wwwdebug;
|
||||
}
|
||||
|
||||
|
||||
sub fatal {
|
||||
print(STDERR "[",scalar(localtime),"] fatal: $_[0]\n");
|
||||
print("<h4 align=\"center\"><i>** Fatal: $_[0]</i></h4>\n") if $wwwdebug;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
sub abortall {
|
||||
print(STDERR "[",scalar(localtime),"] abortall: $_[0]\n");
|
||||
print("Content-Type: text/html\n\n",
|
||||
"<html>\n<head>\n<title>Abort</title>\n</head>\n",
|
||||
"<body><h1>Abort!</h1>\n",
|
||||
"<b><i>** Aborting: $_[0]</i></b>\n",
|
||||
"</body>\n</html>\n") if $wwwdebug;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
sub fflush {
|
||||
$| = 1; print('');
|
||||
}
|
||||
|
||||
|
||||
sub urlargs {
|
||||
my @args = @_;
|
||||
my %args = ();
|
||||
my $val;
|
||||
|
||||
foreach (@args) {
|
||||
$args{$1} = $2 if /(\S+)=(\S*)/;
|
||||
}
|
||||
@args = ();
|
||||
|
||||
foreach ($Conf->allvariables) {
|
||||
$val = $args{$_} || $Conf->variable($_);
|
||||
push(@args, "$_=$val") unless ($val eq $Conf->vardefault($_));
|
||||
delete($args{$_});
|
||||
}
|
||||
|
||||
foreach (keys(%args)) {
|
||||
push(@args, "$_=$args{$_}");
|
||||
}
|
||||
|
||||
return($#args < 0 ? '' : '?'.join(';',@args));
|
||||
}
|
||||
|
||||
|
||||
sub fileref {
|
||||
my ($desc, $path, $line, @args) = @_;
|
||||
return("<a href=\"source$path".
|
||||
&urlargs(@args).
|
||||
($line > 0 ? "#L$line" : "").
|
||||
"\"\>$desc</a>");
|
||||
}
|
||||
|
||||
|
||||
sub diffref {
|
||||
my ($desc, $path, $darg) = @_;
|
||||
|
||||
($darg,$dval) = $darg =~ /(.*?)=(.*)/;
|
||||
return("<a href=\"diff$path".
|
||||
&urlargs(($darg ? "diffvar=$darg" : ""),
|
||||
($dval ? "diffval=$dval" : ""),
|
||||
@args).
|
||||
"\"\>$desc</a>");
|
||||
}
|
||||
|
||||
|
||||
sub idref {
|
||||
my ($desc, $id, @args) = @_;
|
||||
return("<a href=\"ident".
|
||||
&urlargs(($id ? "i=$id" : ""),
|
||||
@args).
|
||||
"\"\>$desc</a>");
|
||||
}
|
||||
|
||||
|
||||
sub http_wash {
|
||||
my $t = shift;
|
||||
$t =~ s/\+/ /g;
|
||||
$t =~ s/\%([\da-f][\da-f])/pack("C", hex($1))/gie;
|
||||
|
||||
# Paranoia check. Regexp-searches in Glimpse won't work.
|
||||
# if ($t =~ tr/;<>*|\`&$!#()[]{}:\'\"//) {
|
||||
|
||||
# Should be sufficient to keep "open" from doing unexpected stuff.
|
||||
if ($t =~ tr/<>|\"\'\`//) {
|
||||
&abortall("Illegal characters in HTTP-parameters.");
|
||||
}
|
||||
|
||||
return($t);
|
||||
}
|
||||
|
||||
|
||||
sub markspecials {
|
||||
$_[0] =~ s/([\&\<\>])/\0$1/g;
|
||||
}
|
||||
|
||||
|
||||
sub htmlquote {
|
||||
$_[0] =~ s/\0&/&/g;
|
||||
$_[0] =~ s/\0</</g;
|
||||
$_[0] =~ s/\0>/>/g;
|
||||
}
|
||||
|
||||
|
||||
sub freetextmarkup {
|
||||
$_[0] =~ s#((ftp|http)://\S*[^\s.])#<a href=\"$1\">$1</a>#g;
|
||||
$_[0] =~ s/(<(.*@.*)>)/<a href=\"mailto:$2\">$1<\/a>/g;
|
||||
}
|
||||
|
||||
|
||||
sub linetag {
|
||||
#$frag =~ s/\n/"\n".&linetag($virtp.$fname, $line)/ge;
|
||||
# my $tag = '<a href="'.$_[0].'#L'.$_[1].
|
||||
# '" name="L'.$_[1].'">'.$_[1].' </a>';
|
||||
my $tag;
|
||||
$tag .= ' ' if $_[1] < 10;
|
||||
$tag .= ' ' if $_[1] < 100;
|
||||
$tag .= &fileref($_[1], $_[0], $_[1]).' ';
|
||||
$tag =~ s/<a/<a name=L$_[1]/;
|
||||
# $_[1]++;
|
||||
return($tag);
|
||||
}
|
||||
|
||||
|
||||
sub markupfile {
|
||||
my ($INFILE, $virtp, $fname, $outfun) = @_;
|
||||
|
||||
$line = 1;
|
||||
|
||||
# A C/C++ file
|
||||
if ($fname =~ /\.([ch]|cpp?|cc)$/i) { # Duplicated in genxref.
|
||||
|
||||
&SimpleParse::init($INFILE, @cterm);
|
||||
|
||||
tie (%xref, "DB_File", $Conf->dbdir."/xref", O_RDONLY, 0664, $DB_HASH)
|
||||
|| &warning("Cannot open xref database.");
|
||||
|
||||
&$outfun(# "<pre>\n".
|
||||
#"<a name=\"L".$line++.'"></a>');
|
||||
&linetag($virtp.$fname, $line++));
|
||||
|
||||
($btype, $frag) = &SimpleParse::nextfrag;
|
||||
|
||||
while (defined($frag)) {
|
||||
&markspecials($frag);
|
||||
|
||||
if ($btype eq 'comment') {
|
||||
# Comment
|
||||
# Convert mail adresses to mailto:
|
||||
&freetextmarkup($frag);
|
||||
$frag = "<b><i>$frag</i></b>";
|
||||
$frag =~ s#\n#</i></b>\n<b><i>#g;
|
||||
} elsif ($btype eq 'string') {
|
||||
# String
|
||||
$frag = "<i>$frag</i>";
|
||||
|
||||
} elsif ($btype eq 'include') {
|
||||
# Include directive
|
||||
$frag =~ s#\"(.*)\"#
|
||||
'"'.&fileref($1, $virtp.$1).'"'#e;
|
||||
$frag =~ s#<(.*)>#
|
||||
"<".&fileref
|
||||
($1,
|
||||
$Conf->mappath($Conf->incprefix."/$1")).
|
||||
">"#e;
|
||||
} else {
|
||||
# Code
|
||||
$frag =~ s#(^|[^a-zA-Z_\#0-9])([a-zA-Z_~][a-zA-Z0-9_]*)\b#
|
||||
"$1".(defined($xref{$2}) ?
|
||||
&idref($2,$2) :
|
||||
"$2")#ge;
|
||||
}
|
||||
|
||||
&htmlquote($frag);
|
||||
$frag =~ s/\n/"\n".&linetag($virtp.$fname, $line++)/ge;
|
||||
&$outfun($frag);
|
||||
|
||||
($btype, $frag) = &SimpleParse::nextfrag;
|
||||
}
|
||||
|
||||
# &$outfun("</pre>\n");
|
||||
untie(%xref);
|
||||
|
||||
} elsif ($fname =~ /\.(gif|jpg)$/) {
|
||||
&$outfun("<img src=\"http:source".$virtp.$fname. &urlargs("raw=1").
|
||||
"\" border=0 alt=\"$fname\" align=middle>\n");
|
||||
|
||||
} elsif ($fname eq 'CREDITS') {
|
||||
while (<$INFILE>) {
|
||||
&SimpleParse::untabify($_);
|
||||
&markspecials($_);
|
||||
&htmlquote($_);
|
||||
s/^N:\s+(.*)/<hr>\n<h3>$1<\/h3>/gm;
|
||||
s/^(E:\s+)(\S+@\S+)/$1<a href=\"mailto:$2\">$2<\/a>/gm;
|
||||
s/^(W:\s+)(.*)/$1<a href=\"$2\">$2<\/a>/gm;
|
||||
# &$outfun("<a name=\"L$.\"><\/a>".$_);
|
||||
&$outfun(&linetag($virtp.$fname, $.).$_);
|
||||
}
|
||||
} else {
|
||||
while (<$INFILE>) {
|
||||
&SimpleParse::untabify($_);
|
||||
&markspecials($_);
|
||||
&htmlquote($_);
|
||||
&freetextmarkup($_);
|
||||
# &$outfun("<a name=\"L$.\"><\/a>".$_);
|
||||
&$outfun(&linetag($virtp.$fname, $.).$_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub fixpaths {
|
||||
$Path->{'virtf'} = '/'.shift;
|
||||
$Path->{'root'} = $Conf->sourceroot;
|
||||
|
||||
while ($Path->{'virtf'} =~ s#/[^/]+/\.\./#/#g) {
|
||||
}
|
||||
$Path->{'virtf'} =~ s#/\.\./#/#g;
|
||||
|
||||
$Path->{'virtf'} .= '/' if (-d $Path->{'root'}.$Path->{'virtf'});
|
||||
$Path->{'virtf'} =~ s#//+#/#g;
|
||||
|
||||
($Path->{'virt'}, $Path->{'file'}) = $Path->{'virtf'} =~ m#^(.*/)([^/]*)$#;
|
||||
|
||||
$Path->{'real'} = $Path->{'root'}.$Path->{'virt'};
|
||||
$Path->{'realf'} = $Path->{'root'}.$Path->{'virtf'};
|
||||
|
||||
@pathelem = $Path->{'virtf'} =~ /([^\/]+$|[^\/]+\/)/g;
|
||||
|
||||
$fpath = '';
|
||||
foreach (@pathelem) {
|
||||
$fpath .= $_;
|
||||
push(@addrelem, $fpath);
|
||||
}
|
||||
|
||||
unshift(@pathelem, $Conf->sourcerootname.'/');
|
||||
unshift(@addrelem, "");
|
||||
|
||||
foreach (0..$#pathelem) {
|
||||
if (defined($addrelem[$_])) {
|
||||
$Path->{'xref'} .= &fileref($pathelem[$_], "/$addrelem[$_]");
|
||||
} else {
|
||||
$Path->{'xref'} .= $pathelem[$_];
|
||||
}
|
||||
}
|
||||
$Path->{'xref'} =~ s#/</a>#</a>/#gi;
|
||||
}
|
||||
|
||||
|
||||
sub init {
|
||||
my @a;
|
||||
|
||||
$HTTP->{'path_info'} = &http_wash($ENV{'PATH_INFO'});
|
||||
$HTTP->{'this_url'} = &http_wash(join('', 'http://',
|
||||
$ENV{'SERVER_NAME'},
|
||||
':', $ENV{'SERVER_PORT'},
|
||||
$ENV{'SCRIPT_NAME'},
|
||||
$ENV{'PATH_INFO'},
|
||||
'?', $ENV{'QUERY_STRING'}));
|
||||
|
||||
foreach ($ENV{'QUERY_STRING'} =~ /([^;&=]+)(?:=([^;&]+)|)/g) {
|
||||
push(@a, &http_wash($_));
|
||||
}
|
||||
$HTTP->{'param'} = {@a};
|
||||
|
||||
$HTTP->{'param'}->{'v'} ||= $HTTP->{'param'}->{'version'};
|
||||
$HTTP->{'param'}->{'a'} ||= $HTTP->{'param'}->{'arch'};
|
||||
$HTTP->{'param'}->{'i'} ||= $HTTP->{'param'}->{'identifier'};
|
||||
|
||||
|
||||
$identifier = $HTTP->{'param'}->{'i'};
|
||||
$readraw = $HTTP->{'param'}->{'raw'};
|
||||
|
||||
if (defined($readraw)) {
|
||||
print("\n");
|
||||
} else {
|
||||
print("Content-Type: text/html\n\n");
|
||||
}
|
||||
|
||||
$Conf = new LXR::Config;
|
||||
|
||||
foreach ($Conf->allvariables) {
|
||||
$Conf->variable($_, $HTTP->{'param'}->{$_}) if $HTTP->{'param'}->{$_};
|
||||
}
|
||||
|
||||
&fixpaths($HTTP->{'path_info'} || $HTTP->{'param'}->{'file'});
|
||||
|
||||
if (defined($readraw)) {
|
||||
open(RAW, $Path->{'realf'});
|
||||
while (<RAW>) {
|
||||
print;
|
||||
}
|
||||
close(RAW);
|
||||
exit;
|
||||
}
|
||||
|
||||
return($Conf, $HTTP, $Path);
|
||||
}
|
||||
|
||||
|
||||
sub expandtemplate {
|
||||
my ($templ, %expfunc) = @_;
|
||||
my ($expfun, $exppar);
|
||||
|
||||
while ($templ =~ s/(\{[^\{\}]*)\{([^\{\}]*)\}/$1\01$2\02/s) {}
|
||||
|
||||
$templ =~ s/(\$(\w+)(\{([^\}]*)\}|))/{
|
||||
if (defined($expfun = $expfunc{$2})) {
|
||||
if ($3 eq '') {
|
||||
&$expfun;
|
||||
} else {
|
||||
$exppar = $4;
|
||||
$exppar =~ s#\01#\{#gs;
|
||||
$exppar =~ s#\02#\}#gs;
|
||||
&$expfun($exppar);
|
||||
}
|
||||
} else {
|
||||
$1;
|
||||
}
|
||||
}/ges;
|
||||
|
||||
$templ =~ s/\01/\{/gs;
|
||||
$templ =~ s/\02/\}/gs;
|
||||
return($templ);
|
||||
}
|
||||
|
||||
|
||||
# What follows is a pretty hairy way of expanding nested templates.
|
||||
# State information is passed via localized variables.
|
||||
|
||||
# The first one is simple, the "banner" template is empty, so we
|
||||
# simply return an appropriate value.
|
||||
sub bannerexpand {
|
||||
if ($who eq 'source' || $who eq 'diff') {
|
||||
return($Path->{'xref'});
|
||||
} else {
|
||||
return('');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub titleexpand {
|
||||
if ($who eq 'source' || $who eq 'diff') {
|
||||
return($Conf->sourcerootname.$Path->{'virtf'});
|
||||
|
||||
} elsif ($who eq 'ident') {
|
||||
my $i = $HTTP->{'param'}->{'i'};
|
||||
return($Conf->sourcerootname.' identfier search'.
|
||||
($i ? " \"$i\"" : ''));
|
||||
|
||||
} elsif ($who eq 'search') {
|
||||
my $s = $HTTP->{'param'}->{'string'};
|
||||
return($Conf->sourcerootname.' freetext search'.
|
||||
($s ? " \"$s\"" : ''));
|
||||
|
||||
} elsif ($who eq 'find') {
|
||||
my $s = $HTTP->{'param'}->{'string'};
|
||||
return($Conf->sourcerootname.' file search'.
|
||||
($s ? " \"$s\"" : ''));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub thisurl {
|
||||
my $url = $HTTP->{'this_url'};
|
||||
|
||||
$url =~ s/([\?\&\;\=])/sprintf('%%%02x',(unpack('c',$1)))/ge;
|
||||
return($url);
|
||||
}
|
||||
|
||||
|
||||
sub baseurl {
|
||||
return($Conf->baseurl);
|
||||
}
|
||||
|
||||
# This one isn't too bad either. We just expand the "modes" template
|
||||
# by filling in all the relevant values in the nested "modelink"
|
||||
# template.
|
||||
sub modeexpand {
|
||||
my $templ = shift;
|
||||
my $modex = '';
|
||||
my @mlist = ();
|
||||
local $mode;
|
||||
|
||||
if ($who eq 'source') {
|
||||
push(@mlist, "<b><i>source navigation</i></b>");
|
||||
} else {
|
||||
push(@mlist, &fileref("source navigation", $Path->{'virtf'}));
|
||||
}
|
||||
|
||||
if ($who eq 'diff') {
|
||||
push(@mlist, "<b><i>diff markup</i></b>");
|
||||
|
||||
} elsif ($who eq 'source' && $Path->{'file'}) {
|
||||
push(@mlist, &diffref("diff markup", $Path->{'virtf'}));
|
||||
}
|
||||
|
||||
if ($who eq 'ident') {
|
||||
push(@mlist, "<b><i>identifier search</i></b>");
|
||||
} else {
|
||||
push(@mlist, &idref("identifier search", ""));
|
||||
}
|
||||
|
||||
if ($who eq 'search') {
|
||||
push(@mlist, "<b><i>freetext search</i></b>");
|
||||
} else {
|
||||
push(@mlist, "<a href=\"search".
|
||||
&urlargs."\">freetext search</a>");
|
||||
}
|
||||
|
||||
if ($who eq 'find') {
|
||||
push(@mlist, "<b><i>file search</i></b>");
|
||||
} else {
|
||||
push(@mlist, "<a href=\"find".
|
||||
&urlargs."\">file search</a>");
|
||||
}
|
||||
|
||||
foreach $mode (@mlist) {
|
||||
$modex .= &expandtemplate($templ,
|
||||
('modelink', sub { return($mode) }));
|
||||
}
|
||||
|
||||
return($modex);
|
||||
}
|
||||
|
||||
# This is where it gets a bit tricky. varexpand expands the
|
||||
# "variables" template using varname and varlinks, the latter in turn
|
||||
# expands the nested "varlinks" template using varval.
|
||||
sub varlinks {
|
||||
my $templ = shift;
|
||||
my $vlex = '';
|
||||
my ($val, $oldval);
|
||||
local $vallink;
|
||||
|
||||
$oldval = $Conf->variable($var);
|
||||
foreach $val ($Conf->varrange($var)) {
|
||||
if ($val eq $oldval) {
|
||||
$vallink = "<b><i>$val</i></b>";
|
||||
} else {
|
||||
if ($who eq 'source') {
|
||||
$vallink = &fileref($val,
|
||||
$Conf->mappath($Path->{'virtf'},
|
||||
"$var=$val"),
|
||||
0,
|
||||
"$var=$val");
|
||||
|
||||
} elsif ($who eq 'diff') {
|
||||
$vallink = &diffref($val, $Path->{'virtf'}, "$var=$val");
|
||||
|
||||
} elsif ($who eq 'ident') {
|
||||
$vallink = &idref($val, $identifier, "$var=$val");
|
||||
|
||||
} elsif ($who eq 'search') {
|
||||
$vallink = "<a href=\"search".
|
||||
&urlargs("$var=$val",
|
||||
"string=".$HTTP->{'param'}->{'string'}).
|
||||
"\">$val</a>";
|
||||
|
||||
} elsif ($who eq 'find') {
|
||||
$vallink = "<a href=\"find".
|
||||
&urlargs("$var=$val",
|
||||
"string=".$HTTP->{'param'}->{'string'}).
|
||||
"\">$val</a>";
|
||||
}
|
||||
}
|
||||
$vlex .= &expandtemplate($templ,
|
||||
('varvalue', sub { return($vallink) }));
|
||||
|
||||
}
|
||||
return($vlex);
|
||||
}
|
||||
|
||||
|
||||
sub varexpand {
|
||||
my $templ = shift;
|
||||
my $varex = '';
|
||||
local $var;
|
||||
|
||||
foreach $var ($Conf->allvariables) {
|
||||
$varex .= &expandtemplate($templ,
|
||||
('varname', sub {
|
||||
return($Conf->vardescription($var))}),
|
||||
('varlinks', \&varlinks));
|
||||
}
|
||||
return($varex);
|
||||
}
|
||||
|
||||
|
||||
sub makeheader {
|
||||
local $who = shift;
|
||||
|
||||
if ($Conf->htmlhead && !open(TEMPL, $Conf->htmlhead)) {
|
||||
&warning("Template ".$Conf->htmlhead." does not exist.");
|
||||
$template ||= "<html><body>\n<hr>\n";
|
||||
} else {
|
||||
$save = $/; undef($/);
|
||||
$template = <TEMPL>;
|
||||
$/ = $save;
|
||||
close(TEMPL);
|
||||
}
|
||||
|
||||
print(
|
||||
#"<!doctype html public \"-//W3C//DTD HTML 3.2//EN\">\n",
|
||||
# "<html>\n",
|
||||
# "<head>\n",
|
||||
# "<title>",$Conf->sourcerootname," Cross Reference</title>\n",
|
||||
# "<base href=\"",$Conf->baseurl,"\">\n",
|
||||
# "</head>\n",
|
||||
|
||||
&expandtemplate($template,
|
||||
('title', \&titleexpand),
|
||||
('banner', \&bannerexpand),
|
||||
('baseurl', \&baseurl),
|
||||
('thisurl', \&thisurl),
|
||||
('modes', \&modeexpand),
|
||||
('variables', \&varexpand)));
|
||||
}
|
||||
|
||||
|
||||
sub makefooter {
|
||||
local $who = shift;
|
||||
|
||||
if ($Conf->htmltail && !open(TEMPL, $Conf->htmltail)) {
|
||||
&warning("Template ".$Conf->htmltail." does not exist.");
|
||||
$template = "<hr>\n</body>\n";
|
||||
} else {
|
||||
$save = $/; undef($/);
|
||||
$template = <TEMPL>;
|
||||
$/ = $save;
|
||||
close(TEMPL);
|
||||
}
|
||||
|
||||
print(&expandtemplate($template,
|
||||
('banner', \&bannerexpand),
|
||||
('thisurl', \&thisurl),
|
||||
('modes', \&modeexpand),
|
||||
('variables', \&varexpand)),
|
||||
"</html>\n");
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
246
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/Config.pm
Normal file
246
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/Config.pm
Normal file
@@ -0,0 +1,246 @@
|
||||
# $Id: Config.pm,v 1.3 1998/04/30 11:58:17 argggh Exp $
|
||||
|
||||
package LXR::Config;
|
||||
|
||||
use LXR::Common;
|
||||
|
||||
require Exporter;
|
||||
@ISA = qw(Exporter);
|
||||
# @EXPORT = '';
|
||||
|
||||
$confname = 'lxr.conf';
|
||||
|
||||
|
||||
sub new {
|
||||
my ($class, @parms) = @_;
|
||||
my $self = {};
|
||||
bless($self);
|
||||
$self->_initialize(@parms);
|
||||
return($self);
|
||||
}
|
||||
|
||||
|
||||
sub makevalueset {
|
||||
my $val = shift;
|
||||
my @valset;
|
||||
|
||||
if ($val =~ /^\s*\(([^\)]*)\)/) {
|
||||
@valset = split(/\s*,\s*/,$1);
|
||||
} elsif ($val =~ /^\s*\[\s*(\S*)\s*\]/) {
|
||||
if (open(VALUESET, "$1")) {
|
||||
$val = join('',<VALUESET>);
|
||||
close(VALUESET);
|
||||
@valset = split("\n",$val);
|
||||
} else {
|
||||
@valset = ();
|
||||
}
|
||||
} else {
|
||||
@valset = ();
|
||||
}
|
||||
return(@valset);
|
||||
}
|
||||
|
||||
|
||||
sub parseconf {
|
||||
my $line = shift;
|
||||
my @items = ();
|
||||
my $item;
|
||||
|
||||
foreach $item ($line =~ /\s*(\[.*?\]|\(.*?\)|\".*?\"|\S+)\s*(?:$|,)/g) {
|
||||
if ($item =~ /^\[\s*(.*?)\s*\]/) {
|
||||
if (open(LISTF, "$1")) {
|
||||
$item = '('.join(',',<LISTF>).')';
|
||||
close(LISTF);
|
||||
} else {
|
||||
$item = '';
|
||||
}
|
||||
}
|
||||
if ($item =~ s/^\((.*)\)/$1/s) {
|
||||
$item = join("\0",($item =~ /\s*(\S+)\s*(?:$|,)/gs));
|
||||
}
|
||||
$item =~ s/^\"(.*)\"/$1/;
|
||||
|
||||
push(@items, $item);
|
||||
}
|
||||
return(@items);
|
||||
}
|
||||
|
||||
|
||||
sub _initialize {
|
||||
my ($self, $conf) = @_;
|
||||
my ($dir, $arg);
|
||||
|
||||
unless ($conf) {
|
||||
($conf = $0) =~ s#/[^/]+$#/#;
|
||||
$conf .= $confname;
|
||||
}
|
||||
|
||||
unless (open(CONFIG, $conf)) {
|
||||
&fatal("Couldn't open configuration file \"$conf\".");
|
||||
}
|
||||
while (<CONFIG>) {
|
||||
s/\#.*//;
|
||||
next if /^\s*$/;
|
||||
|
||||
if (($dir, $arg) = /^\s*(\S+):\s*(.*)/) {
|
||||
if ($dir eq 'variable') {
|
||||
@args = &parseconf($arg);
|
||||
if (@args[0]) {
|
||||
$self->{vardescr}->{$args[0]} = $args[1];
|
||||
push(@{$self->{variables}},$args[0]);
|
||||
$self->{varrange}->{$args[0]} = [split(/\0/,$args[2])];
|
||||
$self->{vdefault}->{$args[0]} = $args[3];
|
||||
$self->{vdefault}->{$args[0]} ||=
|
||||
$self->{varrange}->{$args[0]}->[0];
|
||||
$self->{variable}->{$args[0]} =
|
||||
$self->{vdefault}->{$args[0]};
|
||||
}
|
||||
} elsif ($dir eq 'sourceroot' ||
|
||||
$dir eq 'srcrootname' ||
|
||||
$dir eq 'baseurl' ||
|
||||
$dir eq 'incprefix' ||
|
||||
$dir eq 'dbdir' ||
|
||||
$dir eq 'glimpsebin' ||
|
||||
$dir eq 'htmlhead' ||
|
||||
$dir eq 'htmltail' ||
|
||||
$dir eq 'htmldir') {
|
||||
if ($arg =~ /(\S+)/) {
|
||||
$self->{$dir} = $1;
|
||||
}
|
||||
} elsif ($dir eq 'map') {
|
||||
if ($arg =~ /(\S+)\s+(\S+)/) {
|
||||
push(@{$self->{maplist}}, [$1,$2]);
|
||||
}
|
||||
} else {
|
||||
&warning("Unknown config directive (\"$dir\")");
|
||||
}
|
||||
next;
|
||||
}
|
||||
&warning("Noise in config file (\"$_\")");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub allvariables {
|
||||
my $self = shift;
|
||||
return(@{$self->{variables}});
|
||||
}
|
||||
|
||||
|
||||
sub variable {
|
||||
my ($self, $var, $val) = @_;
|
||||
$self->{variable}->{$var} = $val if defined($val);
|
||||
return($self->{variable}->{$var});
|
||||
}
|
||||
|
||||
|
||||
sub vardefault {
|
||||
my ($self, $var) = @_;
|
||||
return($self->{vdefault}->{$var});
|
||||
}
|
||||
|
||||
|
||||
sub vardescription {
|
||||
my ($self, $var, $val) = @_;
|
||||
$self->{vardescr}->{$var} = $val if defined($val);
|
||||
return($self->{vardescr}->{$var});
|
||||
}
|
||||
|
||||
|
||||
sub varrange {
|
||||
my ($self, $var) = @_;
|
||||
return(@{$self->{varrange}->{$var}});
|
||||
}
|
||||
|
||||
|
||||
sub varexpand {
|
||||
my ($self, $exp) = @_;
|
||||
$exp =~ s{\$\{?(\w+)\}?}{
|
||||
$self->{variable}->{$1} =~ /^([a-zA-Z0-9\.\-]*)$/ ? $1 : ''
|
||||
}ge;
|
||||
return($exp);
|
||||
}
|
||||
|
||||
|
||||
sub baseurl {
|
||||
my $self = shift;
|
||||
return($self->varexpand($self->{'baseurl'}));
|
||||
}
|
||||
|
||||
|
||||
sub sourceroot {
|
||||
my $self = shift;
|
||||
return($self->varexpand($self->{'sourceroot'}));
|
||||
}
|
||||
|
||||
|
||||
sub sourcerootname {
|
||||
my $self = shift;
|
||||
return($self->varexpand($self->{'srcrootname'}));
|
||||
}
|
||||
|
||||
|
||||
sub incprefix {
|
||||
my $self = shift;
|
||||
return($self->varexpand($self->{'incprefix'}));
|
||||
}
|
||||
|
||||
|
||||
sub dbdir {
|
||||
my $self = shift;
|
||||
return($self->varexpand($self->{'dbdir'}));
|
||||
}
|
||||
|
||||
|
||||
sub glimpsebin {
|
||||
my $self = shift;
|
||||
return($self->varexpand($self->{'glimpsebin'}));
|
||||
}
|
||||
|
||||
|
||||
sub htmlhead {
|
||||
my $self = shift;
|
||||
return($self->varexpand($self->{'htmlhead'}));
|
||||
}
|
||||
|
||||
|
||||
sub htmltail {
|
||||
my $self = shift;
|
||||
return($self->varexpand($self->{'htmltail'}));
|
||||
}
|
||||
|
||||
|
||||
sub htmldir {
|
||||
my $self = shift;
|
||||
return($self->varexpand($self->{'htmldir'}));
|
||||
}
|
||||
|
||||
|
||||
sub mappath {
|
||||
my ($self, $path, @args) = @_;
|
||||
my (%oldvars) = %{$self->{variable}};
|
||||
my ($m);
|
||||
|
||||
foreach $m (@args) {
|
||||
$self->{variable}->{$1} = $2 if $m =~ /(.*?)=(.*)/;
|
||||
}
|
||||
|
||||
foreach $m (@{$self->{maplist}}) {
|
||||
$path =~ s/$m->[0]/$self->varexpand($m->[1])/e;
|
||||
}
|
||||
|
||||
$self->{variable} = {%oldvars};
|
||||
return($path);
|
||||
}
|
||||
|
||||
#sub mappath {
|
||||
# my ($self, $path) = @_;
|
||||
# my ($m);
|
||||
#
|
||||
# foreach $m (@{$self->{maplist}}) {
|
||||
# $path =~ s/$m->[0]/$self->varexpand($m->[1])/e;
|
||||
# }
|
||||
# return($path);
|
||||
#}
|
||||
|
||||
1;
|
||||
121
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/INSTALL
Normal file
121
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/INSTALL
Normal file
@@ -0,0 +1,121 @@
|
||||
In order to install LXR, you will need:
|
||||
|
||||
- Perl version 5 or later.
|
||||
- A webserver with cgi-script capabilities.
|
||||
|
||||
and optionally, to enable the freetext search queries:
|
||||
|
||||
- Glimpse
|
||||
|
||||
|
||||
If you don't have Perl installed, get it from
|
||||
<URL:http://www.perl.com/perl/info/software.html>.
|
||||
|
||||
If you need a webserver, take a look at Apache at
|
||||
<URL:http://www.apache.org/>
|
||||
|
||||
If you want Glimpse and the freetext searching facilites, visit
|
||||
<URL:http://glimpse.cs.arizona.edu/>.
|
||||
|
||||
|
||||
LXR has so far been tested on the GNU/Linux operating system using the
|
||||
Apache webserver. Other unix-like operating systems and decently
|
||||
featured webservers should do as well.
|
||||
|
||||
|
||||
To install LXR itself:
|
||||
|
||||
- Set the variables PERLBIN and INSTALLPREFIX in the makefile to
|
||||
reflect where the Perl 5 binary is located on your system and where
|
||||
you want the LXR files to be installed.
|
||||
|
||||
- Do "make install".
|
||||
|
||||
- Edit $(INSTALLPREFIX)/http/lxr.conf to fit your source code
|
||||
installations and needs.
|
||||
|
||||
- Make sure the files in $(INSTALLPREFIX)/http can be reached via
|
||||
your webserver. Make sure your webserver executes the files
|
||||
search, source, ident and diff as cgi-scripts. With the Apache
|
||||
webserver this can be accomplished by making
|
||||
$(INSTALLPREFIX)/http/.htaccess contain the following lines:
|
||||
|
||||
<Files ~ (search|source|ident|diff)$>
|
||||
SetHandler cgi-script
|
||||
</Files>
|
||||
|
||||
- Generate the identifier database. Go to the directory you
|
||||
configured as "dbdir" and do "$(INSTALLPREFIX)/bin/genxref foo",
|
||||
where foo is the subdirectory containing the actual source code.
|
||||
|
||||
- (Optional) Generate the Glimpse database. Go to the directory you
|
||||
configured as "dbdir" and do "glimpseindex -H . foo", where foo is
|
||||
the same as above. You might want to add other options to the
|
||||
commandline (e.g. "-n"), see the Glimpse documentation for details.
|
||||
|
||||
|
||||
If it doesn't work:
|
||||
|
||||
- Make sure all the permissions are right. Remember that the
|
||||
webserver needs to be able to access most of them.
|
||||
|
||||
- Check that all the Perl scripts find their library files, also when
|
||||
executed by the webserver.
|
||||
|
||||
The lxr.conf file:
|
||||
|
||||
LXR does not care much about your directory structure, all relevant
|
||||
paths can be configured from the lxr.conf file. This file is located
|
||||
in the same directory as the perl script files. This makes it
|
||||
possible to have different source trees in different directories on
|
||||
the web server.
|
||||
|
||||
LXR recognizes the following options in the configuration file.
|
||||
|
||||
htmlhead
|
||||
The header of all html files. This is a template that
|
||||
contains mainly html code but it can also contain some special
|
||||
directives, these are documented below.
|
||||
|
||||
htmltail
|
||||
Template for bottom of pages.
|
||||
|
||||
htmldir
|
||||
Template for the directory listing.
|
||||
|
||||
sourceroot
|
||||
The root of the source that you want to index.
|
||||
|
||||
sourcerootname
|
||||
The name of the root (more....)
|
||||
|
||||
incprefix
|
||||
Where to find source specific include files.
|
||||
|
||||
dbdir
|
||||
Where to find the database files that lxr needs (fileidx xref and
|
||||
the glimpse files).
|
||||
|
||||
glimpsebin
|
||||
Location of the glimpse binary on your system.
|
||||
|
||||
variable
|
||||
This defines a variable that can be used in templates and
|
||||
the config file. The syntax is
|
||||
variable: <name>, <text>, <values>, <default>
|
||||
<name> is the name of the variable, <text> is a textual description,
|
||||
<values> are the possible values of the variable.
|
||||
<default> is the default value of the variable.
|
||||
|
||||
The <values> field can either be a list starting with a "(" and
|
||||
ending with a ")", with elements separated with ",", or it can be
|
||||
[ <filename> ]. In this case the values are read from a file with
|
||||
one value on each line.
|
||||
|
||||
map - This makes it possible to rewrite directories using variables.
|
||||
The linux sourcecode for instance contains several different
|
||||
architectures, the include files for each of these are found in the
|
||||
directory /include/asm-<architecture>/. To remap each of these
|
||||
according to a variable $a you can specify
|
||||
map: /include/asm[^\/]*/ /include/asm-$a/
|
||||
Find creative uses for this option :-)
|
||||
33
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/Makefile
Normal file
33
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/Makefile
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
# Makefile for installation and configuration of LXR
|
||||
|
||||
# The location of your perl5 binary
|
||||
PERLBIN=/usr/bin/perl
|
||||
# LXR will be installed here
|
||||
INSTALLPREFIX=/tmp/lxr
|
||||
|
||||
# End of configuration parameters
|
||||
CGISCRIPTS=find ident search diff source
|
||||
PERLMODULES=SimpleParse.pm Common.pm Config.pm
|
||||
|
||||
config: $(CGISCRIPTS) $(PERLMODULES) genxref
|
||||
|
||||
$(CGISCRIPTS) genxref: %: %.in
|
||||
sed s%@perlbin@%$(PERLBIN)% < $< > $@
|
||||
|
||||
|
||||
install: config genxref
|
||||
install --directory $(INSTALLPREFIX)/http
|
||||
install --directory $(INSTALLPREFIX)/http/lib
|
||||
install --directory $(INSTALLPREFIX)/http/lib/LXR
|
||||
install --directory $(INSTALLPREFIX)/bin
|
||||
install --directory $(INSTALLPREFIX)/source
|
||||
install --mode 755 $(CGISCRIPTS) $(INSTALLPREFIX)/http/
|
||||
install --mode 750 genxref $(INSTALLPREFIX)/bin/
|
||||
install --mode 755 Common.pm Config.pm $(INSTALLPREFIX)/http/lib/LXR
|
||||
install --mode 755 SimpleParse.pm $(INSTALLPREFIX)/http/lib/
|
||||
install --mode 644 http/* $(INSTALLPREFIX)/http/
|
||||
|
||||
clean:
|
||||
rm -f $(CGISCRIPTS) genxref
|
||||
|
||||
12
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/README
Normal file
12
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/README
Normal file
@@ -0,0 +1,12 @@
|
||||
This is version 0.2 of the LXR cross-referencing engine. This is primarily
|
||||
a security update to version 0.1.
|
||||
|
||||
The LXR engine is free software. See the file COPYING for copying
|
||||
permission.
|
||||
|
||||
See the file INSTALL for installation instructions.
|
||||
|
||||
To visit the original LXR site, point your browser towards
|
||||
<URL:http://lxr.linux.no/>.
|
||||
|
||||
To contact the authors, send mail to <lxr@linux.no>.
|
||||
107
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/SimpleParse.pm
Normal file
107
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/SimpleParse.pm
Normal file
@@ -0,0 +1,107 @@
|
||||
# $Id: SimpleParse.pm,v 1.2 1998/04/30 11:58:17 argggh Exp $
|
||||
|
||||
use strict;
|
||||
|
||||
package SimpleParse;
|
||||
|
||||
require Exporter;
|
||||
|
||||
use vars qw(@ISA @EXPORT);
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(&doparse &untabify &init &nextfrag);
|
||||
|
||||
my $INFILE; # Input file handle
|
||||
my @frags; # Fragments in queue
|
||||
my @bodyid; # Array of body type ids
|
||||
my @open; # Fragment opening delimiters
|
||||
my @term; # Fragment closing delimiters
|
||||
my $split; # Fragmentation regexp
|
||||
my $open; # Fragment opening regexp
|
||||
my $tabwidth; # Tab width
|
||||
|
||||
sub init {
|
||||
my @blksep;
|
||||
|
||||
($INFILE, @blksep) = @_;
|
||||
|
||||
while (@_ = splice(@blksep,0,3)) {
|
||||
push(@bodyid, $_[0]);
|
||||
push(@open, $_[1]);
|
||||
push(@term, $_[2]);
|
||||
}
|
||||
|
||||
foreach (@open) {
|
||||
$open .= "($_)|";
|
||||
$split .= "$_|";
|
||||
}
|
||||
chop($open);
|
||||
|
||||
foreach (@term) {
|
||||
next if $_ eq '';
|
||||
$split .= "$_|";
|
||||
}
|
||||
chop($split);
|
||||
|
||||
$tabwidth = 8;
|
||||
}
|
||||
|
||||
|
||||
sub untabify {
|
||||
my $t = $_[1] || 8;
|
||||
|
||||
$_[0] =~ s/([^\t]*)\t/$1.(' ' x ($t - (length($1) % $t)))/ge;
|
||||
return($_[0]);
|
||||
}
|
||||
|
||||
|
||||
sub nextfrag {
|
||||
my $btype = undef;
|
||||
my $frag = undef;
|
||||
|
||||
while (1) {
|
||||
if ($#frags < 0) {
|
||||
my $line = <$INFILE>;
|
||||
|
||||
if ($. == 1 &&
|
||||
$line =~ /^.*-[*]-.*?[ \t;]tab-width:[ \t]*([0-9]+).*-[*]-/) {
|
||||
$tabwidth = $1;
|
||||
}
|
||||
|
||||
&untabify($line, $tabwidth);
|
||||
# $line =~ s/([^\t]*)\t/
|
||||
# $1.(' ' x ($tabwidth - (length($1) % $tabwidth)))/ge;
|
||||
|
||||
@frags = split(/($split)/o, $line);
|
||||
}
|
||||
|
||||
last if $#frags < 0;
|
||||
|
||||
unless ($frags[0]) {
|
||||
shift(@frags);
|
||||
|
||||
} elsif (defined($frag)) {
|
||||
if (defined($btype)) {
|
||||
my $next = shift(@frags);
|
||||
|
||||
$frag .= $next;
|
||||
last if $next =~ /^$term[$btype]$/;
|
||||
|
||||
} else {
|
||||
last if $frags[0] =~ /^$open$/o;
|
||||
$frag .= shift(@frags);
|
||||
}
|
||||
} else {
|
||||
$frag = shift(@frags);
|
||||
if (defined($frag) && (@_ = $frag =~ /^$open$/o)) {
|
||||
my $i = 1;
|
||||
$btype = grep { $i = ($i && !defined($_)) } @_;
|
||||
}
|
||||
}
|
||||
}
|
||||
$btype = $bodyid[$btype] if $btype;
|
||||
|
||||
return($btype, $frag);
|
||||
}
|
||||
|
||||
1;
|
||||
206
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/diff.in
Normal file
206
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/diff.in
Normal file
@@ -0,0 +1,206 @@
|
||||
#!@perlbin@
|
||||
# $Id: diff,v 1.2 1998/04/30 11:58:15 argggh Exp $
|
||||
|
||||
# diff -- Display diff output with markup.
|
||||
#
|
||||
# Arne Georg Gleditsch <argggh@ifi.uio.no>
|
||||
# Per Kristian Gjermshus <pergj@ifi.uio.no>
|
||||
#
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
######################################################################
|
||||
|
||||
use lib 'lib/';
|
||||
use SimpleParse;
|
||||
use LXR::Common;
|
||||
use LXR::Config;
|
||||
use DB_File;
|
||||
|
||||
|
||||
sub htmlsub {
|
||||
my ($s, $l) = @_;
|
||||
my @s = split(/(<[^>]*>|&[\#\w\d]+;?)/, $s);
|
||||
$s = '';
|
||||
|
||||
while (@s) {
|
||||
my $f = substr(shift(@s), 0, $l);
|
||||
$l -= length($f);
|
||||
$s .= $f;
|
||||
$f = shift(@s);
|
||||
if ($f =~ /^&/) {
|
||||
if ($l > 0) {
|
||||
$s .= $f;
|
||||
$l--;
|
||||
}
|
||||
} else {
|
||||
$s .= $f;
|
||||
}
|
||||
}
|
||||
$s .= ' ' x $l;
|
||||
return $s;
|
||||
}
|
||||
|
||||
|
||||
sub printdiff {
|
||||
|
||||
unless ($diffvar) {
|
||||
foreach ($Conf->allvariables) {
|
||||
push(@vars, $Conf->vardescription($_));
|
||||
}
|
||||
|
||||
$vars[$#vars-1] .= " or ".pop(@vars) if $#vars > 0;
|
||||
|
||||
print("<p align=center>\n",
|
||||
"Please indicate the version of the file you wish to\n",
|
||||
"compare to by clicking on the appropriate\n",
|
||||
join(", ",@vars)," button.\n",
|
||||
"</p>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
unless ($Path->{'file'}) {
|
||||
print("<h3 align=center>Diff not yet supported for directories.</h3>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
$origvirt = $Path->{'virt'}.$Path->{'file'};
|
||||
$origreal = $Path->{'real'}.$Path->{'file'};
|
||||
|
||||
$origval = $Conf->variable($diffvar);
|
||||
$Conf->variable($diffvar,$diffval);
|
||||
$diffvirt = $Conf->mappath($Path->{'virt'}).$Path->{'file'};
|
||||
$diffreal = $Conf->sourceroot.$diffvirt;
|
||||
$Conf->variable($diffvar,$origval);
|
||||
|
||||
# print("<h3>Diff of $origvirt -> $diffvirt</h3>\n");
|
||||
# print("<h3>($origreal -> $diffreal)</h3>\n");
|
||||
|
||||
# FIXME: Check existence of $origreal & $diffreal.
|
||||
|
||||
&fflush;
|
||||
unless (open(DIFF, "-|")){
|
||||
open(STDERR, ">&STDOUT");
|
||||
exec('diff', '-U0', $origreal, $diffreal);
|
||||
print "*** Diff subprocess died unexpextedly: $!\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
while (<DIFF>) {
|
||||
if (($os, $ol, $ns, $nl) =
|
||||
/@@ -(\d+)(?:,(\d+)|) \+(\d+)(?:,(\d+)|) @@/) {
|
||||
$os++ if $ol eq '0';
|
||||
$ns++ if $nl eq '0';
|
||||
$ol = 1 unless defined($ol);
|
||||
$nl = 1 unless defined($nl);
|
||||
|
||||
$bo = $os + $ofs;
|
||||
if ($ol < $nl) {
|
||||
$ofs += $nl - $ol;
|
||||
|
||||
$dir = '>>';
|
||||
$ms = $nl - $ol;
|
||||
$ml = $ol;
|
||||
$orig{$os+$ol} = $ms;
|
||||
} else {
|
||||
$dir = '<<';
|
||||
$ms = $ol - $nl;
|
||||
$ml = $nl;
|
||||
$new{$ns+$nl} = $ms;
|
||||
}
|
||||
foreach (0..$ml - 1) {
|
||||
$chg{$bo + $_} = '!!';
|
||||
}
|
||||
foreach (0..$ms - 1) {
|
||||
$chg{$bo + $ml + $_} = $dir;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
close(<DIFF>);
|
||||
|
||||
|
||||
print("<h1>Diff markup</h1>\n",
|
||||
"<h3>Differences between ",
|
||||
|
||||
&fileref("$origvirt <i>(".$Conf->vardescription($diffvar).
|
||||
" $origval)</i>", $origvirt, undef, "$diffvar=$origval"),
|
||||
" and ",
|
||||
|
||||
&fileref("$diffvirt <i>(".$Conf->vardescription($diffvar).
|
||||
" $diffval)</i>",$diffvirt, undef, "$diffvar=$diffval"),
|
||||
"</h3><hr>\n");
|
||||
|
||||
# "<table width=\"100%\" border=0 cellpadding=0><tr><td>",
|
||||
#
|
||||
# &fileref("<b>$origvirt <i>(".$Conf->vardescription($diffvar).
|
||||
# " $origval)</i></b>", $origvirt, undef, "$diffvar=$origval"),
|
||||
# "<hr></td>\n<td></td>\n<td>",
|
||||
#
|
||||
# &fileref("<b>$diffvirt <i>(".$Conf->vardescription($diffvar).
|
||||
# " $diffval)</i></b>",$diffvirt, undef, "$diffvar=$diffval"),
|
||||
# "<hr></td>\n</tr></table>\n");
|
||||
|
||||
|
||||
open(FOO, $origreal);
|
||||
$orig = '';
|
||||
&markupfile(\*FOO, $Path->{'virt'}, $Path->{'file'},
|
||||
sub { $orig .= shift });
|
||||
$len = $.+$ofs;
|
||||
close(FOO);
|
||||
|
||||
$Conf->variable($diffvar, $diffval);
|
||||
|
||||
open(FOO, $diffreal);
|
||||
$new = '';
|
||||
&markupfile(\*FOO, $Conf->mappath($Path->{'virt'}), $Path->{'file'},
|
||||
sub { $new .= shift });
|
||||
close(FOO);
|
||||
|
||||
$Conf->variable($diffvar, $origval);
|
||||
|
||||
$i = 1; $orig =~ s/^/"\n" x ($orig{$i++})/mge;
|
||||
$i = 1; $new =~ s/^/"\n" x ($new{$i++})/mge;
|
||||
|
||||
@orig = split(/\n/, $orig);
|
||||
@new = split(/\n/, $new);
|
||||
|
||||
print("<pre>");
|
||||
foreach $i (0..$len) {
|
||||
$o = &htmlsub($orig[$i], 50);
|
||||
# $n = &htmlsub($new[$i], 999);
|
||||
$n = $new[$i];
|
||||
|
||||
# print("<tr><td><code>$o</code></td>".
|
||||
# "<td><font color=red> ", $chg{$i+1}, " </font></td>".
|
||||
# "<td><code>$n</code></td></tr>\n");
|
||||
print("$o <font color=red>", ($chg{$i+1} || " "), "</font> $n\n");
|
||||
}
|
||||
print("</pre>");
|
||||
|
||||
# print("</td></tr></table>");
|
||||
}
|
||||
|
||||
|
||||
($Conf, $HTTP, $Path) = &init;
|
||||
$diffvar = $HTTP->{'param'}->{'diffvar'};
|
||||
$diffval = $HTTP->{'param'}->{'diffval'};
|
||||
|
||||
&makeheader('diff');
|
||||
&printdiff;
|
||||
&makefooter('diff');
|
||||
|
||||
|
||||
71
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/find.in
Normal file
71
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/find.in
Normal file
@@ -0,0 +1,71 @@
|
||||
#!@perlbin@
|
||||
# $Id: find,v 1.3 1998/04/30 11:58:16 argggh Exp $
|
||||
|
||||
# find -- Find files
|
||||
#
|
||||
# Arne Georg Gleditsch <argggh@ifi.uio.no>
|
||||
# Per Kristian Gjermshus <pergj@ifi.uio.no>
|
||||
#
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
######################################################################
|
||||
|
||||
use lib 'lib/';
|
||||
use LXR::Common;
|
||||
use LXR::Config;
|
||||
|
||||
sub find {
|
||||
print("<p align=center>\n",
|
||||
"Search for files using regular expressions\n",
|
||||
"<form method=get action=\"find\">\n");
|
||||
|
||||
foreach ($Conf->allvariables) {
|
||||
if ($Conf->variable($_) ne $Conf->vardefault($_)) {
|
||||
print("<input type=hidden name=\"",$_, "\" ",
|
||||
"value=\"", $Conf->variable($_), "\">\n");
|
||||
}
|
||||
}
|
||||
|
||||
print("Find file: <input type=text name=\"string\" ",
|
||||
"value=\"",$searchtext,"\" size =60>\n",
|
||||
"<input type=submit value=\"search\">\n",
|
||||
"</form>\n");
|
||||
|
||||
|
||||
if ($searchtext ne "") {
|
||||
unless (open(FILELLISTING,$Conf->dbdir."/.glimpse_filenames")) {
|
||||
&warning("Could not open .glimpse_filenames.");
|
||||
return;
|
||||
}
|
||||
print("<hr>\n");
|
||||
$sourceroot = $Conf->sourceroot;
|
||||
while($file = <FILELLISTING>) {
|
||||
$file =~ s/^$sourceroot//;
|
||||
if($file =~ /$searchtext/) {
|
||||
print(&fileref("$file", "/$file"),"<br>\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
($Conf, $HTTP, $Path) = &init;
|
||||
$searchtext = $HTTP->{'param'}->{'string'};
|
||||
|
||||
&makeheader('find');
|
||||
&find;
|
||||
&makefooter('find');
|
||||
|
||||
338
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/genxref.in
Normal file
338
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/genxref.in
Normal file
@@ -0,0 +1,338 @@
|
||||
#!@perlbin@
|
||||
# $Id: genxref,v 1.5 1998/04/22 12:16:12 pergj Exp $
|
||||
|
||||
# genxref.pl -- Finds identifiers in a set of C files using an
|
||||
# extremely fuzzy algorithm. It sort of works.
|
||||
#
|
||||
# Arne Georg Gleditsch <argggh@ifi.uio.no>
|
||||
# Per Kristian Gjermshus <pergj@ifi.uio.no>
|
||||
#
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
# TODO: ns/cmd/xfe/src/MozillaApp.h, XFE_MozillaApp
|
||||
|
||||
######################################################################
|
||||
|
||||
use lib 'lib/';
|
||||
use integer;
|
||||
use DB_File;
|
||||
|
||||
|
||||
%itype = (('macro', 'M'),
|
||||
('typedef', 'T'),
|
||||
('struct', 'S'),
|
||||
('enum', 'E'),
|
||||
('union', 'U'),
|
||||
('function', 'F'),
|
||||
('funcprot', 'f'),
|
||||
('class', 'C'), # (C++)
|
||||
('classforw', 'c'), # (C++)
|
||||
('var', 'V'));
|
||||
# ('reference', 'R')
|
||||
|
||||
@reserved = ('auto', 'break', 'case', 'char', 'const', 'continue',
|
||||
'default', 'do', 'double', 'else', 'enum', 'extern',
|
||||
'float', 'for', 'goto', 'if', 'int', 'long', 'register',
|
||||
'return', 'short', 'signed', 'sizeof', 'static',
|
||||
'struct', 'switch', 'typedef', 'union', 'unsigned',
|
||||
'void', 'volatile', 'while', 'fortran', 'asm',
|
||||
'inline', 'operator',
|
||||
'class', # (C++)
|
||||
# Her b<>r vi ha flere av disse:
|
||||
'__asm__','__inline__');
|
||||
|
||||
|
||||
$ident = '\~?_*[a-zA-Z][a-zA-Z0-9_]*';
|
||||
|
||||
|
||||
$realpath = $ARGV[0];
|
||||
$realpath ||= '.';
|
||||
$realpath .= '/';
|
||||
|
||||
|
||||
sub wash {
|
||||
my $towash = $_[0];
|
||||
$towash =~ s/[^\n]+//gs;
|
||||
return($towash);
|
||||
}
|
||||
|
||||
sub stripodd {
|
||||
my $tostrip = $_[0];
|
||||
while ($tostrip =~ s/\{([^\{\}]*)\}/
|
||||
"\05".&wash($1)/ges) {}
|
||||
$tostrip =~ s/\05/\{\}/gs;
|
||||
$tostrip =~ s/[\{\}]//gs;
|
||||
return($tostrip);
|
||||
}
|
||||
|
||||
sub classes {
|
||||
my @c = (shift =~ /($ident)\s*(?:$|,)/gm);
|
||||
if (@c) {
|
||||
return(join(":", @c)."::");
|
||||
} else {
|
||||
return('');
|
||||
}
|
||||
}
|
||||
|
||||
sub findident {
|
||||
print(STDERR "Starting pass 1: Collect identifier definitions.\n");
|
||||
|
||||
$start = time;
|
||||
$fnum = 0; $defs = 0;
|
||||
|
||||
foreach $f (@f) {
|
||||
$f =~ s/^$realpath//o;
|
||||
$fileidx{++$fnum} = $f;
|
||||
|
||||
open(SRCFILE, $realpath.$f);
|
||||
$_ = $/; undef($/); $contents = <SRCFILE>; $/ = $_;
|
||||
close(SRCFILE);
|
||||
|
||||
print(STDERR
|
||||
"(Pass 1) $f (",length($contents),
|
||||
"), file $fnum of ",$#f+1,"...\n");
|
||||
|
||||
# Remove comments.
|
||||
$contents =~ s/\/\*(.*?)\*\//&wash($1)/ges;
|
||||
$contents =~ s/\/\/[^\n]*//g; # C++
|
||||
|
||||
# Unwrap continunation lines.
|
||||
$contents =~ s/\\\s*\n/$1\05/gs;
|
||||
while ($contents =~ s/\05([^\n\05]+)\05/$1\05\05/gs) {}
|
||||
$contents =~ s/(\05+)([^\n]*)/"$2"."\n" x length($1)/gse;
|
||||
|
||||
# Find macro (un)definitions.
|
||||
$l = 0;
|
||||
foreach ($contents =~ /^(.*)/gm) {
|
||||
$l++;
|
||||
if (/^[ \t]*\#\s*(define|undef)\s+($ident)/o) {
|
||||
$xref{$2} .= "$itype{'macro'}$fnum:$l\t";
|
||||
$defs++;
|
||||
}
|
||||
}
|
||||
|
||||
# We want to do some funky heuristics with preprocessor blocks
|
||||
# later, so mark them. (FIXME: #elif)
|
||||
$contents =~ s/^[ \t]*\#\s*if.*/\01/gm;
|
||||
$contents =~ s/^[ \t]*\#\s*else.*/\02/gm;
|
||||
$contents =~ s/^[ \t]*\#\s*endif.*/\03/gm;
|
||||
|
||||
# Strip all preprocessor directives.
|
||||
$contents =~ s/^[ \t]*\#(.*)//gm;
|
||||
|
||||
# Now, remove all odd block markers ({,}) we find inside
|
||||
# #else..#endif blocks. (And pray they matched one in the
|
||||
# preceding #if..#else block.)
|
||||
while ($contents =~ s/\02([^\01\02\03]*\03)/&stripodd($1)/ges ||
|
||||
$contents =~ s/\01([^\01\02\03]*)\03/$1/gs) {}
|
||||
|
||||
while ($contents =~ /([\01\02\03\04\05])/gs) {
|
||||
print(STDERR "\t ** stray ".($1 eq "\01"
|
||||
? "#if"
|
||||
: ($1 eq "\02"
|
||||
? "#else"
|
||||
: ($1 eq "\03"
|
||||
? "#endif"
|
||||
: "control sequence"
|
||||
)
|
||||
)
|
||||
)." found.\n");
|
||||
}
|
||||
$contents =~ s/[\01\02\03\04\05]//gs;
|
||||
|
||||
# Remove all but outermost blocks. (No local variables.)
|
||||
while ($contents =~ s/\{([^\{\}]*)\}/
|
||||
"\05".&wash($1)/ges) {}
|
||||
$contents =~ s/\05/\{\}/gs;
|
||||
|
||||
# Remove nested parentheses.
|
||||
while ($contents =~ s/\(([^\)]*)\(/\($1\05/g ||
|
||||
$contents =~ s/\05([^\(\)]*)\)/ $1 /g) {}
|
||||
|
||||
# Some heuristics here: Try to recognize "code" and delete
|
||||
# everything up to the next block delimiter.
|
||||
# $contents =~ s/([\;\}\{])(\s*$ident\s*\([^\)]*\)[^\{\}]*)/
|
||||
# "$1".&wash($2)/goes;
|
||||
# $contents =~ s/([\;\{])(\s*\**$ident\s*\=[^\{\}]*)/
|
||||
# "$1".&wash($2)/goes;
|
||||
|
||||
# Parentheses containing commas are probably not interesting.
|
||||
$contents =~ s/\(([^\)]*\,[^\)]*)\)/
|
||||
"()".&wash($1)/ges;
|
||||
|
||||
|
||||
# This operator-stuff messes things up. (C++)
|
||||
$contents =~ s/operator[\<\>\=\!\+\-\*\%\/]{1,2}/operator/g;
|
||||
|
||||
# Ranges are uninteresting (and confusing).
|
||||
$contents =~ s/\[.*?\]//gs;
|
||||
|
||||
# And so are assignments.
|
||||
$contents =~ s/\=(.*?);/";".&wash($1)/ges;
|
||||
|
||||
# From here on, \01 and \02 are used to encapsulate found
|
||||
# identifiers,
|
||||
|
||||
# Find struct, enum and union definitions.
|
||||
$contents =~ s/((struct|enum|union)\s+($ident|)\s*({}|(;)))/
|
||||
"$2 ".($3 ? "\01".$itype{$2}.$3."\02 " : "").$5.&wash($1)/goes;
|
||||
|
||||
# Find class definitions. (C++)
|
||||
$contents =~ s/((class)\s+($ident)\s*(:[^;\{]*|)({}|(;)))/
|
||||
"$2 "."\01".$itype{$2.($6 ? 'forw' : '')}.
|
||||
&classes($4).$3."\02 ".$6.&wash($1)/goes;
|
||||
|
||||
@contents = split(/[;\}]/, $contents);
|
||||
$contents = '';
|
||||
|
||||
foreach (@contents) {
|
||||
s/^(\s*)(struct|enum|union|inline)/$1/;
|
||||
|
||||
if (/$ident[^a-zA-Z0-9_]+$ident/) { # It takes two, baby.
|
||||
|
||||
$t = /^\s*typedef/s; # Is this a type definition?
|
||||
|
||||
s/($ident(?:\s*::\s*$ident|)) # ($1) Match the identifier
|
||||
([\s\)]* # ($2) Tokens allowed after identifier
|
||||
(\([^\)]*\) # ($3) Function parameters?
|
||||
(?:\s*:[^\{]*|) # inheritage specification (C++)
|
||||
|) # No function parameters
|
||||
\s*($|,|\{))/ # ($4) Allowed termination chars.
|
||||
"\01". # identifier marker
|
||||
($t # if type definition...
|
||||
? $itype{'typedef'} # ..mark as such
|
||||
: ($3 # $3 is empty unless function definition.
|
||||
? ($4 eq '{' # Terminating token indicates
|
||||
? $itype{'function'} # function or
|
||||
: $itype{'funcprot'}) # function prototype.
|
||||
: $itype{'var'}) # Variable.
|
||||
)."$1\02 ".&wash($2)/goesx;
|
||||
}
|
||||
|
||||
$contents .= $_;
|
||||
}
|
||||
|
||||
$l = 0;
|
||||
foreach ($contents =~ /^(.*)/gm) {
|
||||
$l++;
|
||||
while (/\01(.)(?:(.+?)\s*::\s*|)($ident)\02/go) {
|
||||
$xref{$3} .= "$1$fnum:$l".($2 ? ":$2" : "")."\t";
|
||||
$defs++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# S<> juksar me litt.
|
||||
foreach (@reserved) {
|
||||
delete($xref{$_});
|
||||
}
|
||||
|
||||
print(STDERR
|
||||
"Completed pass 1 (",(time-$start),"s):",
|
||||
" $defs definitions found.\n\n");
|
||||
}
|
||||
|
||||
|
||||
sub findusage {
|
||||
print(STDERR "Starting pass 2: Generate reference statistics.\n");
|
||||
|
||||
$start = time;
|
||||
$fnum = 0; $refs = 0;
|
||||
|
||||
foreach $f (@f) {
|
||||
$f =~ s/^$realpath//o;
|
||||
$fnum++;
|
||||
$lcount = 0;
|
||||
%tref = ();
|
||||
|
||||
open(SRCFILE, $realpath.$f);
|
||||
$_ = $/; undef($/); $contents = <SRCFILE>; $/ = $_;
|
||||
close(SRCFILE);
|
||||
|
||||
print(STDERR
|
||||
"(Pass 2) $f (",length($contents),
|
||||
"), file $fnum of ",$#f+1,"...\n");
|
||||
|
||||
# Remove comments
|
||||
$contents =~ s/\/\*(.*?)\*\//&wash($1)/ges;
|
||||
$contents =~ s/\/\/[^\n]*//g;
|
||||
|
||||
# Remove include statements
|
||||
$contents =~ s/^[ \t]*\#include[ \t]+[^\n]*//gm;
|
||||
|
||||
# FIXME: "var"
|
||||
|
||||
@lines = split(/\n/, $contents);
|
||||
|
||||
foreach $line (@lines) {
|
||||
$lcount++;
|
||||
foreach ($line =~ /(?:^|[^a-zA-Z_\#])($ident)\b/og) {
|
||||
$tref{$_} .= "$lcount," if $xref{$_};
|
||||
}
|
||||
}
|
||||
|
||||
while (($a, $b) = each(%tref)) {
|
||||
chop($b);
|
||||
$xref{$a} .= "R$fnum:$b\t";
|
||||
$refs++;
|
||||
}
|
||||
}
|
||||
print(STDERR
|
||||
"Completed pass 2 (",(time-$start),"s):",
|
||||
"$refs references to known identifiers found.\n\n");
|
||||
}
|
||||
|
||||
|
||||
sub dumpdb {
|
||||
print(STDERR "Starting pass 3: Dump database to disk.\n");
|
||||
|
||||
$start = time;
|
||||
tie (%xrefdb, "DB_File" , "xref", O_RDWR|O_CREAT, 0664, $DB_HASH)
|
||||
|| die("Could not open \"xref\" for writing");
|
||||
|
||||
$i = 0;
|
||||
while (($k, $v) = each(%xref)) {
|
||||
$i++;
|
||||
delete($xref{$k});
|
||||
$xrefdb{$k} = $v;
|
||||
unless ($i % 100) {
|
||||
print(STDERR "(Pass 3) identifier $i of maximum $defs...\n");
|
||||
}
|
||||
}
|
||||
|
||||
untie(%xrefdb);
|
||||
print(STDERR
|
||||
"Completed pass 3 (",(time-$start),"s):",
|
||||
"Information on $i identifiers dumped to disk.\n\n");
|
||||
}
|
||||
|
||||
|
||||
tie (%fileidx, "DB_File", "fileidx", O_RDWR|O_CREAT, 0660, $DB_HASH)
|
||||
|| die("Could not open \"fileidx\" for writing");
|
||||
|
||||
open(FILES, "find $realpath -print |");
|
||||
while (<FILES>) {
|
||||
chop;
|
||||
push(@f, $_) if /\.([ch]|cpp?|cc)$/i; # Duplicated in lib/LXR/Common.pm
|
||||
}
|
||||
close(FILES);
|
||||
|
||||
&findident;
|
||||
&findusage;
|
||||
&dumpdb;
|
||||
|
||||
dbmclose(%fileidx);
|
||||
|
||||
108
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/http/blurb.html
Normal file
108
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/http/blurb.html
Normal file
@@ -0,0 +1,108 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Linux Cross-Reference</TITLE>
|
||||
</HEAD>
|
||||
<BODY BGCOLOR=WHITE>
|
||||
<H1 ALIGN=CENTER>
|
||||
Cross-Referencing Linux<BR>
|
||||
<A HREF="http:source/">
|
||||
<I>Browse the code</I></A></H1>
|
||||
|
||||
<HR><H2>Motivation</H2>
|
||||
The Linux Cross-Reference project is the testbed application of a
|
||||
general hypertext cross-referencing tool. (Or the other way around.)
|
||||
|
||||
<P>
|
||||
The main goal of the project is to create a versatile
|
||||
cross-referencing tool for relatively large code repositories. The
|
||||
project is based on stock web technology, so the codeview client may
|
||||
be chosen from the full range of available web browsers. On the
|
||||
server side, any Unix-based web server with cgi-script capability
|
||||
should do nicely.
|
||||
|
||||
<P>
|
||||
The main feature of the indexer is of course the ability to jump
|
||||
easily to the declaration of any global identifier. Indeed, even all
|
||||
<I>references</I> to global identifiers are indexed. Quick access to
|
||||
function declarations, data (type) definitions and preprocessor macros
|
||||
makes code browsing just that tad more convenient. At-a-glance
|
||||
overview of e.g. which code areas that will be affected by changing a
|
||||
function or type definition should also come in useful during
|
||||
development and debugging.
|
||||
|
||||
<P>
|
||||
Other bits of hypertextual sugar, such as e-mail and include file
|
||||
links, are provided as well, but is on the whole, well, sugar. Some
|
||||
minimal visual markup is also done. (Style sheets are considered as a
|
||||
way to do this in the future.)
|
||||
|
||||
|
||||
<HR><H2>Technicalities</H2>
|
||||
The index generator is written in <A HREF="http://www.perl.org">Perl</A>
|
||||
and relies heavily on Perl's regular expression facilities. The
|
||||
algorithm used is very brute force and extremely sloppy. The
|
||||
rationale behind the sloppiness is that too little information renders
|
||||
the database useless, while too much information simply means the
|
||||
users have to think and navigate at the same time.
|
||||
|
||||
<P>
|
||||
The Linux source code, with which the project has initially been
|
||||
linked, presents the indexer with some very tough obstacles.
|
||||
Specifically, the heavy use of preprocessor macros makes the parsing a
|
||||
virtual nightmare. We want to index the information in the
|
||||
preprocessor directives as well as the actual C code, so we have to
|
||||
parse both at once, which leads to no end of trouble. (Strict parsing
|
||||
is right out.) Still, we're pretty satisfied with what the indexer
|
||||
manages to get out of it.
|
||||
|
||||
<P>
|
||||
There's also the question of actually broken code. We want to
|
||||
reasonably index all code portions, even if some of it is not entirely
|
||||
syntactically valid. This is another reason for the sloppiness.
|
||||
|
||||
<P>
|
||||
There are obviously disadvantages to this approach. No scope checking
|
||||
is done, and the most annoying effect of this is mistaking local
|
||||
identifers for references to global ones with the same name. This
|
||||
particular problem (and others) can only be solved by doing (almost)
|
||||
full parsing. The feasibility of combining this with the fuzzy way
|
||||
indexing is currently done is being looked into.
|
||||
|
||||
<P>
|
||||
An identifier is a macro, typedef, struct, enum, union, function,
|
||||
function prototype or variable. For the Linux source code between
|
||||
50000 and 60000 identifiers are collected. The individual files of the
|
||||
sourcecode are formatted on the fly and presented with clickable
|
||||
identifiers.
|
||||
|
||||
<P>
|
||||
It is possible to search among the identifiers and the entire
|
||||
kernel source text. The freetext search is implemented using <A
|
||||
HREF="http://glimpse.cs.arizona.edu">Glimpse</A>, so all the
|
||||
capabilities of Glimpse are available. Especially the regular expression
|
||||
search capabilities are useful.
|
||||
|
||||
<HR><H2>Availability</H2>
|
||||
The code for the indexer is released under the
|
||||
<A HREF="http://www.gnu.org">GNU</A>
|
||||
<A HREF="http://www.gnu.org/copyleft/copyleft.html">Copyleft</A>
|
||||
license. Go to <A HREF="http://lxr.linux.no">LXR main site</A> to
|
||||
get the latest version.
|
||||
|
||||
|
||||
<HR><H2>Contacting the authors</H2>
|
||||
We would very much like to receive feedback on this project. If you
|
||||
find it useful or have suggestions on how to make improvements, feel
|
||||
free to send us e-mail. We hope that this will be a useful tool, both
|
||||
for experienced developers and beginners wanting to explore the Linux
|
||||
sourcecode.
|
||||
|
||||
<HR>
|
||||
|
||||
<ADDRESS>
|
||||
<A HREF="mailto:lxr@linux.no">
|
||||
Arne Georg Gleditsch and Per Kristian Gjermshus</A>
|
||||
</ADDRESS>
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,37 @@
|
||||
# Configuration file.
|
||||
|
||||
# Define typed variable "v", read valueset from file.
|
||||
variable: v, Version, [/local/lxr/source/versions], [/local/lxr/source/defversion]
|
||||
|
||||
# Define typed variable "a". First value is default.
|
||||
variable: a, Architecture, (i386, alpha, m68k, mips, ppc, sparc, sparc64)
|
||||
|
||||
# Define the base url for the LXR files.
|
||||
baseurl: http://lxr/
|
||||
|
||||
# These are the templates for the HTML heading, directory listing and
|
||||
# footer, respectively.
|
||||
htmlhead: /local/lxr/http/template-head
|
||||
htmltail: /local/lxr/http/template-tail
|
||||
htmldir: /local/lxr/http/template-dir
|
||||
|
||||
# The source is here.
|
||||
sourceroot: /local/lxr/source/$v/linux/
|
||||
srcrootname: Linux
|
||||
|
||||
# "#include <foo.h>" is mapped to this directory (in the LXR source
|
||||
# tree)
|
||||
incprefix: /include
|
||||
|
||||
# The database files go here.
|
||||
dbdir: /local/lxr/source/$v/
|
||||
|
||||
# Glimpse can be found here.
|
||||
glimpsebin: /local/bin/glimpse
|
||||
|
||||
# The power of regexps. This is pretty Linux-specific, but quite
|
||||
# useful. Tinker with it and see what it does. (How's that for
|
||||
# documentation?)
|
||||
map: /include/asm[^\/]*/ /include/asm-$a/
|
||||
map: /arch/[^\/]+/ /arch/$a/
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Linux Cross-Reference</TITLE>
|
||||
</HEAD>
|
||||
<BODY BGCOLOR=WHITE>
|
||||
<H1 ALIGN=CENTER>
|
||||
Help doing searches<BR>
|
||||
<A HREF="http:/source/">
|
||||
<I>Browse the code</I></A></H1>
|
||||
|
||||
|
||||
<I> This text is directly stolen from the Glimpse manual page. I have
|
||||
tried to remove things that do not apply to the lxr searcher, but
|
||||
beware, some things might have slipped through. I'll try to put
|
||||
together something better when I get the time. For more information on
|
||||
glimpse go to the <A HREF="http://glimpse.cs.arizona.edu">Glimpse
|
||||
homepage</A>.</I>
|
||||
|
||||
<A NAME="Patterns"></A><H2>Patterns</H2>
|
||||
<P>
|
||||
glimpse supports a large variety of patterns, including simple
|
||||
strings, strings with classes of characters, sets of strings,
|
||||
wild cards, and regular expressions (see <A HREF="#Limitations">Limitations</A>).
|
||||
|
||||
<P> <H3>Strings</H3>
|
||||
|
||||
Strings are any sequence of characters, including the special symbols
|
||||
`^' for beginning of line and `$' for end of line. The following
|
||||
special characters (`$', `^', `*', `[', `^', `|', `(', `)', `!', and
|
||||
`\' ) as well as the following meta characters special to glimpse (and
|
||||
agrep): `;', `,', `#', `>', `<', `-', and `.', should be preceded by
|
||||
`\\' if they are to be matched as regular characters. For example,
|
||||
\\^abc\\\\ corresponds to the string ^abc\\, whereas ^abc corresponds
|
||||
to the string abc at the beginning of a line.
|
||||
|
||||
<P> <H3>Classes of characters</H3>
|
||||
a list of characters inside [] (in order) corresponds to any character
|
||||
from the list. For example, [a-ho-z] is any character between a and h
|
||||
or between o and z. The symbol `^' inside [] complements the list.
|
||||
For example, [^i-n] denote any character in the character set except
|
||||
character 'i' to 'n'.
|
||||
The symbol `^' thus has two meanings, but this is consistent with
|
||||
egrep.
|
||||
The symbol `.' (don't care) stands for any symbol (except for the
|
||||
newline symbol).
|
||||
|
||||
<P> <H3>Boolean operations</H3>
|
||||
Glimpse
|
||||
supports an `AND' operation denoted by the symbol `;'
|
||||
an `OR' operation denoted by the symbol `,',
|
||||
a limited version of a 'NOT' operation (starting at version 4.0B1)
|
||||
denoted by the symbol `~',
|
||||
or any combination.
|
||||
For example, pizza;cheeseburger' will output all lines containing
|
||||
both patterns.
|
||||
'{political,computer};science' will match 'political science'
|
||||
or 'science of computers'.
|
||||
|
||||
|
||||
<P><H3>Wild cards</H3>
|
||||
The symbol '#' is used to denote a sequence
|
||||
of any number (including 0)
|
||||
of arbitrary characters (see <A HREF="#Limitations">Limitations</A>).
|
||||
The symbol # is equivalent to .* in egrep.
|
||||
In fact, .* will work too, because it is a valid regular expression
|
||||
(see below), but unless this is part of an actual regular expression,
|
||||
# will work faster.
|
||||
(Currently glimpse is experiencing some problems with #.)
|
||||
|
||||
|
||||
<P><H3>Combination of exact and approximate matching</H3>
|
||||
Any pattern inside angle brackets <> must match the text exactly even
|
||||
if the match is with errors. For example, <mathemat>ics matches
|
||||
mathematical with one error (replacing the last s with an a), but
|
||||
mathe<matics> does not match mathematical no matter how many errors are
|
||||
allowed. (This option is buggy at the moment.)
|
||||
|
||||
|
||||
<H3>Regular expressions</H3>
|
||||
Since the index is word based, a regular expression must match words
|
||||
that appear in the index for glimpse to find it. Glimpse first strips
|
||||
the regular expression from all non-alphabetic characters, and
|
||||
searches the index for all remaining words. It then applies the
|
||||
regular expression matching algorithm to the files found in the index.
|
||||
For example, glimpse 'abc.*xyz' will search the index for all files
|
||||
that contain both 'abc' and 'xyz', and then search directly for
|
||||
'abc.*xyz' in those files. (If you use glimpse -w 'abc.*xyz', then
|
||||
'abcxyz' will not be found, because glimpse will think that abc and
|
||||
xyz need to be matches to whole words.) The syntax of regular
|
||||
expressions in glimpse is in general the same as that for agrep. The
|
||||
union operation `|', Kleene closure `*', and parentheses () are all
|
||||
supported. Currently '+' is not supported. Regular expressions are
|
||||
currently limited to approximately 30 characters (generally excluding
|
||||
meta characters). The maximal number of errors
|
||||
for regular expressions that use '*' or '|' is 4.
|
||||
|
||||
<P>
|
||||
<A NAME="Limitations"></A><H2>Limitations</H2>
|
||||
The index of glimpse is word based. A pattern that contains more than
|
||||
one word cannot be found in the index. The way glimpse overcomes this
|
||||
weakness is by splitting any multi-word pattern into its set of words
|
||||
and looking for all of them in the index.
|
||||
For example, <I>'linear programming'</I> will first consult the index
|
||||
to find all files containing both <I>linear</I> and <I>programming</I>,
|
||||
and then apply agrep to find the combined pattern.
|
||||
This is usually an effective solution, but it can be slow for
|
||||
cases where both words are very common, but their combination is not.
|
||||
|
||||
<P>
|
||||
As was mentioned in the section on <A HREF="#Patterns">Patterns</A> above, some characters
|
||||
serve as meta characters for glimpse and need to be
|
||||
preceded by '\\' to search for them. The most common
|
||||
examples are the characters '.' (which stands for a wild card),
|
||||
and '*' (the Kleene closure).
|
||||
So, "glimpse ab.de" will match abcde, but "glimpse ab\\.de"
|
||||
will not, and "glimpse ab*de" will not match ab*de, but
|
||||
"glimpse ab\\*de" will.
|
||||
The meta character - is translated automatically to a hypen
|
||||
unless it appears between [] (in which case it denotes a range of
|
||||
characters).
|
||||
|
||||
<P>
|
||||
There is no size limit for simple patterns and simple patterns
|
||||
within Boolean expressions.
|
||||
More complicated patterns, such as regular expressions,
|
||||
are currently limited to approximately 30 characters.
|
||||
Lines are limited to 1024 characters.
|
||||
|
||||
<P>
|
||||
<HR>
|
||||
|
||||
<ADDRESS>
|
||||
<A HREF="mailto:lxr@linux.no">
|
||||
Arne Georg Gleditsch and Per Kristian Gjermshus</A>
|
||||
</ADDRESS>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,15 @@
|
||||
<table border=0 cellspacing=4>
|
||||
<tr valign=middle>
|
||||
<td>
|
||||
<td nowrap><b>Name</b>
|
||||
<td nowrap><b>Size</b>
|
||||
<td nowrap><b>Last modified (GMT)</b>
|
||||
<td nowrap><b>Description</b>
|
||||
$files{
|
||||
<tr valign=middle>
|
||||
<td nowrap>$iconlink
|
||||
<td nowrap>$namelink
|
||||
<td nowrap align=right>$filesize{$bytes bytes}
|
||||
<td nowrap>$modtime
|
||||
<td>$description{<i>$desctext</i>}}
|
||||
</table>
|
||||
@@ -0,0 +1,27 @@
|
||||
<!doctype html public "-//W3C//DTD HTML 3.2//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>$title</title>
|
||||
<base href="$baseurl">
|
||||
</head>
|
||||
|
||||
<body bgcolor=white>
|
||||
<div align=center>
|
||||
$modes{ ~ <b>[</b> $modelink <b>]</b>} ~
|
||||
</div>
|
||||
|
||||
<h1 align=center>
|
||||
<a href="http://www.linux.org/">
|
||||
Linux</a>
|
||||
<a href="http:blurb.html">
|
||||
Cross Reference</a><br>
|
||||
$banner
|
||||
</h1>
|
||||
|
||||
<div align=center>
|
||||
$variables{
|
||||
<b>$varname:</b>
|
||||
$varlinks{ ~ <b>[</b> $varvalue <b>]</b>} ~
|
||||
<br>}
|
||||
</div>
|
||||
<hr>
|
||||
@@ -0,0 +1,11 @@
|
||||
<hr>
|
||||
<div align=center>
|
||||
$modes{ ~ <b>[</b> $modelink <b>]</b>} ~
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
This page was automatically generated by the
|
||||
<a href="http:blurb.html">LXR engine</a>.
|
||||
<br>
|
||||
Visit the <a href="http://lxr.linux.no/">LXR main site</a> for more
|
||||
information.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 230 B |
161
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/ident.in
Normal file
161
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/ident.in
Normal file
@@ -0,0 +1,161 @@
|
||||
#!@perlbin@
|
||||
# $Id: ident,v 1.6 1998/04/30 11:58:16 argggh Exp $
|
||||
|
||||
# ident -- Look up identifiers
|
||||
#
|
||||
# Arne Georg Gleditsch <argggh@ifi.uio.no>
|
||||
# Per Kristian Gjermshus <pergj@ifi.uio.no>
|
||||
#
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
######################################################################
|
||||
|
||||
use lib 'lib/';
|
||||
use LXR::Common;
|
||||
use LXR::Config;
|
||||
use DB_File;
|
||||
|
||||
%ty = (('M', 'preprocessor macro'),
|
||||
('V', 'variable'),
|
||||
('f', 'function prototype'),
|
||||
('F', 'function'),
|
||||
('C', 'class'), # C++
|
||||
('c', '(forwarded) class'), # C++
|
||||
('T', 'type'),
|
||||
('S', 'struct type'),
|
||||
('E', 'enum type'),
|
||||
('U', 'union type'));
|
||||
|
||||
|
||||
sub ident {
|
||||
print("<form method=get action=\"ident\">\n");
|
||||
|
||||
foreach ($Conf->allvariables) {
|
||||
if ($Conf->variable($_) ne $Conf->vardefault($_)) {
|
||||
print("<input type=hidden name=\"",$_, "\" ",
|
||||
"value=\"", $Conf->variable($_), "\">\n");
|
||||
}
|
||||
}
|
||||
|
||||
print("Identifier: <input type=text name=\"i\" ",
|
||||
"value=\"",$identifier,"\" size=60>\n",
|
||||
"<input type=submit value=\"Go get it\">\n",
|
||||
"</form>\n");
|
||||
|
||||
|
||||
if ($identifier) {
|
||||
tie(%xref, "DB_File", $Conf->dbdir."/xref",
|
||||
O_RDONLY, undef, $DB_HASH) ||
|
||||
&fatal("Could not open \"".$Conf->dbdir."/xref\"");
|
||||
|
||||
@refs = split(/\t/,$xref{$identifier});
|
||||
|
||||
print("<h1>$identifier</h1>\n");
|
||||
|
||||
if (@refs) {
|
||||
tie(%fileidx, "DB_File", $Conf->dbdir."/fileidx",
|
||||
O_RDONLY, undef, $DB_HASH) ||
|
||||
&fatal("Could not open \"".$Conf->dbdir."/fileidx\"");
|
||||
|
||||
foreach (@refs) {
|
||||
$f{$1} .= "$2\t" if /^(.)(.*)/;
|
||||
}
|
||||
|
||||
foreach $t (keys(%ty)) {
|
||||
if ($f{$t}) {
|
||||
print("Defined as a $ty{$t} in:<ul>\n");
|
||||
|
||||
@_ = split(/\t/, $f{$t});
|
||||
unshift(@_);
|
||||
foreach (@_) {
|
||||
($fnum, $line, @clss) = split(/:/, $_);
|
||||
|
||||
print("<li>",
|
||||
&fileref("$fileidx{$fnum}, line $line",
|
||||
"/$fileidx{$fnum}", $line));
|
||||
|
||||
if (@clss) {
|
||||
if ($t eq 'F' || $t eq 'f') {
|
||||
print(", as member of ");
|
||||
if ($xref{$clss[0]}) {
|
||||
print(&idref("class $clss[0]", $clss[0]));
|
||||
} else {
|
||||
print("class $clss[0]");
|
||||
}
|
||||
} elsif ($t eq 'C') {
|
||||
print(", inheriting <ul>\n");
|
||||
foreach (@clss) {
|
||||
print("<li>");
|
||||
if ($xref{$_}) {
|
||||
print(&idref("class $_", $clss[0]));
|
||||
} else {
|
||||
print("class $_");
|
||||
}
|
||||
}
|
||||
print("</ul>");
|
||||
}
|
||||
}
|
||||
print("\n");
|
||||
}
|
||||
print("</ul>\n");
|
||||
}
|
||||
}
|
||||
|
||||
print("Referenced (in ",int(grep(/^R/, @refs))," files total) in:\n",
|
||||
"<ul>\n");
|
||||
$concise = $#refs > 100;
|
||||
foreach (@refs) {
|
||||
if (/^R(.+):([\d,]+)/) {
|
||||
$fnam = $fileidx{$1};
|
||||
@fpos = split(/,/, $2);
|
||||
if ($#fpos > 0) {
|
||||
if ($concise) {
|
||||
print("<li>", &fileref("$fnam", "/$fnam"),
|
||||
", ",$#fpos+1," times\n");
|
||||
} else {
|
||||
print("<li>$fnam:\n<ul>\n");
|
||||
foreach (@fpos) {
|
||||
print("<li>", &fileref("line $_",
|
||||
"/$fnam", $_),
|
||||
"\n");
|
||||
}
|
||||
print("</ul>\n");
|
||||
}
|
||||
} else {
|
||||
print("<li>", &fileref("$fnam, line $fpos[0]",
|
||||
"/$fnam", $fpos[0]),
|
||||
"\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
print("</ul>\n");
|
||||
untie(%fileidx);
|
||||
|
||||
} else {
|
||||
print("<br><b>Not used</b>");
|
||||
}
|
||||
|
||||
untie(%xref);
|
||||
}
|
||||
}
|
||||
|
||||
($Conf, $HTTP, $Path) = &init;
|
||||
$identifier = $HTTP->{'param'}->{'i'};
|
||||
|
||||
&makeheader('ident');
|
||||
&ident;
|
||||
&makefooter('ident');
|
||||
|
||||
127
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/search.in
Normal file
127
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/search.in
Normal file
@@ -0,0 +1,127 @@
|
||||
#!@perlbin@
|
||||
# $Id: search,v 1.3 1998/04/30 11:58:16 argggh Exp $
|
||||
|
||||
# search -- Freetext search
|
||||
#
|
||||
# Arne Georg Gleditsch <argggh@ifi.uio.no>
|
||||
# Per Kristian Gjermshus <pergj@ifi.uio.no>
|
||||
#
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
######################################################################
|
||||
|
||||
use lib 'lib/';
|
||||
use LXR::Common;
|
||||
use LXR::Config;
|
||||
|
||||
$maxhits = 1000;
|
||||
|
||||
sub search {
|
||||
print("<p align=center>\n",
|
||||
"This searchpage is powered by ",
|
||||
"<a href=\"http://glimpse.cs.arizona.edu\">Glimpse</a>\n");
|
||||
|
||||
print("<form method=get action=\"search\">\n");
|
||||
|
||||
foreach ($Conf->allvariables) {
|
||||
if ($Conf->variable($_) ne $Conf->vardefault($_)) {
|
||||
print("<input type=hidden name=\"",$_, "\" ",
|
||||
"value=\"", $Conf->variable($_), "\">\n");
|
||||
}
|
||||
}
|
||||
|
||||
print("Search for: <input type=text name=\"string\" ",
|
||||
"value=\"",$searchtext,"\" size=60>\n",
|
||||
"<input type=submit value=\"search\">\n",
|
||||
# $Query->checkbox("case",0,0,"Case sensitive search"),
|
||||
# $Query->checkbox("regexp",1,0,"Regular expression search"),
|
||||
# $Query->popup_menu("fuzz",[0,1,2,3,4,5,6,7],0),
|
||||
"</form>\n",
|
||||
|
||||
"<a href=\"search_help.html\">Hints</a> ",
|
||||
"making queries.\n");
|
||||
|
||||
$| = 1; print('');
|
||||
|
||||
if ($searchtext ne "") {
|
||||
print("<hr>\n");
|
||||
unless (open(GLIMPSE, "-|")) {
|
||||
open(STDERR, ">&STDOUT");
|
||||
$!='';
|
||||
exec($Conf->glimpsebin,"-H".$Conf->dbdir,'-y','-n',$searchtext);
|
||||
print("Glimpse subprocess died unexpextedly: $!\n");
|
||||
exit;
|
||||
}
|
||||
|
||||
$numlines = 0;
|
||||
while (<GLIMPSE>) {
|
||||
$numlines++;
|
||||
push(@glimpselines,$_);
|
||||
if ($numlines > $maxhits) {
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
close(GLIMPSE);
|
||||
|
||||
$retval = $? >> 8;
|
||||
|
||||
# The manpage for glimpse says that it returns 2 on syntax errors or
|
||||
# inaccessible files. It seems this is not the case.
|
||||
# We will have to work around it for the time being.
|
||||
|
||||
if ($retval == 0) {
|
||||
if (@glimpselines == 0) {
|
||||
print("No matching files<br>\n");
|
||||
} else {
|
||||
if ($numlines > $maxhits) {
|
||||
print("<b> Too many hits, displaying first $maxhits</b><br>\n");
|
||||
}
|
||||
print("<h1>$searchtext</h1>\n");
|
||||
$sourceroot = $Conf->sourceroot;
|
||||
foreach $glimpseline (@glimpselines) {
|
||||
|
||||
$glimpseline =~ s/$sourceroot//;
|
||||
($file, $line, $text) =
|
||||
$glimpseline =~ /(.*?):\s*(\d+)\s*:(.*)/;
|
||||
$text =~ s/&/&/g;
|
||||
$text =~ s/</</g;
|
||||
$text =~ s/>/>/g;
|
||||
|
||||
print(&fileref("$file, line $line", "/$file", $line),
|
||||
" -- $text<br>\n");
|
||||
}
|
||||
}
|
||||
} elsif ($retval == 1) {
|
||||
$glimpsebin = $Conf->glimpsebin;
|
||||
$glimpseresponse = join("<br>",@glimpselines);
|
||||
$glimpseresponse =~ s/$glimpsebin/Reason/;
|
||||
$glimpseresponse =~ s/glimpse: error in searching index//;
|
||||
print("<b>Search failed</b><br>\n$glimpseresponse");
|
||||
} else {
|
||||
print("Unexpected returnvalue $retval from Glimpse\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
($Conf, $HTTP, $Path) = &init;
|
||||
$searchtext = $HTTP->{'param'}->{'string'};
|
||||
|
||||
&makeheader('search');
|
||||
&search;
|
||||
&makefooter('search');
|
||||
|
||||
|
||||
235
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/source.in
Normal file
235
study/tools/SourceBrowser/lxr/lxr-0.3.1/lxr-0.3/source.in
Normal file
@@ -0,0 +1,235 @@
|
||||
#!@perlbin@
|
||||
# $Id: source,v 1.4 1998/05/14 11:59:22 argggh Exp $
|
||||
|
||||
# source -- Present sourcecode as html, complete with references
|
||||
#
|
||||
# Arne Georg Gleditsch <argggh@ifi.uio.no>
|
||||
# Per Kristian Gjermshus <pergj@ifi.uio.no>
|
||||
#
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
######################################################################
|
||||
|
||||
use lib 'lib/';
|
||||
use SimpleParse;
|
||||
use LXR::Common;
|
||||
use LXR::Config;
|
||||
|
||||
|
||||
sub descexpand {
|
||||
my $templ = shift;
|
||||
|
||||
if ($index{$filename}) {
|
||||
return(&expandtemplate($templ,
|
||||
('desctext', sub {return($index{$filename})})
|
||||
));
|
||||
} else {
|
||||
return('');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub diricon {
|
||||
if ($filename eq '..') {
|
||||
return(&fileref("<img src=\"/icons/back.gif\"".
|
||||
" border=0 alt=\"Back\">",
|
||||
$parentdir));
|
||||
} else {
|
||||
return(&fileref("<img src=\"/icons/folder.gif\"".
|
||||
" border=0 alt=\"Folder\">",
|
||||
$Path->{'virt'}.$filename));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub dirname {
|
||||
if ($filename eq '..') {
|
||||
return(&fileref("Parent directory", $parentdir));
|
||||
} else {
|
||||
return(&fileref($filename, $Path->{'virt'}.$filename));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub fileicon {
|
||||
if ($filename =~ /^.*\.[ch]$/) {
|
||||
return(&fileref("<img src=\"/icons/c.gif\"".
|
||||
" border=0 alt=\"C file\">",
|
||||
$Path->{'virt'}.$filename));
|
||||
} elsif ($filename =~ /^.*\.(cpp|cc)$/) {
|
||||
# TODO: Find a nice icon for c++ files (KDE?)
|
||||
return(&fileref("<img src=\"/icons/c.gif\"".
|
||||
" border=0 alt=\"C++ file\">",
|
||||
$Path->{'virt'}.$filename));
|
||||
} else {
|
||||
return(&fileref("<img src=\"/icons/text.gif\"".
|
||||
" border=0 alt=\"File\">",
|
||||
$Path->{'virt'}.$filename));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub filename {
|
||||
return(&fileref($filename,
|
||||
$Path->{'virt'}.$filename));
|
||||
}
|
||||
|
||||
|
||||
sub filesize {
|
||||
my $templ = shift;
|
||||
my $s = (-s $Path->{'real'}.$filename);
|
||||
|
||||
return(&expandtemplate($templ,
|
||||
('bytes', sub {return($s)}),
|
||||
('kbytes', sub {return($s/1024)}),
|
||||
('mbytes', sub {return($s/1048576)})
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
sub modtime {
|
||||
my @t = gmtime((stat($Path->{'real'}.$filename))[9]);
|
||||
$t[5] += 1900;
|
||||
$t[4]++;
|
||||
return(sprintf("%04d-%02d-%02d %02d:%02d:%02d", reverse(splice(@t, 0, 6))));
|
||||
}
|
||||
|
||||
|
||||
sub direxpand {
|
||||
my $templ = shift;
|
||||
my $direx = '';
|
||||
local $filename;
|
||||
local $filestat;
|
||||
|
||||
foreach $filename (@dirs) {
|
||||
$direx .= &expandtemplate($templ,
|
||||
('iconlink', \&diricon),
|
||||
('namelink', \&dirname),
|
||||
('filesize', sub {return('')}),
|
||||
('modtime', \&modtime),
|
||||
('description', \&descexpand));
|
||||
}
|
||||
|
||||
foreach $filename (@files) {
|
||||
next if $filename =~ /^.*\.[oa]$|^core$|^00-INDEX$/;
|
||||
$direx .= &expandtemplate($templ,
|
||||
('iconlink', \&fileicon),
|
||||
('namelink', \&filename),
|
||||
('filesize', \&filesize),
|
||||
('modtime', \&modtime),
|
||||
('description', \&descexpand));
|
||||
}
|
||||
|
||||
return($direx);
|
||||
}
|
||||
|
||||
sub printdir {
|
||||
my $template;
|
||||
my $index;
|
||||
local %index;
|
||||
local @dirs;
|
||||
local @files;
|
||||
local $parentdir;
|
||||
|
||||
|
||||
$template = "<ul>\n\$files{\n<li>\$iconlink \$namelink\n}</ul>\n";
|
||||
if ($Conf->htmldir) {
|
||||
unless (open(TEMPL, $Conf->htmldir)) {
|
||||
&warning("Template ".$Conf->htmldir." does not exist.");
|
||||
} else {
|
||||
$save = $/; undef($/);
|
||||
$template = <TEMPL>;
|
||||
$/ = $save;
|
||||
close(TEMPL);
|
||||
}
|
||||
}
|
||||
|
||||
if (opendir(DIR, $Path->{'real'})) {
|
||||
foreach $f (sort(grep/^[^\.]/,readdir(DIR))) {
|
||||
if (-d $Path->{'real'}.$f) {
|
||||
push(@dirs,"$f/");
|
||||
} else {
|
||||
push(@files,$f);
|
||||
}
|
||||
}
|
||||
closedir(DIR);
|
||||
} else {
|
||||
print("<p align=center>\n<i>This directory does not exist.</i>\n");
|
||||
if ($Path->{'real'} =~ m#(.+[^/])[/]*$#) {
|
||||
if (-e $1) {
|
||||
&warning("Unable to open ".$Path->{'real'});
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (-f $Path->{'real'}."00-INDEX") {
|
||||
open(INDEX,$Path->{'real'}."00-INDEX") ||
|
||||
&warning("Existing \"00-INDEX\" could not be opened.");
|
||||
$save = $/; undef($/);
|
||||
$index = <INDEX>;
|
||||
$/ = $save;
|
||||
|
||||
%index = $index =~ /\n(\S*)\s*\n\t-\s*([^\n]*)/gs;
|
||||
}
|
||||
|
||||
if ($Path->{'virt'} =~ m#^(.*/)[^/]*/$#) {
|
||||
$parentdir = $1;
|
||||
unshift(@dirs, '..');
|
||||
}
|
||||
|
||||
print(&expandtemplate($template,
|
||||
('files', \&direxpand)));
|
||||
}
|
||||
|
||||
|
||||
sub printfile {
|
||||
|
||||
unless ($Path->{'file'}) {
|
||||
&printdir;
|
||||
|
||||
if (open(SRCFILE, $Path->{'real'}.README)) {
|
||||
print("<hr><pre>");
|
||||
&markupfile(\*SRCFILE, $Path->{'virt'}, 'README',
|
||||
sub { print shift });
|
||||
print("</pre>");
|
||||
close(SRCFILE);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (open(SRCFILE, $Path->{'realf'})) {
|
||||
print("<pre>");
|
||||
&markupfile(\*SRCFILE, $Path->{'virt'}, $Path->{'file'},
|
||||
sub { print shift });
|
||||
print("</pre>");
|
||||
close(SRCFILE);
|
||||
|
||||
} else {
|
||||
print("<p align=center>\n<i>This file does not exist.</i>\n");
|
||||
|
||||
if (-f $Path->{'real'}.$Path->{'file'}) {
|
||||
&warning("Unable to open ".$Path->{'realf'});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
($Conf, $HTTP, $Path) = &init;
|
||||
|
||||
&makeheader('source');
|
||||
&printfile;
|
||||
&makefooter('source');
|
||||
|
||||
Reference in New Issue
Block a user