=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/Doc/httpd.sm1,v retrieving revision 1.15 retrieving revision 1.22 diff -u -p -r1.15 -r1.22 --- OpenXM/src/kan96xx/Doc/httpd.sm1 2002/11/10 07:00:03 1.15 +++ OpenXM/src/kan96xx/Doc/httpd.sm1 2013/03/07 02:10:32 1.22 @@ -1,10 +1,20 @@ -%% $OpenXM: OpenXM/src/kan96xx/Doc/httpdsm1,v 1.14 2002/11/09 12:42:25 takayama Exp $ +%% $OpenXM: OpenXM/src/kan96xx/Doc/httpd.sm1,v 1.21 2012/12/23 01:27:54 takayama Exp $ %% common modules for httpd on sm1. +% [(Strict) 1] system_variable % for debugging. +/httpd.rawplus 0 def /Oxserver_history_variable (Oxserver_history_variable_) def /httpd.image.type [(getenv) (OpenXM_PSTOIMG_TYPE)] extension def +/httpd_sm1.cookie + [(oxGenPass)] extension +def +/httpd.set-cookie { + [(Set-Cookie: httpd_sm1=) httpd_sm1.cookie] cat +} def + + [(getenv) (OXWEB_DEBUG)] extension tag 0 eq { /httpd.debug 0 def } { @@ -134,6 +144,7 @@ def (HTTP/0.9 200 OK) sendln (Connection: close) sendln (Content-Type: text/html) sendln + httpd.set-cookie sendln 0 sendln %% (
) sendln result sendln @@ -287,27 +298,6 @@ def } 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 - httpd.debug { ss message } { } ifelse - [ ss to_records pop] /arg1 set - ] pop - popVariables - arg1 -} def /askToSendFile { /arg1 set @@ -427,7 +417,7 @@ def i 3 add /i set } { c 43 eq { % c == + - s j 32 put + httpd.rawplus { s j 43 put } { s j 32 put } ifelse j 1 add /j set i 1 add /i set } { @@ -454,6 +444,7 @@ def [/in-preformatHTML /sss /c] pushVariables [ /sss arg1 def + sss toString /sss set sss (array) dc /sss set sss { /c set @@ -762,18 +753,9 @@ def [/in-httpd_type /fname /ftype /i /ans] pushVariables [ /fname arg1 def - fname (array) dc /fname set - fname reverse /fname set - [ - 0 1 fname length 1 sub { - /i set - fname i get 46 eq { % '.' - exit - } { fname i get } ifelse - } for - ] /ftype set - ftype reverse {(string) dc} map cat /ftype set - /ans (text/plain) def + fname getFileType /ftype set + + /ans (text/plain) def % .txt, .jar, ftype (gif) eq { /ans (image/gif) def }{ } ifelse @@ -789,9 +771,12 @@ def ftype (html) eq ftype (htm) eq or { /ans (text/html) def } { } ifelse - ftype (txt) eq { - /ans (text/html) def - } { } ifelse + ftype (wav) eq { + /ans (audio/x-wav) def + } { } ifelse + ftype (class) eq { + /ans (application/octet-stream) def + } { } ifelse /arg1 ans def ] pop popVariables @@ -824,4 +809,49 @@ def ] pop popVariables arg1 +} def + +/httpd.startBrowserUnix { + /arg1 set + [/portnum /browser /cmd /fd /msg /htmlfn] pushVariables + [ + arg1 /portnum set + portnum toString /portnum set + [(getenv) (OX_BROWSER)] extension /browser set + { + browser tag 0 eq { + [(ostype)] extension 1 get (mac) eq { + [(sleep 3 ; open http://localhost:) portnum ( & ) ] cat + /cmd set cmd message + }{ + [(sleep 3 ; firefox http://localhost:) portnum ( & ) ] cat + /cmd set cmd message + }ifelse + cmd system + exit + }{ } ifelse + browser (mac) eq, browser (MAC) eq, or { + (.sm1.httpd.startBrowserUnix.html) /htmlfn set + htmlfn (w) file /fd set + fd tag 0 eq { (httpd.startBrowserUnix fails to open a file.) error } + { } ifelse + [() nl + () + (Click here to connect to the ox server) + () nl + () nl + ] cat /msg set + fd msg writestring fd closefile + [(sleep 3 ; open ) htmlfn ( &) ] cat + /cmd set cmd message + cmd system + exit + }{ } ifelse + [(sleep 3 ; ) browser ( http://localhost:) portnum ( & ) ] cat + /cmd set cmd message + cmd system + exit + } loop + ] pop + popVariables } def \ No newline at end of file