diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c index 9c83cd4f6a5..09687644592 100644 --- a/ext/ffi/ffi.c +++ b/ext/ffi/ffi.c @@ -34,6 +34,14 @@ #include #include +#ifdef HAVE_GLOB +#ifdef PHP_WIN32 +#include "win32/glob.h" +#else +#include +#endif +#endif + ZEND_DECLARE_MODULE_GLOBALS(ffi) typedef enum _zend_ffi_tag_kind { @@ -4713,10 +4721,50 @@ ZEND_INI_BEGIN() STD_ZEND_INI_ENTRY("ffi.preload", NULL, ZEND_INI_SYSTEM, OnUpdateString, preload, zend_ffi_globals, ffi_globals) ZEND_INI_END() +static int zend_ffi_preload_glob(const char *filename) /* {{{ */ +{ +#ifdef HAVE_GLOB + glob_t globbuf; + int ret; + unsigned int i; + + memset(&globbuf, 0, sizeof(glob_t)); + + ret = glob(filename, 0, NULL, &globbuf); +#ifdef GLOB_NOMATCH + if (ret == GLOB_NOMATCH || !globbuf.gl_pathc) { +#else + if (!globbuf.gl_pathc) { +#endif + /* pass */ + } else { + for(i=0 ; i + +--INI-- +ffi.enable=1 +ffi.preload={PWD}/300*.h +--FILE-- +printf("Hello World from %s!\n", "PHP"); +?> +--EXPECT-- +Hello World from PHP! diff --git a/php.ini-development b/php.ini-development index 186d67be6be..f67f407c0c0 100644 --- a/php.ini-development +++ b/php.ini-development @@ -1916,5 +1916,5 @@ ldap.max_links = -1 ; "true" - always enabled ;ffi.enable=preload -; List of headers files to preload +; List of headers files to preload, wilcards allowed. ;ffi.preload= diff --git a/php.ini-production b/php.ini-production index 60e3231c941..19a409cc7af 100644 --- a/php.ini-production +++ b/php.ini-production @@ -1918,5 +1918,5 @@ ldap.max_links = -1 ; "true" - always enabled ;ffi.enable=preload -; List of headers files to preload +; List of headers files to preload, wilcards allowed. ;ffi.preload=