#!/usr/bin/perl
#
# tree2html - convert FHS pic directory trees to HTML
#
# Copyright © 1997-1999  Daniel Quinlan
#
# 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.

sub tree2html {
    $_ = <>;
    $tab = "\t";

    # print table header
    print "<TABLE CELLSPACING=10>\n";

    # read table data
    while (<>) {
	next if /^copy/;
	if (/^dir/) {
	    s@dir\((.*),(.*)\)@<B>$1</B>\t<B>$2</B>@;
	}
	if (/^sub/) {
	    s@sub\(\"(.*)\",\"(.*)\"\)@$1\t$2@;
	}

	chop;
	if ($_ eq "_") {
	    &printcells;
	    @out = '';
	    next;
	}
	@cells = split(/$tab/);
	$col = 0;
	for $cell (@cells) {
	    $out[$col] .= $cell . "<BR>\n";
	    $col++;
	}
    }
    &printcells;
    print "</TABLE>\n";
}

sub printcells {
    print "<TR>\n";
    for $cell (@out) {
	print "<TD NOWRAP>\n", $cell;
    }
    $once=1;
}

&tree2html;
