version 1.1, 2001/08/09 13:05:49 |
version 1.7, 2001/08/21 14:21:29 |
|
|
%% $OpenXM$ |
%% $OpenXM: OpenXM/src/kan96xx/Doc/httpd-sm1.sm1,v 1.6 2001/08/21 14:12:45 takayama Exp $ |
%% http server by sm1 |
%% http server by sm1 |
%% You need to set IE (internet explorer) as follows: |
%% Note to run on the Windows (TM). |
%% (1) Visit the menu |
%% (A) You need to set IE (internet explorer) as follows: |
%% tool / internet option / connection / LAN configuration |
%% (1) Visit the menu |
%% (2) Add localhost to the list of not using the proxy server. |
%% tool / internet option / connection / LAN configuration |
|
%% (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, ox_sm1.exe and ox.exe |
|
|
|
|
|
/httpd.image.name (kobeuniv2.jpg) def |
|
/httpd.image.type (jpeg) def |
/httpd.port 1200 def |
/httpd.port 1200 def |
|
|
/httpd.initialization |
/httpd.initialization |
|
|
] cat |
] cat |
def |
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 { |
(ox_sm1.started) boundp { |
} { |
} { |
%% Initialize oxasir. |
%% Initialize ox_sm1 |
sm1connectr |
[(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 oxmathcap |
ox.ccc oxsetmathcap |
ox.ccc oxsetmathcap |
} ifelse |
} ifelse |
|
|
/httpd.port 1200 rrr add def |
/httpd.port 1200 rrr add def |
httpd.port message |
httpd.port message |
|
|
[(sleep 3; start iexplore http://localhost:) |
% [(sleep 3; start iexplore http://localhost:) |
httpd.port toString |
% httpd.port toString |
( &)] cat system |
% ( &)] cat system |
|
[(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 ; |
httpd ; |
] pop |
] pop |
popVariables |
popVariables |
|
|
10 (string) dc /mmm set |
10 (string) dc /mmm set |
} ifelse |
} ifelse |
[(sm1.socket) (select) [httpd.server.fd 0 get 0]] extension { |
[(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 |
[(sm1.socket) (write) [httpd.server.fd 0 get mmm]] extension message |
} ifelse |
} ifelse |
|
|
popVariables |
popVariables |
} def |
} 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 { |
/httpd.serial 0 def |
/httpd.serial 0 def |
/httpd.history [ ] def |
/httpd.history [ ] def |
|
/httpd.result.history [ 0 ] def |
{ |
{ |
httpd_startserver ; |
httpd_startserver ; |
httpd_action ; |
httpd_action ; |
|
|
|
|
/httpd_action { |
/httpd_action { |
[/in-httpd /ff /httpd.com /httpd.result /sss |
[/in-httpd /ff /httpd.com /httpd.result /sss |
/sss.engine /sss.web /err |
/sss.engine /sss.web /err /httpd.sendFile |
] pushVariables |
] pushVariables |
[ |
[ |
{ |
{ |
|
|
(------------ start ----------------------) message |
(------------ start ----------------------) message |
ff message |
ff message |
(-----------------------------------------) message |
(-----------------------------------------) message |
ff removeGET webstringToAscii /httpd.com set |
ff 1 copy askToSendFile /httpd.sendFile set |
httpd.com message |
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 |
(------------ end ----------------------) message |
( ) message |
( ) message |
httpd.serial 0 eq { |
httpd.serial 0 eq { |
/httpd.com httpd.initialization def |
/httpd.com httpd.initialization def |
} { } ifelse |
} { } ifelse |
|
httpd.sendFile tag 0 eq { } |
|
{ |
|
httpd.sendFile httpd.image.type send-image |
|
exit %% exit the loop LOOP-A |
|
} ifelse |
httpd.com metaCommand { |
httpd.com metaCommand { |
httpd.textarea.valid { |
httpd.textarea.valid { |
ox.ccc |
ox.ccc |
|
|
} ifelse |
} ifelse |
(<font color="green"> Output-) httpd.serial toString |
(<font color="green"> Output-) httpd.serial toString |
(: </font> ) |
(: </font> ) |
|
(<a href=") httpd.image.name ("> (in pretty format) </a>) %%test |
httpd.result preformatHTML |
httpd.result preformatHTML |
|
httpd.result.history httpd.result append /httpd.result.history set |
] cat |
] cat |
send-page-3 exit |
send-page-3 exit %% exit the loop LOOP-A |
} { exit } ifelse %% metaCommand |
} { exit } ifelse %% metaCommand |
} ifelse |
} ifelse |
} loop |
} loop %% LOOP-A |
] pop |
] pop |
popVariables |
popVariables |
} def |
} def |
|
|
0 sendln |
0 sendln |
%% (<FORM NAME="myFORM" METHOD="POST">) sendln |
%% (<FORM NAME="myFORM" METHOD="POST">) sendln |
result sendln |
result sendln |
|
|
|
%%(<img src="hoge.jpeg"> <img>) sendln %%test. It does not work always?! |
|
%%(<a href="hoge.jpeg"> Pretty format </a>) sendln %%test. It works. |
|
|
(<FORM NAME="myFORM">) sendln |
(<FORM NAME="myFORM">) sendln |
(<INPUT TYPE=submit VALUE="submit">) sendln |
(<INPUT TYPE=submit VALUE="submit">) sendln |
[(<textarea name=) httpd.textarea.name |
[(<textarea name=) httpd.textarea.name |
|
|
popVariables |
popVariables |
} def |
} def |
|
|
|
/send-image { |
|
/arg2 set |
|
/arg1 set |
|
[/in-send-jpeg /fname /imagetype /ff /fsize] pushVariables |
|
[ |
|
/fname arg1 def % set the jpeg file name. |
|
/imagetype arg2 def % jpeg or gif |
|
[(stat) fname] extension 0 get tag 0 eq { |
|
(Warning (send-image): the file ) messagen fname messagen ( is not found.) message |
|
/notFound goto |
|
}{ }ifelse |
|
[(stat) fname] extension 1 get 0 get toString /fsize set |
|
(HTTP/1.1 200 OK) dup message sendln |
|
(Server: httpd_sm1) dup message sendln |
|
%% (ETag: "2197-bf6c-3b2d6541") sendln ??? |
|
(Accept-Ranges: bytes) dup message sendln |
|
[(Content-Length: ) fsize] cat dup message sendln |
|
(Connection: close) dup message sendln |
|
[(Content-Type: image/) imagetype] cat dup message sendln |
|
[(flush)] extension |
|
0 sendln |
|
fname sendBinaryFile |
|
0 sendln |
|
[(flush)] extension |
|
/notFound |
|
] pop |
|
popVariables |
|
} def |
|
|
/httpd.sm1man |
/httpd.sm1man |
("http://www.math.sci.kobe-u.ac.jp/OpenXM/1.1.3/doc/asir2000/html-jp/man_toc.html") |
("http://www.math.sci.kobe-u.ac.jp/OpenXM/1.1.3/doc/kan96xx/onlinehelp/index.html") |
def |
def |
/httpd.sm1man.index |
/httpd.sm1man.index |
("http://www.math.sci.kobe-u.ac.jp/OpenXM/1.1.3/doc/asir2000/html-jp/man_262.html#SEC262") |
("http://www.math.sci.kobe-u.ac.jp/OpenXM/1.1.3/doc/asir2000/html-jp/man_262.html#SEC262") |
def |
def |
/httpd.asir.intro |
/httpd.asir.intro |
("http://www.math.sci.kobe-u.ac.jp/~taka/asir-book-html/main") |
("http://www.math.sci.kobe-u.ac.jp/OpenXM/1.1.3/doc/kan96xx/ttt/index.html") |
def |
def |
/send-menu-1 { |
/send-menu-1 { |
|
|
|
|
(HELP:) sendln |
(HELP:) sendln |
[(<font color="red"> |
[(<font color="red"> |
<a href=) httpd.sm1man ( > Sm1manual (Ja) </a> </font>, )] cat sendln |
<a href=) httpd.sm1man ( > Sm1manual (Ja) </a> </font>, )] cat sendln |
[(<font color="purple"> |
|
<a href=) httpd.sm1man.index ( > Index (Ja) </a> </font>, )] cat sendln |
|
[(<font color="blue"> |
[(<font color="blue"> |
<a href=) httpd.asir.intro ( > Intro (Ja) </a> </font>, )] cat sendln |
<a href=) httpd.asir.intro ( > Intro (Ja) </a> </font>, )] cat sendln |
} def |
} def |
|
|
(array) dc |
(array) dc |
def |
def |
} ifelse |
} ifelse |
|
|
|
|
|
%% Decompose into tokens separated by a space. |
|
%% (GET /hoge.jpeg ???) ---> [(GET) (/hoge.jpeg) (???)] |
|
/toTokensBySpace { |
|
/arg1 set |
|
[/in-toTokesBySpace /ss /ss2 /i] pushVariables |
|
[ |
|
/ss arg1 def |
|
ss 1 copy /ss set |
|
ss (array) dc /ss2 set |
|
0 1 ss2 length 1 sub { |
|
/i set |
|
ss2 i get 32 eq { %% equal to space |
|
ss i (,) put |
|
} { } ifelse |
|
} for |
|
ss message |
|
[ ss to_records pop] /arg1 set |
|
] pop |
|
popVariables |
|
arg1 |
|
} def |
|
|
|
/askToSendFile { |
|
/arg1 set |
|
[/in-askToSendFile /ss /fname] pushVariables |
|
[ |
|
/ss arg1 def |
|
/fname null def |
|
ss toTokensBySpace /ss set |
|
ss 0 get (GET) eq { |
|
ss 1 get length 1 gt { |
|
ss 1 get (array) dc 1 get 63 eq { %% See if /? |
|
/fname null def |
|
}{ |
|
/fname ss 1 get def % set the file name. |
|
fname (array) dc rest /fname set % remove / |
|
fname { (string) dc } map cat /fname set |
|
} ifelse |
|
}{ /fname null def } ifelse |
|
}{ |
|
/fname null def |
|
} ifelse |
|
(::::) messagen ss message fname message |
|
/arg1 fname def |
|
] pop |
|
popVariables |
|
arg1 |
|
} def |
|
|
%% remove GET /?msg= |
%% remove GET /?msg= |
/removeGET { |
/removeGET { |