From 88c6758d4e326a9714e0bfccd3309c3e5a282ef9 Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Sat, 10 Nov 2001 18:06:28 +0000 Subject: [PATCH] - Fixing this bad idea --- ext/standard/basic_functions.c | 3 -- ext/standard/file.c | 82 ---------------------------------- ext/standard/file.h | 3 -- 3 files changed, 88 deletions(-) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 83b3f73768..45ebbdf50d 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -576,9 +576,6 @@ function_entry basic_functions[] = { PHP_FE(pclose, NULL) PHP_FE(popen, NULL) PHP_FE(readfile, NULL) -#ifdef HAVE_MMAP - PHP_FE(mmapfile, NULL) -#endif PHP_FE(rewind, NULL) PHP_FE(rmdir, NULL) PHP_FE(umask, NULL) diff --git a/ext/standard/file.c b/ext/standard/file.c index 8669dfb099..dd5d5ab37e 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1634,88 +1634,6 @@ PHP_FUNCTION(readfile) /* }}} */ -#ifdef HAVE_MMAP - -/* {{{ proto string mmapfile (string filename [, int bytes_to_read]) - Read a file into a variable with mmap */ -PHP_FUNCTION(mmapfile) -{ - zval **arg1, **arg2; - int in, bytes_to_read = 0; - char *data; - char *in_addr; - struct stat f_stat; - - memset (&f_stat, 0, sizeof (f_stat)); - - /* check args */ - switch (ARG_COUNT(ht)) { - case 1: - if (zend_get_parameters_ex (1, &arg1) == FAILURE) { - WRONG_PARAM_COUNT; - } - break; - case 2: - if (zend_get_parameters_ex (2, &arg1, &arg2) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex (arg2); - bytes_to_read = (*arg2)->value.lval; - break; - default: - WRONG_PARAM_COUNT; - } - convert_to_string_ex (arg1); - - if ((in = open ((*arg1)->value.str.val, O_RDONLY)) == -1) { - php_error (E_WARNING, "can't re-open input file for mmap"); - RETURN_FALSE; - } - - if (fstat (in, &f_stat)) { - php_error (E_WARNING, "cannot get file information"); - RETURN_FALSE; - } - - if (!bytes_to_read) { - bytes_to_read = f_stat.st_size; - } else { - bytes_to_read = (bytes_to_read < f_stat.st_size) ? bytes_to_read : f_stat.st_size; - } - - if ((in_addr = mmap (NULL, bytes_to_read, PROT_READ, MAP_SHARED, in, 0)) == (char*) -1) { - php_error (E_WARNING, "can't mmap file"); - RETURN_FALSE; - } - - data = emalloc (bytes_to_read + 1); - data[bytes_to_read + 1] = '\0'; - - if (!memcpy(data, in_addr, bytes_to_read)) { - efree (data); - php_error (E_WARNING, "cannot copy file to memory"); - RETURN_FALSE; - } - - if (munmap(in_addr, bytes_to_read)) { - efree (data); - php_error (E_WARNING, "cannot unmap the file"); - RETURN_FALSE; - } - - if (close(in)) { - efree (data); - php_error (E_WARNING, "cannot close file"); - RETURN_FALSE; - } - - RETURN_STRINGL(data, bytes_to_read + 1, 0); -} -/* }}} */ - -#endif - - /* {{{ proto int umask([int mask]) Return or change the umask */ PHP_FUNCTION(umask) diff --git a/ext/standard/file.h b/ext/standard/file.h index d9598ff118..361c4e2f23 100644 --- a/ext/standard/file.h +++ b/ext/standard/file.h @@ -48,9 +48,6 @@ PHP_FUNCTION(mkdir); PHP_FUNCTION(rmdir); PHP_FUNCTION(fpassthru); PHP_FUNCTION(readfile); -#ifdef HAVE_MMAP -PHP_FUNCTION(mmapfile); -#endif PHP_FUNCTION(umask); PHP_FUNCTION(rename); PHP_FUNCTION(unlink); -- 2.40.0