diff options
| author | Wez Furlong <wez@php.net> | 2002-03-15 21:03:08 +0000 | 
|---|---|---|
| committer | Wez Furlong <wez@php.net> | 2002-03-15 21:03:08 +0000 | 
| commit | 0f65280cb5118d8c1a85db6626f7be365f3d1b26 (patch) | |
| tree | 931b09acc5041eb771017e3ebf9ecb9aa833d722 /ext/standard/php_fopen_wrapper.c | |
| parent | 3a1ebd4f519facbd7ec769304857aad40e49cf1c (diff) | |
| download | php-git-0f65280cb5118d8c1a85db6626f7be365f3d1b26.tar.gz | |
New PHP streams...
Diffstat (limited to 'ext/standard/php_fopen_wrapper.c')
| -rw-r--r-- | ext/standard/php_fopen_wrapper.c | 39 | 
1 files changed, 23 insertions, 16 deletions
diff --git a/ext/standard/php_fopen_wrapper.c b/ext/standard/php_fopen_wrapper.c index 26c9ec2a9e..37b3b2b90f 100644 --- a/ext/standard/php_fopen_wrapper.c +++ b/ext/standard/php_fopen_wrapper.c @@ -30,26 +30,33 @@  #include "php_standard.h"  #include "php_fopen_wrappers.h" - -/* {{{ php_fopen_url_wrap_php - */ -FILE *php_fopen_url_wrap_php(const char *path, char *mode, int options, int *issock, int *socketd, char **opened_path TSRMLS_DC) +php_stream * php_stream_url_wrap_php(char * path, char * mode, int options, char ** opened_path TSRMLS_DC)  { -	const char *res = path + 6; - -	*issock = 0; +	FILE * fp = NULL; +	php_stream * stream = NULL; -	if (!strcasecmp(res, "stdin")) { -		return fdopen(dup(STDIN_FILENO), mode); -	} else if (!strcasecmp(res, "stdout")) { -		return fdopen(dup(STDOUT_FILENO), mode); -	} else if (!strcasecmp(res, "stderr")) { -		return fdopen(dup(STDERR_FILENO), mode); +	if (!strcasecmp(path, "stdin")) { +		fp = fdopen(dup(STDIN_FILENO), mode); +	} else if (!strcasecmp(path, "stdout")) { +		fp = fdopen(dup(STDOUT_FILENO), mode); +	} else if (!strcasecmp(path, "stderr")) { +		fp = fdopen(dup(STDERR_FILENO), mode);  	} -	 -	return NULL; +	/* TODO: implement php://output as a stream to write to the current output buffer ? */ + +	if (fp)	{ +		stream = php_stream_fopen_from_file(fp, mode); +		if (stream == NULL) +			fclose(fp); +	} +	return stream;  } -/* }}} */ + +php_stream_wrapper php_stream_php_wrapper =	{ +	php_stream_url_wrap_php, +	NULL +}; +  /*   * Local variables:  | 
