cataphract Fri, 05 Nov 2010 18:53:48 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=305108
Log: - Renamed php_stream_rep_nonstand_mode to php_stream_mode_sanitize_fdopen_fopencookie, made it not exported and movied it from php_streams.h to php_streams_int.h. Changed paths: U php/php-src/branches/PHP_5_3/main/php_streams.h U php/php-src/branches/PHP_5_3/main/streams/cast.c U php/php-src/branches/PHP_5_3/main/streams/php_streams_int.h U php/php-src/branches/PHP_5_3/main/streams/plain_wrapper.c U php/php-src/trunk/main/php_streams.h U php/php-src/trunk/main/streams/cast.c U php/php-src/trunk/main/streams/php_streams_int.h U php/php-src/trunk/main/streams/plain_wrapper.c Modified: php/php-src/branches/PHP_5_3/main/php_streams.h =================================================================== --- php/php-src/branches/PHP_5_3/main/php_streams.h 2010-11-05 18:12:30 UTC (rev 305107) +++ php/php-src/branches/PHP_5_3/main/php_streams.h 2010-11-05 18:53:48 UTC (rev 305108) @@ -462,12 +462,6 @@ #define PHP_STREAM_CAST_MASK (PHP_STREAM_CAST_TRY_HARD | PHP_STREAM_CAST_RELEASE | PHP_STREAM_CAST_INTERNAL) BEGIN_EXTERN_C() PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show_err TSRMLS_DC); -/* This functions transforms the first char to 'w' if it's not 'r', 'a' or 'w' - * and strips any subsequent chars except '+' and 'b'. - * Use this to sanitize stream->mode if you call e.g. fdopen, fopencookie or - * any other function that expects standard modes and you allow non-standard - * ones. result should be a char[5]. */ -PHPAPI void php_stream_rep_nonstand_mode(php_stream *stream, char *result); END_EXTERN_C() /* use this to check if a stream can be cast into another form */ #define php_stream_can_cast(stream, as) _php_stream_cast((stream), (as), NULL, 0 TSRMLS_CC) Modified: php/php-src/branches/PHP_5_3/main/streams/cast.c =================================================================== --- php/php-src/branches/PHP_5_3/main/streams/cast.c 2010-11-05 18:12:30 UTC (rev 305107) +++ php/php-src/branches/PHP_5_3/main/streams/cast.c 2010-11-05 18:53:48 UTC (rev 305108) @@ -144,9 +144,9 @@ #endif /* }}} */ -/* {{{ php_stream_rep_nonstand_mode +/* {{{ php_stream_mode_sanitize_fdopen_fopencookie * Result should have at least size 5, e.g. to write wbx+\0 */ -PHPAPI void php_stream_rep_nonstand_mode(php_stream *stream, char *result) +void php_stream_mode_sanitize_fdopen_fopencookie(php_stream *stream, char *result) { /* replace modes not supported by fdopen and fopencookie, but supported * by PHP's fread(), so that their calls won't fail */ @@ -233,7 +233,7 @@ { char fixed_mode[5]; - php_stream_rep_nonstand_mode(stream, fixed_mode); + php_stream_mode_sanitize_fdopen_fopencookie(stream, fixed_mode); *(FILE**)ret = fopencookie(stream, fixed_mode, PHP_STREAM_COOKIE_FUNCTIONS); } Modified: php/php-src/branches/PHP_5_3/main/streams/php_streams_int.h =================================================================== --- php/php-src/branches/PHP_5_3/main/streams/php_streams_int.h 2010-11-05 18:12:30 UTC (rev 305107) +++ php/php-src/branches/PHP_5_3/main/streams/php_streams_int.h 2010-11-05 18:53:48 UTC (rev 305108) @@ -59,6 +59,13 @@ #define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG) #endif +/* This functions transforms the first char to 'w' if it's not 'r', 'a' or 'w' + * and strips any subsequent chars except '+' and 'b'. + * Use this to sanitize stream->mode if you call e.g. fdopen, fopencookie or + * any other function that expects standard modes and you allow non-standard + * ones. result should be a char[5]. */ +void php_stream_mode_sanitize_fdopen_fopencookie(php_stream *stream, char *result); + void php_stream_tidy_wrapper_error_log(php_stream_wrapper *wrapper TSRMLS_DC); void php_stream_display_wrapper_errors(php_stream_wrapper *wrapper, const char *path, const char *caption TSRMLS_DC); Modified: php/php-src/branches/PHP_5_3/main/streams/plain_wrapper.c =================================================================== --- php/php-src/branches/PHP_5_3/main/streams/plain_wrapper.c 2010-11-05 18:12:30 UTC (rev 305107) +++ php/php-src/branches/PHP_5_3/main/streams/plain_wrapper.c 2010-11-05 18:53:48 UTC (rev 305108) @@ -491,7 +491,7 @@ /* we were opened as a plain file descriptor, so we * need fdopen now */ char fixed_mode[5]; - php_stream_rep_nonstand_mode(stream, fixed_mode); + php_stream_mode_sanitize_fdopen_fopencookie(stream, fixed_mode); data->file = fdopen(data->fd, fixed_mode); if (data->file == NULL) { return FAILURE; Modified: php/php-src/trunk/main/php_streams.h =================================================================== --- php/php-src/trunk/main/php_streams.h 2010-11-05 18:12:30 UTC (rev 305107) +++ php/php-src/trunk/main/php_streams.h 2010-11-05 18:53:48 UTC (rev 305108) @@ -462,12 +462,6 @@ #define PHP_STREAM_CAST_MASK (PHP_STREAM_CAST_TRY_HARD | PHP_STREAM_CAST_RELEASE | PHP_STREAM_CAST_INTERNAL) BEGIN_EXTERN_C() PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show_err TSRMLS_DC); -/* This functions transforms the first char to 'w' if it's not 'r', 'a' or 'w' - * and strips any subsequent chars except '+' and 'b'. - * Use this to sanitize stream->mode if you call e.g. fdopen, fopencookie or - * any other function that expects standard modes and you allow non-standard - * ones. result should be a char[5]. */ -PHPAPI void php_stream_rep_nonstand_mode(php_stream *stream, char *result); END_EXTERN_C() /* use this to check if a stream can be cast into another form */ #define php_stream_can_cast(stream, as) _php_stream_cast((stream), (as), NULL, 0 TSRMLS_CC) Modified: php/php-src/trunk/main/streams/cast.c =================================================================== --- php/php-src/trunk/main/streams/cast.c 2010-11-05 18:12:30 UTC (rev 305107) +++ php/php-src/trunk/main/streams/cast.c 2010-11-05 18:53:48 UTC (rev 305108) @@ -144,9 +144,9 @@ #endif /* }}} */ -/* {{{ php_stream_rep_nonstand_mode +/* {{{ php_stream_mode_sanitize_fdopen_fopencookie * Result should have at least size 5, e.g. to write wbx+\0 */ -PHPAPI void php_stream_rep_nonstand_mode(php_stream *stream, char *result) +void php_stream_mode_sanitize_fdopen_fopencookie(php_stream *stream, char *result) { /* replace modes not supported by fdopen and fopencookie, but supported * by PHP's fread(), so that their calls won't fail */ @@ -233,7 +233,7 @@ { char fixed_mode[5]; - php_stream_rep_nonstand_mode(stream, fixed_mode); + php_stream_mode_sanitize_fdopen_fopencookie(stream, fixed_mode); *(FILE**)ret = fopencookie(stream, fixed_mode, PHP_STREAM_COOKIE_FUNCTIONS); } Modified: php/php-src/trunk/main/streams/php_streams_int.h =================================================================== --- php/php-src/trunk/main/streams/php_streams_int.h 2010-11-05 18:12:30 UTC (rev 305107) +++ php/php-src/trunk/main/streams/php_streams_int.h 2010-11-05 18:53:48 UTC (rev 305108) @@ -59,6 +59,13 @@ #define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG) #endif +/* This functions transforms the first char to 'w' if it's not 'r', 'a' or 'w' + * and strips any subsequent chars except '+' and 'b'. + * Use this to sanitize stream->mode if you call e.g. fdopen, fopencookie or + * any other function that expects standard modes and you allow non-standard + * ones. result should be a char[5]. */ +void php_stream_mode_sanitize_fdopen_fopencookie(php_stream *stream, char *result); + void php_stream_tidy_wrapper_error_log(php_stream_wrapper *wrapper TSRMLS_DC); void php_stream_display_wrapper_errors(php_stream_wrapper *wrapper, const char *path, const char *caption TSRMLS_DC); Modified: php/php-src/trunk/main/streams/plain_wrapper.c =================================================================== --- php/php-src/trunk/main/streams/plain_wrapper.c 2010-11-05 18:12:30 UTC (rev 305107) +++ php/php-src/trunk/main/streams/plain_wrapper.c 2010-11-05 18:53:48 UTC (rev 305108) @@ -491,7 +491,7 @@ /* we were opened as a plain file descriptor, so we * need fdopen now */ char fixed_mode[5]; - php_stream_rep_nonstand_mode(stream, fixed_mode); + php_stream_mode_sanitize_fdopen_fopencookie(stream, fixed_mode); data->file = fdopen(data->fd, fixed_mode); if (data->file == NULL) { return FAILURE;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php