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