#!/usr/local/bin/perl -w


use lib '/u/gage/xmlrpc/daemon/';
use Webwork;

sub echo {
    return shift;
}

sub listLib {
    my $in = shift;
  	return( Webwork::listLib($in) );
}
sub renderProblem {
    my $in = shift;
  	return( Webwork::renderProblem($in) );
}
sub readFile {
    my $in = shift;
  	return( Webwork::readFile($in) );
}
sub hello {
	print "Receiving request for hello world\n";
	return "Hello world?";
}

sub pretty_print_rh {
	my $rh = shift;
	my $out = "";
	my $type = ref($rh);
	if ( ref($rh) =~/HASH/ ) {
 		foreach my $key (sort keys %{$rh})  {
 			$out .= "  $key => " . pretty_print_rh( $rh->{$key} ) . "\n";
 		}
	} elsif ( ref($rh) =~ /SCALAR/ ) {
		$out = "scalar reference ". ${$rh};
	} elsif ( ref($rh) =~/Base64/ ) {
		$out .= "base64 reference " .$$rh;
	} else {
		$out =  $rh;
	}
	if (defined($type) ) {
		$out .= " type = $type \n";
	}
	return $out;
}

sub tth {
	my $in = shift;
	my $tthpath = "/usr/local/bin/tth";
    # $tthpath -L -f5 -r 2>/dev/null " . $inputString;
    return $in;

}

$map = {
  echo   		=> 	\&echo,
  listLib 		=> 	\&listLib,
  renderProblem => 	\&renderProblem,
  readFile		=>	\&readFile,
  hello			=>  \&hello,
  tth			=>	\&tth
};

1;