summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Bakken <ssb@php.net>1999-11-14 11:05:37 +0000
committerStig Bakken <ssb@php.net>1999-11-14 11:05:37 +0000
commit5f8f410e51ebb5b6279632b6bc923be296dce047 (patch)
treee7d8048d494251fca5ae8bbebcef337f7f23af43
parent4ebf7b85ad80ebaca652c52593d5329ccd0dc386 (diff)
downloadphp-git-5f8f410e51ebb5b6279632b6bc923be296dce047.tar.gz
@Added tmpfile() function (Stig)
Removed the mkstemp stuff and added tmpfile() function instead.
-rw-r--r--configure.in1
-rw-r--r--ext/standard/file.c18
-rw-r--r--ext/standard/file.h1
-rw-r--r--main/php.h4
4 files changed, 19 insertions, 5 deletions
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 */