version 1.3, 2004/09/27 01:20:46 |
version 1.4, 2004/09/27 08:32:05 |
|
|
% $OpenXM: OpenXM/src/kan96xx/Doc/cgi.sm1,v 1.2 2004/09/24 13:15:27 takayama Exp $ |
% $OpenXM: OpenXM/src/kan96xx/Doc/cgi.sm1,v 1.3 2004/09/27 01:20:46 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. |
|
|
/cgiPolymake { |
/cgiPolymake { |
{ |
{ |
[(getenv) (QUERY_STRING)] extension /cgi.query_string set |
[(getenv) (QUERY_STRING)] extension /cgi.query_string set |
cgi.query_string isString { } |
cgi.query_string isString { |
|
cgi.query_string length 0 eq { |
|
cgiPolymake.errorMessage message exit |
|
} { } ifelse |
|
} |
{ |
{ |
cgiPolymake.errorMessage message exit |
cgiPolymake.errorMessage message exit |
} ifelse |
} ifelse |
cgi.body.http0 message |
cgi.body.http0 message |
cgi.query_string cgiPolymake.0 |
cgi.query_string cgiPolymake.0 |
cgi.body cgiReplyInHttp0 /cgi.body.http set |
cgi.body cgiReplyInHttp0 /cgi.body.http set |
cgi.body.http message |
cgi.body.http message |
exit |
exit |
} loop |
} loop |
|
[(flush)] extension |
} def |
} def |
/cgiPolymake.errorMessage |
/cgiPolymake.errorMessage |
[ (Content-Type: text/html) nl |
[ (Content-Type: text/html) nl |
|
|
(</pre>) nl |
(</pre>) nl |
(<form>) nl |
(<form>) nl |
(<input type=submit>) nl |
(<input type=submit>) nl |
(<textarea name="oxMesassageBody") nl |
(<textarea name="oxMessageBody") nl |
( rows=10 cols="80" wrap="soft"></textarea>) nl |
( rows=10 cols="80" wrap="soft"></textarea>) nl |
(</form>) nl |
(</form>) nl |
(</body></html>) nl |
(</body></html>) nl |
|
|
[ |
[ |
/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] extension /kv set |
[(cgiUrlEncodingToKeyValuePair) [(?) sss] cat] extension /kv set |
kv (oxMessageBody) getNode /comm set |
kv (oxMessageBody) getNode /comm set |
|
% [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. |
comm (array) dc /comm set |
comm (array) dc /comm set |
/i 0 def |
/i 0 def |
|
|
[cgiPolymake.polymakeName (stringInOut://cgi_body.poly) acti0] addStdoutStderr |
[cgiPolymake.polymakeName (stringInOut://cgi_body.poly) acti0] addStdoutStderr |
oxshell pop |
oxshell pop |
pError [@@@stdout @@@stderr] append /pError set |
pError [@@@stdout @@@stderr] append /pError set |
/cgi.body cgi_body def |
/cgi.body cgi_body def |
] pop |
] pop |
popVariables |
popVariables |
} def |
} def |
|
|
/ss arg1 def |
/ss arg1 def |
[[(Content-Body) ss] |
[[(Content-Body) ss] |
% [(Content-Type) (text/plain)] |
% [(Content-Type) (text/plain)] |
[(oxshell-stdout) @@@stdout] |
[(oxshell-stdout) [(cgiStringToUrlEncoding) @@@stdout] extension] |
[(oxshell-stderr) @@@stderr] |
[(oxshell-stderr) [(cgiStringToUrlEncoding) @@@stderr] extension] |
] /sskv set |
] /sskv set |
[(cgiKeyValuePairToHttpString) sskv] extension /arg1 set |
[(cgiKeyValuePairToHttpString) sskv] extension /arg1 set |
] pop |
] pop |
|
|
|
|
% ------------ 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 { |
/arg2 set /arg1 set |
/arg2 set /arg1 set |
[/saction /sfile /ff /ff1 /sss2 /goo /pp /pp2] pushVariables |
[/saction /sfile /ff /ff1 /sss2 /goo /pp /pp2] pushVariables |
|
|
@@@polymake.k0.ccc ( QuoteMode(0); ) oxexecutestring |
@@@polymake.k0.ccc ( QuoteMode(0); ) oxexecutestring |
[(treeToPolymake) ptree] extension /pNative set |
[(treeToPolymake) ptree] extension /pNative set |
%% step 2: calling the polymake |
%% step 2: calling the polymake |
[(which) (polymake)] oxshell tag 0 eq |
% [(which) (polymake)] oxshell tag 0 eq |
|
1 % always call web service |
{ |
{ |
% cgi-polymake |
% cgi-polymake |
(Trying web service.) message |
(Trying web service.) message |