=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/Doc/httpd-sm1.sm1,v retrieving revision 1.2 retrieving revision 1.7 diff -u -p -r1.2 -r1.7 --- OpenXM/src/kan96xx/Doc/httpd-sm1.sm1 2001/08/10 08:33:03 1.2 +++ OpenXM/src/kan96xx/Doc/httpd-sm1.sm1 2001/08/21 14:21:29 1.7 @@ -1,14 +1,17 @@ -%% $OpenXM: OpenXM/src/kan96xx/Doc/httpd-sm1.sm1,v 1.1 2001/08/09 13:05:49 takayama Exp $ +%% $OpenXM: OpenXM/src/kan96xx/Doc/httpd-sm1.sm1,v 1.6 2001/08/21 14:12:45 takayama Exp $ %% http server by sm1 +%% Note to run on the Windows (TM). %% (A) You need to set IE (internet explorer) as follows: %% (1) Visit the menu %% tool / internet option / connection / LAN configuration -%% (2) Add localhost to the list of not using the proxy server. +%% (2) Add localhost to the list of hosts which are not accessed via +%% the proxy server. %% (B) You need to have the "start.exe" at c:\windows\command\start.exe -%% (C) cygwin1.dll should be by sm1.exe and ox.exe +%% (C) cygwin1.dll should be by sm1.exe, ox_sm1.exe and ox.exe - +/httpd.image.name (kobeuniv2.jpg) def +/httpd.image.type (jpeg) def /httpd.port 1200 def /httpd.initialization @@ -20,11 +23,28 @@ ] cat def -[(parse) (ox-win.sm1) pushfile] extension +[(ostype)] extension 0 get +(windows) eq { + %% Native windows environment or cygwin. + [(parse) (ox-win.sm1) pushfile] extension +}{ + [(parse) (ox.sm1) pushfile] extension +} ifelse + (ox_sm1.started) boundp { } { - %% Initialize oxasir. - sm1connectr_win + %% Initialize ox_sm1 + [(ostype)] extension 0 get + (windows) eq { + [(getenv) (OSTYPE)] extension + (cygwin) eq { + sm1connectr %% Cygwin + }{ + sm1connectr_win %% Native Windows. + } ifelse + }{ + sm1connectr %% Unix + } ifelse ox.ccc oxmathcap ox.ccc oxsetmathcap } ifelse @@ -41,14 +61,22 @@ def % [(sleep 3; start iexplore http://localhost:) % httpd.port toString % ( &)] cat system - [(forkExec) - [ - (c:/windows/command/start) - (iexplore) %% Starting internet explorer (TM). - [(http://localhost:) httpd.port toString] cat - ] - [ ] - 3] extension + [(ostype)] extension 0 get + (windows) eq { + %% On windows. + [(forkExec) + [ + (c:/windows/command/start) + (iexplore) %% Starting internet explorer (TM). + [(http://localhost:) httpd.port toString] cat + ] + [ ] + 3] extension + }{ + %% On unix. + [(sleep 3 ; netscape http://localhost:) httpd.port toString ( & ) ] cat + system + } ifelse httpd ; ] pop popVariables @@ -83,7 +111,7 @@ def 10 (string) dc /mmm set } ifelse [(sm1.socket) (select) [httpd.server.fd 0 get 0]] extension { - (Warning: your peer closed the connection. Do not send the data.) message + (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 @@ -91,9 +119,33 @@ def 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 ; @@ -105,7 +157,7 @@ def /httpd_action { [/in-httpd /ff /httpd.com /httpd.result /sss - /sss.engine /sss.web /err + /sss.engine /sss.web /err /httpd.sendFile ] pushVariables [ { @@ -119,13 +171,24 @@ def (------------ start ----------------------) message ff message (-----------------------------------------) message - ff removeGET webstringToAscii /httpd.com set - httpd.com message + ff 1 copy askToSendFile /httpd.sendFile set + httpd.sendFile tag 0 eq { + ff removeGET webstringToAscii /httpd.com set + } { + /httpd.com (NONE) def + } ifelse + [(httpd.com=) httpd.com] cat message + (httpd.sendFile=) messagen httpd.sendFile message (------------ end ----------------------) message ( ) message httpd.serial 0 eq { /httpd.com httpd.initialization def } { } ifelse + httpd.sendFile tag 0 eq { } + { + httpd.sendFile httpd.image.type send-image + exit %% exit the loop LOOP-A + } ifelse httpd.com metaCommand { httpd.textarea.valid { ox.ccc @@ -195,12 +258,14 @@ def } ifelse ( Output-) httpd.serial toString (: ) + ( (in pretty format) ) %%test httpd.result preformatHTML + httpd.result.history httpd.result append /httpd.result.history set ] cat - send-page-3 exit + send-page-3 exit %% exit the loop LOOP-A } { exit } ifelse %% metaCommand } ifelse - } loop + } loop %% LOOP-A ] pop popVariables } def @@ -250,6 +315,10 @@ def 0 sendln %% (