cvs: /php4/sapi/roxen roxen.c
| From: | David Hedbor | Date: | Wed, 12 Apr 2000 23:00:16 +0000 |
| Subject: | cvs: /php4/sapi/roxen roxen.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-13477@lists.php.net to get a copy of this message | ||
neotron Wed Apr 12 16:00:16 2000 EDT
Modified files:
/php4/sapi/roxen roxen.c
Log:
- Fixed a couple of POST problems.
- Use virtual path functionality when available, to set the cwd of the
script to it's own directory prior to starting it.
- Fixed a bug in php_roxen_sapi_header_handler.
Index: php4/sapi/roxen/roxen.c
diff -u php4/sapi/roxen/roxen.c:1.27 php4/sapi/roxen/roxen.c:1.28
--- php4/sapi/roxen/roxen.c:1.27 Fri Apr 7 09:50:55 2000
+++ php4/sapi/roxen/roxen.c Wed Apr 12 15:59:46 2000
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: roxen.c,v 1.27 2000/04/07 16:50:55 cmv Exp $ */
+/* $Id: roxen.c,v 1.28 2000/04/12 22:59:46 neotron Exp $ */
#include "php.h"
#ifdef HAVE_ROXEN
@@ -335,11 +335,12 @@
header_name = sapi_header->header;
header_content = p = strchr(header_name, ':');
- if(!p) return 0;
+ if(p) {
do {
header_content++;
} while(*header_content == ' ');
- THREAD_SAFE_RUN(php_roxen_set_header(header_name, header_content, p), "header
handler");
+ THREAD_SAFE_RUN(php_roxen_set_header(header_name, header_content, p), "header
handler");
+ }
sapi_free_header(sapi_header);
return 0;
}
@@ -409,7 +410,6 @@
zend_bailout();
return -1;
}
-
push_int(count_bytes);
safe_apply(MY_FD_OBJ, "read_post", 1);
if(Pike_sp[-1].type == PIKE_T_STRING) {
@@ -417,7 +417,7 @@
(total_read = Pike_sp[-1].u.string->len));
buf[total_read] = '\0';
} else
- total_read = -1;
+ total_read = 0;
pop_stack();
return total_read;
}
@@ -447,7 +447,7 @@
{
/* char buf[512]; */
php_info_print_table_start();
- php_info_print_table_row(2, "SAPI module version", "$Id: roxen.c,v 1.27 2000/04/07
16:50:55 cmv Exp $");
+ php_info_print_table_row(2, "SAPI module version", "$Id: roxen.c,v 1.28 2000/04/12
22:59:46 neotron Exp $");
/* php_info_print_table_row(2, "Build date", Ns_InfoBuildDate());
php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile());
php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog());
@@ -492,33 +492,25 @@
static sapi_module_struct sapi_module = {
"Roxen",
+ php_module_startup, /* startup */
+ php_module_shutdown_wrapper, /* shutdown */
+ NULL, /* activate */
+ NULL, /* deactivate */
+ php_roxen_sapi_ub_write, /* unbuffered write */
+ NULL, /* flush */
+ NULL, /* get uid */
+ NULL, /* getenv */
+ php_error, /* error handler */
+ php_roxen_sapi_header_handler, /* header handler */
+ php_roxen_sapi_send_headers, /* send headers handler */
+ NULL, /* send header handler */
+ php_roxen_sapi_read_post, /* read POST data */
+ php_roxen_sapi_read_cookies, /* read Cookies */
+ NULL, /* register server variables */
+ NULL, /* Log message */
+ NULL, /* Block interruptions */
+ NULL, /* Unblock interruptions */
- php_module_startup, /* startup */
- php_module_shutdown_wrapper, /* shutdown */
-
- NULL, /* activate */
- NULL, /* deactivate */
-
- php_roxen_sapi_ub_write, /* unbuffered write */
- NULL, /* flush */
- NULL, /* get uid */
- NULL, /* getenv */
-
- php_error, /* error handler */
-
- php_roxen_sapi_header_handler, /* header handler */
- php_roxen_sapi_send_headers, /* send headers handler */
- NULL, /* send header handler */
-
- php_roxen_sapi_read_post, /* read POST data */
- php_roxen_sapi_read_cookies, /* read Cookies */
-
- NULL, /* register server variables */
- NULL, /* Log message */
-
- NULL, /* Block interruptions */
- NULL, /* Unblock interruptions */
-
STANDARD_SAPI_MODULE_PROPERTIES
};
@@ -588,7 +580,8 @@
static int php_roxen_module_main(SLS_D)
{
- int res;
+ int res, len;
+ char *dir;
zend_file_handle file_handle;
#ifdef ZTS
CLS_FETCH();
@@ -598,9 +591,25 @@
GET_THIS();
#endif
#endif
+
+ /* Change virtual directory, if the feature is enabled */
+#ifdef VIRTUAL_DIR
+ dir = malloc(len = strlen(THIS->filename));
+ strcpy(dir, THIS->filename);
+ while(--len >= 0 && dir[len] != '/')
+ ;
+ /* VERY BAD, but should work */
+ if(len > 0) {
+ dir[len] = '\0';
+ PHP_CHDIR(dir);
+ }
+ free(dir);
+#endif
+
file_handle.type = ZEND_HANDLE_FILENAME;
file_handle.filename = THIS->filename;
file_handle.free_filename = 0;
+
THREADS_ALLOW();
res = php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC);
THREADS_DISALLOW();
@@ -633,7 +642,7 @@
#endif
if(current_thread == th_self())
- error("PHP4.Interpetor->run: Tried to run a PHP-script from a PHP "
+ error("PHP4.Interpreter->run: Tried to run a PHP-script from a PHP "
"callback!");
get_all_args("PHP4.Interpreter->run", args, "%S%m%O%*", &script,
&request_data, &my_fd_obj, &done_callback);
@@ -648,17 +657,22 @@
THIS->my_fd_obj = my_fd_obj;
THIS->filename = script->str;
current_thread = th_self();
- SG(request_info).query_string = lookup_string_header("QUERY_STRING", 0);;
+ SG(request_info).query_string = lookup_string_header("QUERY_STRING", 0);
SG(server_context) = (void *)1; /* avoid server_context == NULL */
- /* path_translated is the absolute path to the file */
+
+ /* path_translated is apparently the absolute path to the file, not
+ the translated PATH_INFO
+ */
SG(request_info).path_translated =
- lookup_string_header("PATH_TRANSLATED", NULL);
+ lookup_string_header("SCRIPT_FILENAME", NULL);
SG(request_info).request_uri = lookup_string_header("DOCUMENT_URI", NULL);
if(!SG(request_info).request_uri)
SG(request_info).request_uri = lookup_string_header("SCRIPT_NAME", NULL);
SG(request_info).request_method = lookup_string_header("REQUEST_METHOD",
"GET");
- SG(request_info).content_length = lookup_integer_header("CONTENT_LENGTH", 0);
- SG(request_info).content_type = "text/html";
+ SG(request_info).content_length = lookup_integer_header("HTTP_CONTENT_LENGTH", 0);
+ SG(request_info).content_type = lookup_string_header("HTTP_CONTENT_TYPE", NULL);
+
+ /* FIXME: Check for auth stuff needs to be fixed... */
SG(request_info).auth_user = NULL;
SG(request_info).auth_password = NULL;
@@ -697,7 +711,7 @@
* This functions allocates basic structures
*/
-void pike_module_init()
+void pike_module_init( void )
{
if (!roxen_php_initialized) {
#ifdef ZTS