--- gforth/httpd.fs 2002/06/02 21:19:09 1.11 +++ gforth/httpd.fs 2006/10/07 17:06:15 1.20 @@ -1,6 +1,6 @@ #! /usr/local/bin/gforth -\ Copyright (C) 2000 Free Software Foundation, Inc. +\ Copyright (C) 2000,2002,2003,2004 Free Software Foundation, Inc. \ This file is part of Gforth. @@ -23,7 +23,7 @@ warnings off require string.fs Variable DocumentRoot s" /usr/local/httpd/htdocs/" DocumentRoot $! -Variable UserDir s" .html-data/" UserDir $! +Variable UserDir s" public_html/" UserDir $! Variable url Variable posted @@ -94,9 +94,9 @@ Variable maxnum : ?cr ( -- ) #tib @ 1 >= IF source 1- + c@ #cr = #tib +! THEN ; -: refill-loop ( -- flag ) +: refill-loop ( -- flag ) base @ >r base off BEGIN refill ?cr WHILE ['] interpret catch drop >in @ 0= UNTIL - true ELSE maxnum off false THEN ; + true ELSE maxnum off false THEN r> base ! ; : get-input ( -- flag ior ) s" /nosuchfile" url $! s" HTTP/1.0" protocol $! s" close" connection $! @@ -112,10 +112,10 @@ Variable maxnum Variable htmldir : rework-htmldir ( addr u -- addr' u' / ior ) - htmldir $! htmldir $@ compact.. htmldir $!len drop - htmldir $@ 3 min s" ../" compare 0= + htmldir $! htmldir $@ compact-filename htmldir $!len drop + htmldir $@ s" ../" string-prefix? IF -1 EXIT THEN \ can't access below current directory - htmldir $@ 1 min s" ~" compare 0= + htmldir $@ s" ~" string-prefix? IF UserDir $@ htmldir dup $@ 2dup '/ scan '/ skip nip - nip $ins ELSE DocumentRoot $@ htmldir 0 $ins THEN @@ -144,7 +144,7 @@ Variable htmldir : .connection ( -- ) ." Connection: " - connection $@ s" Keep-Alive" compare 0= maxnum @ 0> and + connection $@ s" Keep-Alive" str= maxnum @ 0> and IF connection $@ type cr ." Keep-Alive: timeout=15, max=" maxnum @ 0 .r cr -1 maxnum +! ELSE ." close" cr maxnum off THEN ; @@ -181,7 +181,7 @@ mime set-current s" application/pgp-signature" transparent: sig s" application/x-bzip2" transparent: bz2 s" application/x-gzip" transparent: gz -s" /etc/mime.types" mime-read +s" /etc/mime.types" ['] mime-read catch [IF] 2drop [THEN] definitions @@ -228,7 +228,7 @@ Defer redirect ( addr u -- ) THEN THEN THEN THEN outfile-id flush-file throw ; : httpd ( n -- ) dup maxnum ! 0 <# #S #> Keep-Alive $! - BEGIN ['] http catch maxnum @ 0= or UNTIL ; + maxnum @ 0 DO ['] http catch maxnum @ 0= or ?LEAVE LOOP ; script? [IF] :noname &100 httpd bye ; is bootmessage [THEN]