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 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'configure.tcl') 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; -- cgit v1.2.3