diff options
author | Thies C. Arntzen <thies@php.net> | 2000-06-06 12:16:44 +0000 |
---|---|---|
committer | Thies C. Arntzen <thies@php.net> | 2000-06-06 12:16:44 +0000 |
commit | 10eb67a3aac6cd78d69ed98a6fc1e1380df652ff (patch) | |
tree | 3ea1d68be97a006ffbc7466109dfd75c551651cf /ext/standard/file.c | |
parent | 8ed100e5c56cfeb21d278f285a697bce8722064f (diff) | |
download | php-git-10eb67a3aac6cd78d69ed98a6fc1e1380df652ff.tar.gz |
@- added fflush() function. (Eric Huss)
# the socket fsync() might not work on Win32.
#
# i'm not sure if we need any code for flushing sockets as they are
# currently alway written via write().
Diffstat (limited to 'ext/standard/file.c')
-rw-r--r-- | ext/standard/file.c | 37 |
1 files changed, 37 insertions, 0 deletions
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 */ |