cvs: php4 /sapi/apache2filter sapi_apache2.c

From: Date: Mon, 23 Jul 2001 04:50:13 +0000
Subject: cvs: php4 /sapi/apache2filter sapi_apache2.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-6324@lists.php.net to get a copy of this message
sas Mon Jul 23 00:50:13 2001 EDT Modified files: /php4/sapi/apache2filter sapi_apache2.c Log: Handle file buckets for now; that allows us to pass something to the engine which it can handle. Index: php4/sapi/apache2filter/sapi_apache2.c diff -u php4/sapi/apache2filter/sapi_apache2.c:1.30 php4/sapi/apache2filter/sapi_apache2.c:1.31 --- php4/sapi/apache2filter/sapi_apache2.c:1.30 Fri Jun 22 19:20:49 2001 +++ php4/sapi/apache2filter/sapi_apache2.c Mon Jul 23 00:50:13 2001 @@ -308,9 +308,6 @@ { php_struct *ctx; apr_bucket *b; - apr_status_t rv; - const char *str; - apr_ssize_t n; void *conf = ap_get_module_config(f->r->per_dir_config, &php4_module); SLS_FETCH(); @@ -340,9 +337,7 @@ * we "flatten" the buckets by creating a single string buffer. */ if (ctx->state == 1 && APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(ctx->bb))) { - int fd; zend_file_handle zfd; - smart_str content = {0}; apr_bucket *eos; CLS_FETCH(); ELS_FETCH(); @@ -356,53 +351,30 @@ ctx->state = 2; /* Handle phpinfo/phpcredits/built-in images */ - if (php_handle_special_queries(SLS_C PLS_CC)) - goto ok; - - /* Loop over all buckets and put them into the buffer */ - APR_BRIGADE_FOREACH(b, ctx->bb) { - rv = apr_bucket_read(b, &str, &n, 1); - if (rv == APR_SUCCESS && n > 0) - smart_str_appendl(&content, str, n); - } - - /* Empty script */ - if (!content.c) goto skip_execution; - - smart_str_0(&content); - - /* - * This hack is used only for testing purposes and will - * go away when the scripting engine will be able to deal - * with something more complex than files/-handles. - */ - -#if 1 -#define FFFF "/tmp/really_silly" - fd = open(FFFF, O_WRONLY|O_TRUNC|O_CREAT, 0600); - - write(fd, content.c, content.len); + if (!php_handle_special_queries(SLS_C PLS_CC)) { - close(fd); - - zfd.type = ZEND_HANDLE_FILENAME; - zfd.filename = FFFF; - zfd.free_filename = 0; - zfd.opened_path = NULL; + b = APR_BRIGADE_FIRST(ctx->bb); + + if (APR_BUCKET_IS_FILE(b)) { + const char *path; + + apr_file_name_get(&path, ((apr_bucket_file *) b->data)->fd); + + zfd.type = ZEND_HANDLE_FILENAME; + zfd.filename = (char *) path; + zfd.free_filename = 0; + zfd.opened_path = NULL; + + php_execute_script(&zfd CLS_CC ELS_CC PLS_CC); + } else { + +#define NO_DATA "The PHP Filter did not receive suitable input data" + + eos = apr_bucket_transient_create(NO_DATA, sizeof(NO_DATA)-1); + APR_BRIGADE_INSERT_HEAD(bb, eos); + } + } - php_execute_script(&zfd CLS_CC ELS_CC PLS_CC); -#else - CG(in_compilation) = 1; - zend_eval_string(content, NULL, "foo" CLS_CC ELS_CC); -#endif - - smart_str_free(&content); - goto ok; -skip_execution: -#define NO_DATA "php_filter did not get ANY data" - eos = apr_bucket_transient_create(NO_DATA, sizeof(NO_DATA)-1); - APR_BRIGADE_INSERT_HEAD(bb, eos); -ok: php_apache_request_dtor(f SLS_CC); SG(server_context) = 0;

« previous php.cvs (#6324) next »