[system] / trunk / xmlrpc / modules / WWd.pm Repository:
ViewVC logotype

View of /trunk/xmlrpc/modules/WWd.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 279 - (download) (as text) (annotate)
Fri May 17 21:44:04 2002 UTC (17 years ago) by gage
File size: 2000 byte(s)
Experimental xmlrpc WeBWorK webservices

    1 #!/usr/local/bin/perl  -w
    2 package WWd;
    3 
    4 use lib '/u/gage/xmlrpc/daemon/';
    5 use Webwork;
    6 
    7 
    8 
    9 
   10 ############utilities
   11 
   12 sub echo {
   13     shift if UNIVERSAL::isa($_[0] => __PACKAGE__);
   14     my $in = shift;
   15     return(ref($in). "  $in ");
   16 }
   17 
   18 sub listLib {
   19     shift if UNIVERSAL::isa($_[0] => __PACKAGE__);
   20     my $in = shift;
   21     return( Webwork::listLib($in) );
   22 }
   23 sub renderProblem {
   24     shift if UNIVERSAL::isa($_[0] => __PACKAGE__);
   25     my $in = shift;
   26     return( Webwork::renderProblem($in) );
   27 }
   28 sub readFile {
   29     shift if UNIVERSAL::isa($_[0] => __PACKAGE__);
   30     my $in = shift;
   31     return( Webwork::readFile($in) );
   32 }
   33 sub hello {
   34   shift if UNIVERSAL::isa($_[0] => __PACKAGE__);
   35   print "Receiving request for hello world\n";
   36   return "Hello world?";
   37 }
   38 
   39 sub pretty_print_rh {
   40   my $rh = shift;
   41   my $out = "";
   42   my $type = ref($rh);
   43   if ( ref($rh) =~/HASH/ ) {
   44     foreach my $key (sort keys %{$rh})  {
   45       $out .= "  $key => " . pretty_print_rh( $rh->{$key} ) . "\n";
   46     }
   47   } elsif ( ref($rh) =~ /SCALAR/ ) {
   48     $out = "scalar reference ". ${$rh};
   49   } elsif ( ref($rh) =~/Base64/ ) {
   50     $out .= "base64 reference " .$$rh;
   51   } else {
   52     $out =  $rh;
   53   }
   54   if (defined($type) ) {
   55     $out .= " type = $type \n";
   56   }
   57   return $out;
   58 }
   59 
   60 sub tth {
   61   shift if UNIVERSAL::isa($_[0] => __PACKAGE__);
   62   my $in = shift;
   63   my $tthpath = "/usr/local/bin/tth";
   64     my $out;
   65     $inputString    = "<<END_OF_TTH_INPUT_STRING;\n\n\n" . $in . "\nEND_OF_TTH_INPUT_STRING\necho \"\" >/dev/null";
   66     #it's not clear why another command is needed.
   67 
   68     if (-x $tthpath ) {
   69       my $tthcmd      = "$tthpath -L -f5 -r 2>/dev/null " . $inputString;
   70       if (open(TTH, "$tthcmd   |")) {
   71           local($/);
   72       $/ = undef;
   73       $out = <TTH>;
   74       $/ = "\n";
   75       close(TTH);
   76       }else {
   77           $out = "<BR>there has been an error in executing $tthcmd<BR>";
   78       }
   79   } else {
   80     $out = "<BR> Can't execute the program tth at |$tthpath|<BR>";
   81     }
   82 
   83     #return "<!-- \r\n" . $in . "\r\n-->\r\n\r\n" . $out . "\r\n\r\n";
   84     return $out;
   85 
   86 }
   87 
   88 
   89 
   90 1;
   91 
   92 
   93 
   94 
   95 
   96 
   97 
   98 

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9