cvs: php-src /main php_streams.h /main/streams streams.c
| From: | Sara Golemon | Date: | Wed, 10 Jan 2007 22:43:17 +0000 |
| Subject: | cvs: php-src /main php_streams.h /main/streams streams.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-42662@lists.php.net to get a copy of this message | ||
pollita Wed Jan 10 22:43:17 2007 UTC
Modified files:
/php-src/main php_streams.h
/php-src/main/streams streams.c
Log:
Add convenience function for openeing files with unicode names
http://cvs.php.net/viewvc.cgi/php-src/main/php_streams.h?r1=1.120&r2=1.121&diff_format=u
Index: php-src/main/php_streams.h
diff -u php-src/main/php_streams.h:1.120 php-src/main/php_streams.h:1.121
--- php-src/main/php_streams.h:1.120 Mon Jan 1 09:29:35 2007
+++ php-src/main/php_streams.h Wed Jan 10 22:43:17 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_streams.h,v 1.120 2007/01/01 09:29:35 sebastian Exp $ */
+/* $Id: php_streams.h,v 1.121 2007/01/10 22:43:17 pollita Exp $ */
#ifndef PHP_STREAMS_H
#define PHP_STREAMS_H
@@ -618,12 +618,18 @@
PHPAPI int php_unregister_url_stream_wrapper_volatile(char *protocol TSRMLS_DC);
PHPAPI void php_stream_fix_encoding(php_stream *stream, const char *mode, php_stream_context
*context TSRMLS_DC);
PHPAPI php_stream *_php_stream_open_wrapper_ex(char *path, char *mode, int options, char
**opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
+PHPAPI php_stream *_php_stream_u_open_wrapper(zend_uchar type, zstr path, int path_len, char
*mode, int options, zstr *opened_path, int *opened_path_len, php_stream_context *context STREAMS_DC
TSRMLS_DC);
PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, char **path_for_open,
int options TSRMLS_DC);
PHPAPI void *php_stream_locate_eol(php_stream *stream, zstr zbuf, int buf_len TSRMLS_DC);
#define php_stream_open_wrapper(path, mode, options, opened) _php_stream_open_wrapper_ex((path),
(mode), (options), (opened), NULL STREAMS_CC TSRMLS_CC)
#define php_stream_open_wrapper_ex(path, mode, options, opened,
context) _php_stream_open_wrapper_ex((path), (mode), (options), (opened), (context) STREAMS_CC
TSRMLS_CC)
+#define php_stream_u_open_wrapper(type, path, path_len, mode, options, opened, context) \
+ _php_stream_u_open_wrapper((type), (path), (path_len), (mode), (options), (opened), NULL,
(context) STREAMS_CC TSRMLS_CC)
+#define php_stream_u_open_wrapper_ex(type, path, path_len, mode, options, opened, opened_len,
context) \
+ _php_stream_u_open_wrapper((type), (path), (path_len), (mode), (options), (opened), (opened_len),
(context) STREAMS_CC TSRMLS_CC)
+
#define php_stream_get_from_zval(stream, zstream, mode, options, opened, context) \
if (Z_TYPE_PP((zstream)) == IS_RESOURCE) { \
php_stream_from_zval((stream), (zstream)); \
http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.142&r2=1.143&diff_format=u
Index: php-src/main/streams/streams.c
diff -u php-src/main/streams/streams.c:1.142 php-src/main/streams/streams.c:1.143
--- php-src/main/streams/streams.c:1.142 Mon Jan 1 09:29:35 2007
+++ php-src/main/streams/streams.c Wed Jan 10 22:43:17 2007
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: streams.c,v 1.142 2007/01/01 09:29:35 sebastian Exp $ */
+/* $Id: streams.c,v 1.143 2007/01/10 22:43:17 pollita Exp $ */
#define _GNU_SOURCE
#include "php.h"
@@ -2434,6 +2434,61 @@
}
/* }}} */
+/* {{{ _php_stream_u_open_wrapper */
+PHPAPI php_stream *_php_stream_u_open_wrapper(zend_uchar type, zstr path, int path_len,
+ char *mode, int options, zstr *opened_path, int *opened_path_len,
+ php_stream_context *context STREAMS_DC TSRMLS_DC)
+{
+ php_stream *stream;
+ char *filename = NULL;
+ int filename_len;
+
+ if (opened_path) {
+ opened_path->v = NULL;
+ }
+ if (opened_path_len) {
+ *opened_path_len = 0;
+ }
+
+ if (type == IS_STRING) {
+ stream = php_stream_open_wrapper_ex(path.s, mode, options, (char**)opened_path, context);
+
+ if (opened_path_len && opened_path && opened_path->s) {
+ *opened_path_len = strlen(opened_path->s);
+ }
+
+ return stream;
+ }
+
+ /* type == IS_UNICODE */
+ if (FAILURE == php_stream_path_encode(NULL, &filename, &filename_len, path.u, path_len,
options, context)) {
+ return NULL;
+ }
+
+ stream = php_stream_open_wrapper_ex(filename, mode, options, (char**)opened_path, context);
+ efree(filename);
+
+ if (opened_path && opened_path->s) {
+ UChar *upath;
+ int upath_len;
+
+ if (SUCCESS == php_stream_path_decode(NULL, &upath, &upath_len, opened_path->s,
strlen(opened_path->s), options, context)) {
+ efree(opened_path->s);
+ opened_path->u = upath;
+ if (opened_path_len) {
+ *opened_path_len = upath_len;
+ }
+ } else {
+ /* Shouldn't happen */
+ efree(opened_path->s);
+ opened_path->s = NULL;
+ }
+ }
+
+ return stream;
+}
+/* }}} */
+
/* {{{ context API */
PHPAPI php_stream_context *php_stream_context_set(php_stream *stream, php_stream_context *context)
{