Index: /trunk/Ohana/src/perl/src/mkdist
===================================================================
--- /trunk/Ohana/src/perl/src/mkdist	(revision 4866)
+++ /trunk/Ohana/src/perl/src/mkdist	(revision 4866)
@@ -0,0 +1,128 @@
+#!/usr/bin/env perl
+
+$diff = 0;
+$list = 0;
+@tARGV = ();
+for (; @ARGV > 0; ) {
+    if ($ARGV[0] eq "-diff") {
+	$diff = 1;
+        shift; next;
+    }
+    if ($ARGV[0] eq "-list") {
+	$list = 1;
+        shift; next;
+    }
+    if ($ARGV[0] eq "-h")     { &usage (); }
+    if ($ARGV[0] eq "-help")  { &usage (); }
+    if ($ARGV[0] eq "--help") { &usage (); }
+    @tARGV = (@tARGV, $ARGV[0]);
+    shift;
+}
+@ARGV = @tARGV;
+
+$distdir = "distributions";
+
+if (!$list && @ARGV != 2) { &usage (); }
+if ( $list && @ARGV != 0) { &usage (); }
+
+@files = <$distdir/*.dst>;
+foreach $file (@files) {
+    open (FILE, $file) || die "ERROR: can't open distribution file\n";
+    @sublist = <FILE>;
+    close (FILE);
+    push @list, @sublist;
+    $Ns = @sublist;
+    $Nt = @list;
+}
+
+$group = $ARGV[0];
+$version = $ARGV[1];
+
+$ingroup = 0;
+@name = ();
+@tag = ();
+
+if ($list) { 
+    printf STDERR "Available Distributions\n";
+    printf STDERR "%-16s  %7s\n", "Module", "Version";
+    printf STDERR "-------------------------\n";
+}
+
+foreach $line (@list) {
+
+    ($key) = split (" ", $line);
+
+    # found DISTRIBUTION
+    if ($key eq "DISTRIBUTION") {
+	($tmp, $word1, $word2) = split (" ", $line);
+	if (($word1 eq $group) && ($word2 eq $version)) { $ingroup = 1; }
+	if ($list) { printf STDERR "%-16s  %7s\n", $word1, $word2; }
+    }
+    if (!$ingroup || $list) { next; }
+
+    # found END
+    if ($key eq "END") { last; }
+
+    # found USE
+    if ($key eq "USE") {
+	($tmp, $word1, $word2) = split (" ", $line);
+	if ($word2 eq "") {
+	    $tag  = "";
+	    $name = $word1;
+	} else {
+	    $tag  = $word1;
+	    $name = $word2;
+	}	    
+	if ($name eq "") { die "missing tag\n"; }
+	push @name, $name;
+	push @tag, $tag;
+    }
+}
+
+if ($list) { exit 0; }
+if (@name == 0) { die "ERROR: $group $version not found\n"; }
+
+if ($diff) { &difflist (); }
+
+for ($i = 0; $i < @name; $i++) {
+    if ($tag[$i] eq "") {
+	&vsystem ("cvs co $name[$i]");
+    } else {
+	&vsystem ("cvs co -r $tag[$i] $name[$i]");
+    }	
+}
+
+if ($group eq "elixir-config") {
+    &vsystem ("mv config $group-$version");
+} else {
+    &vsystem ("mv ohana $group-$version");
+}
+&vsystem ("rm -r `find $group-$version -name CVS`");
+&vsystem ("tar cvzf tarballs/$group-$version.tgz  $group-$version");
+&vsystem ("rm -r $group-$version");
+
+sub vsystem {
+    print STDERR "@_\n";
+    $status = system ("@_");
+    $status;
+}
+
+sub usage {
+    print STDERR "USAGE: mkdist -list\n   : list valid distributions \n";
+    print STDERR "USAGE: mkdist (group) (version)\n   : make a distribution tarball\n";
+    print STDERR "USAGE: mkdist -diff (group) (version)\n";
+    print STDERR "   : show the difference between the distribution and current tree\n";
+    exit 2;
+}
+
+sub difflist {
+
+    for ($i = 0; $i < @name; $i++) {
+	if ($tag[$i] eq "") {
+	    &vsystem ("cvs -q rdiff -s -r HEAD $name[$i]");
+	} else {
+	    &vsystem ("cvs -q rdiff -s -r $tag[$i] $name[$i]");
+	}	
+    }
+    exit 0;
+}
Index: /trunk/Ohana/src/perl/src/mkhtml
===================================================================
--- /trunk/Ohana/src/perl/src/mkhtml	(revision 4866)
+++ /trunk/Ohana/src/perl/src/mkhtml	(revision 4866)
@@ -0,0 +1,183 @@
+#!/usr/bin/env perl
+
+$template = "template.htm";
+if ($ARGV[0] eq "-template") { 
+    shift @ARGV;
+    $template = $ARGV[0]; 
+    shift @ARGV; 
+}
+
+if (@ARGV != 3) { die "USAGE: mkhtml [-template template] (root) (src) (html)\n"; }
+
+$root     = $ARGV[0];
+$root     =~ s|/*$||; # strip trailing /'s to clean path
+
+$input    = $ARGV[1];
+$output   = $ARGV[2];
+$config   = "Configure";
+
+# print STDERR "template: $template\n";
+
+# load variables from Configure (eg, ROOT, etc)
+# these are interpolated except in the content section
+open (FILE, $config);
+@input = <FILE>;
+close (FILE);
+foreach $line (@input) {
+    ($var, $eq, $value) = split (" ", $line);
+    $$var = $value;
+}
+
+# load data from template
+open (FILE, $template);
+@template = <FILE>;
+close (FILE);
+
+# load data from input file
+open (FILE, $input);
+@input = <FILE>;
+close (FILE);
+
+# default metadata values:
+$title = &rootname ($input);
+if ($title eq "index") { $title = &basename (&dirname ($input)); }
+
+$page  = &rootname ($input);
+if ($page  eq "index") { $page  = &basename (&dirname ($input)); }
+
+$path  = &dirname ($input);
+
+$ext   = &extname ($input);
+
+# file is the entry in the index listing
+$file  = $output;
+if ($file =~ m|index.html|) { $file = &dirname ($output); }
+$file  =~ s|^$root|ROOT|;
+
+# apply ROOT variable to content (this comes from Configure)
+# foreach $line (@input) { while ($line =~ m|\$ROOT|) { $line =~ s|\$ROOT|$ROOT|; } }
+
+# search for the metadata lines in input file
+while (@input) {
+    $line = shift @input;
+    if ($line =~ /^\s*$/) { next; }
+    if ($line =~ /<meta\s+name=title\s+content=/) {
+	($title) = $line =~ /<meta\s+name=title\s+content=(.*)>/;
+	next;
+    }
+    if ($line =~ /<meta\s+name=page\s+content=/) {
+	($page) = $line =~ /<meta\s+name=page\s+content=(.*)>/;
+	next;
+    }
+    unshift @input, $line;
+    last;
+}
+
+# create the output file
+open (OUT, ">$output");
+
+$found = $menu = 0;
+foreach $line (@template) {
+    
+    chop $line;
+    while ($line =~ m|ROOT|) { $line =~ s|ROOT|$ROOT|; }
+    
+    # interpolate over basic metadata entries
+    if ($line =~ m|<meta\s+name=page>|) {
+	print OUT "$page\n";
+	next;
+    }
+    if ($line =~ m|<meta\s+name=title>|) {
+	print OUT "$title\n";
+	next;
+    }
+    if ($line =~ m|<meta\s+name=body>|) {
+	# add in parsing of <p> tags, etc in here
+	&dumpinput;
+	next;
+    }
+
+    # parse the index file
+    if ($line =~ m|<meta\s+name=index\s+file=|) {
+	($index) = $line =~ m|<meta\s+name=index\s+file=(.*)>|;
+	$index = "$path/$index";
+	open (INDEX, $index);
+	@index = <INDEX>;
+	# need to find and tag this file 
+	foreach $index (@index) {
+	    if ($index =~ m|href=$file>|) {
+		$index =~ s|class=doc|class=sel|;
+		$index =~ s|class=dir|class=dsl|;
+		$index =~ s|class=dl|class=sl|;
+		$index =~ s|$file>\s+-\s+|$file> + |;
+	    }
+	    # interpolate ROOT
+	    while ($index =~ m|ROOT|) { $index =~ s|ROOT|$ROOT|; }
+	}
+
+	close (INDEX);
+	print OUT @index;
+	next;
+    }
+    print OUT "$line\n";
+}
+    
+close (OUT);
+exit 0;
+
+sub dumpinput {
+
+    if ($ext eq "txt") {
+	print OUT "<pre>\n";
+    }
+    print OUT "@input";
+    if ($ext eq "txt") {
+	print OUT "</pre>\n";
+    }
+}
+
+# behaves just like system basename function (returns last portion of path)
+sub basename {
+
+    my ($file) = $_[0];
+    my ($base, @words);
+
+    @words = split ("/", $file);
+    $base = $words[-1];
+    return $base;
+}
+
+
+# behaves just like system dirname function (strips last portion of path)
+sub dirname {
+
+    my ($file) = $_[0];
+    my ($base, @words);
+
+    @words = split ("/", $file);
+    if (@words == 1) { return "."; }
+
+    pop @words;
+    $file = join ('/', @words);
+    return $file;
+}
+
+# behaves just like system basename function (returns last portion of path)
+sub extname {
+    my ($file) = &basename ($_[0]);
+    my($ext) = $file =~ m|\S*\.(\S*)$|;
+    return $ext;
+}
+
+# behaves just like system basename function (returns last portion of path)
+sub rootname {
+    my ($file) = &basename ($_[0]);
+    my($ext) = $file =~ m|(\S*)\.\S*$|;
+    return $ext;
+}
+
+# input metadata lines:
+# <meta name="file"  content="test">
+# <meta name="title" content="a test title">
+# <meta name="page"  content="test">
+
Index: /trunk/Ohana/src/perl/src/mkidx
===================================================================
--- /trunk/Ohana/src/perl/src/mkidx	(revision 4866)
+++ /trunk/Ohana/src/perl/src/mkidx	(revision 4866)
@@ -0,0 +1,231 @@
+#!/usr/bin/env perl
+
+use strict;
+
+if (@ARGV != 1) { die "USAGE: mkidx (directory)\n"; }
+
+# input is the name of a directory and current level
+# outputs are: directory list, document list, index file for directory
+# menu for that directory
+
+# parse input info
+my($path);
+$path  = $ARGV[0];
+$path  =~ s|/*$||; # strip trailing /'s to clean path
+
+local($mkidx::root) = $path;
+
+&mksubidx ($path, 0, 0, "template.htm");
+exit 0;
+
+sub mksubidx {
+    # USAGE: mksubidx (path) (entry) (template) (index)
+    my($path)  	  = shift @_;
+    my($level) 	  = shift @_;
+    my($entry)    = shift @_;
+    my($template) = shift @_;
+    my(@updex)    = @_;
+
+    my($i, $j);
+    my($line, $value, $dir);
+    my(@list);
+    my($file, $root, $link, $ext);
+    my(@seq)    = ();
+    my(@dirs)   = ();
+    my(@mydirs) = ();
+    my(@docs)   = ();
+    my(@txts)   = ();
+    my(@index)  = ();
+    my(@mydex)  = ();
+    my($Nmydex);
+    my(@seqline);
+
+    # if this directory contains a template file, reset entry and level
+    # supply the template file to mkhtml here and below
+    if (-e "$path/template.htm") {
+	@updex = ();
+	$level = 0;
+	$entry = 0;
+	$template = "$path/template.htm";
+    }
+    # print STDERR "idx: $template\n";
+
+    # put leading portion of updex here
+    for ($i = 0; $i < $entry; $i++) {
+	push @index, $updex[$i];
+    }
+
+    # find all dirs in this directory
+    @list = <$path/*>;
+    foreach $file (@list) {
+	if (! -d $file) { next; }
+	$root = &basename ($file);
+	$link = $file;
+	$link =~ s|^$mkidx::root|ROOT|;
+
+	# list special directories here
+	if ($root eq "CVS") { next; }
+	if (-e "$file/noindex.idx") { next; }
+
+	push @mydirs, $file;
+
+	$line = sprintf "<tr><td class=dir%d> <a class=dl %-30s -%20s </a></td></tr>", $level, "href=$link>", $root;
+	push @mydex, $line;
+	push @seq, $root;
+    }
+
+    # find all docs (htm, txt) in this directory
+    @list = (<$path/*.htm>,<$path/*.hts>,<$path/*.txt>);
+    foreach $file (@list) {
+	if (! -f $file) { next; }
+
+	$ext = &extname ($file);
+	$root = &rootname ($file);
+
+	$link = $file;
+	$link =~ s|.$ext$|.html|;
+	$link =~ s|^$mkidx::root|ROOT|;
+
+	# list special files here
+	if ($root eq "index") { next; }
+	if ($root eq "template") { next; }
+	if ($root eq "sequence") { next; }
+
+	# print STDERR "ext: $ext, root: $root\n";
+
+	push @docs, $file;
+	push @mydirs, "0";
+	
+	if ($ext ne "hts") {
+	    # simple case: no extra information:
+	    $line = sprintf "<tr><td class=doc%d> <a class=dl %-30s &nbsp; %20s </a></td></tr>", $level, "href=$link>", $root;
+	    push @mydex, $line;
+	    push @seq, &basename ($file);
+	}
+    }
+
+    # look for directory sequencing information
+    if (-f "$path/sequence.idx") { 
+	open (FILE, "$path/sequence.idx");
+	@seqline = <FILE>;
+	close (FILE);
+      OUT:
+	for ($i = 0; $i < @seqline; $i++) {
+	    $Nmydex = @mydex;
+	    chop $seqline[$i];
+	  IN:
+	    for ($j = 0; $j < $Nmydex; $j++) {
+		$line  = shift @mydex;
+		$value = shift @seq;
+		$dir   = shift @mydirs;
+		if ($seqline[$i] eq $value) {
+		    push @index, $line;
+		    push @dirs, $dir;
+		    # print "ADD SEQ: $dir, $line\n";
+		    next OUT;
+		} else {
+		    push @mydex, $line;
+		    push @mydirs, $dir;
+		    push @seq, $value;
+		}
+	    }
+	}	
+    }
+    # add trailing portion of updex here
+    foreach $line (@mydex) {
+	$dir = shift @mydirs;
+	# print "ADD VAL: $dir, $line\n";
+	push @dirs, $dir;
+	push @index, $line;
+    }
+
+    # add trailing portion of updex here
+    for ($i = $entry; $i < @updex; $i++) {
+	push @index, $updex[$i];
+    }
+
+    for ($i = 0; $i < @dirs; $i++) {
+	if ($dirs[$i] eq 0) { next; }
+	&mksubidx ($dirs[$i], $level + 1, $i + $entry + 1, $template, @index);
+    }
+
+    # output index for this directory
+    open (FILE, ">$path/index.idx");
+    foreach $line (@index) {
+	print FILE "$line\n";
+    }
+    close (FILE);
+
+    # create html for docs in this directory
+    foreach $file (@docs, "$path/index.htm") {
+	$ext  = &extname ($file);
+	# print STDERR "ext: $ext\n";
+	# $root  = &rootname ($file);
+	# print STDERR "root: $root\n";
+	$link = $file;
+	$link =~ s|.$ext$|.html|;
+	system "mkhtml -template $template $mkidx::root $file $link";
+    }
+    return;
+}
+
+# behaves just like system basename function (returns last portion of path)
+sub basename {
+
+    my ($file) = $_[0];
+    my ($base, @words);
+
+    @words = split ("/", $file);
+    $base = $words[-1];
+    return $base;
+}
+
+# behaves just like system basename function (returns last portion of path)
+sub extname {
+    my ($file) = &basename ($_[0]);
+    my($ext) = $file =~ m|\S*\.(\S*)$|;
+    return $ext;
+}
+
+# behaves just like system basename function (returns last portion of path)
+sub rootname {
+    my ($file) = &basename ($_[0]);
+    my($ext) = $file =~ m|(\S*)\.\S*$|;
+    return $ext;
+}
+
+# behaves just like system dirname function (strips last portion of path)
+sub dirname {
+
+    my ($file) = $_[0];
+    my ($base, @words);
+
+    @words = split ("/", $file);
+    if (@words == 1) { return "."; }
+
+    pop @words;
+    $file = join ('/', @words);
+    return $file;
+}
+
+###
+#    # find all txt files in this directory
+#    @list = <$path/*.txt>;
+#    foreach $file (@list) {
+#	if (! -f $file) { next; }
+#
+#	$ext = &extname ($file);
+#
+#	$root = &basename ($file);
+#	$root =~ s|.txt$||;
+#	$link = $file;
+#	$link =~ s|.txt$|.html|;
+#	$link =~ s|^$mkidx::root|ROOT|;
+#
+#	push @txts, $file;
+#
+#	# simple case: no extra information:
+#	$line = sprintf "<tr><td class=doc%d> <a class=dl %-30s  %20s </a></td></tr>", $level, "href=$link>", $root;
+#	push @index, $line;
+#    }
+
