mod_tcl-1.0d8-2001112900 see NEWS and README for changes
diff --git a/INSTALL b/INSTALL
index 6c32803..07f3e09 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,7 +1,70 @@
-% tar -zxf mod_tcl.tar.gz
-% mv mod_tcl apache_2.0a9/modules/.
-% cd apache_2.0a9
-% autoconf
-% autoheader
-% ./configure
-% make
+Mail bug reports to: general@tcl.apache.org
+
+
+mod_tcl 1.0d8-2001112900 INSTALL
+--------------------------------
+
+This installation refers to installing mod_tcl 1.0d8-2001112900 with
+Apache 2.0.28. This installation document refers to no other versions
+of mod_tcl or Apache.
+
+1. Ungzip and untar the mod_tcl.tar.gz file.
+ (tar -zxf mod_tcl.tar.gz)
+2. Move the mod_tcl directory to the modules directory in the httpd
+ root.
+ (mv mod_tcl httpd-2_0_28/modules)
+3. Change directory to the root level of the httpd distribution and run
+ the `autoconf' and `autoheader' commands. You must have the
+ autoconf distribution installed, which is available from any GNU mirror.
+ (cd httpd-2_0_28;autoconf;autoheader)
+4. Configure the make process by typing `./configure'. You may include
+ other options.
+ (./configure)
+5. Make the distribution and install it.
+ (make;make install)
+6. At this point the compile and installation has completed and you
+ need to edit the httpd.conf file, this is usually located at
+ /usr/local/apache2/conf for a default install.
+
+Sample httpd.conf entry for using mod_tcl in a VirtualHost statement
+--------------------------------------------------------------------
+
+<VirtualHost 206.9.161.23>
+ ServerName alpha-decay.com
+ ServerAlias www.alpha-decay.com
+
+ DocumentRoot "/export/web/alpha-decay.com"
+
+ <Directory /export/web/alpha-decay.com>
+ AddHandler tcl-handler tm
+
+ Tcl_ContentHandler content_handler
+ </Directory>
+
+ <Directory />
+ Options FollowSymLinks
+ AllowOverride None
+ </Directory>
+
+ <Directory /export/web/alpha-decay.com/images>
+ SetHandler default-handler
+
+ Options Indexes FollowSymLinks
+
+ AllowOverride None
+
+ Order allow,deny
+ Allow from all
+ </Directory>
+
+ <Directory /export/web/alpha-decay.com/files>
+ SetHandler default-handler
+
+ Options Indexes FollowSymLinks
+
+ AllowOverride None
+
+ Order allow,deny
+ Allow from all
+ </Directory>
+</VirtualHost>
diff --git a/NEWS b/NEWS
index 8cf6b36..29ce3c5 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,19 @@
+Changes in 1.0d8-2001112900
+--------------------------------------------------------------------------------
+- Some structures changed in Apache 2.0.28, noteably in the connection record,
+some variables were axed. (keptalive and keepalives).
+- Some variables sizes changed in the request_rec structure, from 32 bits to 64
+bits, which isn't supported by Tcl in 8.3.4. (allowed and allowed_methods).
+- <Tcl> raw args no longer work in 2.0.28.
+- The use of the `Tcl' directory to enable mod_tcl in a directory is deprecated.
+- No longer use `SetHandler tcl-handler', use `Addhandler tcl-handler tm' in a
+directory statement, (tm is the extension to match [.tm]). If you use
+SetHandler it will interfere with mod_dir.c and other handlers, unless you don't
+care about the other handlers. I'm not sure if this is an Apache bug or what?
+For mod_dir.c it appears to be called and but tries to match against
+tcl-handler? See the INSTALL file for an example of a configuration in 2.0.28,
+see the test_script.tm example for an example script.
+
Changes in 1.0d7
--------------------------------------------------------------------------------
- Migration to Apache 2.0.16
@@ -5,35 +21,32 @@
Changes in 1.0d7pre
--------------------------------------------------------------------------------
-- Fixed <Tcl>...</Tcl>, these should be placed outside of <Directory>/<Location> directives. Everything in <Tcl>...</Tcl> is added to a global variable and then made local to the namespace of the file, this is due to several problems with handling configuration, mainly that exection would either result in a "this directive doesn't belong here" or a problem with the configuration not being built yet as in an EXEC_ON_READ.
+- Fixed <Tcl>...</Tcl>, these should be placed outside of <Directory>/<Location>
+directives. Everything in <Tcl>...</Tcl> is added to a global variable and then
+made local to the namespace of the file, this is due to several problems with
+handling configuration, mainly that exection would either result in a "this
+directive doesn't belong here" or a problem with the configuration not being
+built yet as in an EXEC_ON_READ.
- Fixed a bug in ap_create_environment.
-- Fixed a bug with writing <Tcl>...</Tcl> logic to the local namespace [2001032300]
+- Fixed a bug with writing <Tcl>...</Tcl> logic to the local namespace
+[2001032300]
Changes in 1.0d6
--------------------------------------------------------------------------------
-- ap_send_http_header no longer does anything so the command just returns TCL_OK which essentially makes it null, I'll probably get rid of it later.
+- ap_send_http_header no longer does anything so the command just returns TCL_OK
+which essentially makes it null, I'll probably get rid of it later.
- made changes in league with Apache 2.0.14. Handlers were moved around etc.
Changes in 1.0d5
--------------------------------------------------------------------------------
-- Configuration checks for mmap() and will use malloc(),read(),free() in that order to replace mmap() procedures.
-- Constants and commands are now placed in the ::apache namespace, so you must import that namespace into your scripts.
-- A test script is included with the distribution for testing and example purposes. test_script.tm
-
-TODO
---------------------------------------------------------------------------------
-
-1. Add configuration documentation to README, add documentation regarding `r' and `r_set' commands.
-DONE 2. Possible addition of option to build shared object (.so) library. (It appears Apache 2.0 has a configuration directive for this --enable-shared, but it appears to be not implemented yet...).
-3. A couple of hooks are broken (Apache bug?) the DECLINE causes the server to exit on signal 11 (SEGV).
-4. Add non-standard hooks?
-5. Add filters?
-6. libapreq (doesn't appear to be ported to 2.0 completley yet...)
-7. Decide what goals need to be acheived for release 1.0
-8. Make necessary changes along with Apache 2.0 revisions.
-9. Look into TCL threads. A preliminary investigation to enabling TCL threads caused SEGVs randomly...?
+- Configuration checks for mmap() and will use malloc(),read(),free() in that
+order to replace mmap() procedures.
+- Constants and commands are now placed in the ::apache namespace, so you must
+import that namespace into your scripts.
+- A test script is included with the distribution for testing and example
+purposes. test_script.tm
Map
--------------------------------------------------------------------------------
@@ -55,10 +68,10 @@
- 1.0d6 -| ap_send_http_header deprecated, updated to be peachy with
| Apache 2.0.14
|
-% 1.0d7 %| migration to Apache 2.0.16, fixed bugs
+- 1.0d7 -| migration to Apache 2.0.16, fixed bugs
|
-- 1.0d8 -|
+% 1.0d8 %| remaining at 1.0d8 until Apache 2.0 is release quality.
|
-- 1.0d9 -|
+- 1.0d9 -| stabalization with Apache 2.0 release API and bug fixes.
|
-- 1.0.0 -|
+- 1.0.0 -| release.
diff --git a/README b/README
index 060af4d..07f523e 100644
--- a/README
+++ b/README
@@ -1,482 +1,20 @@
-mod_tcl 1.0 Developer Documentation
------------------------------------
+Tested Platforms
+----------------
-This documentation referes to mod_tcl 1.0d7.
-Please see tcl.apache.org for more information.
+SunOS-5.8/gcc-3.0.2/tcl-8.3.4/Apache-2.0.28
+Documentation
+-------------
-Configuration Directives
-------------------------
+As this module is still in development there is no end user documentation.
+The source file breaks down like this:
-Determine if the module should be active
-@param 1 On or Off
-Tcl
-
-Set an array variable or a scalar variable
-@param 1 Array variable if param 3 is non-null, otherwise a scalar variable
-@param 2 Name of an array element if param 3 is non-null, otherwise value to set scalar
-@param 3 Value to set array element to
-Tcl_Var
-
-Append to a list
-@param 1 List variable to append to
-@param 2 Value to append
-Tcl_ListVar
-
-Add a content handler to be executed
-@param 1 The name of a procedure that is to be called when a content handler is called
-Tcl_ContentHandler
-
-Add a post read request hook
-@param 1 The name of a procedure that is to be called when a read request hook is called
-Tcl_Hook_Post_Read_Request
-
-Add a translate name hook
-@param 1 The name of a procedure that is to be called when a translate name hook is called
-Tcl_Hook_Translate_Name
-
-Add a header parser hook
-@param 1 The name of a procedure that is to be called when a header parser hook is called
-Tcl_Hook_Header_Parser
-
-Add an access checker hook
-@param 1 The name of a procedure that is to be called when an access checker hook is called
-Tcl_Hook_Access_Checker
-
-Add a check user id hook
-@param 1 The name of a procedure that is to be called when a check user id hook is called
-Tcl_Hook_Check_User_ID
-
-Add an auth checker hook
-@param 1 The name of a procedure that is to be called when an auth checker hook is called
-Tcl_Hook_Auth_Checker
-
-Add a type checker hook
-@param 1 The name of a procedure that is to be called when a type checker hook is called
-Tcl_Hook_Type_Checker
-
-Add a fixups hook
-@param 1 The name of a procedure that is to be called when a fixups hook is called
-Tcl_Hook_Fixups
-
-Add a log transaction hook
-@param 1 The name of a procedure that is to be called when a log transaction hook is called
-Tcl_Hook_Log_Transaction
-
-Add raw TCL to the interpeter
-@param 1 A TCL script that will be executed in the interpreter
-<Tcl>
-
-End adding raw TCL to the interpreter
-</Tcl>
-
-Constants Provided
-------------------
-
-DECLINED
-DONE
-OK
-
-M_POST
-M_GET
-M_PUT
-M_DELETE
-M_CONNECT
-M_OPTIONS
-M_TRACE
-M_PATCH
-M_PROPFIND
-M_PROPPATCH
-M_MKCOL
-M_COPY
-M_MOVE
-M_LOCK
-M_UNLOCK
-M_INVALID
-
-HTTP_CONTINUE
-HTTP_SWITCHING_PROTOCOLS
-HTTP_PROCESSING
-HTTP_OK
-HTTP_CREATED
-HTTP_ACCEPTED
-HTTP_NON_AUTHORITATIVE
-HTTP_NO_CONTENT
-HTTP_RESET_CONTENT
-HTTP_PARTIAL_CONTENT
-HTTP_MULTI_STATUS
-HTTP_MULTIPLE_CHOICES
-HTTP_MOVED_PERMANENTLY
-HTTP_MOVED_TEMPORARILY
-HTTP_SEE_OTHER
-HTTP_NOT_MODIFIED
-HTTP_USE_PROXY
-HTTP_TEMPORARY_REDIRECT
-HTTP_BAD_REQUEST
-HTTP_UNAUTHORIZED
-HTTP_PAYMENT_REQUIRED
-HTTP_FORBIDDEN
-HTTP_NOT_FOUND
-HTTP_METHOD_NOT_ALLOWED
-HTTP_NOT_ACCEPTABLE
-HTTP_PROXY_AUTHENTICATION_REQUIRED
-HTTP_REQUEST_TIME_OUT
-HTTP_CONFLICT
-HTTP_GONE
-HTTP_LENGTH_REQUIRED
-HTTP_PRECONDITION_FAILED
-HTTP_REQUEST_ENTITY_TOO_LARGE
-HTTP_REQUEST_URI_TOO_LARGE
-HTTP_UNSUPPORTED_MEDIA_TYPE
-HTTP_RANGE_NOT_SATISFIABLE
-HTTP_EXPECTATION_FAILED
-HTTP_UNPROCESSABLE_ENTITY
-HTTP_LOCKED
-HTTP_FAILED_DEPENDENCY
-HTTP_INTERNAL_SERVER_ERROR
-HTTP_NOT_IMPLEMENTED
-HTTP_BAD_GATEWAY
-HTTP_SERVICE_UNAVAILABLE
-HTTP_GATEWAY_TIME_OUT
-HTTP_VERSION_NOT_SUPPORTED
-HTTP_VARIANT_ALSO_VARIES
-HTTP_INSUFFICIENT_STORAGE
-HTTP_NOT_EXTENDED
-
-REMOTE_HOST
-REMOTE_NAME
-REMOTE_NOLOOKUP
-REMOTE_DOUBLE_REV
-
-APLOG_EMERG
-APLOG_ALERT
-APLOG_CRIT
-APLOG_ERR
-APLOG_WARNING
-APLOG_NOTICE
-APLOG_INFO
-APLOG_DEBUG
-APLOG_NOERRNO
-
-REQUEST_NO_BODY
-REQUEST_CHUNKED_ERROR
-REQUEST_CHUNKED_DECHUNK
-
-Commands
---------
-
-Abort request
-@param 1 A string with the reason of abortion
-@deffunc abort 1
-abort
-
-Read posted data and set the array pram
-@deffunc read_post
-read_post
-
-Generate a random integer
-@return An integer
-@deffunc random
-random
-
-Seed random number generation
-@param 1 An integer to seed random number generation
-@deffunc srandom 1
-srandom
-
-Encode data to base64
-@param 1 Data to be encoded
-@return Base64 string of converted data
-@deffunc base64_encode 1
-base64_encode
-
-Decode data from base64
-@param 1 Base64 string to be converted to data
-@return Data that was converted from base64
-@deffunc base64_decode
-base64_decode
-
-Call ap_allow_options
-@return An integer with the mask of options
-@deffunc ap_allow_options
-ap_allow_options
-
-Call ap_allow_overrides
-@return An integer
-@deffunc ap_allow_overrides
-ap_allow_overrides
-
-Call ap_default_type
-@return A string
-@deffunc ap_default_type
-ap_default_type
-
-Call ap_document_root
-@return A string
-@deffunc ap_document_root
-ap_document_root
-
-Call ap_get_remote_host
-@param 1 An integer specifying the type of lookup
-@return A string
-@deffunc ap_get_remote_host 1
-ap_get_remote_host
-
-Call ap_get_remote_logname
-@return A string
-@deffunc ap_get_remote_logname
-ap_get_remote_logname
-
-Call ap_construct_url
-@param 1 A uri
-@return A string
-@deffunc ap_construct_url 1
-ap_construct_url
-
-Call ap_get_server_name
-@return A string
-@deffunc ap_get_server_name
-ap_get_server_name
-
-Call ap_get_limit_req_body
-@return An integer
-@deffunc ap_get_limit_req_body
-ap_get_limit_req_body
-
-Call ap_get_limit_xml_body
-@return An integer
-@deffunc ap_get_limit_xml_body
-ap_get_limit_xml_body
-
-Call ap_custom_response
-@param 1 An integer
-@param 2 A string
-@deffunc ap_custom_response 1 2
-ap_custom_response
-
-Call ap_exists_config_define
-@param 1 A string
-@return An integer
-@deffunc ap_exists_config_define 1
-ap_exists_config_define
-
-Call ap_auth_type
-@return A string
-@deffunc ap_auth_type
-ap_auth_type
-
-Call ap_auth_name
-@return A string
-@deffunc ap_auth_name
-ap_auth_name
-
-Call ap_satisfies
-@return An integer
-@deffunc ap_satisfies
-ap_satisfies
-
-Call ap_requires
-@return A list { {integer, string} ... }
-@deffunc ap_requires
-ap_requires
-
-Call ap_log_error
-@param 1 An integer specifying log level
-@param 2 An integer specifying the status
-@param 3 A string specifying the error
-@deffunc ap_log_error 1 2 3
-ap_log_error
-
-Call ap_send_http_header
-@deffunc ap_send_http_header
-ap_send_http_header
-
-Call ap_send_http_trace
-@return An integer
-@deffunc ap_send_http_trace
-ap_send_http_trace
-
-Call ap_send_http_options
-@return An integer
-@deffunc ap_send_http_options
-ap_send_http_options
-
-Call ap_finalize_request_protocol
-@deffunc ap_finalize_request_protocol
-ap_finalize_request_protocol
-
-Call ap_send_error_response
-@param 1 An integer with recursion level
-@deffunc ap_send_error_response
-ap_send_error_response
-
-Call ap_set_content_length
-@param 1 An integer specifying length
-@deffunc ap_set_content_length 1
-ap_set_content_length
-
-Call ap_set_keepalive
-@return An integer
-@deffunc ap_set_keepalive
-ap_set_keepalive
-
-Call ap_rationalize_mtime
-@param 1 An integer specifying mtime
-@return An integer
-@deffunc ap_rationalize_mtime 1
-ap_rationalize_mtime
-
-Call ap_make_etag
-@param 1 An integer specifying force_weak
-@return A string
-@deffunc ap_make_etag 1
-ap_make_etag
-
-Call ap_set_etag
-@deffunc ap_set_etag
-ap_set_etag
-
-Call ap_set_last_modified
-@deffunc ap_set_last_modified
-ap_set_last_modified
-
-Call ap_meets_conditions
-@return An integer
-@deffunc ap_meets_conditions
-ap_meets_conditions
-
-Call ap_rputs
-@param 1 Either -nonewline or a string to write
-@param 2 if param 1 is -nonewline then a string to write
-@deffunc ap_rputs 1 2
-ap_rputs
-
-Call ap_rwrite
-@param 1 Data to write
-@deffunc ap_rwrite 1
-ap_rwrite
-
-Call ap_rflush
-@deffunc ap_rflush
-ap_rflush
-
-Call ap_get_status_line
-@param 1 An integer specifying status
-@return A string
-@deffunc ap_get_status_line 1
-ap_get_status_line
-
-Call ap_setup_client_block
-@param 1 An integer specifying read policy
-@return An integer
-@deffunc ap_setup_client_block 1
-ap_setup_client_block
-
-Call ap_get_client_block, sets variable R with data
-@param 1 An integer specifying the number of bytes to read
-@return An integer specifying the actual number of bytes read
-@deffunc ap_get_client_block 1
-ap_get_client_block
-
-Call ap_discard_request_body
-@return An integer
-@deffunc ap_discard_request_body
-ap_discard_request_body
-
-Call ap_note_auth_failure
-@deffunc ap_note_auth_failure
-ap_note_auth_failure
-
-Call ap_note_basic_auth_failure
-@deffunc ap_note_basic_auth_failure
-ap_note_basic_auth_failure
-
-Call ap_note_digest_auth_failure
-@deffunc ap_note_digest_auth_failure
-ap_note_digest_auth_failure
-
-Call ap_get_basic_auth_pw, sets R with password
-@return An integer
-@deffunc ap_get_basic_auth_pw
-ap_get_basic_auth_pw
-
-Call ap_parse_uri
-@param 1 A string specifying a uri
-@deffunc ap_parse_uri 1
-ap_parse_uri
-
-Call ap_method_number_of
-@param 1 A string with a method name
-@return An integer specifying the method number
-@deffunc ap_method_number_of 1
-ap_method_number_of
-
-Call ap_method_name_of
-@param 1 An integer specifying a method number
-@return A string specifying a method name
-@deffunc ap_method_name_of 1
-ap_method_name_of
-
-Call ap_internal_redirect
-@param 1 A string specifying a uri to redirect to
-@deffunc ap_internal_redirect 1
-ap_internal_redirect
-
-Call ap_internal_redirect_handler
-@param 1 A string specifying a uri to redirect to
-@deffunc ap_internal_redirect_handler 1
-ap_internal_redirect_handler
-
-Call ap_some_auth_required
-@return An integer
-@deffunc ap_some_auth_required
-ap_some_auth_required
-
-Call ap_update_mtime
-@param 1 An integer specifying a dependancy
-@deffunc ap_update_mtime 1
-ap_update_mtime
-
-Call ap_allow_methods
-@param 1 An integer specifying a reset
-@param 2 A string specifying methods
-@deffunc ap_allow_methods 1 2
-ap_allow_methods
-
-Call ap_get_server_version
-@return A string
-@deffunc ap_get_server_version
-ap_get_server_version
-
-Call ap_add_version_component
-@param 1 A string specifying a version component to add
-@deffunc ap_add_version_component 1
-ap_add_version_component
-
-Call ap_get_server_built
-@return A string
-@deffunc ap_get_server_built
-ap_get_server_built
-
-Call ap_create_environment, sets array env
-@deffunc ap_create_environment
-ap_create_environment
-
-Reads variables from request_rec structure
-@param 1 variable or "connection" or "server"
-@param 2 if param 1 "connection" or "server" then a variable to read
-@return The variable read, could be an integer, string, or list
-@deffunc r 1 2
-r
-
-Sets variables in request_rec structure
-@param 1 variable or "connection" or "server"
-@param 2 if param 1 "connection" or "server" then variable
-@param x variable list of data to be written
-@deffunc r_set 1 2 ...
-r_set
-
-Ouput text/html
-@param 1 A script of text to output
-@deffunc output 1
-output
+tcl_core.c:
+ core routines, handlers, configuration, initialization
+tcl_cmds.c:
+ commands for reading and writing variables from apache structures (request_rec
+ etc.)
+tcl_misc.c:
+ vasprintf() and asprintf() if your system doesn't have it
+mod_tcl.h:
+ includes, prototypes
diff --git a/mod_tcl.h b/mod_tcl.h
index a30f72e..461b678 100644
--- a/mod_tcl.h
+++ b/mod_tcl.h
@@ -72,7 +72,8 @@
#include "http_protocol.h"
#include "http_request.h"
#include "util_script.h"
-#include "util_uri.h"
+//#include "util_uri.h"
+#include "apr_uri.h"
#include "ap_config_auto.h"
diff --git a/tcl_cmds.c b/tcl_cmds.c
index e38d470..4272e75 100644
--- a/tcl_cmds.c
+++ b/tcl_cmds.c
@@ -836,11 +836,6 @@
return Tcl_NewIntObj(_r->connection->keepalive);
}
-static Tcl_Obj* r_connection_keptalive(void)
-{
- return Tcl_NewIntObj(_r->connection->keptalive);
-}
-
static Tcl_Obj* r_connection_double_reverse(void)
{
return Tcl_NewIntObj(_r->connection->double_reverse);
@@ -881,11 +876,6 @@
return obj;
}
-static Tcl_Obj* r_connection_remain(void)
-{
- return Tcl_NewLongObj(_r->connection->remain);
-}
-
static Tcl_Obj* r_server_defn_name(void)
{
return Tcl_NewStringObj(_r->server->defn_name, -1);
@@ -1047,8 +1037,9 @@
static int r_set_allowed(int objc, Tcl_Obj *CONST objv[])
{
+/* needs to be apr_int64_t, TCL doesn't support this in 8.3.4...
Tcl_GetIntFromObj(interp, objv[2], &(_r->allowed));
-
+*/
return TCL_OK;
}
@@ -1068,21 +1059,21 @@
Tcl_WrongNumArgs(interp, 2, objv, "method_mask method_list");
return TCL_ERROR;
}
-
+/* needs to be apr_int64_t, TCL doesn't support this in 8.3.4...
Tcl_GetIntFromObj(interp, objv[2], &(_r->allowed_methods->method_mask));
if (Tcl_ListObjGetElements(interp, objv[3], &xxobjc, &xxobjv) == TCL_ERROR) {
return TCL_ERROR;
}
- _r->allowed_methods->method_list = (apr_array_header_t*) apr_array_make(_r->allowed_methods->method_list->cont, xxobjc, sizeof(char*));
+ _r->allowed_methods->method_list = (apr_array_header_t*) apr_array_make(_r->allowed_methods->method_list->pool, xxobjc, sizeof(char*));
for (i = 0; i < xxobjc; i++) {
char *xx = (char*) apr_array_push(_r->allowed_methods->method_list);
- xx = apr_pstrdup(_r->allowed_methods->method_list->cont, Tcl_GetString(xxobjv[i]));
+ xx = apr_pstrdup(_r->allowed_methods->method_list->pool, Tcl_GetString(xxobjv[i]));
}
-
+*/
return TCL_OK;
}
@@ -1110,6 +1101,13 @@
return TCL_OK;
}
+static int r_set_filename(int objc, Tcl_Obj *CONST objv[])
+{
+ _r->filename = apr_pstrdup(_r->pool, Tcl_GetString(objv[2]));
+
+ return TCL_OK;
+}
+
static int r_set_subprocess_env(int objc, Tcl_Obj *CONST objv[])
{
if (objc != 4) {
@@ -1158,12 +1156,12 @@
return TCL_ERROR;
}
- _r->content_languages = apr_array_make(_r->content_languages->cont, xxobjc, sizeof(char*));
+ _r->content_languages = apr_array_make(_r->content_languages->pool, xxobjc, sizeof(char*));
for (i = 0; i < xxobjc; i++) {
char *xx = apr_array_push(_r->content_languages);
- xx = apr_pstrdup(_r->content_languages->cont, Tcl_GetString(xxobjv[i]));
+ xx = apr_pstrdup(_r->content_languages->pool, Tcl_GetString(xxobjv[i]));
}
return TCL_OK;
@@ -1234,7 +1232,7 @@
static int r_set_parsed_uri(int objc, Tcl_Obj *CONST objv[])
{
- Tcl_SetObjResult(interp, Tcl_NewIntObj(ap_parse_uri_components(_r->pool, Tcl_GetString(objv[2]), &(_r->parsed_uri))));
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(apr_uri_parse(_r->pool, Tcl_GetString(objv[2]), &(_r->parsed_uri))));
return TCL_OK;
}
@@ -1282,7 +1280,7 @@
{ "content_type", r_content_type, r_set_content_type },
{ "err_headers_out", r_err_headers_out, r_set_err_headers_out },
{ "expecting_100", r_expecting_100, NULL },
- { "filename", r_filename, NULL },
+ { "filename", r_filename, r_set_filename },
{ "handler", r_handler, NULL },
{ "headers_in", r_headers_in, NULL },
{ "headers_out", r_headers_out, r_set_headers_out },
@@ -1323,14 +1321,12 @@
{ "remote_logname", r_connection_remote_logname, NULL },
{ "aborted", r_connection_aborted, NULL },
{ "keepalive", r_connection_keepalive, NULL },
- { "keptalive", r_connection_keptalive, NULL },
{ "doublereverse", r_connection_double_reverse, NULL },
{ "keepalives", r_connection_keepalives, NULL },
{ "local_ip", r_connection_local_ip, NULL },
{ "local_host", r_connection_local_host, NULL },
{ "id", r_connection_id, NULL },
{ "notes", r_connection_notes, r_set_connection_notes },
- { "remain", r_connection_remain, NULL },
{ NULL, NULL, NULL }
};
diff --git a/tcl_core.c b/tcl_core.c
index f1b7aa1..f1a2eb8 100644
--- a/tcl_core.c
+++ b/tcl_core.c
@@ -74,51 +74,54 @@
/* 8 */ inline int tcl_fixups(request_rec *r);
/* 9 */ inline int tcl_log_transaction(request_rec *r);
-static const char* add_hand(cmd_parms *parms, void *mconfig, const char *arg);
+static const char* add_hand1(cmd_parms *parms, void *mconfig, const char *arg);
+static const char* add_hand2(cmd_parms *parms, void *mconfig, const char *arg1, const char *arg2);
static const char* sfl(cmd_parms *parms, void *mconfig, int flag);
static const char* tcl_set(cmd_parms *parms, void *mconfig, const char *one, const char *two, const char *three);
static const char* tcl_setlist(cmd_parms *parms, void *mconfig, const char *one, const char *two);
-static const char* tcl_raw_args(cmd_parms *parms, void *mconfig, char *arg);
+//static const char* tcl_raw_args(cmd_parms *parms, void *mconfig, char *arg);
-typedef const char* (*fz_t)(void);
+//typedef const char* (*fz_t)(void);
static const command_rec tcl_commands[] = {
- AP_INIT_FLAG( "Tcl", (fz_t) sfl, (void*) 1, OR_AUTHCFG, "turn mod_tcl on or off." ),
- AP_INIT_TAKE23( "Tcl_Var", (fz_t) tcl_set, NULL, OR_AUTHCFG, "set global variables in TCL." ),
- AP_INIT_TAKE2( "Tcl_ListVar", (fz_t) tcl_setlist, NULL, OR_AUTHCFG, "set global list variables." ),
+ /* this doesn't do anything anymore */
+ AP_INIT_FLAG( "Tcl", /*(fz_t)*/ sfl, (void*) 1, OR_AUTHCFG, "turn mod_tcl on or off." ),
+ AP_INIT_TAKE23( "Tcl_Var", /*(fz_t)*/ tcl_set, NULL, OR_AUTHCFG, "set global variables in TCL." ),
+ AP_INIT_TAKE2( "Tcl_ListVar", /*(fz_t)*/ tcl_setlist, NULL, OR_AUTHCFG, "set global list variables." ),
- /* this may be phased out, it should now be, Tcl_ContentHandler */
- AP_INIT_TAKE1( "Tcl_ContentHandlers", (fz_t) add_hand, (void*) 0, OR_AUTHCFG, "add content handler." ),
+ /* this will be phased out, it should now be, Tcl_ContentHandler */
+ AP_INIT_TAKE1( "Tcl_ContentHandlers", /*(fz_t)*/ add_hand1, (void*) 8, OR_AUTHCFG, "add content handler." ),
+ AP_INIT_TAKE1( "Tcl_ContentHandler", /*(fz_t)*/ add_hand1, (void*) 8, OR_AUTHCFG, "add content handlers." ),
- AP_INIT_TAKE1( "Tcl_ContentHandler", (fz_t) add_hand, (void*) 0, OR_AUTHCFG, "add content handlers." ),
- AP_INIT_TAKE1( "Tcl_Hook_Post_Read_Request", (fz_t) add_hand, (void*) 1, OR_AUTHCFG, "add post_read_request handlers." ),
- AP_INIT_TAKE1( "Tcl_Hook_Translate_Name", (fz_t) add_hand, (void*) 2, OR_AUTHCFG, "add translate_name handlers." ),
- AP_INIT_TAKE1( "Tcl_Hook_Header_Parser", (fz_t) add_hand, (void*) 3, OR_AUTHCFG, "add header_parser handlers." ),
- AP_INIT_TAKE1( "Tcl_Hook_Access_Checker", (fz_t) add_hand, (void*) 4, OR_AUTHCFG, "add access_checker handlers." ),
- AP_INIT_TAKE1( "Tcl_Hook_Check_User_ID", (fz_t) add_hand, (void*) 5, OR_AUTHCFG, "add check_user_id handlers." ),
- AP_INIT_TAKE1( "Tcl_Hook_Auth_Checker", (fz_t) add_hand, (void*) 6, OR_AUTHCFG, "add auth_checker handlers." ),
- AP_INIT_TAKE1( "Tcl_Hook_Type_Checker", (fz_t) add_hand, (void*) 7, OR_AUTHCFG, "add type_checker handlers." ),
- AP_INIT_TAKE1( "Tcl_Hook_Fixups", (fz_t) add_hand, (void*) 8, OR_AUTHCFG, "add fixups handlers." ),
- AP_INIT_TAKE1( "Tcl_Hook_Log_Transaction", (fz_t) add_hand, (void*) 9, OR_AUTHCFG, "add log_transaction handlers." ),
- AP_INIT_RAW_ARGS( "<Tcl>", (fz_t) tcl_raw_args, NULL, RSRC_CONF|EXEC_ON_READ, "add raw tcl to the interpreter." ),
+ AP_INIT_TAKE2( "Tcl_Hook_Post_Read_Request", /*(fz_t)*/ add_hand2, (void*) 0, OR_AUTHCFG, "add post_read_request handlers." ),
+ AP_INIT_TAKE2( "Tcl_Hook_Translate_Name", /*(fz_t)*/ add_hand2, (void*) 1, OR_AUTHCFG, "add translate_name handlers." ),
+ AP_INIT_TAKE1( "Tcl_Hook_Header_Parser", /*(fz_t)*/ add_hand1, (void*) 2, OR_AUTHCFG, "add header_parser handlers." ),
+ AP_INIT_TAKE1( "Tcl_Hook_Access_Checker", /*(fz_t)*/ add_hand1, (void*) 3, OR_AUTHCFG, "add access_checker handlers." ),
+ AP_INIT_TAKE1( "Tcl_Hook_Check_User_ID", /*(fz_t)*/ add_hand1, (void*) 4, OR_AUTHCFG, "add check_user_id handlers." ),
+ AP_INIT_TAKE1( "Tcl_Hook_Auth_Checker", /*(fz_t)*/ add_hand1, (void*) 5, OR_AUTHCFG, "add auth_checker handlers." ),
+ AP_INIT_TAKE1( "Tcl_Hook_Type_Checker", /*(fz_t)*/ add_hand1, (void*) 6, OR_AUTHCFG, "add type_checker handlers." ),
+ AP_INIT_TAKE1( "Tcl_Hook_Fixups", /*(fz_t)*/ add_hand1, (void*) 7, OR_AUTHCFG, "add fixups handlers." ),
+ AP_INIT_TAKE1( "Tcl_Hook_Handler", /*(fz_t)*/ add_hand1, (void*) 8, OR_AUTHCFG, "add content handler." ),
+ AP_INIT_TAKE1( "Tcl_Hook_Log_Transaction", /*(fz_t)*/ add_hand1, (void*) 9, OR_AUTHCFG, "add log_transaction handlers." ),
+// AP_INIT_RAW_ARGS( "<Tcl>", /*(fz_t)*/ tcl_raw_args, NULL, RSRC_CONF|EXEC_ON_READ, "add raw tcl to the interpreter." ),
{ NULL }
};
static void register_hooks(apr_pool_t *p)
-{
+{
ap_hook_pre_config(tcl_init, NULL, NULL, APR_HOOK_REALLY_FIRST);
ap_hook_post_config(tcl_init_handler, NULL, NULL, APR_HOOK_MIDDLE);
-// ap_hook_post_read_request(tcl_post_read_request, NULL, NULL, APR_HOOK_FIRST);
-// ap_hook_translate_name(tcl_translate_name, NULL, NULL, APR_HOOK_FIRST);
- ap_hook_header_parser(tcl_header_parser, NULL, NULL, APR_HOOK_FIRST);
- ap_hook_access_checker(tcl_access_checker, NULL, NULL, APR_HOOK_FIRST);
- ap_hook_check_user_id(tcl_check_user_id, NULL, NULL, APR_HOOK_FIRST);
- ap_hook_auth_checker(tcl_auth_checker, NULL, NULL, APR_HOOK_FIRST);
- ap_hook_type_checker(tcl_type_checker, NULL, NULL, APR_HOOK_FIRST);
- ap_hook_fixups(tcl_fixups, NULL, NULL, APR_HOOK_FIRST);
- ap_hook_handler(tcl_handler, NULL, NULL, APR_HOOK_FIRST);
- ap_hook_log_transaction(tcl_log_transaction, NULL, NULL, APR_HOOK_FIRST);
+ ap_hook_post_read_request(tcl_post_read_request, NULL, NULL, APR_HOOK_MIDDLE);
+ ap_hook_translate_name(tcl_translate_name, NULL, NULL, APR_HOOK_MIDDLE);
+ ap_hook_header_parser(tcl_header_parser, NULL, NULL, APR_HOOK_MIDDLE);
+ ap_hook_access_checker(tcl_access_checker, NULL, NULL, APR_HOOK_MIDDLE);
+ ap_hook_check_user_id(tcl_check_user_id, NULL, NULL, APR_HOOK_MIDDLE);
+ ap_hook_auth_checker(tcl_auth_checker, NULL, NULL, APR_HOOK_MIDDLE);
+ ap_hook_type_checker(tcl_type_checker, NULL, NULL, APR_HOOK_MIDDLE);
+ ap_hook_fixups(tcl_fixups, NULL, NULL, APR_HOOK_MIDDLE);
+ ap_hook_handler(tcl_handler, NULL, NULL, APR_HOOK_MIDDLE);
+ ap_hook_log_transaction(tcl_log_transaction, NULL, NULL, APR_HOOK_MIDDLE);
}
AP_DECLARE_DATA module tcl_module = {
@@ -139,6 +142,7 @@
typedef struct {
int fl;
char *handlers[10];
+ char *file_location[2];
apr_array_header_t *var_list;
} tcl_config_rec;
@@ -164,11 +168,12 @@
tclr->var_list = apr_array_make(p, 0, sizeof(var_cache));
memset(tclr->handlers, 0, 10 * sizeof(char*));
+ memset(tclr->file_location, 0, 2 * sizeof(char*));
return tclr;
}
-static const char* add_hand(cmd_parms *parms, void *mconfig, const char* arg)
+static const char* add_hand1(cmd_parms *parms, void *mconfig, const char* arg)
{
int pos = (int) parms->info;
tcl_config_rec *tclr = (tcl_config_rec*) mconfig;
@@ -178,6 +183,17 @@
return NULL;
}
+static const char* add_hand2(cmd_parms *parms, void *mconfig, const char* arg1, const char* arg2)
+{
+ int pos = (int) parms->info;
+ tcl_config_rec *tclr = (tcl_config_rec*) mconfig;
+
+ tclr->handlers[pos] = apr_pstrdup(parms->pool, arg1);
+ tclr->file_location[pos] = apr_pstrdup(parms->pool, arg2);
+
+ return NULL;
+}
+
static const char* sfl(cmd_parms *parms, void *mconfig, int flag)
{
int f = (int) parms->info;
@@ -229,7 +245,7 @@
return NULL;
}
-
+/*
static const char* tcl_raw_args(cmd_parms *cmd, void *mconfig, char *arg)
{
char **xx, *z = apr_pstrdup(cmd->pool, "");
@@ -245,17 +261,17 @@
break;
}
- /* ick */
+ // ick
z = apr_pstrcat(cmd->pool, z, l, "\n", NULL);
}
- /* ick */
+ // ick
raw_tcl = realloc(raw_tcl, strlen(z) + 1);
strcat(raw_tcl, z);
return NULL;
}
-
+*/
void run_script(Tcl_Interp* interp, char *fmt, ...)
{
char *bptr = NULL;
@@ -554,19 +570,19 @@
static void tcl_init_handler(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
{
- ap_add_version_component(pconf, "mod_tcl/1.0d7");
+ ap_add_version_component(pconf, "mod_tcl/1.0d8-2001112900");
}
static int run_handler(request_rec *r, int hh)
{
int xx = HTTP_NOT_FOUND, i;
tcl_config_rec *tclr = (tcl_config_rec*) ap_get_module_config(r->per_dir_config, &tcl_module);
- size_t flen = strlen(r->filename);
+ size_t flen;
file_cache *fptr = NULL, *fa = (file_cache*) fcache->elts;
var_cache *vl = (var_cache*) tclr->var_list->elts;
struct stat st;
- if (!(tclr->fl & 1) || !interp) {
+ if (!interp) {
return DECLINED;
}
@@ -575,6 +591,16 @@
return DECLINED;
}
+ if (hh < 2) {
+ /* this will be rewritten by some translation... */
+ r->filename = tclr->file_location[hh];
+ }
+ else if (r->finfo.filetype != APR_REG) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r->server, "request URI does not match a file, a translation phase may have failed, r->filename = %s", r->filename);
+ return DECLINED;
+ }
+
+ flen = strlen(r->filename);
stat(r->filename, &st);
for (i = 0; i < fcache->nelts; i++) {
@@ -598,22 +624,22 @@
}
#ifdef HAVE_MMAP
- mptr = mmap((caddr_t) 0, r->finfo.size, PROT_READ, MAP_SHARED, fd, 0);
+ mptr = mmap((caddr_t) 0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
#else
- mptr = malloc(r->finfo.size);
- read(fd, mptr, r->finfo.size);
+ mptr = malloc(st.st_size);
+ read(fd, mptr, st.st_size);
#endif /* HAVE_MMAP */
- bptr = (char*) malloc(r->finfo.size + flen + 21);
+ bptr = (char*) malloc(st.st_size + flen + 21);
memcpy(bptr, "namespace eval ", 15); pos += 15;
memcpy(bptr + pos, r->filename, flen); pos += flen;
memcpy(bptr + pos, " {\n", 3); pos += 3;
- memcpy(bptr + pos, mptr, r->finfo.size); pos += r->finfo.size;
+ memcpy(bptr + pos, mptr, st.st_size); pos += st.st_size;
memcpy(bptr + pos, "\n}\0", 3);
#ifdef HAVE_MMAP
- munmap((char*) mptr, r->finfo.size);
+ munmap((char*) mptr, st.st_size);
#else
free(mptr);
#endif /* HAVE_MMAP */
@@ -622,7 +648,7 @@
fptr = (file_cache*) apr_array_push(fcache);
- fptr->file = apr_pstrdup(fcache->cont, r->filename);
+ fptr->file = apr_pstrdup(fcache->pool, r->filename);
memcpy(&(fptr->st), &st, sizeof(struct stat));
obj = Tcl_NewStringObj(bptr, -1);
@@ -668,22 +694,22 @@
}
#ifdef HAVE_MMAP
- mptr = mmap((caddr_t) 0, r->finfo.size, PROT_READ, MAP_SHARED, fd, 0);
+ mptr = mmap((caddr_t) 0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
#else
- mptr = malloc(r->finfo.size);
- read(fd, mptr, r->finfo.size);
+ mptr = malloc(st.st_size);
+ read(fd, mptr, st.st_size);
#endif /* HAVE_MMAP */
- bptr = malloc(r->finfo.size + flen + 21);
+ bptr = malloc(st.st_size + flen + 21);
memcpy(bptr, "namespace eval ", 15); pos += 15;
memcpy(bptr + pos, r->filename, flen); pos += flen;
memcpy(bptr + pos, " {\n", 3); pos += 3;
- memcpy(bptr + pos, mptr, r->finfo.size); pos += r->finfo.size;
+ memcpy(bptr + pos, mptr, st.st_size); pos += st.st_size;
memcpy(bptr + pos, "\n}\0", 3);
#ifdef HAVE_MMAP
- munmap((char*) mptr, r->finfo.size);
+ munmap((char*) mptr, st.st_size);
#else
free(mptr);
#endif /* HAVE_MMAP */
@@ -692,7 +718,7 @@
fptr = (file_cache*) apr_array_push(fcache);
- fptr->file = apr_pstrdup(fcache->cont, r->filename);
+ fptr->file = apr_pstrdup(fcache->pool, r->filename);
memcpy(&(fptr->st), &st, sizeof(struct stat));
obj = Tcl_NewStringObj(bptr, -1);
@@ -736,52 +762,53 @@
return xx;
}
+inline int tcl_post_read_request(request_rec *r)
+{
+ return run_handler(r, 0);
+}
+
+inline int tcl_translate_name(request_rec *r)
+{
+ return run_handler(r, 1);
+}
+
+inline int tcl_header_parser(request_rec *r)
+{
+ return run_handler(r, 2);
+}
+
+inline int tcl_access_checker(request_rec *r)
+{
+ return run_handler(r, 3);
+}
+
+inline int tcl_check_user_id(request_rec *r)
+{
+ return run_handler(r, 4);
+}
+
+inline int tcl_auth_checker(request_rec *r)
+{
+ return run_handler(r, 5);
+}
+
+inline int tcl_type_checker(request_rec *r)
+{
+ return run_handler(r, 6);
+}
+
+inline int tcl_fixups(request_rec *r)
+{
+ return run_handler(r, 7);
+}
+
+
inline int tcl_handler(request_rec *r)
{
if (strcmp("tcl-handler", r->handler)) {
return DECLINED;
}
- return run_handler(r, 0);
-}
-
-inline int tcl_post_read_request(request_rec *r)
-{
- return run_handler(r, 1);
-}
-
-inline int tcl_translate_name(request_rec *r)
-{
- return run_handler(r, 2);
-}
-
-inline int tcl_header_parser(request_rec *r)
-{
- return run_handler(r, 3);
-}
-
-inline int tcl_access_checker(request_rec *r)
-{
- return run_handler(r, 4);
-}
-
-inline int tcl_check_user_id(request_rec *r)
-{
- return run_handler(r, 5);
-}
-
-inline int tcl_auth_checker(request_rec *r)
-{
- return run_handler(r, 6);
-}
-
-inline int tcl_type_checker(request_rec *r)
-{
- return run_handler(r, 7);
-}
-
-inline int tcl_fixups(request_rec *r)
-{
return run_handler(r, 8);
}
diff --git a/test_script.tm b/test_script.tm
index 1476f05..640af5d 100644
--- a/test_script.tm
+++ b/test_script.tm
@@ -85,10 +85,9 @@
[r connection remote_host]
[r connection remote_logname]
[r connection aborted]
-[r connection keepalive]
-[r connection keptalive]
+#[r connection keepalive]
[r connection doublereverse]
-[r connection keepalives]
+#[r connection keepalives]
[r connection local_ip]
[r connection local_host]
[r connection id]