mirror of
https://github.com/php/php-src.git
synced 2025-08-20 09:24:05 +02:00
@- 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().
This commit is contained in:
parent
8ed100e5c5
commit
10eb67a3aa
3 changed files with 39 additions and 0 deletions
|
@ -361,6 +361,7 @@ function_entry basic_functions[] = {
|
||||||
PHP_FE(fstat, NULL)
|
PHP_FE(fstat, NULL)
|
||||||
PHP_FE(fseek, NULL)
|
PHP_FE(fseek, NULL)
|
||||||
PHP_FE(ftell, NULL)
|
PHP_FE(ftell, NULL)
|
||||||
|
PHP_FE(fflush, NULL)
|
||||||
PHP_FE(fwrite, NULL)
|
PHP_FE(fwrite, NULL)
|
||||||
PHP_FALIAS(fputs, fwrite, NULL)
|
PHP_FALIAS(fputs, fwrite, NULL)
|
||||||
PHP_FE(mkdir, NULL)
|
PHP_FE(mkdir, NULL)
|
||||||
|
|
|
@ -1116,6 +1116,43 @@ PHP_FUNCTION(fwrite)
|
||||||
RETURN_LONG(ret);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* }}} */
|
/* }}} */
|
||||||
/* {{{ proto int set_file_buffer(int fp, int buffer)
|
/* {{{ proto int set_file_buffer(int fp, int buffer)
|
||||||
Set file write buffer */
|
Set file write buffer */
|
||||||
|
|
|
@ -49,6 +49,7 @@ PHP_FUNCTION(fgets);
|
||||||
PHP_FUNCTION(fgetss);
|
PHP_FUNCTION(fgetss);
|
||||||
PHP_FUNCTION(fgetcsv);
|
PHP_FUNCTION(fgetcsv);
|
||||||
PHP_FUNCTION(fwrite);
|
PHP_FUNCTION(fwrite);
|
||||||
|
PHP_FUNCTION(fflush);
|
||||||
PHP_FUNCTION(rewind);
|
PHP_FUNCTION(rewind);
|
||||||
PHP_FUNCTION(ftell);
|
PHP_FUNCTION(ftell);
|
||||||
PHP_FUNCTION(fseek);
|
PHP_FUNCTION(fseek);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue