From 0d386684e7a1247bdf098b21ebaf0a6bf94da39a Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 3 Nov 2024 17:02:05 +1100 Subject: fixed configure.tcl bugs preventing from running --- configure.tcl | 35 +++++++++++++++++++++++------------ http-cache.tcl | 5 ----- tcl-httpd | 2 ++ tcl-httpd.conf | 6 +++--- www/index.html | 3 +++ www/louie.png | Bin 0 -> 4950 bytes 6 files changed, 31 insertions(+), 20 deletions(-) create mode 100644 www/index.html create mode 100644 www/louie.png diff --git a/configure.tcl b/configure.tcl index 76fd37e..6f11546 100755 --- a/configure.tcl +++ b/configure.tcl @@ -2,7 +2,7 @@ namespace eval http { # The directory which files are searched for. - variable srv {/home/aleksei/www/files/} + variable srv {/home/aleksei/tcl-httpd/www/} namespace eval cache { variable precache { @@ -33,7 +33,7 @@ proc temp {} { -set config [open /etc/tcl-httpd.conf] +set config [open /home/aleksei/tcl-httpd/tcl-httpd.conf] ## Configure the server, whilst verifying options. @@ -49,9 +49,10 @@ namespace eval temp { } - proc module_path } + ## Configuration files can take preemptive actions, such as preloading files + ## into the cache or loading a user written module. namespace eval actions { proc @MODULE {v} { if [info exists ::http::configure::module_path] { @@ -68,23 +69,33 @@ namespace eval temp { } } - proc @PRECACHE {a b} { - ::http::cache::add $b + proc @PRECACHE {filename} { + ::http::cache::add $filename } } - + while {[gets $config line] != -1} { - if [regexp {^[[:lower:]_]+=[[:alnum:][:punct:]]+$} $line] { + + variable regexp_comment {^[[:space:]]*\#}; + variable regexp_form_variable {^[[:lower:]_]+=[[:alnum:][:punct:]]+$}; + variable regexp_form_action {^@[[:upper:]]+ [[:alnum:][:punct:]]+$}; + + if [regexp $regexp_comment $line] { + # Line that is a comment. + } elseif [regexp $regexp_form_variable $line] { set n [string first "=" $line] - set a [string range start [expr n-1]] - set b [string range [expr n+1] end] + set a [string range $line 0 [expr $n-1]] + set b [string range $line [expr $n+1] end] # RUN VERIFICATION + #namespace eval ::http::configure "$a $b" namespace eval ::http::configure "variable $a $b" - } elseif [regexp {^@[[:upper:]]+ [[:alnum:][:punct:]]+$} $line] { + } elseif [regexp $regexp_form_action $line] { + ## Line of form @ACTION arguments set n [string first " " $line] - set a [string range start [expr n-1]] - set b [string range [expr n+1] end] + set a [string range $line 0 [expr $n-1]] + set b [string range $line [expr $n+1] end] # PERFORM ACTION + namespace eval ::http::actions "$a $b" } else { append error_message " $line_number" set error_state 1; diff --git a/http-cache.tcl b/http-cache.tcl index f377770..ee58981 100755 --- a/http-cache.tcl +++ b/http-cache.tcl @@ -27,9 +27,4 @@ namespace eval cache { } } - # Process the precache - foreach i $::http::configure::precache { - add [string cat $::http::configure::srv $i] - } - } diff --git a/tcl-httpd b/tcl-httpd index 575a3fa..8066ada 100755 --- a/tcl-httpd +++ b/tcl-httpd @@ -5,6 +5,8 @@ source configure.tcl source http.tcl +source http-cache.tcl + source html.tcl socket -server http::server 8000 diff --git a/tcl-httpd.conf b/tcl-httpd.conf index efd3030..279bc68 100644 --- a/tcl-httpd.conf +++ b/tcl-httpd.conf @@ -1,3 +1,3 @@ -srv=/home/aleksei/www/files/ -@MODULE template -@PRECACHE /style.css +srv=/home/aleksei/tcl-httpd/www/ +#@MODULE template +#@PRECACHE /style.css diff --git a/www/index.html b/www/index.html new file mode 100644 index 0000000..91a454b --- /dev/null +++ b/www/index.html @@ -0,0 +1,3 @@ + + Hello + diff --git a/www/louie.png b/www/louie.png new file mode 100644 index 0000000..129461c Binary files /dev/null and b/www/louie.png differ -- cgit v1.2.3