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);
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) {
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;
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);
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);
#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);
}
}
/* }}} */
}
/* }}} */
+/* {{{ 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)
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;