#!/usr/bin/perl

require("/home/takoyaki/www/data/blog2html.pl") if $ENV{'LOGNAME'} eq "takoyaki";
require("/Users/larry/micah/bin/blog2html.pl") if $ENV{'LOGNAME'} eq "larry";
require("/arpa/hm/m/msittig/bin/blog2html.pl") if $ENV{'LOGNAME'} eq "msittig";

$debug = 1;
sub error{ print "hi: @_\n" if $debug == 1 };

my ($blosxom, $body);
$blosxom = 0;

my ($arg, $file, $tabs, $nn);
$nn = 0;
while ($ARGV[$nn]) {
    &error("starting loop - arg=$ARGV[$nn]");
    if ($ARGV[$nn] eq "-t") { 
	$nn++;
	$tabs = $ARGV[$nn++];
	&error("tabs is $tabs"); next; 
    }
    if ($ARGV[$nn] eq "-b") {
	$nn++;
	$blosxom = 1;
	&error("saving top line for blosxom.");
	next;
    }
    $file = $ARGV[$nn];
    &error("file is $file");
    $nn++;
}   
&error("file=$file and tabs=$tabs");

$file or die("b2h: no input.\n");

if( open (IN, $file) ) {
    chomp($junk = <IN>) if $blosxom;
    chomp($body = join('',<IN>));
    close (IN);
} else {
    $body = $file ;
}

print "($junk)\n" if $junk;
print &blog2html($body, $tabs)."\n";
