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

Diff for /OpenXM/src/kan96xx/Doc/cgi.sm1 between version 1.4 and 1.15

version 1.4, 2004/09/27 08:32:05 version 1.15, 2013/09/22 08:07:51
Line 1 
Line 1 
 % $OpenXM: OpenXM/src/kan96xx/Doc/cgi.sm1,v 1.3 2004/09/27 01:20:46 takayama Exp $  % $OpenXM: OpenXM/src/kan96xx/Doc/cgi.sm1,v 1.14 2013/09/22 05:17:17 takayama Exp $
 %  OpenXM/src/polymake/cgi/cgi-polymake.sh  %  OpenXM/src/polymake/cgi/cgi-polymake.sh
 %   is a shell script to call sm1/polymake as a CGI script.  %   is a shell script to call sm1/polymake as a CGI script.
 %  Override as /doPolymake {doPolymake.OoHG} def if you need.  %  Override as /doPolymake {doPolymake.OoHG} def if you need.
   
   /cgi.verbose 0 def
   
 [(plugin-cgi)  [(plugin-cgi)
 [(Key words: )  [(Key words: )
  ( cgiUrlEncodingToKeyValuePair)   ( cgiUrlEncodingToKeyValuePair)
Line 39 
Line 41 
    [[(URL),(/index.html)]     [[(URL),(/index.html)]
    ] /kv set     ] /kv set
    [(cgiKeyValuePairToUrlEncodingString) kv] extension /sss set     [(cgiKeyValuePairToUrlEncodingString) kv] extension /sss set
    [(GET ) , sss , ( HTTP/0.9) , nl , nl ] cat /sss2 set  %   [(GET ) , sss , ( HTTP/0.9) , nl , nl ] cat /sss2 set
      [(GET ) , sss , ( HTTP/0.9) ,  nl ,
       (HOST: ) , url , nl
       nl ] cat /sss2 set
   
    sss2 message     sss2 message
    [(sm1.socket) (connect) [80 url]] extension 0 get /goo set     [(sm1.socket) (connect) [80 url]] extension 0 get /goo set
Line 84 
Line 89 
 /cgiPolymake.polymakeName (polymake) def  /cgiPolymake.polymakeName (polymake) def
 %/cgiPolymake.polymakeName (polymake_dummy) def  %/cgiPolymake.polymakeName (polymake_dummy) def
 %/cgiPolymake.polymakeName (hoge) def  %/cgiPolymake.polymakeName (hoge) def
   /cgiPolymake.log 1 def
   
 [(cgiPolymake)  [(cgiPolymake)
 [(Make sm1 to a polymake server based on CGI/OoHG)  [(Make sm1 to a polymake server based on CGI/OoHG)
Line 91 
Line 97 
 ]] putUsages  ]] putUsages
 % Server-side-script  % Server-side-script
 % oxMessageBody=action input-data-for-polymake  % oxMessageBody=action input-data-for-polymake
 % sm1 -q -s "[(parse) (cgi.sm1) pushfile] extension cgiPolymake quit "  % t.t : oxMessageBody=FACETS++POINTS%0A1+0+0+%0A1+1+0+%0A1+0+1%0A
 % env QUERY_STRING="t?oxMessageBody=FACETS+POINTS+1+0+0%0A" sm1 -q -s "[(parse) (cgi.sm1) pushfile] extension cgiPolymake quit "  %   t?oxMe...
   % env CONTENT_LENGTH=57 sm1 -q -s "[(parse) (cgi.sm1) pushfile] extension cgiPolymake quit " <t.t
 /cgiPolymake {  /cgiPolymake {
   {    {
    [(getenv) (QUERY_STRING)] extension /cgi.query_string set     [(getenv) (CONTENT_LENGTH)] extension /cgi.content_length set
      cgi.content_length isString {
      } {
          cgiPolymake.errorMessage message  exit
      } ifelse
      cgi.content_length .. (integer) dc /cgi.content_length set
      cgi.content_length 1 lt {
          cgiPolymake.errorMessage message  exit
      } { } ifelse
      [(read) 0 cgi.content_length] extension /cgi.query_string set
      cgiPolymake.log {
         cgi.query_string (string) dc sm1log
      } { } ifelse
    cgi.query_string isString {     cgi.query_string isString {
      cgi.query_string length 0 eq  {       cgi.query_string length 0 eq  {
        cgiPolymake.errorMessage message  exit         cgiPolymake.errorMessage message  exit
Line 123 
Line 142 
     (1 1 0 ) nl      (1 1 0 ) nl
     (1 0 1 ) nl      (1 0 1 ) nl
     (</pre>) nl      (</pre>) nl
     (<form>) nl      (<form method="POST">) nl
     (<input type=submit>) nl      (<input type=submit>) nl
     (<textarea name="oxMessageBody") nl      (<textarea name="oxMessageBody") nl
     ( rows=10 cols="80" wrap="soft"></textarea>) nl      ( rows=10 cols="80" wrap="soft"></textarea>) nl
Line 141  def
Line 160  def
   [    [
     /sss arg1 def      /sss arg1 def
 % Step 1.  analyze the query string in URL encoding.  % Step 1.  analyze the query string in URL encoding.
     [(cgiUrlEncodingToKeyValuePair) [(?) sss] cat] extension /kv set      [(cgiUrlEncodingToKeyValuePair) sss] extension /kv set
     kv (oxMessageBody) getNode /comm set      kv (oxMessageBody) getNode /comm set
 %   [nl nl] cat message sss message kv message  % for debug.  %   [nl nl] cat message sss message kv message  % for debug.
 % Step 2. Extract action part and file part for polymake.  % Step 2. Extract action part and file part for polymake.
Line 212  def
Line 231  def
 % ------------  client side script ---------------  % ------------  client side script ---------------
 /cgiQueryPolymake.hostname (polymake.math.kobe-u.ac.jp) def  /cgiQueryPolymake.hostname (polymake.math.kobe-u.ac.jp) def
 /cgiQueryPolymake.cginame (/cgi-bin/cgi-polymake.sh) def  /cgiQueryPolymake.cginame (/cgi-bin/cgi-polymake.sh) def
 /cgiQueryPolymake {  %/cgiQueryPolymake { cgiQueryPolymake.curl } def
   /cgiQueryPolymake { cgiQueryPolymake.native } def
   /cgiQueryPolymake.curl {
   /arg2 set /arg1 set    /arg2 set /arg1 set
     [/saction /sfile /ff /ff1 /sss2 /goo /pp /pp2 /key /body /fd] pushVariables
     [
       /saction arg1 def /sfile arg2 def
   % step1. Generate query in URL encoding.
        [(http://) cgiQueryPolymake.hostname cgiQueryPolymake.cginame] cat
        /ff1 set
   % full URL necessary for virtual host of apache.
        [[(oxMessageBody)
          [saction ( )
           sfile nl ] cat
          ]
        ] /ff set
   
        ff 0 get 0 get /key set
        ff 0 get 1 get /body set
   % step 2. Call the server and get the response in pp
        /cgi.verbose 1 def
        (/tmp/sm1-q-cgi.txt) (w) file /fd set
        fd body writestring
        fd closefile
   %     [(curl) (--form) [key (=@/tmp/sm1-q-cgi.txt)] cat  ff1] /ff set
   %     ff  addStdoutStderr oxshell  @@@stdout /pp set
        [(curl  --form ) [key (=@/tmp/sm1-q-cgi.txt )] cat  ff1 (>/tmp/sm1-q-cgi-out.txt)] cat /ff set
        ff system
        [nl (/tmp/sm1-q-cgi-out.txt) pushfile] cat /pp set
   
        cgi.verbose { pp message } {  } ifelse
        [(cgiHttpToKeyValuePair) pp] extension /pp2 set
        pp2 message
   % step 3. Analyze the response.
        [pp2 (Content-Body) getNode
         pp2 (oxshell-stdout) getNode
         pp2 (oxshell-stderr) getNode
        ] /arg1 set
     ] pop
     popVariables
     arg1
   } def
   
   /cgiQueryPolymake.native {
     /arg2 set /arg1 set
   [/saction /sfile /ff /ff1 /sss2 /goo /pp /pp2] pushVariables    [/saction /sfile /ff /ff1 /sss2 /goo /pp /pp2] pushVariables
   [    [
     /saction arg1 def /sfile arg2 def      /saction arg1 def /sfile arg2 def
 % step1. Generate query in URL encoding.  % step1. Generate query in URL encoding.
     [[(URL) cgiQueryPolymake.cginame]       [(http://) cgiQueryPolymake.hostname cgiQueryPolymake.cginame] cat
      [(oxMessageBody)       /ff1 set
      [saction ( )  % full URL necessary for virtual host of apache.
       sfile nl ] cat       [[(oxMessageBody)
      ]] /ff set         [saction ( )
      [(cgiKeyValuePairToUrlEncodingString) ff] extension /ff1 set          sfile nl ] cat
      [(GET ) , ff1 , ( HTTP/0.9) , nl , nl ] cat /sss2 set         ]
        ] /ff set
        [(cgiKeyValuePairToUrlEncodingString) ff] extension /ff set
        [(POST ) , ff1 , ( HTTP/0.9) , nl ,
   %      (Connection: Keep-Alive) , nl ,
         (HOST: ) cgiQueryPolymake.hostname , nl ,
         (Content-length: ) , ff length (dollar) dc , nl , nl
         ff nl] cat /sss2 set
 % step 2. Call the server and get the response in pp  % step 2. Call the server and get the response in pp
      [(sm1.socket) (connect)       [(sm1.socket) (connect)
         [80 cgiQueryPolymake.hostname]] extension 0 get /goo set          [80 cgiQueryPolymake.hostname]] extension 0 get /goo set
      [(sm1.socket) (write) [goo sss2]]  extension       [(sm1.socket) (write) [goo sss2]]  extension
      goo readHTTP0 /pp set       goo readHTTP0 /pp set
      pp message  
        % For the case of error.
        [(regexec) (200 OK) [pp]] extension length 0 eq {
           (sss2=) message
           sss2 message
           (pp=) message
           pp message
           (cgi.sm1: there seems to be an error in the HTTP connection.)
        } { } ifelse
   
        cgi.verbose { pp message } {  } ifelse
      [(sm1.socket) (close) [goo]] extension       [(sm1.socket) (close) [goo]] extension
      [(cgiHttpToKeyValuePair) pp] extension /pp2 set       [(cgiHttpToKeyValuePair) pp] extension /pp2 set
   
Line 244  def
Line 323  def
   arg1    arg1
 } def  } def
   
   /cgi.test1 {
     (FACETS)
     [(POINTS) nl
      (1 0 0 ) nl
      (1 1 0 ) nl
      (1 0 1 ) nl
     ] cat
     cgiQueryPolymake message
   } def
 % Overrides doPolymake  % Overrides doPolymake
 %/doPolymake { doPolymake.OoHG } def  %/doPolymake { doPolymake.OoHG } def
   %/polymake.start { polymake.start.OoHG } def
   
 [(doPolymake.OoHG)  [(doPolymake.OoHG)
 [(It first looks for local polymake. If there is, it calls the local polymake.)  [(It first looks for local polymake. If there is, it calls the local polymake.)
  (If not, it calls http://polymake.math.kobe-u.ac.jp/cgi-bin/cgi-polymake.sh)   (If not, it calls http://polymake.math.kobe-u.ac.jp/cgi-bin/cgi-polymake.sh)
  (to make a computation in polymake.)   (to make a computation in polymake.)
  (See doPolymake for the syntax. doPolymake.OoHG may overrides doPolymake.)   (See doPolymake for the syntax. doPolymake.OoHG may overrides doPolymake.)
    (If you use curl to call the server set as follows after loading cgi.sm1)
    (/cgiQueryPolymake { cgiQueryPolymake.curl } def)
 ]] putUsages  ]] putUsages
 /doPolymake.OoHG  {  /doPolymake.OoHG  {
   /arg1 set    /arg1 set
Line 261  def
Line 352  def
   [    [
     arg1 0 get /pAction set      arg1 0 get /pAction set
     arg1 1 get /pData set      arg1 1 get /pData set
     polymake.start      polymake.start.OoHG
   
     /pError [ ] def      /pError [ ] def
 %% step 1:  polymake tfb ===> polymake native data  %% step 1:  polymake tfb ===> polymake native data
Line 279  def
Line 370  def
        (Trying web service.) message         (Trying web service.) message
        pAction pNative  cgiQueryPolymake /doPolymake.OoHG.result set         pAction pNative  cgiQueryPolymake /doPolymake.OoHG.result set
   
         [(regexec) (Not Found) [doPolymake.OoHG.result 0 get ]]
         extension length 0 eq not {
            doPolymake.OoHG.result message
            (The polymake cgi seems to be out of service.) error
         } {  } ifelse
   
       doPolymake.OoHG.result 0 get /pNative set        doPolymake.OoHG.result 0 get /pNative set
   
   
       pError doPolymake.OoHG.result rest append /pError set        pError doPolymake.OoHG.result rest append /pError set
     } {      } {
 % local polymake  % local polymake
Line 301  def
Line 400  def
   ] pop    ] pop
   popVariables    popVariables
   arg1    arg1
   } def
   
   /polymake.start.OoHG {
     (ox.k0.loaded) boundp {  }
     { [(parse) (ox.sm1) pushfile] extension
       /@@@polymake.k0.ccc [ ] def
     } ifelse
     @@@polymake.k0.ccc [ ] eq {
        k0connectr /@@@polymake.k0.ccc oxk0.ccc def /oxk0.ccc [ ] def
        @@@polymake.k0.ccc oxsetmathcap @@@polymake.k0.ccc oxmathcap
     } {  } ifelse
     @@@polymake.k0.ccc 0 get (closed) eq {
        k0connectr /@@@polymake.k0.ccc oxk0.ccc def /oxk0.ccc [ ] def
        @@@polymake.k0.ccc oxsetmathcap @@@polymake.k0.ccc oxmathcap
     } {  } ifelse
     [(which) (polymake2tfb)] oxshell tag 0 eq {
        (polymake2tfb is not installed in this system.) error
     } {  } ifelse
 } def  } def
   
   

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.15

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