From: Stig Bakken Date: Sun, 14 Nov 1999 11:05:37 +0000 (+0000) Subject: @Added tmpfile() function (Stig) X-Git-Tag: php-4.0b3_RC5~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5f8f410e51ebb5b6279632b6bc923be296dce047;p=php @Added tmpfile() function (Stig) Removed the mkstemp stuff and added tmpfile() function instead. --- diff --git a/configure.in b/configure.in index 78651a51d8..1161c9e7f0 100644 --- a/configure.in +++ b/configure.in @@ -333,7 +333,6 @@ unsetenv \ usleep \ utime \ vsnprintf \ -mkstemp \ ) AC_REPLACE_FUNCS(strlcat strlcpy) diff --git a/ext/standard/file.c b/ext/standard/file.c index 3d35389e08..2a9d98a2cc 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -232,6 +232,7 @@ function_entry file_functions[] = { PHP_FE(rename, NULL) PHP_FE(copy, NULL) PHP_FE(tempnam, NULL) + PHP_FE(tmpfile, NULL) PHP_FE(file, NULL) PHP_FE(fgetcsv, NULL) PHP_FE(flock, NULL) @@ -591,6 +592,23 @@ PHP_FUNCTION(tempnam) } /* }}} */ +/* {{{ proto int tmpfile() + Create a temporary file that will be deleted automatically after use. */ +PHP_FUNCTION(tmpfile) +{ + FILE *fp; + if (ARG_COUNT(ht) != 0) { + WRONG_PARAM_COUNT; + } + fp = tmpfile(); + if (fp == NULL) { + php_error(E_WARNING, "tmpfile: %s", strerror(errno)); + RETURN_FALSE; + } + ZEND_REGISTER_RESOURCE(return_value, fp, le_fopen); +} +/* }}} */ + /* {{{ proto int fopen(string filename, string mode [, int use_include_path]) Open a file or a URL and return a file pointer */ diff --git a/ext/standard/file.h b/ext/standard/file.h index 072e7ae534..10824638eb 100644 --- a/ext/standard/file.h +++ b/ext/standard/file.h @@ -40,6 +40,7 @@ extern zend_module_entry file_module_entry; extern PHP_MINIT_FUNCTION(file); PHP_FUNCTION(tempnam); +PHP_FUNCTION(tmpfile); PHP_FUNCTION(fopen); PHP_FUNCTION(fclose); PHP_FUNCTION(popen); diff --git a/main/php.h b/main/php.h index b0dd5cb7b4..d732b42c89 100644 --- a/main/php.h +++ b/main/php.h @@ -168,10 +168,6 @@ typedef zval pval; extern char *strerror(int); #endif -#ifdef HAVE_MKSTEMP -# define mktemp mkstemp -#endif - #include "fopen-wrappers.h" #if APACHE /* apache httpd */