[PHP4BETA] CVS update: php4/php4isapi

From: Date: Sun, 09 May 1999 18:41:00 +0000
Subject: [PHP4BETA] CVS update: php4/php4isapi
Groups: php.version4 
Request: Send a blank email to php-version4+get-733@lists.php.net to get a copy of this message
Date: Sunday May 9, 1999 @ 14:41 Author: andi Update of /repository/php4/php4isapi In directory php:/tmp/cvs-serv14456/php4isapi Modified Files: php4isapi.c Log Message: * Make read_post() read input by chunks instead of returning a single string. This will allow us to efficiently support file upload through SAPI in the future. * Fixes Index: php4/php4isapi/php4isapi.c diff -u php4/php4isapi/php4isapi.c:1.12 php4/php4isapi/php4isapi.c:1.13 --- php4/php4isapi/php4isapi.c:1.12 Sun May 9 09:55:15 1999 +++ php4/php4isapi/php4isapi.c Sun May 9 14:41:00 1999 @@ -181,27 +181,35 @@ } -/* does not support queries over 4GB */ -static char *sapi_isapi_read_post(SLS_D) + +static int sapi_isapi_read_post(char *buffer, uint count_bytes SLS_DC) { LPEXTENSION_CONTROL_BLOCK lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context); - DWORD cbRead, cbSize; - char *result; - - result = (char *) emalloc(lpECB->cbTotalBytes+1); - memcpy(result, lpECB->lpbData, lpECB->cbAvailable); + DWORD read_from_buf=0; + DWORD read_from_input=0; + DWORD total_read=0; - cbRead = lpECB->cbAvailable; + if (SG(read_post_bytes) < lpECB->cbAvailable) { + read_from_buf = MIN(lpECB->cbAvailable-SG(read_post_bytes), count_bytes); + memcpy(buffer, lpECB->lpbData+SG(read_post_bytes), read_from_buf); + total_read += read_from_buf; + } + if (read_from_buf<count_bytes + && (SG(read_post_bytes)+read_from_buf) < lpECB->cbTotalBytes) { + DWORD cbRead=0, cbSize; - while (cbRead < lpECB->cbTotalBytes) { - cbSize = lpECB->cbTotalBytes - cbRead; - if (!lpECB->ReadClient(lpECB->ConnID, result+cbRead, &cbSize) || cbSize==0) { - break; + read_from_input = MIN(count_bytes-read_from_buf, lpECB->cbTotalBytes-SG(read_post_bytes)-read_from_buf); + while (cbRead < read_from_input) { + cbSize = read_from_input - cbRead; + if (!lpECB->ReadClient(lpECB->ConnID, buffer+read_from_buf+cbRead, &cbSize) || cbSize==0) { + break; + } + cbRead += cbSize; } - cbRead += cbSize; + total_read += cbRead; } - result[cbRead] = 0; - return result; + SG(read_post_bytes) += total_read; + return total_read; } -- PHP 4 Beta

« previous php.version4 (#733) next »