summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/standard/basic_functions.c1
-rw-r--r--ext/standard/file.c37
-rw-r--r--ext/standard/file.h1
3 files changed, 39 insertions, 0 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index ee38b43c9d..f994b70545 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -361,6 +361,7 @@ function_entry basic_functions[] = {
PHP_FE(fstat, NULL)
PHP_FE(fseek, NULL)
PHP_FE(ftell, NULL)
+ PHP_FE(fflush, NULL)
PHP_FE(fwrite, NULL)
PHP_FALIAS(fputs, fwrite, NULL)
PHP_FE(mkdir, NULL)
diff --git a/ext/standard/file.c b/ext/standard/file.c
index b5df693593..232b1ee048 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -1117,6 +1117,43 @@ PHP_FUNCTION(fwrite)
}
/* }}} */
+/* {{{ proto int fflush(int fp)
+ flushes output */
+
+PHP_FUNCTION(fflush)
+{
+ pval **arg1;
+ int ret,type;
+ int issock=0;
+ int socketd=0;
+ void *what;
+
+ if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ what = zend_fetch_resource(arg1,-1,"File-Handle",&type,3,le_fopen,le_popen,le_socket);
+ ZEND_VERIFY_RESOURCE(what);
+
+ if (type == le_socket) {
+ issock=1;
+ socketd=*(int*)what;
+ }
+
+ if (issock){
+ ret = fsync(socketd);
+ } else {
+ ret = fflush((FILE*)what);
+ }
+
+ if (ret) {
+ RETURN_FALSE;
+ } else {
+ RETURN_TRUE;
+ }
+}
+
+/* }}} */
/* {{{ proto int set_file_buffer(int fp, int buffer)
Set file write buffer */
diff --git a/ext/standard/file.h b/ext/standard/file.h
index b2ff0f4f22..334e69af2b 100644
--- a/ext/standard/file.h
+++ b/ext/standard/file.h
@@ -49,6 +49,7 @@ PHP_FUNCTION(fgets);
PHP_FUNCTION(fgetss);
PHP_FUNCTION(fgetcsv);
PHP_FUNCTION(fwrite);
+PHP_FUNCTION(fflush);
PHP_FUNCTION(rewind);
PHP_FUNCTION(ftell);
PHP_FUNCTION(fseek);