summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYour Name <you@example.com>2024-11-03 17:02:05 +1100
committerYour Name <you@example.com>2024-11-03 17:02:05 +1100
commit0d386684e7a1247bdf098b21ebaf0a6bf94da39a (patch)
tree5e81e6610aa38fcb39b618e9fb876466dcc40e7d
parenta3bdaf37b72013fe581f108c4798137e1ea267cd (diff)
fixed configure.tcl bugs preventing from runningHEADmaster
-rwxr-xr-xconfigure.tcl35
-rwxr-xr-xhttp-cache.tcl5
-rwxr-xr-xtcl-httpd2
-rw-r--r--tcl-httpd.conf6
-rw-r--r--www/index.html3
-rw-r--r--www/louie.pngbin0 -> 4950 bytes
6 files changed, 31 insertions, 20 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;
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 @@
+<html>
+ Hello
+</html>
diff --git a/www/louie.png b/www/louie.png
new file mode 100644
index 0000000..129461c
--- /dev/null
+++ b/www/louie.png
Binary files differ