===================================================================
RCS file: /home/cvs/OpenXM/src/kan96xx/Doc/httpd.sm1,v
retrieving revision 1.14
retrieving revision 1.17
diff -u -p -r1.14 -r1.17
--- OpenXM/src/kan96xx/Doc/httpd.sm1 2002/11/09 12:42:25 1.14
+++ OpenXM/src/kan96xx/Doc/httpd.sm1 2005/11/17 08:15:51 1.17
@@ -1,4 +1,4 @@
-%% $OpenXM: OpenXM/src/kan96xx/Doc/httpd.sm1,v 1.13 2002/11/03 12:43:03 takayama Exp $
+%% $OpenXM: OpenXM/src/kan96xx/Doc/httpd.sm1,v 1.16 2005/02/27 05:28:05 takayama Exp $
%% common modules for httpd on sm1.
/Oxserver_history_variable (Oxserver_history_variable_) def
/httpd.image.type
@@ -82,6 +82,7 @@ def
/httpd.serial 0 def
/httpd.history [ ] def
/httpd.result.history [ 0 ] def
+ [(nobody)] extension pop
{
httpd_startserver ;
httpd_action ;
@@ -286,27 +287,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
@@ -453,6 +433,7 @@ def
[/in-preformatHTML /sss /c] pushVariables
[
/sss arg1 def
+ sss toString /sss set
sss (array) dc /sss set
sss {
/c set
@@ -629,6 +610,17 @@ def
tname s i0 get append /tname set
} for
+ %% Remove space and cr/lf from the key word.
+ [
+ 0 1 tname length 1 sub {
+ /j set
+ tname j get 36 le {
+ } {
+ tname j get
+ } ifelse
+ } for
+ ] /tname set
+
/j 0 def
i0 1 s length 1 sub {
/i set
@@ -686,6 +678,7 @@ def
/fname (index.html) def
}{
/fname msg 1 get def
+ (fname=) messagen fname (array) dc message
fname tag 5 eq not {
[(MSG) (
Invalid file name.
)]
httpd_sendfile
@@ -693,9 +686,7 @@ def
} { } ifelse
fname (array) dc /fname set
fname length 1 lt {
- [(MSG) ( Invalid file name.
)]
- httpd_sendfile
- /httpd_sendfile.L1 /httpd_sendfile.L1 goto
+ /fname (index.html) (array) dc def
} { } ifelse
fname [47] eq {
@@ -712,6 +703,10 @@ def
/fname2 fname def
[httpd.root fname2] cat /fname set
[(fname=) fname] cat message
+ fname httpd.check_name {
+ [(MSG) (Warning: invalid file name.)] httpd_sendfile
+ /httpd_sendfile.L1 /httpd_sendfile.L1 goto
+ } { } ifelse
[(stat) fname] extension 0 get tag 0 eq {
[(MSG) (Warning (sendfile): the file ) fname2 ( is not found.) ]
httpd_sendfile
@@ -781,4 +776,72 @@ def
] pop
popVariables
arg1
-} def
+} def
+
+/httpd.check_name {
+ /arg1 set
+ [/in-httpd.check_name /fname /invalid] pushVariables
+ [
+ /fname arg1 def
+ /invalid 0 def
+ [(regionMatches) fname [(..) (/.)]] extension 0 get -1 eq
+ {
+ } {
+ (The file name contains .. or /. ) message
+ /invalid 1 def /httpd.check_name.L1 /httpd.check_name.L1 goto
+ } ifelse
+ fname length 0 eq {
+ (Warning: empty file name.)
+ /invalid 1 def /httpd.check_name.L1 /httpd.check_name.L1 goto
+ }{ } ifelse
+ fname (array) dc 0 get 47 eq {
+ }{
+ (Warning: The first letter is not /) message
+ /invalid 1 def /httpd.check_name.L1 /httpd.check_name.L1 goto
+ } ifelse
+ /httpd.check_name.L1
+ /arg1 invalid 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 {
+ [(sleep 3 ; netscape http://localhost:) portnum ( & ) ] cat
+ /cmd set cmd message
+ 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