===================================================================
RCS file: /home/cvs/OpenXM/src/kan96xx/Doc/httpd-sm1.sm1,v
retrieving revision 1.7
retrieving revision 1.19
diff -u -p -r1.7 -r1.19
--- OpenXM/src/kan96xx/Doc/httpd-sm1.sm1 2001/08/21 14:21:29 1.7
+++ OpenXM/src/kan96xx/Doc/httpd-sm1.sm1 2009/02/22 17:30:03 1.19
@@ -1,4 +1,4 @@
-%% $OpenXM: OpenXM/src/kan96xx/Doc/httpd-sm1.sm1,v 1.6 2001/08/21 14:12:45 takayama Exp $
+%% $OpenXM: OpenXM/src/kan96xx/Doc/httpd-sm1.sm1,v 1.18 2005/11/17 08:15:51 takayama Exp $
%% http server by sm1
%% Note to run on the Windows (TM).
%% (A) You need to set IE (internet explorer) as follows:
@@ -9,6 +9,7 @@
%% (B) You need to have the "start.exe" at c:\windows\command\start.exe
%% (C) cygwin1.dll should be by sm1.exe, ox_sm1.exe and ox.exe
+[(parse) (httpd.sm1) pushfile] extension pop
/httpd.image.name (kobeuniv2.jpg) def
/httpd.image.type (jpeg) def
@@ -35,20 +36,32 @@ def
} {
%% Initialize ox_sm1
[(ostype)] extension 0 get
- (windows) eq {
- [(getenv) (OSTYPE)] extension
- (cygwin) eq {
- sm1connectr %% Cygwin
- }{
- sm1connectr_win %% Native Windows.
- } ifelse
- }{
- sm1connectr %% Unix
- } ifelse
+ sm1connectr
ox.ccc oxmathcap
ox.ccc oxsetmathcap
} ifelse
+/ox-win.start.iconic 1 def
+/ox.win.set.start {
+ [(stat) (c:\windows\system32\cmd.exe)] extension 0 get
+ 0 eq {
+ /ox.win.start.0 [(c:\windows\system32\cmd.exe) (/c) (start)] def
+ /ox.win.start [ox.win.start.0 aload pop
+ ox-win.start.iconic { (/min) } { } ifelse ] def
+ }{
+ [(stat) (c:\winnt\system32\cmd.exe)] extension 0 get
+ 0 eq {
+ /ox.win.start.0 [(c:\winnt\system32\cmd.exe) (/c) (start) ] def
+ /ox.win.start [ox.win.start.0 aload pop
+ ox-win.start.iconic { (/min) } { } ifelse ] def
+ }{
+ /ox.win.start.0 [ (start) ] def
+ /ox.win.start [ ox.win.start.0 aload pop
+ ox-win.start.iconic { (/min) } { } ifelse ] def
+ } ifelse
+ } ifelse
+} def
+
/websm1 {
[/rrr ] pushVariables
[
@@ -64,9 +77,11 @@ def
[(ostype)] extension 0 get
(windows) eq {
%% On windows.
+ ox.win.set.start
[(forkExec)
[
- (c:/windows/command/start)
+ %%(c:/windows/command/start)
+ ox.win.start.0 aload pop
(iexplore) %% Starting internet explorer (TM).
[(http://localhost:) httpd.port toString] cat
]
@@ -74,98 +89,26 @@ def
3] extension
}{
%% On unix.
- [(sleep 3 ; netscape http://localhost:) httpd.port toString ( & ) ] cat
- system
+ httpd.port httpd.startBrowserUnix
} ifelse
httpd ;
] pop
popVariables
} def
-/httpd_startserver {
- [(sm1.socket) (open) [httpd.port (localhost)]] extension
- /httpd.server.fdAndPort set
- (sm1.socket.open returns ) messagen httpd.server.fdAndPort message
- [(sm1.socket) (accept) [httpd.server.fdAndPort 0 get]] extension
- /httpd.server.fd set
- (connected.) message
- (sm1.socket.accept returns ) messagen httpd.server.fd message
-} def
-/httpd_stopserver {
- [(sm1.socket) (close) httpd.server.fd ] extension message
-} def
-
-/send_packet {
- /arg1 set
- [(sm1.socket) (write) [httpd.server.fd 0 get arg1]] extension message
-} def
-
-/sendln {
- /arg1 set
- [/in-sendln /mmm] pushVariables
- [ arg1 /mmm set
- mmm tag 5 eq {
- [mmm 10 (string) dc] cat /mmm set
- }{
- 10 (string) dc /mmm set
- } ifelse
- [(sm1.socket) (select) [httpd.server.fd 0 get 0]] extension {
- (Warning (sendln): your peer closed the connection. Do not send the data.) message
- } {
- [(sm1.socket) (write) [httpd.server.fd 0 get mmm]] extension message
- } ifelse
- ] pop
- popVariables
-} def
-
-/sendBinaryFile {
- /arg1 set
- [/in-sendln /fname /fd /c /cdata] pushVariables
- [ arg1 /fname set
- [(sendBinaryFile: sending data) ] cat message
- [(fp2openForRead) fname] extension /fd set fd message
- fd 0 lt {
- [(Error: sendBinaryFile: file ) fname ( is not found.)] cat message
- /aaaa goto
- } { } ifelse
- [(fp2pushfile) fname] extension /cdata set
- [(sm1.socket) (select) [httpd.server.fd 0 get 0]] extension {
- (Warning (sendBinaryFile): your peer closed the connection. Do not send the data.)
- message
- exit
- } {
- [(sm1.socket) (writeByte) [httpd.server.fd 0 get cdata]] extension pop
- } ifelse
- /aaaa
- ] pop
- popVariables
-} def
-
-/httpd {
- /httpd.serial 0 def
- /httpd.history [ ] def
- /httpd.result.history [ 0 ] def
- {
- httpd_startserver ;
- httpd_action ;
- httpd_stopserver ;
- (5 sleep) system
- httpd.serial 1 add /httpd.serial set
- } loop
-} def
-
/httpd_action {
[/in-httpd /ff /httpd.com /httpd.result /sss
/sss.engine /sss.web /err /httpd.sendFile
+ /oxserver.vname
] pushVariables
[
{
[(sm1.socket) (select) [httpd.server.fd 0 get -1]] extension
%% wait for ever
- [(sm1.socket) (read) [httpd.server.fd 0 get ]] extension /ff set
- ff length 0 eq {
- (connection is closed.) message
+ [(sm1.socket) (readHTTP) [httpd.server.fd 0 get ]] extension /ff set
+ ff tag 0 eq {
+ (connection is closed.) message exit
}
{
(------------ start ----------------------) message
@@ -183,6 +126,7 @@ def
( ) message
httpd.serial 0 eq {
/httpd.com httpd.initialization def
+ /httpd.textarea.valid 1 def
} { } ifelse
httpd.sendFile tag 0 eq { }
{
@@ -191,8 +135,15 @@ def
} ifelse
httpd.com metaCommand {
httpd.textarea.valid {
+ /oxserver.vname
+ [Oxserver_history_variable httpd.serial toString] cat
+ def
ox.ccc
- [ httpd.com ] cat
+ [
+ httpd.com
+ ( /) oxserver.vname ( set )
+ oxserver.vname ( )
+ ] cat
oxexecutestring ;
}{
send-page-warning exit
@@ -271,103 +222,15 @@ def
} def
-/send-page-bye {
- (HTTP/0.9 200 OK) sendln
-%% (Date: Sun, 18 Mar 2001 02:54:50 GMT) sendln
-%% (Server: sm1/0.1 (Unix)) sendln
-%% (Last-Modified: Wed, 23 Aug 2000 11:19:27 GMT) sendln
-%% (ETag: "1f8f-5df-39a3b33f") sendln
-%% (Accept-Ranges: bytes) sendln
-%% (Content-Length: 10) sendln
- (Connection: close) sendln
-% (Content-Type: text/plain) sendln
- (Content-Type: text/html) sendln
- 0 sendln
- () sendln
- (Shutdown the engine.
) sendln
- (See you! Web/sm1 ) sendln
- () sendln
- 0 sendln
- [(flush)] extension
-} def
-/send-page-2 {
- (HTTP/0.9 200 OK) sendln
-%% (Content-Length: 10) sendln
- (Connection: close) sendln
- (Content-Type: text/html) sendln
- 0 sendln
- (
) sss ()] cat /arg1 set - ] pop - popVariables - arg1 -} def /metaCommand { /arg1 set