PHP_FALIAS(realpath, warn_not_available, NULL)
#endif
+#ifdef HAVE_FNMATCH
+ PHP_FE(fnmatch, NULL)
+#else
+ PHP_FALIAS(fnmatch, warn_not_available, NULL)
+#endif
+
/* functions from fsock.c */
PHP_FE(fsockopen, third_and_fourth_args_force_ref)
PHP_FE(pfsockopen, third_and_fourth_args_force_ref)
PHP_FE(rewinddir, NULL)
PHP_STATIC_FE("readdir", php_if_readdir, NULL)
PHP_FALIAS(dir, getdir, NULL)
-
+#ifdef HAVE_GLOB
+ PHP_FE(glob, NULL)
+#else
+ PHP_FALIAS(glob, warn_not_available, NULL)
+#endif
/* functions from filestat.c */
PHP_FE(fileatime, NULL)
PHP_FE(filectime, NULL)
fi
])
+AC_CHECK_FUNCS(fnmatch glob)
+
if test "$PHP_SAPI" = "cgi"; then
AC_DEFINE(ENABLE_CHROOT_FUNC, 1, [Whether to enable chroot() function])
fi
#include "win32/readdir.h"
#endif
+#ifdef HAVE_GLOB
+#include <glob.h>
+#endif
+
typedef struct {
int default_dir;
} php_dir_globals;
rewinddir(dirp->dir);
}
/* }}} */
+
/* {{{ proto string readdir([resource dir_handle])
Read directory entry from dir_handle */
/* }}} */
+#ifdef HAVE_GLOB
+/* {{{ proto array glob(string pattern [, int flags])
+ */
+PHP_FUNCTION(glob)
+{
+ char *pattern = NULL;
+ int argc = ZEND_NUM_ARGS();
+ int pattern_len;
+ long flags;
+ glob_t globbuf;
+ zval *new_val;
+ int n;
+ char path[MAXPATHLEN];
+ char *ret=NULL;
+
+ if (zend_parse_parameters(argc TSRMLS_CC, "s|l", &pattern, &pattern_len, &flags) == FAILURE)
+ return;
+
+ globbuf.gl_offs = 0;
+ if(glob(pattern, 0, NULL, &globbuf)) {
+ RETURN_FALSE;
+ }
+
+ array_init(return_value);
+ for(n=0;n<globbuf.gl_pathc;n++) {
+ MAKE_STD_ZVAL(new_val);
+ ZVAL_STRING(new_val, globbuf.gl_pathv[n], 1);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &new_val,
+ sizeof(zval *), NULL);
+ ret = VCWD_GETCWD(path, MAXPATHLEN);
+ }
+ globfree(&globbuf);
+}
+/* }}} */
+#endif
/*
* Local variables:
php_file_globals file_globals;
#endif
+#ifdef HAVE_FNMATCH
+#include <fnmatch.h>
+#endif
+
/* }}} */
/* {{{ ZTS-stuff / Globals / Prototypes */
/* }}} */
+#ifdef HAVE_FNMATCH
+/* {{{ proto bool fnmatch(string pattern, string filename [, int flags])
+ Match filename against pattern */
+PHP_FUNCTION(fnmatch)
+{
+ char *pattern = NULL;
+ char *filename = NULL;
+ int argc = ZEND_NUM_ARGS();
+ int pattern_len;
+ int filename_len;
+ long flags=0;
+
+ if (zend_parse_parameters(argc TSRMLS_CC, "ss|l",
+ &pattern, &pattern_len,
+ &filename, &filename_len,
+ &flags)
+ == FAILURE)
+ return;
+
+ RETURN_BOOL( ! fnmatch( pattern, filename, flags ));
+}
+/* }}} */
+#endif
+
/*
* Local variables:
* tab-width: 4
PHP_FUNCTION(select);
#if (!defined(PHP_WIN32) && !defined(__BEOS__) && HAVE_REALPATH) || defined(ZTS)
PHP_FUNCTION(realpath);
+PHP_FUNCTION(fnmatch);
#endif
PHP_NAMED_FUNCTION(php_if_ftruncate);
PHP_NAMED_FUNCTION(php_if_fstat);
PHP_FUNCTION(rewinddir);
PHP_NAMED_FUNCTION(php_if_readdir);
PHP_FUNCTION(getdir);
+PHP_FUNCTION(glob);
#endif /* PHP_DIR_H */