httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@locus.apache.org
Subject cvs commit: apache-2.0/src/main buff.c http_core.c util_ebcdic.c util_script.c
Date Mon, 15 May 2000 17:51:28 GMT
trawick     00/05/15 10:51:26

  Modified:    src/include util_ebcdic.h util_md5.h
               src/main buff.c http_core.c util_ebcdic.c util_script.c
  Log:
  util_ebcdic.h, util_ebcdic.c, http_core.c:
    tweak ap_checkconv() for 2.0
  buff.c:
    fix typo in comment
  util_md5.h:
    change CHARSET_EBCDIC to APACHE_XLATE
  util_script.c:
    APR-ize some character set conversion (EBCDIC only)
  
  Revision  Changes    Path
  1.3       +2 -0      apache-2.0/src/include/util_ebcdic.h
  
  Index: util_ebcdic.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/util_ebcdic.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- util_ebcdic.h	2000/05/10 01:22:29	1.2
  +++ util_ebcdic.h	2000/05/15 17:51:17	1.3
  @@ -72,6 +72,8 @@
   
   ap_status_t ap_init_ebcdic(ap_pool_t *);
   
  +ap_xlate_t *ap_checkconv(struct request_rec *);
  +
   #ifdef __cplusplus
   }
   #endif
  
  
  
  1.12      +1 -1      apache-2.0/src/include/util_md5.h
  
  Index: util_md5.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/util_md5.h,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- util_md5.h	2000/05/11 02:32:04	1.11
  +++ util_md5.h	2000/05/15 17:51:18	1.12
  @@ -68,7 +68,7 @@
   API_EXPORT(char *) ap_md5(ap_pool_t *a, const unsigned char *string);
   API_EXPORT(char *) ap_md5_binary(ap_pool_t *a, const unsigned char *buf, int len);
   API_EXPORT(char *) ap_md5contextTo64(ap_pool_t *p, ap_md5_ctx_t *context);
  -#ifdef CHARSET_EBCDIC
  +#ifdef APACHE_XLATE
   API_EXPORT(char *) ap_md5digest(ap_pool_t *p, ap_file_t *infile,
                                   ap_xlate_t *xlate);
   #else
  
  
  
  1.41      +1 -1      apache-2.0/src/main/buff.c
  
  Index: buff.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/buff.c,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- buff.c	2000/05/12 15:47:08	1.40
  +++ buff.c	2000/05/15 17:51:21	1.41
  @@ -440,7 +440,7 @@
   
   /*
    * Read up to nbyte bytes into buf.
  - * If fewer than byte bytes are currently available, then return those.
  + * If fewer than nbyte bytes are currently available, then return those.
    */
   API_EXPORT(ap_status_t) ap_bread_core(BUFF *fb, void *buf, ap_size_t nbyte,
                                         ap_ssize_t *bytes_read)
  
  
  
  1.57      +5 -6      apache-2.0/src/main/http_core.c
  
  Index: http_core.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_core.c,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- http_core.c	2000/05/11 02:32:05	1.56
  +++ http_core.c	2000/05/15 17:51:22	1.57
  @@ -2347,7 +2347,7 @@
       ap_mmap_t *mm = NULL;
   #endif
   #ifdef CHARSET_EBCDIC
  -    int convert_flag;
  +    ap_xlate_t *xlate_to_net;
   #endif
   
       /* This handler has no use for a request body (yet), but we still
  @@ -2406,7 +2406,7 @@
        *
        * Note: convert_flag is not used in the MMAP path;
        */
  -    convert_flag = ap_checkconv(r);
  +    xlate_to_net = ap_checkconv(r);
   #endif  
   #ifdef USE_MMAP_FILES
       if ((r->finfo.size >= MMAP_THRESHOLD)
  @@ -2432,8 +2432,7 @@
   	if (d->content_md5 & 1) {
   	    ap_table_setn(r->headers_out, "Content-MD5",
   			  ap_md5digest(r->pool, fd,
  -                                       convert_flag ?
  -                                       ap_locale_to_ascii : NULL));
  +                                       xlate_to_net));
   	}
   #else
   	if (d->content_md5 & 1) {
  @@ -2477,8 +2476,8 @@
   	    
   	    ap_MD5Init(&context);
   #ifdef CHARSET_EBCDIC
  -            if (convert_flag) {
  -                ap_MD5SetXlate(&context, ap_locale_to_ascii);
  +            if (xlate_to_net) {
  +                ap_MD5SetXlate(&context, xlate_to_net);
               }
   #endif
   	    ap_MD5Update(&context, addr, (unsigned int)r->finfo.size);
  
  
  
  1.3       +46 -1     apache-2.0/src/main/util_ebcdic.c
  
  Index: util_ebcdic.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/util_ebcdic.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- util_ebcdic.c	2000/05/10 01:22:31	1.2
  +++ util_ebcdic.c	2000/05/15 17:51:22	1.3
  @@ -56,13 +56,13 @@
    * University of Illinois, Urbana-Champaign.
    */
   
  -#define CORE_PRIVATE
   #include "ap_config.h"
   
   #ifdef CHARSET_EBCDIC
   
   #include "httpd.h"
   #include "http_log.h"
  +#include "http_core.h"
   #include "util_ebcdic.h"
   
   ap_xlate_t *ap_hdrs_to_ascii, *ap_hdrs_from_ascii;
  @@ -98,6 +98,51 @@
       }
       
       return APR_SUCCESS;
  +}
  +
  +#define ASCIITEXT_MAGIC_TYPE_PREFIX "text/x-ascii-" /* Text files whose content-type starts
with this are passed thru unconverted */
  +
  +/* Check the Content-Type to decide if conversion is needed */
  +ap_xlate_t *ap_checkconv(struct request_rec *r)
  +{
  +    int convert_to_ascii;
  +    const char *type;
  +    ap_xlate_t *zero = NULL;
  +
  +    /* To make serving of "raw ASCII text" files easy (they serve faster 
  +     * since they don't have to be converted from EBCDIC), a new
  +     * "magic" type prefix was invented: text/x-ascii-{plain,html,...}
  +     * If we detect one of these content types here, we simply correct
  +     * the type to the real text/{plain,html,...} type. Otherwise, we
  +     * set a flag that translation is required later on.
  +     */
  +
  +    type = (r->content_type == NULL) ? ap_default_type(r) : r->content_type;
  +
  +    /* If no content type is set then treat it as (ebcdic) text/plain */
  +    convert_to_ascii = (type == NULL);
  +
  +    /* Conversion is applied to text/ files only, if ever. */
  +    if (type && (strncasecmp(type, "text/", 5) == 0 ||
  +		 strncasecmp(type, "message/", 8) == 0)) {
  +	if (strncasecmp(type, ASCIITEXT_MAGIC_TYPE_PREFIX,
  +			sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1) == 0)
  +	    r->content_type = ap_pstrcat(r->pool, "text/",
  +					 type+sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1,
  +					 NULL);
  +        else
  +	    /* translate EBCDIC to ASCII */
  +	    convert_to_ascii = 1;
  +    }
  +    /* Enable conversion if it's a text document */
  +    if (convert_to_ascii) {
  +        ap_bsetopt(r->connection->client, BO_WXLATE, &ap_locale_to_ascii);
  +    }
  +    else {
  +        ap_bsetopt(r->connection->client, BO_WXLATE, &zero);
  +    }
  +
  +    return convert_to_ascii ? ap_locale_to_ascii : NULL;
   }
   
   #endif /* CHARSET_EBCDIC */
  
  
  
  1.31      +14 -8     apache-2.0/src/main/util_script.c
  
  Index: util_script.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/util_script.c,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- util_script.c	2000/04/20 14:36:00	1.30
  +++ util_script.c	2000/05/15 17:51:23	1.31
  @@ -67,6 +67,7 @@
   #include "http_request.h"	/* for sub_req_lookup_uri() */
   #include "util_script.h"
   #include "util_date.h"		/* For parseHTTPdate() */
  +#include "util_ebcdic.h"
   #include <stdlib.h>
   #include <string.h>
   
  @@ -537,21 +538,26 @@
   	     */
   	if (!(l = strchr(w, ':'))) {
   	    int maybeASCII = 0, maybeEBCDIC = 0;
  -	    char *cp;
  +	    unsigned char *cp, native;
  +            ap_size_t inbytes_left, outbytes_left;
   
   	    for (cp = w; *cp != '\0'; ++cp) {
  -		if (isprint(*cp) && !isprint(os_toebcdic[*cp]))
  +                native = ap_xlate_conv_byte(ap_hdrs_from_ascii, *cp);
  +		if (isprint(*cp) && !isprint(native))
   		    ++maybeEBCDIC;
  -		if (!isprint(*cp) && isprint(os_toebcdic[*cp]))
  +		if (!isprint(*cp) && isprint(native))
   		    ++maybeASCII;
  -		}
  +            }
   	    if (maybeASCII > maybeEBCDIC) {
  -		ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server,
  -			 "CGI Interface Error: Script headers apparently ASCII: (CGI = %s)", r->filename);
  -		ascii2ebcdic(w, w, cp - w);
  +		ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r->server,
  +                             "CGI Interface Error: Script headers apparently ASCII: (CGI
= %s)",
  +                             r->filename);
  +                inbytes_left = outbytes_left = cp - w;
  +                ap_xlate_conv_buffer(ap_hdrs_from_ascii,
  +                                     w, &inbytes_left, w, &outbytes_left);
   	    }
   	}
  -#endif
  +#endif /*CHARSET_EBCDIC*/
   	if (!(l = strchr(w, ':'))) {
   	    char malformed[(sizeof MALFORMED_MESSAGE) + 1
   			   + MALFORMED_HEADER_LENGTH_TO_SHOW];
  
  
  

Mime
View raw message