CVS update: php3/functions

From: Date: Wed, 14 Apr 1999 05:14:49 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-5045@lists.php.net to get a copy of this message
Date: Wednesday April 14, 1999 @ 1:14 Author: brianlmoon Update of /repository/php3/functions In directory asf:/u/temp/cvs-serv12751/php3/functions Modified Files: file.c Log Message: Added set_file_buffer function. This is a wrapper for setvbuf. This is specificly needed for atomic appends to files that are larger than 8K. This has been tested with Apache/PHP3.0.7 CGI/FreeBSD2.7 and Apache/PHP3.0.7 CGI/Win98 Index: php3/functions/file.c diff -c php3/functions/file.c:1.203 php3/functions/file.c:1.204 *** php3/functions/file.c:1.203 Tue Mar 30 07:43:29 1999 --- php3/functions/file.c Wed Apr 14 01:14:48 1999 *************** *** 26,32 **** | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | +----------------------------------------------------------------------+ */ ! /* $Id: file.c,v 1.203 1999/03/30 12:43:29 rasmus Exp $ */ #ifdef THREAD_SAFE #include "tls.h" #endif --- 26,32 ---- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | +----------------------------------------------------------------------+ */ ! /* $Id: file.c,v 1.204 1999/04/14 05:14:48 brianlmoon Exp $ */ #ifdef THREAD_SAFE #include "tls.h" #endif *************** *** 204,209 **** --- 204,210 ---- PHP_FE(fseek, NULL) PHP_FE(ftell, NULL) PHP_FE(fwrite, NULL) + PHP_FE(set_file_buffer, NULL) {"fputs", php3_fwrite, NULL}, PHP_FE(mkdir, NULL) PHP_FE(rename, NULL) *************** *** 965,970 **** --- 966,1024 ---- } else { ret = fwrite(arg2->value.str.val,1,num_bytes,fp); } + RETURN_LONG(ret); + } + /* }}} */ + + /* {{{ proto int set_file_buffer(int fp, int buffer) + Set file write buffer */ + /* + wrapper for setvbuf() + */ + void php3_set_file_buffer(INTERNAL_FUNCTION_PARAMETERS) + { + pval *arg1, *arg2; + FILE *fp; + int ret,id,type,buff; + int issock=0; + int *sock, socketd=0; + TLS_VARS; + + switch (ARG_COUNT(ht)) { + case 2: + if (getParameters(ht, 2, &arg1, &arg2)==FAILURE) { + RETURN_FALSE; + } + convert_to_long(arg1); + convert_to_long(arg2); + break; + default: + WRONG_PARAM_COUNT; + /* NOTREACHED */ + break; + } + + id = arg1->value.lval; + buff = arg2->value.lval; + fp = php3_list_find(id,&type); + if (type==GLOBAL(wsa_fp)){ + issock=1; + sock = php3_list_find(id,&type); + socketd=*sock; + } + if ((!fp || (type!=GLOBAL(le_fp) && type!=GLOBAL(le_pp))) && (!socketd || type!=GLOBAL(wsa_fp))) { + php3_error(E_WARNING,"Unable to find file identifier %d",id); + RETURN_FALSE; + } + + /* if buff is 0 then set to non-buffered */ + if(buff==0){ + ret=setvbuf(fp, NULL, _IONBF, 0); + } + else{ + ret=setvbuf(fp, NULL, _IOFBF, buff); + } + RETURN_LONG(ret); } /* }}} */ -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#5045) next »