diff options
author | Your Name <you@example.com> | 2024-11-03 17:02:05 +1100 |
---|---|---|
committer | Your Name <you@example.com> | 2024-11-03 17:02:05 +1100 |
commit | 0d386684e7a1247bdf098b21ebaf0a6bf94da39a (patch) | |
tree | 5e81e6610aa38fcb39b618e9fb876466dcc40e7d /configure.tcl | |
parent | a3bdaf37b72013fe581f108c4798137e1ea267cd (diff) |
Diffstat (limited to 'configure.tcl')
-rwxr-xr-x | configure.tcl | 35 |
1 files changed, 23 insertions, 12 deletions
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; |