[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.9 and 1.18

version 1.9, 2004/11/23 01:37:47 version 1.18, 2020/03/12 07:33:03
Line 1 
Line 1 
 % $OpenXM: OpenXM/src/kan96xx/Doc/cgi.sm1,v 1.8 2004/11/22 12:30:32 takayama Exp $  % $OpenXM: OpenXM/src/kan96xx/Doc/cgi.sm1,v 1.17 2013/10/11 01:08:35 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.
Line 41 
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 86 
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 99 
Line 103 
 /cgiPolymake {  /cgiPolymake {
   {    {
    [(getenv) (CONTENT_LENGTH)] extension /cgi.content_length 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 .. (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     [(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 217  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 {  %This host and cgi are version 2.0 polymake.  dim, ... are different with new versions.
   /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 /pid] 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
   
        /pid [(getpid)] extension toString def
   
   % step 2. Call the server and get the response in pp
        /cgi.verbose 1 def
        [(/tmp/sm1-q-cgi.txt) pid] cat (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) pid ( )] cat  ff1 (>/tmp/sm1-q-cgi-out.txt) pid] cat /ff set
        ff system
        [nl [(/tmp/sm1-q-cgi-out.txt) pid] cat pushfile] cat /pp set
   
   %% Store workfiles under OpenXM_tmp
        [(mkdir -p ) [(getenv) (OpenXM_tmp)] extension] cat system
        [(mv /tmp/sm1-q-cgi.txt) pid ( ) [(getenv) (OpenXM_tmp)] extension] cat system
        [(mv /tmp/sm1-q-cgi-out.txt) pid ( ) [(getenv) (OpenXM_tmp)] extension] cat system
   
        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
Line 233  def
Line 300  def
      ] /ff set       ] /ff set
      [(cgiKeyValuePairToUrlEncodingString) ff] extension /ff set       [(cgiKeyValuePairToUrlEncodingString) ff] extension /ff set
      [(POST ) , ff1 , ( HTTP/0.9) , nl ,       [(POST ) , ff1 , ( HTTP/0.9) , nl ,
       (Connection: Keep-Alive) , nl ,  %      (Connection: Keep-Alive) , nl ,
       (Content-length: ) , ff length (string) dc , nl ,        (HOST: ) cgiQueryPolymake.hostname , nl ,
       ff ] cat /sss2 set        (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
Line 265  def
Line 333  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  %/polymake.start { polymake.start.OoHG } def
   
 [(doPolymake.OoHG)  [(doPolymake.OoHG)
 [(It first looks for local polymake. If there is, it calls the local polymake.)  [(doPolymake.local calls the local polymake.)
  (If not, it calls http://polymake.math.kobe-u.ac.jp/cgi-bin/cgi-polymake.sh)   (This function 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.)
    (The host name and the cgi name are set to the variable)
    (   cgiQueryPolymake.hostname  and cgiQueryPolymake.cginame)
  (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 execute)
    (   usePolymake.OoHG.curl)
    (after loading cgi.sm1)
 ]] putUsages  ]] putUsages
 /doPolymake.OoHG  {  /doPolymake.OoHG  {
   /arg1 set    /arg1 set
Line 283  def
Line 365  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 300  def
Line 382  def
 % cgi-polymake  % cgi-polymake
        (Trying web service.) message         (Trying web service.) message
        pAction pNative  cgiQueryPolymake /doPolymake.OoHG.result set         pAction pNative  cgiQueryPolymake /doPolymake.OoHG.result set
          doPolymake.OoHG.result /@@@doPolymake.vars set
       [(regexec) (Not Found) [doPolymake.OoHG.result 0 get ]]        [(regexec) (Not Found) [doPolymake.OoHG.result 0 get ]]
       extension length 0 eq not {        extension length 0 eq not {
          doPolymake.OoHG.result message           doPolymake.OoHG.result message
Line 350  def
Line 432  def
      (polymake2tfb is not installed in this system.) error       (polymake2tfb is not installed in this system.) error
   } {  } ifelse    } {  } ifelse
 } def  } def
   
   
   /usePolymake.local {
     /doPolymake { doPolymake.local } def
     /polymake.start { polymake.start.local } def
   } def
   
   /usePolymake.OoHG.native {
     /doPolymake { doPolymake.OoHG } def
     /polymake.start { polymake.start.OoHG } def
     /cgiQueryPolymake { cgiQueryPolymake.native } def
   } def
   
   /usePolymake.OoHG.curl {
     [(which) (curl)] oxshell tag 0 eq {
        (Error in usePolymake.OoHG.curl: curl is not found.) error
     } { } ifelse
     /doPolymake { doPolymake.OoHG } def
     /polymake.start { polymake.start.OoHG } def
     /cgiQueryPolymake { cgiQueryPolymake.curl } def
   } def
   
   [(usePolymake.local)
   [(doPolymake calls local polymake)
   ]] putUsages
   
   [(usePolymake.OoHG.native)
   [(doPolymake = doPolymake.OoHG with cgiQueryPolymake.native)
    (cf. doPolymake.OoHG)
    (hostname is set in cgiQueryPolymake.hostname)
    (cginame is set in  cgiQueryPolymake.cginame)
   ]] putUsages
   
   [(usePolymake.OoHG.curl)
   [(doPolymake = doPolymake.OoHG with cgiQueryPolymake.curl)
    (It should be used when cgiQueryPolymake.native does not work)
    (over, e.g., a reverse proxy.)
    (The command curl is required.  cf. cgi.verbose, doPolymake.OoHG)
    (hostname is set in cgiQueryPolymake.hostname)
    (cginame is set in  cgiQueryPolymake.cginame)
   ]] putUsages
   
   
   
   
   
   
   

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.18

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