]> granicus.if.org Git - php/commitdiff
PHP6 Update for get_included_files() and export of path decode for Zend
authorSara Golemon <pollita@php.net>
Tue, 3 Oct 2006 16:28:02 +0000 (16:28 +0000)
committerSara Golemon <pollita@php.net>
Tue, 3 Oct 2006 16:28:02 +0000 (16:28 +0000)
Zend/zend.c
Zend/zend.h
Zend/zend_builtin_functions.c
main/main.c

index 02b8e470afc83bd45ceda0528661ad254b2c73ff..6da0946a85851974a77f4fe07809eef6c39339f9 100644 (file)
@@ -56,6 +56,7 @@ ZEND_API zend_class_entry *zend_standard_class_def = NULL;
 ZEND_API int (*zend_printf)(const char *format, ...);
 ZEND_API zend_write_func_t zend_write;
 ZEND_API int (*zend_path_encode)(char **encpath, int *encpath_len, const UChar *path, int path_len TSRMLS_DC);
+ZEND_API int (*zend_path_decode)(UChar **decpath, int *decpath_len, const char *path, int path_len TSRMLS_DC);
 ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path);
 ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
 ZEND_API void (*zend_block_interruptions)(void);
@@ -624,6 +625,22 @@ static int zend_path_encode_wrapper(char **encpath, int *encpath_len, const UCha
        return SUCCESS;
 }
 
+static int zend_path_decode_wrapper(UChar **decpath, int *decpath_len, const char *path, int path_len TSRMLS_DC)
+{
+       UErrorCode status = U_ZERO_ERROR;
+
+       zend_string_to_unicode_ex(ZEND_U_CONVERTER(UG(filesystem_encoding_conv)), decpath, decpath_len, path, path_len, &status);
+
+       if (U_FAILURE(status)) {
+               efree(*decpath);
+               *decpath = NULL;
+               *decpath_len = 0;
+               return FAILURE;
+       }
+
+       return SUCCESS;
+}
+
 static FILE *zend_fopen_wrapper(const char *filename, char **opened_path)
 {
        if (opened_path) {
@@ -1012,6 +1029,10 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
        if (!zend_path_encode) {
                zend_path_encode = zend_path_encode_wrapper;
        }
+       zend_path_decode = utility_functions->path_decode_function;
+       if (!zend_path_decode) {
+               zend_path_decode = zend_path_decode_wrapper;
+       }
        zend_fopen = utility_functions->fopen_function;
        if (!zend_fopen) {
                zend_fopen = zend_fopen_wrapper;
index 6a626b83ca79fb10bb2ab2a6d5b139c9b7b8e6c1..f822c56bdcce592d84512ccd322b1b48353058ed 100644 (file)
@@ -411,6 +411,7 @@ typedef struct _zend_utility_functions {
        int (*printf_function)(const char *format, ...);
        int (*write_function)(const char *str, uint str_length);
        int (*path_encode_function)(char **encpath, int *encpath_len, const UChar *path, int path_len TSRMLS_DC);
+       int (*path_decode_function)(UChar **decpath, int *decpath_len, const char *path, int path_len TSRMLS_DC);
        FILE *(*fopen_function)(const char *filename, char **opened_path);
        void (*message_handler)(long message, void *data);
        void (*block_interruptions)(void);
@@ -557,6 +558,7 @@ BEGIN_EXTERN_C()
 extern ZEND_API int (*zend_printf)(const char *format, ...);
 extern ZEND_API zend_write_func_t zend_write;
 extern ZEND_API int (*zend_path_encode)(char **encpath, int *encpath_len, const UChar *path, int path_len TSRMLS_DC);
+extern ZEND_API int (*zend_path_decode)(UChar **decpath, int *decpath_len, const char *path, int path_len TSRMLS_DC);
 extern ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path);
 extern ZEND_API void (*zend_block_interruptions)(void);
 extern ZEND_API void (*zend_unblock_interruptions)(void);
index 0bc5e35a2a4c00ae77f73fa7900f2e8e58495c7c..def6eda4864efc2d380ff091a8fe400a8eefa029 100644 (file)
@@ -1197,22 +1197,28 @@ ZEND_FUNCTION(crash)
 
 #endif /* ZEND_DEBUG */
 
-/* {{{ proto array get_included_files(void)
-   Returns an array with the file names that were include_once()'d */
+/* {{{ proto array get_included_files(void) U
+   Returns an array with the file names that were included (includes require and once varieties) */
 ZEND_FUNCTION(get_included_files)
 {
+       HashPosition pos;
+       UChar *ustr;
        zstr entry;
+       int len, ustr_len;
+
        if (ZEND_NUM_ARGS() != 0) {
                ZEND_WRONG_PARAM_COUNT();
        }
 
        array_init(return_value);
-       zend_hash_internal_pointer_reset(&EG(included_files));
-       while (zend_hash_get_current_key(&EG(included_files), &entry, NULL, 0) == HASH_KEY_IS_STRING) {
-               /* UTODO Not sure this should be runtime encoding.. maybe filename encoding
-                * instead */
-               add_next_index_rt_string(return_value, entry.s, 1);
-               zend_hash_move_forward(&EG(included_files));
+       zend_hash_internal_pointer_reset_ex(&EG(included_files), &pos);
+       while (zend_hash_get_current_key_ex(&EG(included_files), &entry, &len, NULL, 0, &pos) == HASH_KEY_IS_STRING) {
+               if (UG(unicode) && SUCCESS == zend_path_decode(&ustr, &ustr_len, entry.s, len - 1 TSRMLS_CC)) {
+                       add_next_index_unicodel(return_value, ustr, ustr_len, 0);
+               } else {
+                       add_next_index_stringl(return_value, entry.s, len - 1, 1);
+               }
+               zend_hash_move_forward_ex(&EG(included_files), &pos);
        }
 }
 /* }}} */
index 73bfdc89f029a42e3a2eee645583ade78e62456a..d70451866eed4583a265edfadaa4fef9ccea0e20 100644 (file)
@@ -983,6 +983,14 @@ static int php_path_encode_for_zend(char **encpath, int *encpath_len, const UCha
 }
 /* }}} */
 
+/* {{{ php_path_decode_for_zend
+ */
+static int php_path_decode_for_zend(UChar **decpath, int *decpath_len, const char *path, int path_len TSRMLS_DC)
+{
+       return php_stream_path_decode(NULL, decpath, decpath_len, path, path_len, 0, NULL);
+}
+/* }}} */
+
 /* {{{ php_fopen_wrapper_for_zend
  */
 static FILE *php_fopen_wrapper_for_zend(const char *filename, char **opened_path)
@@ -1550,6 +1558,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
        zuf.printf_function = php_printf;
        zuf.write_function = php_output_wrapper;
        zuf.path_encode_function = php_path_encode_for_zend;
+       zuf.path_decode_function = php_path_decode_for_zend;
        zuf.fopen_function = php_fopen_wrapper_for_zend;
        zuf.message_handler = php_message_handler_for_zend;
        zuf.block_interruptions = sapi_module.block_interruptions;