Annotation of OpenXM/src/kan96xx/Doc/httpd-sm1.sm1, Revision 1.14
1.14 ! takayama 1: %% $OpenXM: OpenXM/src/kan96xx/Doc/httpd-sm1.sm1,v 1.13 2002/10/17 13:40:28 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.1 takayama 89: ff length 0 eq {
90: (connection is closed.) message
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
108: } { } ifelse
1.3 takayama 109: httpd.sendFile tag 0 eq { }
110: {
111: httpd.sendFile httpd.image.type send-image
112: exit %% exit the loop LOOP-A
113: } ifelse
1.1 takayama 114: httpd.com metaCommand {
115: httpd.textarea.valid {
1.9 takayama 116: /oxserver.vname
117: [Oxserver_history_variable httpd.serial toString] cat
118: def
1.1 takayama 119: ox.ccc
1.9 takayama 120: [
121: httpd.com
122: ( /) oxserver.vname ( set )
123: oxserver.vname ( )
124: ] cat
1.1 takayama 125: oxexecutestring ;
126: }{
127: send-page-warning exit
128: } ifelse
129: [(oxReq) ox.ccc SM_dupErrors ] extension pop
130:
131: [(oxReq) ox.ccc SM_popCMO ] extension pop
132: [(oxReq) ox.ccc SM_popString ] extension pop
133: [(flush)] extension pop
134: %% Select inputs for interruption.
135: %% Wait by the spin lock.
136: {
137: [(oxMultiSelect) [ox.ccc] 1] extension 1 get 0 get
138: /sss.engine set
139: [(sm1.socket) (mselect)
140: [[httpd.server.fd 0 get] 1]
141: ] extension 0 get /sss.web set
142: /sss [sss.engine sss.web] def
143: sss.engine { exit } { } ifelse
144: sss.web { exit } { } ifelse
145: } loop
146: sss message
147:
148: sss 0 get {
149: [(oxGet) ox.ccc] extension /err set
150: [(oxGet) ox.ccc] extension /httpd.result set
151: %% ox.ccc oxpopstring /httpd.result set
152: } {
153: ox.ccc oxreset
154: ox.ccc ("computation is interrupted.";) oxexecutestring ;
155: ox.ccc oxpopstring
156: /httpd.result set
157: exit
158: } ifelse
159: (------------- result -------------) message
160: httpd.result message
161: (----------------------------------) message
162: ( ) message
163:
164: err message
165: err [ ] eq {
166: /httpd.history
167: httpd.history
168: [10 (string) dc
169: 37 (string) dc httpd.serial toString
170: 10 (string) dc
171: httpd.com
172: ( ) %% add extra ;
173: ] cat
174: append
175: def
176: } {
177: ox.ccc cleanErrors
178: [httpd.result 10 (string) dc err toString] cat
179: /httpd.result set
180: } ifelse
181:
182: [httpd.serial 0 eq { } {
183: (<title> Web/sm1 </title> )
184: (<font color="blue"> Input-) httpd.serial toString
185: (: </font> )
186: httpd.com preformatHTML (<br>)
187: } ifelse
188: (<font color="green"> Output-) httpd.serial toString
189: (: </font> )
1.3 takayama 190: (<a href=") httpd.image.name ("> (in pretty format) </a>) %%test
1.1 takayama 191: httpd.result preformatHTML
1.4 takayama 192: httpd.result.history httpd.result append /httpd.result.history set
1.1 takayama 193: ] cat
1.3 takayama 194: send-page-3 exit %% exit the loop LOOP-A
1.1 takayama 195: } { exit } ifelse %% metaCommand
196: } ifelse
1.3 takayama 197: } loop %% LOOP-A
1.1 takayama 198: ] pop
199: popVariables
200: } def
201:
202:
1.3 takayama 203:
1.1 takayama 204: /httpd.sm1man
1.5 takayama 205: ("http://www.math.sci.kobe-u.ac.jp/OpenXM/1.1.3/doc/kan96xx/onlinehelp/index.html")
1.1 takayama 206: def
207: /httpd.sm1man.index
208: ("http://www.math.sci.kobe-u.ac.jp/OpenXM/1.1.3/doc/asir2000/html-jp/man_262.html#SEC262")
209: def
210: /httpd.asir.intro
1.5 takayama 211: ("http://www.math.sci.kobe-u.ac.jp/OpenXM/1.1.3/doc/kan96xx/ttt/index.html")
1.1 takayama 212: def
213: /send-menu-1 {
214:
215: (FILE:) sendln
216: [$<a href="http://localhost:$ httpd.port toString
217: $/?msg=httpdAsirMeta+quit"> Shutdown the sm1 server. </a>, $
218: ] cat sendln
219: %% [$<a href="http://localhost:$ httpd.port toString
220: %% $/?msg=httpdAsirMeta+interrupt"> interrupt </a>, $
221: %% ] cat sendln
222: [$<a href="http://localhost:$ httpd.port toString
223: $/?msg=httpdAsirMeta+save"> save. </a>, $
224: ] cat sendln
225: ( <spacer type=horizontal size=80> ) sendln
226:
227: (HELP:) sendln
228: [(<font color="red">
229: <a href=) httpd.sm1man ( > Sm1manual (Ja) </a> </font>, )] cat sendln
230: [(<font color="blue">
231: <a href=) httpd.asir.intro ( > Intro (Ja) </a> </font>, )] cat sendln
232: } def
233:
234: /send-page-save {
235: [/in-send-page-save /i] pushVariables
236: [
237: (HTTP/0.9 200 OK) sendln
238: (Connection: close) sendln
239: (Content-Type: text/plain) sendln
240: 0 sendln
241: [37 (string) dc ( Saved the following to sm1out.txt )] cat sendln
242: [37 (string) dc ( Save the following by your browser as a text file. )]
243: cat sendln
244:
245: 0 1 httpd.history length 1 sub {
246: /i set
247: httpd.history i get sendln
248: } for
249: ( ) sendln
250: 0 sendln
251: [(flush)] extension
252: [(PrintDollar) 1] system_variable
253: httpd.history output
254: [(PrintDollar) 0] system_variable
255: ] pop
256: popVariables
257: } def
258:
259:
260: /metaCommand {
261: /arg1 set
262: [/in-metaCommand /msg /result] pushVariables
263: [
264: /msg arg1 def
265: /result 1 def
266: msg (httpdAsirMeta quit) eq {
267: ox.ccc ( quit ) oxsubmit
268: ox.ccc oxshutdown
269: send-page-bye
270: quit
271: /result 0 def
272: } { } ifelse
273: msg (httpdAsirMeta save) eq {
274: send-page-save
275: /result 0 def
276: } { } ifelse
277: msg (httpdAsirMeta interrupt) eq {
278: ox.ccc oxreset
279: (Interrupted! <br>) send-page-3
280: /result 0 def
281: } { } ifelse
282: /arg1 result def
283: ] pop
284: popVariables
285: arg1
286: } def
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>