summaryrefslogtreecommitdiff
path: root/ext/standard/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/file.c')
-rw-r--r--ext/standard/file.c172
1 files changed, 93 insertions, 79 deletions
diff --git a/ext/standard/file.c b/ext/standard/file.c
index 4551bef8cf..20a956df9d 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -342,7 +342,7 @@ PHP_FUNCTION(flock)
zval *arg1, *arg3 = NULL;
int act;
php_stream *stream;
- long operation = 0;
+ zend_long operation = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|z/", &arg1, &operation, &arg3) == FAILURE) {
return;
@@ -380,7 +380,7 @@ PHP_FUNCTION(flock)
PHP_FUNCTION(get_meta_tags)
{
char *filename;
- int filename_len;
+ size_t filename_len;
zend_bool use_include_path = 0;
int in_tag = 0, done = 0;
int looking_for_val = 0, have_name = 0, have_content = 0;
@@ -523,11 +523,11 @@ PHP_FUNCTION(get_meta_tags)
PHP_FUNCTION(file_get_contents)
{
char *filename;
- int filename_len;
+ size_t filename_len;
zend_bool use_include_path = 0;
php_stream *stream;
- long offset = -1;
- long maxlen = PHP_STREAM_COPY_ALL;
+ zend_long offset = -1;
+ zend_long maxlen = PHP_STREAM_COPY_ALL;
zval *zcontext = NULL;
php_stream_context *context = NULL;
zend_string *contents;
@@ -552,13 +552,13 @@ PHP_FUNCTION(file_get_contents)
}
if (offset > 0 && php_stream_seek(stream, offset, SEEK_SET) < 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", offset);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position " ZEND_LONG_FMT " in the stream", offset);
php_stream_close(stream);
RETURN_FALSE;
}
if (maxlen > INT_MAX) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "maxlen truncated from %ld to %d bytes", maxlen, INT_MAX);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "maxlen truncated from %pd to %d bytes", maxlen, INT_MAX);
maxlen = INT_MAX;
}
if ((contents = php_stream_copy_to_mem(stream, maxlen, 0)) != NULL) {
@@ -577,14 +577,15 @@ PHP_FUNCTION(file_put_contents)
{
php_stream *stream;
char *filename;
- int filename_len;
+ size_t filename_len;
zval *data;
- long numbytes = 0;
- long flags = 0;
+ zend_long numbytes = 0;
+ zend_long flags = 0;
zval *zcontext = NULL;
php_stream_context *context = NULL;
php_stream *srcstream = NULL;
char mode[3] = "wb";
+ char ret_ok = 1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pz/|lr!", &filename, &filename_len, &data, &flags, &zcontext) == FAILURE) {
return;
@@ -629,11 +630,11 @@ PHP_FUNCTION(file_put_contents)
case IS_RESOURCE: {
size_t len;
if (php_stream_copy_to_stream_ex(srcstream, stream, PHP_STREAM_COPY_ALL, &len) != SUCCESS) {
- numbytes = -1;
+ ret_ok = 0;
} else {
- if (len > LONG_MAX) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "content truncated from %lu to %ld bytes", (unsigned long) len, LONG_MAX);
- len = LONG_MAX;
+ if (len > ZEND_LONG_MAX) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "content truncated from %zu to " ZEND_LONG_FMT " bytes", len, ZEND_LONG_MAX);
+ len = ZEND_LONG_MAX;
}
numbytes = len;
}
@@ -650,7 +651,7 @@ PHP_FUNCTION(file_put_contents)
if (Z_STRLEN_P(data)) {
numbytes = php_stream_write(stream, Z_STRVAL_P(data), Z_STRLEN_P(data));
if (numbytes != Z_STRLEN_P(data)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %ld of %d bytes written, possibly out of free disk space", numbytes, Z_STRLEN_P(data));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %pl of %zd bytes written, possibly out of free disk space", numbytes, Z_STRLEN_P(data));
numbytes = -1;
}
}
@@ -658,7 +659,7 @@ PHP_FUNCTION(file_put_contents)
case IS_ARRAY:
if (zend_hash_num_elements(Z_ARRVAL_P(data))) {
- int bytes_written;
+ size_t bytes_written;
zval *tmp;
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(data), tmp) {
@@ -666,18 +667,14 @@ PHP_FUNCTION(file_put_contents)
if (str->len) {
numbytes += str->len;
bytes_written = php_stream_write(stream, str->val, str->len);
- if (bytes_written < 0 || bytes_written != str->len) {
- if (bytes_written < 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write %d bytes to %s", str->len, filename);
- } else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %d of %d bytes written, possibly out of free disk space", bytes_written, str->len);
- }
- numbytes = -1;
- STR_RELEASE(str);
+ if (bytes_written != str->len) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write %zd bytes to %s", str->len, filename);
+ ret_ok = 0;
+ zend_string_release(str);
break;
}
}
- STR_RELEASE(str);
+ zend_string_release(str);
} ZEND_HASH_FOREACH_END();
}
break;
@@ -689,7 +686,7 @@ PHP_FUNCTION(file_put_contents)
if (zend_std_cast_object_tostring(data, &out, IS_STRING TSRMLS_CC) == SUCCESS) {
numbytes = php_stream_write(stream, Z_STRVAL(out), Z_STRLEN(out));
if (numbytes != Z_STRLEN(out)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %ld of %d bytes written, possibly out of free disk space", numbytes, Z_STRLEN(out));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %pd of %zd bytes written, possibly out of free disk space", numbytes, Z_STRLEN(out));
numbytes = -1;
}
zval_dtor(&out);
@@ -697,12 +694,12 @@ PHP_FUNCTION(file_put_contents)
}
}
default:
- numbytes = -1;
+ ret_ok = 0;
break;
}
php_stream_close(stream);
- if (numbytes < 0) {
+ if (!ret_ok) {
RETURN_FALSE;
}
@@ -717,11 +714,11 @@ PHP_FUNCTION(file_put_contents)
PHP_FUNCTION(file)
{
char *filename;
- int filename_len;
+ size_t filename_len;
char *p, *s, *e;
register int i = 0;
char eol_marker = '\n';
- long flags = 0;
+ zend_long flags = 0;
zend_bool use_include_path;
zend_bool include_new_line;
zend_bool skip_blank_lines;
@@ -735,7 +732,7 @@ PHP_FUNCTION(file)
return;
}
if (flags < 0 || flags > (PHP_FILE_USE_INCLUDE_PATH | PHP_FILE_IGNORE_NEW_LINES | PHP_FILE_SKIP_EMPTY_LINES | PHP_FILE_NO_DEFAULT_CONTEXT)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "'%ld' flag is not supported", flags);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "'" ZEND_LONG_FMT "' flag is not supported", flags);
RETURN_FALSE;
}
@@ -798,7 +795,7 @@ parse_eol:
}
if (target_buf) {
- STR_FREE(target_buf);
+ zend_string_free(target_buf);
}
php_stream_close(stream);
}
@@ -809,7 +806,7 @@ parse_eol:
PHP_FUNCTION(tempnam)
{
char *dir, *prefix;
- int dir_len, prefix_len;
+ size_t dir_len, prefix_len;
char *opened_path;
int fd;
zend_string *p;
@@ -835,7 +832,7 @@ PHP_FUNCTION(tempnam)
RETVAL_STRING(opened_path);
efree(opened_path);
}
- STR_RELEASE(p);
+ zend_string_release(p);
}
/* }}} */
@@ -864,7 +861,7 @@ PHP_NAMED_FUNCTION(php_if_tmpfile)
PHP_NAMED_FUNCTION(php_if_fopen)
{
char *filename, *mode;
- int filename_len, mode_len;
+ size_t filename_len, mode_len;
zend_bool use_include_path = 0;
zval *zcontext = NULL;
php_stream *stream;
@@ -906,7 +903,7 @@ PHPAPI PHP_FUNCTION(fclose)
PHP_STREAM_TO_ZVAL(stream, arg1);
if ((stream->flags & PHP_STREAM_FLAG_NO_FCLOSE) != 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%ld is not a valid stream resource", stream->res->handle);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%pd is not a valid stream resource", stream->res->handle);
RETURN_FALSE;
}
@@ -925,7 +922,7 @@ PHPAPI PHP_FUNCTION(fclose)
PHP_FUNCTION(popen)
{
char *command, *mode;
- int command_len, mode_len;
+ size_t command_len, mode_len;
FILE *fp;
php_stream *stream;
char *posix_mode;
@@ -1010,7 +1007,7 @@ PHPAPI PHP_FUNCTION(feof)
PHPAPI PHP_FUNCTION(fgets)
{
zval *arg1;
- long len = 1024;
+ zend_long len = 1024;
char *buf = NULL;
int argc = ZEND_NUM_ARGS();
size_t line_len = 0;
@@ -1094,7 +1091,7 @@ PHPAPI PHP_FUNCTION(fgetc)
PHPAPI PHP_FUNCTION(fgetss)
{
zval *fd;
- long bytes = 0;
+ zend_long bytes = 0;
size_t len = 0;
size_t actual_len, retval_len;
char *buf = NULL, *retval;
@@ -1156,7 +1153,8 @@ PHPAPI PHP_FUNCTION(fgetss)
Implements a mostly ANSI compatible fscanf() */
PHP_FUNCTION(fscanf)
{
- int result, format_len, type, argc = 0;
+ int result, type, argc = 0;
+ size_t format_len;
zval *args = NULL;
zval *file_handle;
char *buf, *format;
@@ -1197,10 +1195,10 @@ PHPAPI PHP_FUNCTION(fwrite)
{
zval *arg1;
char *arg2;
- int arg2len;
+ size_t arg2len;
int ret;
int num_bytes;
- long arg3 = 0;
+ zend_long arg3 = 0;
char *buffer = NULL;
php_stream *stream;
@@ -1211,7 +1209,11 @@ PHPAPI PHP_FUNCTION(fwrite)
if (ZEND_NUM_ARGS() == 2) {
num_bytes = arg2len;
} else {
- num_bytes = MAX(0, MIN((int)arg3, arg2len));
+ if (arg3 > 0) {
+ num_bytes = MAX(0, MIN((size_t)arg3, arg2len));
+ } else {
+ num_bytes = 0;
+ }
}
if (!num_bytes) {
@@ -1276,7 +1278,7 @@ PHPAPI PHP_FUNCTION(rewind)
PHPAPI PHP_FUNCTION(ftell)
{
zval *arg1;
- long ret;
+ zend_long ret;
php_stream *stream;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) {
@@ -1298,7 +1300,7 @@ PHPAPI PHP_FUNCTION(ftell)
PHPAPI PHP_FUNCTION(fseek)
{
zval *arg1;
- long arg2, whence = SEEK_SET;
+ zend_long arg2, whence = SEEK_SET;
php_stream *stream;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|l", &arg1, &arg2, &whence) == FAILURE) {
@@ -1315,7 +1317,7 @@ PHPAPI PHP_FUNCTION(fseek)
*/
/* DEPRECATED APIs: Use php_stream_mkdir() instead */
-PHPAPI int php_mkdir_ex(const char *dir, long mode, int options TSRMLS_DC)
+PHPAPI int php_mkdir_ex(const char *dir, zend_long mode, int options TSRMLS_DC)
{
int ret;
@@ -1330,7 +1332,7 @@ PHPAPI int php_mkdir_ex(const char *dir, long mode, int options TSRMLS_DC)
return ret;
}
-PHPAPI int php_mkdir(const char *dir, long mode TSRMLS_DC)
+PHPAPI int php_mkdir(const char *dir, zend_long mode TSRMLS_DC)
{
return php_mkdir_ex(dir, mode, REPORT_ERRORS TSRMLS_CC);
}
@@ -1341,9 +1343,9 @@ PHPAPI int php_mkdir(const char *dir, long mode TSRMLS_DC)
PHP_FUNCTION(mkdir)
{
char *dir;
- int dir_len;
+ size_t dir_len;
zval *zcontext = NULL;
- long mode = 0777;
+ zend_long mode = 0777;
zend_bool recursive = 0;
php_stream_context *context;
@@ -1362,7 +1364,7 @@ PHP_FUNCTION(mkdir)
PHP_FUNCTION(rmdir)
{
char *dir;
- int dir_len;
+ size_t dir_len;
zval *zcontext = NULL;
php_stream_context *context;
@@ -1381,7 +1383,7 @@ PHP_FUNCTION(rmdir)
PHP_FUNCTION(readfile)
{
char *filename;
- int filename_len;
+ size_t filename_len;
int size = 0;
zend_bool use_include_path = 0;
zval *zcontext = NULL;
@@ -1409,7 +1411,7 @@ PHP_FUNCTION(readfile)
Return or change the umask */
PHP_FUNCTION(umask)
{
- long arg1 = 0;
+ zend_long arg1 = 0;
int oldumask;
oldumask = umask(077);
@@ -1456,7 +1458,7 @@ PHPAPI PHP_FUNCTION(fpassthru)
PHP_FUNCTION(rename)
{
char *old_name, *new_name;
- int old_name_len, new_name_len;
+ size_t old_name_len, new_name_len;
zval *zcontext = NULL;
php_stream_wrapper *wrapper;
php_stream_context *context;
@@ -1493,7 +1495,7 @@ PHP_FUNCTION(rename)
PHP_FUNCTION(unlink)
{
char *filename;
- int filename_len;
+ size_t filename_len;
php_stream_wrapper *wrapper;
zval *zcontext = NULL;
php_stream_context *context = NULL;
@@ -1524,7 +1526,7 @@ PHP_FUNCTION(unlink)
PHP_NAMED_FUNCTION(php_if_ftruncate)
{
zval *fp;
- long size;
+ zend_long size;
php_stream *stream;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &fp, &size) == FAILURE) {
@@ -1575,7 +1577,19 @@ PHP_NAMED_FUNCTION(php_if_fstat)
ZVAL_LONG(&stat_uid, stat_ssb.sb.st_uid);
ZVAL_LONG(&stat_gid, stat_ssb.sb.st_gid);
#ifdef HAVE_ST_RDEV
+# ifdef PHP_WIN32
+ /* It is unsigned, so if a negative came from userspace, it'll
+ convert to UINT_MAX, but we wan't to keep the userspace value.
+ Almost the same as in php_fstat. This is ugly, but otherwise
+ we would have to maintain a fully compatible struct stat. */
+ if ((int)stat_ssb.sb.st_rdev < 0) {
+ ZVAL_LONG(&stat_rdev, (int)stat_ssb.sb.st_rdev);
+ } else {
+ ZVAL_LONG(&stat_rdev, stat_ssb.sb.st_rdev);
+ }
+# else
ZVAL_LONG(&stat_rdev, stat_ssb.sb.st_rdev);
+# endif
#else
ZVAL_LONG(&stat_rdev, -1);
#endif
@@ -1630,7 +1644,7 @@ PHP_NAMED_FUNCTION(php_if_fstat)
PHP_FUNCTION(copy)
{
char *source, *target;
- int source_len, target_len;
+ size_t source_len, target_len;
zval *zcontext = NULL;
php_stream_context *context;
@@ -1767,7 +1781,7 @@ safe_to_copy:
PHPAPI PHP_FUNCTION(fread)
{
zval *arg1;
- long len;
+ zend_long len;
php_stream *stream;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &arg1, &len) == FAILURE) {
@@ -1781,7 +1795,7 @@ PHPAPI PHP_FUNCTION(fread)
RETURN_FALSE;
}
- ZVAL_NEW_STR(return_value, STR_ALLOC(len, 0));
+ ZVAL_NEW_STR(return_value, zend_string_alloc(len, 0));
Z_STRLEN_P(return_value) = php_stream_read(stream, Z_STRVAL_P(return_value), len);
/* needed because recv/read/gzread doesnt put a null at the end*/
@@ -1795,12 +1809,12 @@ static const char *php_fgetcsv_lookup_trailing_spaces(const char *ptr, size_t le
unsigned char last_chars[2] = { 0, 0 };
while (len > 0) {
- inc_len = (*ptr == '\0' ? 1: php_mblen(ptr, len));
+ inc_len = (*ptr == '\0' ? 1 : php_mblen(ptr, len));
switch (inc_len) {
case -2:
case -1:
inc_len = 1;
- php_ignore_value(php_mblen(NULL, 0));
+ php_mb_reset();
break;
case 0:
goto quit_loop;
@@ -1840,7 +1854,7 @@ PHP_FUNCTION(fputcsv)
zval *fp = NULL, *fields = NULL;
int ret;
char *delimiter_str = NULL, *enclosure_str = NULL, *escape_str = NULL;
- int delimiter_str_len = 0, enclosure_str_len = 0, escape_str_len = 0;
+ size_t delimiter_str_len = 0, enclosure_str_len = 0, escape_str_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ra|sss",
&fp, &fields, &delimiter_str, &delimiter_str_len,
@@ -1891,8 +1905,8 @@ PHP_FUNCTION(fputcsv)
}
/* }}} */
-/* {{{ PHPAPI int php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char TSRMLS_DC) */
-PHPAPI int php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char TSRMLS_DC)
+/* {{{ PHPAPI size_t php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char TSRMLS_DC) */
+PHPAPI size_t php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char TSRMLS_DC)
{
int count, i = 0, ret;
zval *field_tmp;
@@ -1935,7 +1949,7 @@ PHPAPI int php_fputcsv(php_stream *stream, zval *fields, char delimiter, char en
if (++i != count) {
smart_str_appendl(&csvline, &delimiter, 1);
}
- STR_RELEASE(field_str);
+ zend_string_release(field_str);
} ZEND_HASH_FOREACH_END();
smart_str_appendc(&csvline, '\n');
@@ -1959,7 +1973,7 @@ PHP_FUNCTION(fgetcsv)
/* first section exactly as php_fgetss */
- long len = 0;
+ zend_long len = 0;
size_t buf_len;
char *buf;
php_stream *stream;
@@ -1967,11 +1981,11 @@ PHP_FUNCTION(fgetcsv)
{
zval *fd, *len_zv = NULL;
char *delimiter_str = NULL;
- int delimiter_str_len = 0;
+ size_t delimiter_str_len = 0;
char *enclosure_str = NULL;
- int enclosure_str_len = 0;
+ size_t enclosure_str_len = 0;
char *escape_str = NULL;
- int escape_str_len = 0;
+ size_t escape_str_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|zsss",
&fd, &len_zv, &delimiter_str, &delimiter_str_len,
@@ -2056,7 +2070,7 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, char
zend_bool first_field = 1;
/* initialize internal state */
- php_ignore_value(php_mblen(NULL, 0));
+ php_mb_reset();
/* Now into new section that parses buf for delimiter/enclosure fields */
@@ -2082,7 +2096,7 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, char
tptr = temp;
- inc_len = (bptr < limit ? (*bptr == '\0' ? 1: php_mblen(bptr, limit - bptr)): 0);
+ inc_len = (bptr < limit ? (*bptr == '\0' ? 1 : php_mblen(bptr, limit - bptr)): 0);
if (inc_len == 1) {
char *tmp = bptr;
while ((*tmp != delimiter) && isspace((int)*(unsigned char *)tmp)) {
@@ -2171,7 +2185,7 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, char
case -2:
case -1:
- php_ignore_value(php_mblen(NULL, 0));
+ php_mb_reset();
/* break is omitted intentionally */
case 1:
/* we need to determine if the enclosure is
@@ -2226,7 +2240,7 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, char
}
break;
}
- inc_len = (bptr < limit ? (*bptr == '\0' ? 1: php_mblen(bptr, limit - bptr)): 0);
+ inc_len = (bptr < limit ? (*bptr == '\0' ? 1 : php_mblen(bptr, limit - bptr)): 0);
}
quit_loop_2:
@@ -2239,7 +2253,7 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, char
case -2:
case -1:
inc_len = 1;
- php_ignore_value(php_mblen(NULL, 0));
+ php_mb_reset();
/* break is omitted intentionally */
case 1:
if (*bptr == delimiter) {
@@ -2250,7 +2264,7 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, char
break;
}
bptr += inc_len;
- inc_len = (bptr < limit ? (*bptr == '\0' ? 1: php_mblen(bptr, limit - bptr)): 0);
+ inc_len = (bptr < limit ? (*bptr == '\0' ? 1 : php_mblen(bptr, limit - bptr)): 0);
}
quit_loop_3:
@@ -2270,7 +2284,7 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, char
case -2:
case -1:
inc_len = 1;
- php_ignore_value(php_mblen(NULL, 0));
+ php_mb_reset();
/* break is omitted intentionally */
case 1:
if (*bptr == delimiter) {
@@ -2281,7 +2295,7 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, char
break;
}
bptr += inc_len;
- inc_len = (bptr < limit ? (*bptr == '\0' ? 1: php_mblen(bptr, limit - bptr)): 0);
+ inc_len = (bptr < limit ? (*bptr == '\0' ? 1 : php_mblen(bptr, limit - bptr)): 0);
}
quit_loop_4:
memcpy(tptr, hunk_begin, bptr - hunk_begin);
@@ -2312,7 +2326,7 @@ out:
PHP_FUNCTION(realpath)
{
char *filename;
- int filename_len;
+ size_t filename_len;
char resolved_path_buff[MAXPATHLEN];
#ifndef FAST_ZPP
@@ -2456,8 +2470,8 @@ php_meta_tags_token php_next_meta_token(php_meta_tags_data *md TSRMLS_DC)
PHP_FUNCTION(fnmatch)
{
char *pattern, *filename;
- int pattern_len, filename_len;
- long flags = 0;
+ size_t pattern_len, filename_len;
+ zend_long flags = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pp|l", &pattern, &pattern_len, &filename, &filename_len, &flags) == FAILURE) {
return;