--- php_apache.h.orig Thu Apr 11 16:34:31 2002 +++ php_apache.h Thu Jun 20 02:42:54 2002 @@ -19,6 +19,8 @@ #ifndef PHP_APACHE_H #define PHP_APACHE_H +#include + typedef struct php_struct { int state; request_rec *r; @@ -31,6 +33,8 @@ char *post_data; /* Whether or not we've processed PHP in the output filters yet. */ int request_processed; + /* A plain old struct stat generated from the request_rec */ + struct stat statbuf; } php_struct; int php_apache_register_module(void); --- sapi_apache2.orig Mon May 6 11:42:23 2002 +++ sapi_apache2.c Thu Jun 20 02:50:38 2002 @@ -221,6 +221,48 @@ } } +/* See filestat.c in APR for the struct stat -> finfo conversion + This just converts it back to a struct stat */ +static struct stat *php_apache_get_stat(TSRMLS_D) +{ + php_struct *ctx = SG(server_context); + return &(ctx->statbuf); +} + +static void php_apr_finfo2stat(struct stat *st,apr_finfo_t *finfo){ + memset(st,0,sizeof(*st)); + + if(finfo->protection & APR_UREAD) st->st_mode |= S_IRUSR; + if(finfo->protection & APR_UWRITE) st->st_mode |= S_IWUSR; + if(finfo->protection & APR_UEXECUTE) st->st_mode |= S_IXUSR; + + if(finfo->protection & APR_GREAD) st->st_mode |= S_IRGRP; + if(finfo->protection & APR_GWRITE) st->st_mode |= S_IWGRP; + if(finfo->protection & APR_GEXECUTE) st->st_mode |= S_IXGRP; + + if(finfo->protection & APR_WREAD) st->st_mode |= S_IROTH; + if(finfo->protection & APR_WWRITE) st->st_mode |= S_IWOTH; + if(finfo->protection & APR_WEXECUTE) st->st_mode |= S_IXOTH; + + if(finfo->filetype == APR_REG) st->st_mode |= S_IFREG; + if(finfo->filetype == APR_DIR) st->st_mode |= S_IFDIR; + if(finfo->filetype == APR_CHR) st->st_mode |= S_IFCHR; + if(finfo->filetype == APR_BLK) st->st_mode |= S_IFBLK; + if(finfo->filetype == APR_PIPE) st->st_mode |= S_IFIFO; + if(finfo->filetype == APR_LNK) st->st_mode |= S_IFLNK; + + st->st_uid = finfo->user; + st->st_gid = finfo->group; + st->st_size = finfo->size; + st->st_ino = finfo->inode; + st->st_dev = finfo->device; + st->st_nlink = finfo->nlink; + + st->st_atime = finfo->atime / APR_USEC_PER_SEC; + st->st_mtime = finfo->mtime / APR_USEC_PER_SEC; + st->st_ctime = finfo->ctime / APR_USEC_PER_SEC; +} + static sapi_module_struct apache2_sapi_module = { "apache2filter", "Apache 2.0 Filter", @@ -233,7 +275,7 @@ php_apache_sapi_ub_write, /* unbuffered write */ php_apache_sapi_flush, /* flush */ - NULL, /* get uid */ + php_apache_get_stat, /* get uid */ NULL, /* getenv */ php_error, /* error handler */ @@ -421,7 +463,9 @@ { apache2_sapi_module.shutdown(&apache2_sapi_module); sapi_shutdown(); +#ifdef ZTS tsrm_shutdown(); +#endif return APR_SUCCESS; } @@ -454,7 +498,9 @@ return OK; } +#ifdef ZTS tsrm_startup(1, 1, 0, NULL); +#endif sapi_startup(&apache2_sapi_module); apache2_sapi_module.startup(&apache2_sapi_module); apr_pool_cleanup_register(pconf, NULL, php_apache_server_shutdown, apr_pool_cleanup_null); @@ -523,8 +569,11 @@ * filters if we need them. */ ctx->r = r; + php_apr_finfo2stat(&(ctx->statbuf),&(r->finfo)); + return OK; } + static void php_register_hook(apr_pool_t *p) {