[BACK]Return to httpd-rpc.sm1 CVS log [TXT][DIR] Up to [local] / OpenXM / src / kan96xx / Doc

Diff for /OpenXM/src/kan96xx/Doc/httpd-rpc.sm1 between version 1.1 and 1.7

version 1.1, 2002/10/23 13:38:50 version 1.7, 2002/10/28 23:55:57
Line 1 
Line 1 
 %% $OpenXM$  %% $OpenXM: OpenXM/src/kan96xx/Doc/httpd-rpc.sm1,v 1.6 2002/10/28 08:57:28 takayama Exp $
 %% http server by sm1. Used for RPC.  Generic example.  %% http server by sm1. Used for RPC.  Generic example.
   
 [(parse) (httpd.sm1) pushfile] extension pop  [(parse) (httpd.sm1) pushfile] extension pop
Line 9  def
Line 9  def
 /httpd.port 8090 def  /httpd.port 8090 def
 /httpd.serial 0 def  /httpd.serial 0 def
   
 /httpd.image.name (kobeuniv2.jpg) def  /httpd.oxasir.timer 1 def  %% 1 to use timer, but it accepts only one command
                              %% 0 not to use timer. It accepts programs.
   
   %%******* Put initialization codes for ox_asir here.
   /httpd.initialization
    [
     (XM_debug=0; ctrl("debug_window",0); Xm_noX=1;)
     ("Asirweb version 0.80. "+
      " Risa/Asir oxasir version "+rtostr(version());)
    ] cat
   def
   
   /httpd.asirman
    ("http://www.math.sci.kobe-u.ac.jp/OpenXM/1.2.1/doc/asir2000/html-eg/man_toc.html")
   def
   /httpd.asirman.ja
    ("http://www.math.sci.kobe-u.ac.jp/OpenXM/1.2.1/doc/asir2000/html-jp/man_toc.html")
   def
   
 [(parse) (oxasir.sm1) pushfile] extension  [(parse) (oxasir.sm1) pushfile] extension
 oxNoX  oxNoX
 (oxasir.started) boundp {  (oxasir.started) boundp {
Line 20  oxNoX 
Line 36  oxNoX 
   [(x^2-1) (x)] fctr pop    [(x^2-1) (x)] fctr pop
   oxasir.ccc oxmathcap    oxasir.ccc oxmathcap
   oxasir.ccc oxsetmathcap    oxasir.ccc oxsetmathcap
     oxasir.ccc httpd.initialization oxexecutestring ;
     (Initialization returns ...: ) messagen
     oxasir.ccc oxpopcmo message ;
 } ifelse  } ifelse
   
 /webrpc  {  /webrpc  {
Line 34  oxNoX 
Line 53  oxNoX 
        [         [
          ox.win.start.0 aload pop           ox.win.start.0 aload pop
          (iexplore)   %% Starting internet explorer (TM).           (iexplore)   %% Starting internet explorer (TM).
          [(http://localhost:) httpd.port toString] cat           [(http://) [(sm1.socket) (gethostname) []] extension
             (:) httpd.port toString] cat
        ]         ]
        [  ]         [  ]
       3] extension        3] extension
    }{     }{
       %% On unix.        %% On unix.
       [(sleep 3 ; netscape http://localhost:) httpd.port toString ( & ) ] cat        [(sleep 3 ; netscape http://)
                    [(sm1.socket) (gethostname) []] extension
                   (:) httpd.port toString ( & ) ] cat
       system        system
    } ifelse     } ifelse
   
Line 53  oxNoX 
Line 75  oxNoX 
 /httpd_action {  /httpd_action {
   [/in-httpd /ff /httpd.com /httpd.result /sss    [/in-httpd /ff /httpd.com /httpd.result /sss
    /sss.engine /sss.web /err     /sss.engine /sss.web /err
    /oxserver.vname     /oxserver.vname /scheck
   ] pushVariables    ] pushVariables
   [    [
   {    {
        [(sm1.socket) (select) [httpd.server.fd 0 get -1]] extension         [(sm1.socket) (select) [httpd.server.fd 0 get -1]] extension
        %%     wait for ever         %%     wait for ever
         [(sm1.socket) (readHTTP) [httpd.server.fd 0 get ]] extension /ff set          [(sm1.socket) (readHTTP) [httpd.server.fd 0 get ]] extension /ff set
         ff length 0 eq {          ff tag 0 eq {
            (connection is closed.) message             (connection is closed.) message exit
         }          }
         {          {
           (------------  start ----------------------) message            (------------  start ----------------------) message
Line 71  oxNoX 
Line 93  oxNoX 
              [(httpd.com=) httpd.com] cat message               [(httpd.com=) httpd.com] cat message
           (------------  end ----------------------) message            (------------  end ----------------------) message
           (   ) message            (   ) message
           httpd.serial 0 eq {  
             /httpd.com  httpd.initialization def  
           } { } ifelse  
           httpd.com metaCommand {            httpd.com metaCommand {
             httpd.textarea.valid {              httpd.textarea.valid {
   
                 %%% Security check
                 [(regionMatches) httpd.com
                  httpd.refusedCommands] extension /scheck set
                 scheck 0 get -1 eq {
                 }{
                   httpd.refusedCommands scheck 2 get get message
                   (Command is refused.) message
                   [
                    httpd.refusedCommands scheck 2 get get
                    httpd.com
                   ]
                    send-page-refused exit
                 } ifelse
   
               %%%  Executing command, here.                %%%  Executing command, here.
               oxasir.ccc                oxasir.ccc
               httpd.com cookedCommand                httpd.com cookedCommand
Line 120  oxNoX 
Line 154  oxNoX 
             httpd.result message              httpd.result message
             (----------------------------------) message              (----------------------------------) message
             (  ) message              (  ) message
   
               (----------- error -------------) message
             err message              err message
               (-------------------------------) message
             err [ ] eq  {              err [ ] eq  {
             } {              } {
               oxasir.ccc cleanErrors                oxasir.ccc cleanErrors
Line 173  oxNoX 
Line 209  oxNoX 
    (Content-Type: text/html) sendln     (Content-Type: text/html) sendln
    0 sendln     0 sendln
   
   (<H1> Usage </H2> <br> ) sendln    (<H1><font color="green">OpenXM/Risa/Asir Online</font></H2><br>) sendln
   [(Ask by GET /?) httpd.textarea.name (=) ( encoded_codes  HTTP/1.0)] cat  
   sendln  
   (<br>) sendln  
   [(getenv) (OXWEB_POST)] extension tag 0 eq {    [(getenv) (OXWEB_POST)] extension tag 0 eq {
     (<FORM NAME="myFORM">) sendln  % use get      (<FORM NAME="myFORM">) sendln  % use get
   }{    }{
Line 186  oxNoX 
Line 219  oxNoX 
    [(<textarea name=) httpd.textarea.name     [(<textarea name=) httpd.textarea.name
     ( rows=10 cols="80" wrap="soft"></textarea>)] cat sendln      ( rows=10 cols="80" wrap="soft"></textarea>)] cat sendln
    (</FORM>) sendln     (</FORM>) sendln
   
     (Input example---factorization:<font color="blue"> fctr(x^3-1)</font>) sendln
     (<br>) sendln
     [(<font color="blue">
       <a href=) httpd.asirman ( > AsirManual (En) </a> </font>, )] cat sendln
     [(<font color="blue">
       <a href=) httpd.asirman.ja ( > AsirManual (Ja) </a> </font>)] cat sendln
      httpd.oxasir.timer {
       (<br> It accepts only one command. The limit of CPU time is 30 seconds.
             <font color="red"> Do not put <font color="blue"> ; </font>
                                (semi-colon) after the command.
             </font>) sendln
      }{ } ifelse
      (<br>) sendln
     [(You can also retrieve the result by GET /?) httpd.textarea.name (=) ( encoded_codes  HTTP/1.0)] cat
     sendln
      (<br>) sendln
    [$<a href="http://localhost:$ httpd.port toString     [$<a href="http://localhost:$ httpd.port toString
     $/?msg=httpdAsirMeta+quit"> Shutdown the server. </a>, $      $/?msg=httpdAsirMeta+quit"> Shutdown the oxserver (and restart it). </a>$
    ] cat sendln     ] cat sendln
      (<h3 align="right"><font color="gree">Powered by OpenXM and httpd on Kan/sm1 </font> </h3>_) sendln
    0 sendln     0 sendln
    [(flush)] extension     [(flush)] extension
   ] pop    ] pop
Line 205  oxNoX 
Line 255  oxNoX 
    /result arg1 def     /result arg1 def
    (HTTP/0.9 200 OK) sendln     (HTTP/0.9 200 OK) sendln
    (Connection: close) sendln     (Connection: close) sendln
    (Content-Type: text/html) sendln     [(Content-length: ) result length toString ] cat sendln
      (Content-Type: text/plain) sendln
    0 sendln     0 sendln
   
    result sendln     result sendln
Line 215  oxNoX 
Line 266  oxNoX 
   popVariables    popVariables
 } def  } def
   
 %%******* Put initialization codes for ox_asir here.  /send-page-refused {
 /httpd.initialization    /arg1 set
  [    [/in-send-page-refused /reason] pushVariables
   (XM_debug=0; ctrl("debug_window",0); Xm_noX=1;)    [
   ("Asirweb version 0.80. "+     /reason arg1 def
    " Risa/Asir oxasir version "+rtostr(version());)     (HTTP/0.9 200 OK) sendln
  ] cat     (Connection: close) sendln
 def     (Content-Type: text/html) sendln
      0 sendln
   
     (<H2> Your request is refused. </H2> <br> ) sendln
     (Because your input contains the key word <font color="red">) sendln
     reason 0 get sendln
     ( </font> ) sendln
     (<br> <br>) sendln
     (Your input is <br> ) sendln
     (<pre> ) sendln
     reason 1 get sendln
     (</pre> ) sendln
   
      0 sendln
      [(flush)] extension
     ] pop
     popVariables
   } def
   
   %% **** Overwrites the definition in httpd.sm1
   /httpd_startserver {
      (httpd server accessible outside localhost.) message
      %%  get the hostname of this machine.
      [(sm1.socket) (open) [httpd.port
                            [(sm1.socket) (gethostname) [ ] ]extension ] ]
       extension
      /httpd.server.fdAndPort set
      (sm1.socket.open returns  ) messagen httpd.server.fdAndPort message
      [(sm1.socket) (accept) [httpd.server.fdAndPort 0 get]] extension
      /httpd.server.fd set
      (connected.) message
      (sm1.socket.accept returns <httpd.server.fd> ) messagen
      httpd.server.fd message
   
   } def
   
 %% ******* sample of cooked command  %% ******* sample of cooked command
 /cookedCommand {  /cookedCommand.simplest {
   /arg1 set    /arg1 set
   [/in-cookedCommand /httpd.com] pushVariables    [/in-cookedCommand /httpd.com] pushVariables
   [    [
Line 236  def
Line 321  def
   popVariables    popVariables
   arg1    arg1
 } def  } def
   /cookedCommand {
     /arg1 set
     [/in-cookedCommand /httpd.com /fff] pushVariables
     [
       /httpd.com arg1 def
       httpd.oxasir.timer not {
         [(if (1) {)  httpd.com  (; };)] cat
         /fff set
       }{
   %%  It does not work.
   %%      [$timer(30,eval_str("$
   %%          (if (1) {)  httpd.com  (; };)
   %%       $"),"Computation is aborted with the resource limit ( 30 seconds)");$
   %%      ] cat
        [$timer(30,$   httpd.com
           $,"Computation is aborted with the resource limit ( 30 seconds) or there was a syntax error.");$
        ] cat
         /fff set
       } ifelse
       (cooked command is ) messagen fff message
       /arg1 fff def
     ] pop
     popVariables
     arg1
   } def
   /httpd.refusedCommands
      [(shell) (eval_str) (ox_) (sm1_) (m_)
       (connect) (load)  (bload) (bsave)
       (end) (quit) (output) (bload27) (open)
       (plot) (ctrl) (debug) (error) (port) (bind) (accept)
       (draw)  (peek) (poke)
      ]
   def

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.7

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>