cvs: php4 /ext/standard/ basic_functions.c file.c file.h

From: Date: Tue, 06 Jun 2000 12:16:44 +0000
Subject: cvs: php4 /ext/standard/ basic_functions.c file.c file.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-46@lists.php.net to get a copy of this message
thies Tue Jun 6 05:16:44 2000 EDT Modified files: /php4/ext/standard basic_functions.c file.c file.h Log: @- 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(). Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.205 php4/ext/standard/basic_functions.c:1.206 --- php4/ext/standard/basic_functions.c:1.205 Mon Jun 5 16:21:57 2000 +++ php4/ext/standard/basic_functions.c Tue Jun 6 05:16:44 2000 @@ -361,6 +361,7 @@ 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) Index: php4/ext/standard/file.c diff -u php4/ext/standard/file.c:1.87 php4/ext/standard/file.c:1.88 --- php4/ext/standard/file.c:1.87 Mon Jun 5 12:35:15 2000 +++ php4/ext/standard/file.c Tue Jun 6 05:16:44 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: file.c,v 1.87 2000/06/05 19:35:15 rasmus Exp $ */ +/* $Id: file.c,v 1.88 2000/06/06 12:16:44 thies Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1114,6 +1114,43 @@ ret = fwrite((*arg2)->value.str.val,1,num_bytes,(FILE*)what); } RETURN_LONG(ret); +} + +/* }}} */ +/* {{{ 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; + } } /* }}} */ Index: php4/ext/standard/file.h diff -u php4/ext/standard/file.h:1.20 php4/ext/standard/file.h:1.21 --- php4/ext/standard/file.h:1.20 Sun Mar 12 11:42:29 2000 +++ php4/ext/standard/file.h Tue Jun 6 05:16:44 2000 @@ -27,7 +27,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: file.h,v 1.20 2000/03/12 19:42:29 kk Exp $ */ +/* $Id: file.h,v 1.21 2000/06/06 12:16:44 thies Exp $ */ /* Synced with php 3.0 revision 1.30 1999-06-16 [ssb] */ @@ -49,6 +49,7 @@ PHP_FUNCTION(fgetss); PHP_FUNCTION(fgetcsv); PHP_FUNCTION(fwrite); +PHP_FUNCTION(fflush); PHP_FUNCTION(rewind); PHP_FUNCTION(ftell); PHP_FUNCTION(fseek);

« previous php.cvs (#46) next »