Annotation of OpenXM/src/kan96xx/Doc/cgi.sm1, Revision 1.2
1.2 ! takayama 1: % $OpenXM: OpenXM/src/kan96xx/Doc/cgi.sm1,v 1.1 2004/09/24 08:35:47 takayama Exp $
1.1 takayama 2:
1.2 ! takayama 3: % A sample code
! 4: % (OpenXM) cgiQueryGoogle --> it does not work well.
! 5: /cgiQueryGoogle {
1.1 takayama 6: /key set
7: [[(URL),(/search)],
8: [(hl),(ja)],
9: [(ie),(UTF-8)],
10: [(q),key]] /kv set
11: [(cgiKeyValuePairToUrlEncodingString) kv] extension /sss set
12: [(GET ) , sss , ( HTTP/0.9) , nl , nl ] cat /sss2 set
13:
14: [(sm1.socket) (connect) [80 (www.google.co.jp)]] extension 0 get /goo set
15: [(sm1.socket) (write) [goo sss2]] extension
1.2 ! takayama 16: goo readHTTP0 /pp set
1.1 takayama 17: pp message
18: [(sm1.socket) (close) [goo]] extension
19: [(cgiHttpToKeyValuePair) pp] extension /pp2 set
20: } def
21:
1.2 ! takayama 22: % A sample
! 23: % (www.math.kobe-u.ac.jp) cgiGetIndex
! 24: /cgiGetIndex {
1.1 takayama 25: /url set
1.2 ! takayama 26: [[(URL),(/index.html)]
1.1 takayama 27: ] /kv set
28: [(cgiKeyValuePairToUrlEncodingString) kv] extension /sss set
29: [(GET ) , sss , ( HTTP/0.9) , nl , nl ] cat /sss2 set
30:
31: sss2 message
32: [(sm1.socket) (connect) [80 url]] extension 0 get /goo set
33: [(sm1.socket) (write) [goo sss2]] extension
1.2 ! takayama 34: goo readHTTP0 /pp set
1.1 takayama 35: pp message
36: [(sm1.socket) (close) [goo]] extension
37: [(cgiHttpToKeyValuePair) pp] extension /pp2 set
1.2 ! takayama 38: } def
! 39:
! 40: /readHTTP0 {
! 41: /arg1 set
! 42: [/fd /sss /pp /pp2 /nn] pushVariables
! 43: [
! 44: /fd arg1 def
! 45: /sss [ ] def
! 46: {
! 47: [(sm1.socket) (select) [fd -1]] extension {
! 48: } { (select error) error } ifelse
! 49:
! 50: [(sm1.socket) (read) [fd]] extension /pp set
! 51: pp length 0 eq { exit } { } ifelse
! 52: sss pp append /sss set
! 53: } loop
! 54: sss cat /arg1 set
! 55: ] pop
! 56: popVariables
! 57: arg1
! 58: } def
! 59:
! 60: % oxMessageBody=FACET input-data
! 61: /cgiPolymake {
! 62: [(getenv) (QUERY_STRING)] extension cgiPolymake.0
! 63: } def
! 64: /cgiPolymake.0 {
! 65: /arg1 set
! 66: [/sss /kv /comm /i /acti0 /pError] pushVariables
! 67: [
! 68: /sss arg1 def
! 69: [(cgiUrlEncodingToKeyValuePair) sss] extension /kv set
! 70: kv (oxMessageBody) getNode /comm set
! 71: comm (array) dc /comm set
! 72: /i 0 def
! 73: [
! 74: 0 1, comm length 1 sub {
! 75: /i set
! 76: comm,i,get 33 lt {
! 77: exit
! 78: } { comm,i,get } ifelse
! 79: } for
! 80: ] /acti0 set
! 81: acti0 { (string) dc } map cat /acti0 set
! 82:
! 83: /cgi.body comm def
! 84: 0 1 i {
! 85: cgi.body rest /cgi.body set
! 86: } for
! 87: cgi.body { (string) dc } map cat /cgi.body set
! 88:
! 89: % acti0 cgi.body
! 90: /pError [ ] def
! 91: % bug: cgi.body --> oxsVarToFile(), value is not a string object ...
! 92: % [(polymake) (stringInOut://cgi.body) acti0] addStdoutStderr
! 93: /aaa cgi.body def
! 94: [(polymake) (stringInOut://aaa) acti0] addStdoutStderr
! 95: oxshell pop
! 96: pError [@@@stdout @@@stderr] append /pError set
! 97: ] pop
! 98: popVariables
! 99: } def
! 100:
! 101: /cgi.test0 {
! 102: [[(URL) (hoge)]
! 103: [(oxMessageBody)
! 104: [(FACETS )
! 105: (POINTS) nl
! 106: (1 0 0) nl
! 107: (1 1 0) nl
! 108: (1 0 1) nl
! 109: (1 1 1) nl ] cat
! 110: ]] /ff set
! 111: [(cgiKeyValuePairToUrlEncodingString) ff] extension /ff1 set
! 112: ff1 message
! 113: ff1 cgiPolymake.0
! 114: cgi.body message
1.1 takayama 115: } def
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>