#!/usr/bin/perl
# Src2html: Take a source tree and generate Html documents that have hyperlinks
# to the definition of structures, variables, functions, and preprocessor
# definitions. Read the manual page for details on how to use the program.
#
# Version 1.4-alpha. Written by Warren Toomey wkt@cs.adfa.oz.au
#
# 19th January 1996
#
# $Id$
#
if ($#ARGV <= 0 || $#ARGV > 4) { # Check arg count
print(STDERR "Usage: $0 [-na] [-nl] [-d num] input_description\n");
print(STDERR " -na: Don't produce top-level category files\n");
print(STDERR " -nl: Don't produce per-letter files\n");
print(STDERR " -d: Set debugging to given number (0-3)\n");
exit(1);
}
# Set up default option values
$NoLetters= 0;
$NoAll= 0;
$Debug=0;
$Top= $ARGV[$#ARGV];
$Top=~ s/\.s2h$//;
# Parse the options
for ($i=0; $i<= $#ARGV; $i++) {
if ($ARGV[$i] eq "-na") { $NoAll= 1; next; }
if ($ARGV[$i] eq "-nl") { $NoLetters= 1; next; }
if ($ARGV[$i] eq "-d") { $i++; $Debug= $ARGV[$i]; next; }
}
$Title{"m"}= "C Macros";
$Title{"d"}= "C Defines";
$Title{"f"}= "C Functions";
$Title{"v"}= "C Variables";
$Title{"s"}= "C Structs";
$Title{"u"}= "C Unions";
$Title{"t"}= "C Typedefs";
$Title{"e"}= "C Enums";
$Title{"AdaType"}= "Ada Types";
$Title{"AdaProcedure"}= "Ada Procedures";
$Title{"AdaFunction"}= "Ada Functions";
$Title{"AdaPackage"}= "Ada Packages";
$Title{"AdaTask"}= "Ada Tasks";
$Title{"g"}= "All symbols";
&get_s2h; # Read the description file
&make_dirs; # Make directories as needed
&make_ctags; # Generate ctags for all src
&parse_ctags; # Parse ctags, generate html ptr files
foreach $i (keys(%Dirinfo))
{ &rewrite_src($i); } # Rewrite the src code
exit(0); # and exit
## get_s2h: Opens the source description file, reads it, and sets up some
## variables describing where some directories are, and the source directories
## to process. Variables used are:
## Srctree - The root of the source tree we are processing
## Htmlroot - The directory where all WWW documents are kept
## Htmldir - The directory under Htmlroot for this source tree
## Htmltree - The root of the destination tree for the Html code
## Newsrctree - The directory in Htmltree to store the new Htmlised code
## Headers - The directory where we keep information to prepend in some docs
## Formdir - The place to put the index searching script
## Dirinfo{} - The list of dirs and the info about the directory
## Dotdir{} - The directory name with /'s -> .'s
sub get_s2h {
$Newsrctree= 'newsrc'; # Set up as default
$Headers= '.';
#########################################################
# make sure we dump out the last bit of the last file....
# Print out the remainder of the
# current file, incl. the buffered line
if ($In_file == 1) {
if ("$line" ne "") { print OUT $line; }
while () {
s/\&/&/g; s/\</g; s/\>/>/g; print OUT;
}
print OUT "\n\n\n\n\n\n\n\n