tcl-mod_dtcl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject cvs commit: tcl-moddtcl apache_request.c apache_request.h
Date Mon, 04 Jun 2001 09:54:46 GMT
davidw      01/06/04 02:54:46

  Modified:    .        apache_request.c apache_request.h
  Log:
  Added changes from apreq, Mikhail Teterin.
  Submitted by: mi@aldan.algebra.com
  
  Revision  Changes    Path
  1.6       +25 -15    tcl-moddtcl/apache_request.c
  
  Index: apache_request.c
  ===================================================================
  RCS file: /home/cvs/tcl-moddtcl/apache_request.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- apache_request.c	2001/03/19 17:36:42	1.5
  +++ apache_request.c	2001/06/04 09:54:46	1.6
  @@ -268,9 +268,8 @@
   int ApacheRequest___parse(ApacheRequest *req)
   {
       request_rec *r = req->r;
  +    int result;
   
  -    req->parsed = 1;
  -
       if (r->args) {
           split_to_parms(req, r->args);
       }
  @@ -278,20 +277,24 @@
       if (r->method_number == M_POST) { 
   	const char *ct = ap_table_get(r->headers_in, "Content-type"); 
   	if (ct && strcaseEQN(ct, DEFAULT_ENCTYPE, DEFAULT_ENCTYPE_LENGTH)) {
  -	    return ApacheRequest_parse_urlencoded(req); 
  +	    result = ApacheRequest_parse_urlencoded(req); 
   	}
   	else if (ct && strcaseEQN(ct, MULTIPART_ENCTYPE, MULTIPART_ENCTYPE_LENGTH)) {
  -	   return ApacheRequest_parse_multipart(req); 
  +	   result = ApacheRequest_parse_multipart(req); 
   	}
   	else {
   	    ap_log_rerror(REQ_ERROR, 
   			  "[libapreq] unknown content-type: `%s'", ct); 
  -	    return HTTP_INTERNAL_SERVER_ERROR;
  +	    result = HTTP_INTERNAL_SERVER_ERROR;
   	}
       } 
       else {
  -	return ApacheRequest_parse_urlencoded(req); 
  +	result = ApacheRequest_parse_urlencoded(req); 
       }
  +
  +    req->parsed = 1;
  +    return result;
  +
   }
   
   int ApacheRequest_parse_urlencoded(ApacheRequest *req)
  @@ -319,8 +322,17 @@
   }
   
   static void remove_tmpfile(void *data) {
  -    remove((char *) data);
  -    free((char *) data);
  +    ApacheUpload *upload = (ApacheUpload *) data;
  +    ApacheRequest *req = upload->req;
  +
  +    if( ap_pfclose(req->r->pool, upload->fp) )
  +	ap_log_rerror(REQ_ERROR,
  +		      "[libapreq] close error on '%s'", upload->tempname);	
  +    if( remove(upload->tempname) )
  +	ap_log_rerror(REQ_ERROR,
  +		      "[libapreq] remove error on '%s'", upload->tempname);
  +
  +    free(upload->tempname);
   }
   
   FILE *ApacheRequest_tmpfile(ApacheRequest *req, ApacheUpload *upload)
  @@ -332,7 +344,8 @@
       int fd, tries = 100;
       
       while (--tries > 0) {
  -	if ( (name = tempnam(req->temp_dir, prefix)) == NULL ) continue;
  +	if ( (name = tempnam(req->temp_dir, prefix)) == NULL )
  +	    continue;
   	fd = ap_popenf(r->pool, name, O_CREAT|O_EXCL|O_RDWR, 0600);
   	if ( fd >= 0 )
   	    break; /* success */
  @@ -340,7 +353,7 @@
   	    free(name);
       }
       
  -    if ( tries == 0  || (fp = ap_pfdopen(r->pool, fd, "w+") ) == NULL ) {
  +    if ( tries == 0  || (fp = ap_pfdopen(r->pool, fd, "wb+") ) == NULL ) {
   	ap_log_rerror(REQ_ERROR,
   		      "[libapreq] could not open temp file '%s'", name); 	
   	if ( fd >= 0 ) { remove(name); free(name); }
  @@ -349,7 +362,7 @@
   
       upload->fp = fp;
       upload->tempname = name;
  -    ap_register_cleanup(r->pool, (void *)upload->tempname, 
  +    ap_register_cleanup(r->pool, (void *)upload, 
   			remove_tmpfile, ap_null_cleanup);
       return fp;
   
  @@ -462,11 +475,8 @@
   		upload->size += wlen;
   	    }
   
  -	    if (upload->size > 0 && (req->upload_hook == NULL)) {
  +	    if (upload->size > 0 && (upload->fp != NULL)) {
   		fseek(upload->fp, 0, 0);
  -	    }
  -	    else {
  -		upload->fp = NULL;
   	    }
   	}
       }
  
  
  
  1.5       +23 -1     tcl-moddtcl/apache_request.h
  
  Index: apache_request.h
  ===================================================================
  RCS file: /home/cvs/tcl-moddtcl/apache_request.h,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- apache_request.h	2001/03/15 19:36:57	1.4
  +++ apache_request.h	2001/06/04 09:54:46	1.5
  @@ -10,6 +10,28 @@
   #include "http_protocol.h"
   #include "util_script.h"
   
  +#ifdef  SFIO
  +#include "sfio.h"
  +
  +/* sfio 2000 changed _stdopen to _stdfdopen */
  +#if SFIO_VERSION >= 20000101L
  +#define _stdopen _stdfdopen
  +#endif
  +
  +extern Sfio_t*  _stdopen _ARG_((int, const char*)); /*1999*/
  +
  +#undef  FILE
  +#define FILE 			Sfio_t
  +#undef  fwrite
  +#define fwrite(p,s,n,f)		sfwrite((f),(p),(s)*(n))
  +#undef  fseek
  +#define fseek(f,a,b)		sfseek((f),(a),(b))
  +#undef  ap_pfdopen
  +#define ap_pfdopen(p,q,r) 	_stdopen((q),(r))
  +#undef  ap_pfclose
  +#define ap_pfclose(p,q)		sfclose(q)
  +#endif /*SFIO*/
  +
   typedef struct ApacheUpload ApacheUpload;
   
   typedef struct {
  @@ -19,7 +41,7 @@
       int parsed;
       int post_max;
       int disable_uploads;
  -    int (*upload_hook)(void *ptr, char *buf, int len, const ApacheUpload *upload);
  +    int (*upload_hook)(void *ptr, char *buf, int len, ApacheUpload *upload);
       void *hook_data;
       char* temp_dir;
       request_rec *r;
  
  
  

Mime
View raw message