CVS update: php3/functions
| From: | rasmus | Date: | Sun, 07 Mar 1999 21:45:53 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-4522@lists.php.net to get a copy of this message | ||
Date: Sunday March 7, 1999 @ 16:45
Author: rasmus
Update of /repository/php3/functions
In directory asf:/home/rasmus/php3/functions
Modified Files:
post.c
Log Message:
CGI version compiles again
Index: php3/functions/post.c
diff -c php3/functions/post.c:1.115 php3/functions/post.c:1.116
*** php3/functions/post.c:1.115 Sun Mar 7 10:49:21 1999
--- php3/functions/post.c Sun Mar 7 16:45:51 1999
***************
*** 33,38 ****
--- 33,39 ----
#include <stdio.h>
#include "php.h"
#include "internal_functions.h"
+ #include "php3_list.h"
#include "functions/mime.h"
#include "functions/type.h"
#include "functions/php3_string.h"
***************
*** 50,131 ****
*
* This copies the uploaded file to a temporary file.
*/
! static void php3_getput()
! {
#if MODULE_MAGIC_NUMBER > 19961007
! char upload_buffer[BUFSIZ];
! #else
! int bytes;
#endif
! char *fn;
! FILE *fp;
! int length, cnt;
! long bytes;
! length = GLOBAL(request_info).content_length;
! if (length > php3_ini.upload_max_filesize) {
! php3_error(E_WARNING, "Max file size of %ld bytes exceeded - temporary file not
saved", php3_ini.upload_max_filesize);
! SET_VAR_STRING("PHP_UPLOADED_FILE_NAME", estrdup("none"));
! return;
! }
! fn = tempnam(php3_ini.upload_tmp_dir, "php");
! fp = fopen(fn, "w");
! if (!fp) {
! php3_error(E_WARNING, "File Upload Error - Unable to open temporary file
[%s]", fn);
! return;
! }
! cnt = length;
#if FHTTPD
! bytes = fwrite(req->databuffer, 1, length, fp);
#else
#if MODULE_MAGIC_NUMBER > 19961007
! if (should_client_block(GLOBAL(php3_rqst))) {
! void (*handler) (int);
! int dbsize, len_read, dbpos = 0;
! hard_timeout("copy script args", GLOBAL(php3_rqst)); /* start timeout
timer */
! handler = signal(SIGPIPE, SIG_IGN); /* Ignore sigpipes for now */
! while ((len_read = get_client_block(GLOBAL(php3_rqst), upload_buffer, BUFSIZ)) >
0) {
! if ((dbpos + len_read) > length)
! dbsize = length - dbpos;
! else
! dbsize = len_read;
! reset_timeout(GLOBAL(php3_rqst)); /* Make sure we don't timeout
*/
! if((bytes=fwrite(upload_buffer, 1, dbsize, fp))<dbsize)
! {
! bytes+=dbpos;
! break;
! }
! dbpos += dbsize;
! bytes=dbpos;
! }
! signal(SIGPIPE, handler); /* restore normal sigpipe handling */
! kill_timeout(GLOBAL(php3_rqst)); /* stop timeout timer */
! }
#else
! cnt = 0;
! do {
#if APACHE
! char upload_buffer[BUFSIZ];
! bytes = read_client_block(php3_rqst, buf + cnt, min(length - cnt,BUFSIZ));
#endif
#if CGI_BINARY
! bytes = fread(buf + cnt, 1, min(length - cnt,BUFSIZ), stdin);
#endif
#if USE_SAPI
! bytes = GLOBAL(sapi_rqst)->readclient(GLOBAL(sapi_rqst)->scid,buf + cnt, 1,
min(length - cnt,BUFSIZ));
#endif
! cnt += bytes;
! } while (bytes && cnt < length);
#endif
#endif
! fclose(fp);
! if (bytes < length) {
! php3_error(E_WARNING, "Only %d bytes were written, expected to write %ld",
bytes, length);
! }
! SET_VAR_STRING("PHP_UPLOADED_FILE_NAME", estrdup(fn));
! php3_list_do_insert(&GLOBAL(list),fn,GLOBAL(le_uploads)); /* Tell PHP about the file so
the destructor can unlink it later */
}
--- 51,127 ----
*
* This copies the uploaded file to a temporary file.
*/
! static void php3_getput(void) {
! char *buf = NULL;
#if MODULE_MAGIC_NUMBER > 19961007
! char upload_buffer[BUFSIZ];
#endif
! size_t bytes;
! char *fn;
! FILE *fp;
! int length, cnt;
! length = GLOBAL(request_info).content_length;
! if (length > php3_ini.upload_max_filesize) {
! php3_error(E_WARNING, "Max file size of %ld bytes exceeded - temporary file not
saved", php3_ini.upload_max_filesize);
! SET_VAR_STRING("PHP_UPLOADED_FILE_NAME", estrdup("none"));
! return;
! }
! fn = tempnam(php3_ini.upload_tmp_dir, "php");
! fp = fopen(fn, "w");
! if (!fp) {
! php3_error(E_WARNING, "File Upload Error - Unable to open temporary file [%s]", fn);
! return;
! }
! cnt = length;
#if FHTTPD
! bytes = fwrite(req->databuffer, 1, length, fp);
#else
#if MODULE_MAGIC_NUMBER > 19961007
! if (should_client_block(GLOBAL(php3_rqst))) {
! void (*handler) (int);
! int dbsize, len_read, dbpos = 0;
! hard_timeout("copy script args", GLOBAL(php3_rqst)); /* start timeout timer */
! handler = signal(SIGPIPE, SIG_IGN); /* Ignore sigpipes for now */
! while ((len_read = get_client_block(GLOBAL(php3_rqst), upload_buffer, BUFSIZ)) > 0) {
! if ((dbpos + len_read) > length) dbsize = length - dbpos;
! else dbsize = len_read;
! reset_timeout(GLOBAL(php3_rqst)); /* Make sure we don't timeout */
! if((bytes=fwrite(upload_buffer, 1, dbsize, fp))<dbsize) {
! bytes+=dbpos;
! break;
! }
! dbpos += dbsize;
! bytes=dbpos;
! }
! signal(SIGPIPE, handler); /* restore normal sigpipe handling */
! kill_timeout(GLOBAL(php3_rqst)); /* stop timeout timer */
! }
#else
! cnt = 0;
! do {
#if APACHE
! char upload_buffer[BUFSIZ];
! bytes = read_client_block(php3_rqst, buf + cnt, min(length - cnt,BUFSIZ));
#endif
#if CGI_BINARY
! bytes = fread(buf + cnt, 1, ((length-cnt)<BUFSIZ)?length-cnt:BUFSIZ, stdin);
#endif
#if USE_SAPI
! bytes = GLOBAL(sapi_rqst)->readclient(GLOBAL(sapi_rqst)->scid,buf + cnt, 1, min(length -
cnt,BUFSIZ));
#endif
! cnt += bytes;
! } while (bytes && cnt < length);
#endif
#endif
! fclose(fp);
! if (bytes < length) {
! php3_error(E_WARNING, "Only %d bytes were written, expected to write %ld", bytes,
length);
! }
! SET_VAR_STRING("PHP_UPLOADED_FILE_NAME", estrdup(fn));
! php3_list_do_insert(&GLOBAL(list),fn,GLOBAL(le_uploads)); /* Tell PHP about the file so the
destructor can unlink it later */
}
--
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