summaryrefslogtreecommitdiff
path: root/Zend/zend_builtin_functions.c
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>1999-12-04 14:26:26 +0000
committerZeev Suraski <zeev@php.net>1999-12-04 14:26:26 +0000
commitefc84af94003531f2e670cdc754b0c455656198c (patch)
tree71baf7b9def40a676fa93f57d14b48b491d80388 /Zend/zend_builtin_functions.c
parentad30b198d4819491eb5d0524d696a91608aa0f38 (diff)
downloadphp-git-efc84af94003531f2e670cdc754b0c455656198c.tar.gz
- Implement get_used_files() and get_imported_files()
Diffstat (limited to 'Zend/zend_builtin_functions.c')
-rw-r--r--Zend/zend_builtin_functions.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 1f7c498660..4e70e460a2 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -40,6 +40,8 @@ static ZEND_FUNCTION(get_class);
static ZEND_FUNCTION(get_parent_class);
static ZEND_FUNCTION(method_exists);
static ZEND_FUNCTION(leak);
+static ZEND_FUNCTION(get_used_files);
+static ZEND_FUNCTION(get_imported_files);
extern unsigned char first_arg_force_ref[];
@@ -59,6 +61,8 @@ static zend_function_entry builtin_functions[] = {
ZEND_FE(get_parent_class, NULL)
ZEND_FE(method_exists, NULL)
ZEND_FE(leak, NULL)
+ ZEND_FE(get_used_files, NULL)
+ ZEND_FE(get_imported_files, NULL)
{ NULL, NULL, NULL }
};
@@ -421,3 +425,41 @@ ZEND_FUNCTION(leak)
emalloc(leakbytes);
}
+
+
+static int copy_import_use_file(zend_file_handle *fh, zval *array)
+{
+ if (fh->filename) {
+ char *extension_start;
+
+ extension_start = strstr(fh->filename, zend_uv.import_use_extension);
+ if (extension_start) {
+ *extension_start = 0;
+ if (fh->opened_path) {
+ add_assoc_string(array, fh->filename, fh->opened_path, 1);
+ } else {
+ add_assoc_stringl(array, fh->filename, "N/A", sizeof("N/A")-1, 1);
+ }
+ *extension_start = zend_uv.import_use_extension[0];
+ }
+ }
+ return 0;
+}
+
+
+ZEND_FUNCTION(get_used_files)
+{
+ CLS_FETCH();
+
+ array_init(return_value);
+ zend_hash_apply_with_argument(&CG(used_files), (int (*)(void *, void *)) copy_import_use_file, return_value);
+}
+
+
+ZEND_FUNCTION(get_imported_files)
+{
+ ELS_FETCH();
+
+ array_init(return_value);
+ zend_hash_apply_with_argument(&EG(imported_files), (int (*)(void *, void *)) copy_import_use_file, return_value);
+}