version 1.1, 2004/09/24 08:35:47 |
version 1.2, 2004/09/24 13:15:27 |
|
|
% $OpenXM$ |
% $OpenXM: OpenXM/src/kan96xx/Doc/cgi.sm1,v 1.1 2004/09/24 08:35:47 takayama Exp $ |
|
|
% (OpenXM) queryGoogle --> it does not work well. |
% A sample code |
/queryGoogle { |
% (OpenXM) cgiQueryGoogle --> it does not work well. |
|
/cgiQueryGoogle { |
/key set |
/key set |
[[(URL),(/search)], |
[[(URL),(/search)], |
[(hl),(ja)], |
[(hl),(ja)], |
|
|
|
|
[(sm1.socket) (connect) [80 (www.google.co.jp)]] extension 0 get /goo set |
[(sm1.socket) (connect) [80 (www.google.co.jp)]] extension 0 get /goo set |
[(sm1.socket) (write) [goo sss2]] extension |
[(sm1.socket) (write) [goo sss2]] extension |
[(sm1.socket) (select) [goo -1]] extension |
goo readHTTP0 /pp set |
[(sm1.socket) (read) [goo]] extension /pp set % use httpRead instead? |
|
pp message |
pp message |
[(sm1.socket) (close) [goo]] extension |
[(sm1.socket) (close) [goo]] extension |
[(cgiHttpToKeyValuePair) pp] extension /pp2 set |
[(cgiHttpToKeyValuePair) pp] extension /pp2 set |
} def |
} def |
|
|
% (www.math.kobe-u.ac.jp) getIndex |
% A sample |
/getIndex { |
% (www.math.kobe-u.ac.jp) cgiGetIndex |
|
/cgiGetIndex { |
/url set |
/url set |
[[(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 |
|
|
sss2 message |
sss2 message |
[(sm1.socket) (connect) [80 url]] extension 0 get /goo set |
[(sm1.socket) (connect) [80 url]] extension 0 get /goo set |
[(sm1.socket) (write) [goo sss2]] extension |
[(sm1.socket) (write) [goo sss2]] extension |
[(sm1.socket) (select) [goo -1]] extension |
goo readHTTP0 /pp set |
[(sm1.socket) (read) [goo]] extension /pp set |
|
pp message |
pp message |
[(sm1.socket) (close) [goo]] extension |
[(sm1.socket) (close) [goo]] extension |
[(cgiHttpToKeyValuePair) pp] extension /pp2 set |
[(cgiHttpToKeyValuePair) pp] extension /pp2 set |
|
} def |
|
|
|
/readHTTP0 { |
|
/arg1 set |
|
[/fd /sss /pp /pp2 /nn] pushVariables |
|
[ |
|
/fd arg1 def |
|
/sss [ ] def |
|
{ |
|
[(sm1.socket) (select) [fd -1]] extension { |
|
} { (select error) error } ifelse |
|
|
|
[(sm1.socket) (read) [fd]] extension /pp set |
|
pp length 0 eq { exit } { } ifelse |
|
sss pp append /sss set |
|
} loop |
|
sss cat /arg1 set |
|
] pop |
|
popVariables |
|
arg1 |
|
} def |
|
|
|
% oxMessageBody=FACET input-data |
|
/cgiPolymake { |
|
[(getenv) (QUERY_STRING)] extension cgiPolymake.0 |
|
} def |
|
/cgiPolymake.0 { |
|
/arg1 set |
|
[/sss /kv /comm /i /acti0 /pError] pushVariables |
|
[ |
|
/sss arg1 def |
|
[(cgiUrlEncodingToKeyValuePair) sss] extension /kv set |
|
kv (oxMessageBody) getNode /comm set |
|
comm (array) dc /comm set |
|
/i 0 def |
|
[ |
|
0 1, comm length 1 sub { |
|
/i set |
|
comm,i,get 33 lt { |
|
exit |
|
} { comm,i,get } ifelse |
|
} for |
|
] /acti0 set |
|
acti0 { (string) dc } map cat /acti0 set |
|
|
|
/cgi.body comm def |
|
0 1 i { |
|
cgi.body rest /cgi.body set |
|
} for |
|
cgi.body { (string) dc } map cat /cgi.body set |
|
|
|
% acti0 cgi.body |
|
/pError [ ] def |
|
% bug: cgi.body --> oxsVarToFile(), value is not a string object ... |
|
% [(polymake) (stringInOut://cgi.body) acti0] addStdoutStderr |
|
/aaa cgi.body def |
|
[(polymake) (stringInOut://aaa) acti0] addStdoutStderr |
|
oxshell pop |
|
pError [@@@stdout @@@stderr] append /pError set |
|
] pop |
|
popVariables |
|
} def |
|
|
|
/cgi.test0 { |
|
[[(URL) (hoge)] |
|
[(oxMessageBody) |
|
[(FACETS ) |
|
(POINTS) nl |
|
(1 0 0) nl |
|
(1 1 0) nl |
|
(1 0 1) nl |
|
(1 1 1) nl ] cat |
|
]] /ff set |
|
[(cgiKeyValuePairToUrlEncodingString) ff] extension /ff1 set |
|
ff1 message |
|
ff1 cgiPolymake.0 |
|
cgi.body message |
} def |
} def |
|
|