Annotation of OpenXM/src/kan96xx/Doc/httpd-sm1.sm1, Revision 1.16
1.16 ! takayama 1: %% $OpenXM: OpenXM/src/kan96xx/Doc/httpd-sm1.sm1,v 1.15 2002/10/24 02:12:34 takayama Exp $
1.1 takayama 2: %% http server by sm1
1.3 takayama 3: %% Note to run on the Windows (TM).
1.2 takayama 4: %% (A) You need to set IE (internet explorer) as follows:
5: %% (1) Visit the menu
6: %% tool / internet option / connection / LAN configuration
1.3 takayama 7: %% (2) Add localhost to the list of hosts which are not accessed via
8: %% the proxy server.
1.2 takayama 9: %% (B) You need to have the "start.exe" at c:\windows\command\start.exe
1.3 takayama 10: %% (C) cygwin1.dll should be by sm1.exe, ox_sm1.exe and ox.exe
1.1 takayama 11:
1.8 takayama 12: [(parse) (httpd.sm1) pushfile] extension pop
1.1 takayama 13:
1.3 takayama 14: /httpd.image.name (kobeuniv2.jpg) def
15: /httpd.image.type (jpeg) def
1.1 takayama 16: /httpd.port 1200 def
17:
18: /httpd.initialization
19: %% Put initialization codes here.
20: [
21: ([$parse$ $cohom.sm1$ pushfile] extension
22: [$Web/sm1 version 0.80. $
23: $Kan/sm1 ox_sm1 version $ [$Version$] system_variable] cat)
24: ] cat
25: def
26:
1.6 takayama 27: [(ostype)] extension 0 get
28: (windows) eq {
29: %% Native windows environment or cygwin.
1.3 takayama 30: [(parse) (ox-win.sm1) pushfile] extension
31: }{
1.6 takayama 32: [(parse) (ox.sm1) pushfile] extension
1.3 takayama 33: } ifelse
34:
1.1 takayama 35: (ox_sm1.started) boundp {
36: } {
1.3 takayama 37: %% Initialize ox_sm1
1.6 takayama 38: [(ostype)] extension 0 get
1.10 takayama 39: sm1connectr
1.1 takayama 40: ox.ccc oxmathcap
41: ox.ccc oxsetmathcap
42: } ifelse
43:
44: /websm1 {
45: [/rrr ] pushVariables
46: [
47: %% This procedure to generate port number might fail.
48: [(oxGenPass)] extension . (integer) dc /rrr set
49: rrr << rrr 20000 idiv 20000 mul >> sub /rrr set
50: /httpd.port 1200 rrr add def
51: httpd.port message
52:
1.2 takayama 53: % [(sleep 3; start iexplore http://localhost:)
54: % httpd.port toString
55: % ( &)] cat system
1.6 takayama 56: [(ostype)] extension 0 get
57: (windows) eq {
58: %% On windows.
59: [(forkExec)
60: [
1.11 takayama 61: %%(c:/windows/command/start)
1.12 takayama 62: ox.win.start.0 aload pop
1.6 takayama 63: (iexplore) %% Starting internet explorer (TM).
64: [(http://localhost:) httpd.port toString] cat
65: ]
66: [ ]
67: 3] extension
68: }{
69: %% On unix.
70: [(sleep 3 ; netscape http://localhost:) httpd.port toString ( & ) ] cat
71: system
72: } ifelse
1.1 takayama 73: httpd ;
74: ] pop
75: popVariables
76: } def
77:
78:
79: /httpd_action {
80: [/in-httpd /ff /httpd.com /httpd.result /sss
1.3 takayama 81: /sss.engine /sss.web /err /httpd.sendFile
1.9 takayama 82: /oxserver.vname
1.1 takayama 83: ] pushVariables
84: [
85: {
86: [(sm1.socket) (select) [httpd.server.fd 0 get -1]] extension
87: %% wait for ever
1.14 takayama 88: [(sm1.socket) (readHTTP) [httpd.server.fd 0 get ]] extension /ff set
1.15 takayama 89: ff tag 0 eq {
90: (connection is closed.) message exit
1.1 takayama 91: }
92: {
93: (------------ start ----------------------) message
94: ff message
95: (-----------------------------------------) message
1.3 takayama 96: ff 1 copy askToSendFile /httpd.sendFile set
97: httpd.sendFile tag 0 eq {
98: ff removeGET webstringToAscii /httpd.com set
99: } {
100: /httpd.com (NONE) def
101: } ifelse
102: [(httpd.com=) httpd.com] cat message
103: (httpd.sendFile=) messagen httpd.sendFile message
1.1 takayama 104: (------------ end ----------------------) message
105: ( ) message
106: httpd.serial 0 eq {
107: /httpd.com httpd.initialization def
1.16 ! takayama 108: /httpd.textarea.valid 1 def
1.1 takayama 109: } { } ifelse
1.3 takayama 110: httpd.sendFile tag 0 eq { }
111: {
112: httpd.sendFile httpd.image.type send-image
113: exit %% exit the loop LOOP-A
114: } ifelse
1.1 takayama 115: httpd.com metaCommand {
116: httpd.textarea.valid {
1.9 takayama 117: /oxserver.vname
118: [Oxserver_history_variable httpd.serial toString] cat
119: def
1.1 takayama 120: ox.ccc
1.9 takayama 121: [
122: httpd.com
123: ( /) oxserver.vname ( set )
124: oxserver.vname ( )
125: ] cat
1.1 takayama 126: oxexecutestring ;
127: }{
128: send-page-warning exit
129: } ifelse
130: [(oxReq) ox.ccc SM_dupErrors ] extension pop
131:
132: [(oxReq) ox.ccc SM_popCMO ] extension pop
133: [(oxReq) ox.ccc SM_popString ] extension pop
134: [(flush)] extension pop
135: %% Select inputs for interruption.
136: %% Wait by the spin lock.
137: {
138: [(oxMultiSelect) [ox.ccc] 1] extension 1 get 0 get
139: /sss.engine set
140: [(sm1.socket) (mselect)
141: [[httpd.server.fd 0 get] 1]
142: ] extension 0 get /sss.web set
143: /sss [sss.engine sss.web] def
144: sss.engine { exit } { } ifelse
145: sss.web { exit } { } ifelse
146: } loop
147: sss message
148:
149: sss 0 get {
150: [(oxGet) ox.ccc] extension /err set
151: [(oxGet) ox.ccc] extension /httpd.result set
152: %% ox.ccc oxpopstring /httpd.result set
153: } {
154: ox.ccc oxreset
155: ox.ccc ("computation is interrupted.";) oxexecutestring ;
156: ox.ccc oxpopstring
157: /httpd.result set
158: exit
159: } ifelse
160: (------------- result -------------) message
161: httpd.result message
162: (----------------------------------) message
163: ( ) message
164:
165: err message
166: err [ ] eq {
167: /httpd.history
168: httpd.history
169: [10 (string) dc
170: 37 (string) dc httpd.serial toString
171: 10 (string) dc
172: httpd.com
173: ( ) %% add extra ;
174: ] cat
175: append
176: def
177: } {
178: ox.ccc cleanErrors
179: [httpd.result 10 (string) dc err toString] cat
180: /httpd.result set
181: } ifelse
182:
183: [httpd.serial 0 eq { } {
184: (<title> Web/sm1 </title> )
185: (<font color="blue"> Input-) httpd.serial toString
186: (: </font> )
187: httpd.com preformatHTML (<br>)
188: } ifelse
189: (<font color="green"> Output-) httpd.serial toString
190: (: </font> )
1.3 takayama 191: (<a href=") httpd.image.name ("> (in pretty format) </a>) %%test
1.1 takayama 192: httpd.result preformatHTML
1.4 takayama 193: httpd.result.history httpd.result append /httpd.result.history set
1.1 takayama 194: ] cat
1.3 takayama 195: send-page-3 exit %% exit the loop LOOP-A
1.1 takayama 196: } { exit } ifelse %% metaCommand
197: } ifelse
1.3 takayama 198: } loop %% LOOP-A
1.1 takayama 199: ] pop
200: popVariables
201: } def
202:
203:
1.3 takayama 204:
1.1 takayama 205: /httpd.sm1man
1.5 takayama 206: ("http://www.math.sci.kobe-u.ac.jp/OpenXM/1.1.3/doc/kan96xx/onlinehelp/index.html")
1.1 takayama 207: def
208: /httpd.sm1man.index
209: ("http://www.math.sci.kobe-u.ac.jp/OpenXM/1.1.3/doc/asir2000/html-jp/man_262.html#SEC262")
210: def
211: /httpd.asir.intro
1.5 takayama 212: ("http://www.math.sci.kobe-u.ac.jp/OpenXM/1.1.3/doc/kan96xx/ttt/index.html")
1.1 takayama 213: def
214: /send-menu-1 {
215:
216: (FILE:) sendln
217: [$<a href="http://localhost:$ httpd.port toString
218: $/?msg=httpdAsirMeta+quit"> Shutdown the sm1 server. </a>, $
219: ] cat sendln
220: %% [$<a href="http://localhost:$ httpd.port toString
221: %% $/?msg=httpdAsirMeta+interrupt"> interrupt </a>, $
222: %% ] cat sendln
223: [$<a href="http://localhost:$ httpd.port toString
224: $/?msg=httpdAsirMeta+save"> save. </a>, $
225: ] cat sendln
226: ( <spacer type=horizontal size=80> ) sendln
227:
228: (HELP:) sendln
229: [(<font color="red">
230: <a href=) httpd.sm1man ( > Sm1manual (Ja) </a> </font>, )] cat sendln
231: [(<font color="blue">
232: <a href=) httpd.asir.intro ( > Intro (Ja) </a> </font>, )] cat sendln
233: } def
234:
235: /send-page-save {
236: [/in-send-page-save /i] pushVariables
237: [
238: (HTTP/0.9 200 OK) sendln
239: (Connection: close) sendln
240: (Content-Type: text/plain) sendln
241: 0 sendln
242: [37 (string) dc ( Saved the following to sm1out.txt )] cat sendln
243: [37 (string) dc ( Save the following by your browser as a text file. )]
244: cat sendln
245:
246: 0 1 httpd.history length 1 sub {
247: /i set
248: httpd.history i get sendln
249: } for
250: ( ) sendln
251: 0 sendln
252: [(flush)] extension
253: [(PrintDollar) 1] system_variable
254: httpd.history output
255: [(PrintDollar) 0] system_variable
256: ] pop
257: popVariables
258: } def
259:
260:
261: /metaCommand {
262: /arg1 set
263: [/in-metaCommand /msg /result] pushVariables
264: [
265: /msg arg1 def
266: /result 1 def
267: msg (httpdAsirMeta quit) eq {
268: ox.ccc ( quit ) oxsubmit
269: ox.ccc oxshutdown
270: send-page-bye
271: quit
272: /result 0 def
273: } { } ifelse
274: msg (httpdAsirMeta save) eq {
275: send-page-save
276: /result 0 def
277: } { } ifelse
278: msg (httpdAsirMeta interrupt) eq {
279: ox.ccc oxreset
280: (Interrupted! <br>) send-page-3
281: /result 0 def
282: } { } ifelse
283: /arg1 result def
284: ] pop
285: popVariables
286: arg1
287: } def
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>