Annotation of OpenXM/src/kan96xx/Doc/httpd-sm1.sm1, Revision 1.8
1.8 ! takayama 1: %% $OpenXM: OpenXM/src/kan96xx/Doc/httpd-sm1.sm1,v 1.7 2001/08/21 14:21:29 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
39: (windows) eq {
40: [(getenv) (OSTYPE)] extension
41: (cygwin) eq {
42: sm1connectr %% Cygwin
43: }{
44: sm1connectr_win %% Native Windows.
1.7 takayama 45: } ifelse
1.3 takayama 46: }{
1.6 takayama 47: sm1connectr %% Unix
1.3 takayama 48: } ifelse
1.1 takayama 49: ox.ccc oxmathcap
50: ox.ccc oxsetmathcap
51: } ifelse
52:
53: /websm1 {
54: [/rrr ] pushVariables
55: [
56: %% This procedure to generate port number might fail.
57: [(oxGenPass)] extension . (integer) dc /rrr set
58: rrr << rrr 20000 idiv 20000 mul >> sub /rrr set
59: /httpd.port 1200 rrr add def
60: httpd.port message
61:
1.2 takayama 62: % [(sleep 3; start iexplore http://localhost:)
63: % httpd.port toString
64: % ( &)] cat system
1.6 takayama 65: [(ostype)] extension 0 get
66: (windows) eq {
67: %% On windows.
68: [(forkExec)
69: [
70: (c:/windows/command/start)
71: (iexplore) %% Starting internet explorer (TM).
72: [(http://localhost:) httpd.port toString] cat
73: ]
74: [ ]
75: 3] extension
76: }{
77: %% On unix.
78: [(sleep 3 ; netscape http://localhost:) httpd.port toString ( & ) ] cat
79: system
80: } ifelse
1.1 takayama 81: httpd ;
82: ] pop
83: popVariables
84: } def
85:
86:
87: /httpd_action {
88: [/in-httpd /ff /httpd.com /httpd.result /sss
1.3 takayama 89: /sss.engine /sss.web /err /httpd.sendFile
1.1 takayama 90: ] pushVariables
91: [
92: {
93: [(sm1.socket) (select) [httpd.server.fd 0 get -1]] extension
94: %% wait for ever
95: [(sm1.socket) (read) [httpd.server.fd 0 get ]] extension /ff set
96: ff length 0 eq {
97: (connection is closed.) message
98: }
99: {
100: (------------ start ----------------------) message
101: ff message
102: (-----------------------------------------) message
1.3 takayama 103: ff 1 copy askToSendFile /httpd.sendFile set
104: httpd.sendFile tag 0 eq {
105: ff removeGET webstringToAscii /httpd.com set
106: } {
107: /httpd.com (NONE) def
108: } ifelse
109: [(httpd.com=) httpd.com] cat message
110: (httpd.sendFile=) messagen httpd.sendFile message
1.1 takayama 111: (------------ end ----------------------) message
112: ( ) message
113: httpd.serial 0 eq {
114: /httpd.com httpd.initialization def
115: } { } ifelse
1.3 takayama 116: httpd.sendFile tag 0 eq { }
117: {
118: httpd.sendFile httpd.image.type send-image
119: exit %% exit the loop LOOP-A
120: } ifelse
1.1 takayama 121: httpd.com metaCommand {
122: httpd.textarea.valid {
123: ox.ccc
124: [ httpd.com ] cat
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>