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 util_ebcdic.c
Date Wed, 14 Jun 2000 20:38:40 GMT
trawick     00/06/14 13:38:40

  Modified:    src/lib/apr acconfig.h configure.in
               src/lib/apr/i18n/unix xlate.c
               src/lib/apr/include apr_xlate.h
               src/main util_ebcdic.c
  Log:
  Add support to ap_xlate_open() for an app to specify that the
  charset of the locale is to be used for the source or target
  charset.
  
  At EBCDIC initialization, use the locale charset as one of the
  pair when setting up the default translation handles for content.
  
  Revision  Changes    Path
  1.32      +1 -0      apache-2.0/src/lib/apr/acconfig.h
  
  Index: acconfig.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/acconfig.h,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- acconfig.h	2000/06/13 16:26:26	1.31
  +++ acconfig.h	2000/06/14 20:38:11	1.32
  @@ -29,6 +29,7 @@
   /* Various #defines we need to know about */
   #undef HAVE_LOCK_EX
   #undef HAVE_F_SETLK
  +#undef HAVE_CODESET
   #undef HAVE_PTHREAD_PROCESS_SHARED
   #undef DEV_RANDOM
   #undef HAVE_TRUERAND
  
  
  
  1.112     +3 -1      apache-2.0/src/lib/apr/configure.in
  
  Index: configure.in
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/configure.in,v
  retrieving revision 1.111
  retrieving revision 1.112
  diff -u -r1.111 -r1.112
  --- configure.in	2000/06/13 13:05:33	1.111
  +++ configure.in	2000/06/14 20:38:13	1.112
  @@ -193,7 +193,7 @@
   
   dnl #----------------------------- Checks for Any required Functions
   dnl Checks for library functions. (N.B. poll is further down)
  -AC_CHECK_FUNCS(strcasecmp stricmp setsid)
  +AC_CHECK_FUNCS(strcasecmp stricmp setsid nl_langinfo)
   AC_CHECK_FUNCS(sigaction, [ have_sigaction="1" ], [ have_sigaction="0" ]) 
   AC_CHECK_FUNCS(writev)
   AC_CHECK_FUNCS(sendfile, [ sendfile="1" ], [ sendfile="0" ])
  @@ -264,6 +264,7 @@
   AC_CHECK_HEADERS(netinet/in.h, netinet_inh="1", netinet_inh="0")
   AC_CHECK_HEADERS(netinet/tcp.h)
   AC_CHECK_HEADERS(iconv.h)
  +AC_CHECK_HEADERS(langinfo.h)
   
   AC_CHECK_HEADERS(sys/file.h)
   AC_CHECK_HEADERS(sys/ioctl.h)
  @@ -541,6 +542,7 @@
   dnl Checks for libraries.
   AC_CHECK_DEFINE(LOCK_EX, sys/file.h)
   AC_CHECK_DEFINE(F_SETLK, fcntl.h)
  +AC_CHECK_DEFINE(CODESET, langinfo.h)
   AC_CHECK_DEFINE(isascii, ctype.h)
   # We are assuming that if the platform doesn't have POLLIN, it doesn't have
   # any POLL definitions.
  
  
  
  1.8       +38 -9     apache-2.0/src/lib/apr/i18n/unix/xlate.c
  
  Index: xlate.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/i18n/unix/xlate.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- xlate.c	2000/06/13 13:41:19	1.7
  +++ xlate.c	2000/06/14 20:38:18	1.8
  @@ -63,6 +63,9 @@
   
   #if APR_HAS_XLATE
   
  +#ifdef HAVE_LANGINFO_H
  +#include <langinfo.h>
  +#endif
   #ifdef HAVE_ICONV_H
   #include <iconv.h>
   #endif
  @@ -81,7 +84,7 @@
   #endif
   };
   
  -/* get_default_codepage()
  +/* get_default_charset()
    *
    * simple heuristic to determine codepage of source code so that
    * literal strings (e.g., "GET /\r\n") in source code can be translated
  @@ -92,7 +95,7 @@
    * unpacked.
    */
   
  -static const char *get_default_codepage(void)
  +static const char *get_default_charset(void)
   {
   #ifdef __MVS__
       #ifdef __CODESET__
  @@ -121,6 +124,37 @@
       return "unknown";
   }
   
  +/* get_locale_charset()
  + *
  + * If possible on this system, get the charset of the locale.  Otherwise,
  + * defer to get_default_charset().
  + */
  +
  +static const char *get_locale_charset(void)
  +{
  +#if defined(HAVE_NL_LANGINFO) && defined(HAVE_CODESET)
  +    const char *charset;
  +    charset = nl_langinfo(CODESET);
  +    if (charset) {
  +        return charset;
  +    }
  +#endif
  +    return get_default_charset();
  +}
  +
  +static const char *handle_special_names(const char *page)
  +{
  +    if (page == APR_DEFAULT_CHARSET) {
  +        return get_default_charset();
  +    }
  +    else if (page == APR_LOCALE_CHARSET) {
  +        return get_locale_charset();
  +    }
  +    else {
  +        return page;
  +    }
  +}
  +
   static ap_status_t ap_xlate_cleanup(void *convset)
   {
   #ifdef HAVE_ICONV
  @@ -176,14 +210,9 @@
       int found = 0;
   
       *convset = NULL;
  -    
  -    if (!topage) {
  -        topage = get_default_codepage();
  -    }
   
  -    if (!frompage) {
  -        frompage = get_default_codepage();
  -    }
  +    topage = handle_special_names(topage);
  +    frompage = handle_special_names(frompage);
       
       new = (ap_xlate_t *)ap_pcalloc(pool, sizeof(ap_xlate_t));
       if (!new) {
  
  
  
  1.4       +5 -1      apache-2.0/src/lib/apr/include/apr_xlate.h
  
  Index: apr_xlate.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_xlate.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- apr_xlate.h	2000/05/24 11:45:43	1.3
  +++ apr_xlate.h	2000/06/14 20:38:29	1.4
  @@ -120,12 +120,16 @@
             of the caller was not encoded in the same charset as
             APR at compile time.
   
  +          Specify APR_LOCALE_CHARSET for one of the charset
  +          names to indicate the charset of the current locale.
  +
   =cut
    */
   ap_status_t ap_xlate_open(ap_xlate_t **convset, const char *topage, 
                             const char *frompage, ap_pool_t *pool);
   
  -#define APR_DEFAULT_CHARSET NULL
  +#define APR_DEFAULT_CHARSET (const char *)0
  +#define APR_LOCALE_CHARSET (const char *)1
   
   /*
   
  
  
  
  1.9       +13 -2     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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- util_ebcdic.c	2000/05/27 14:05:13	1.8
  +++ util_ebcdic.c	2000/06/14 20:38:32	1.9
  @@ -84,8 +84,19 @@
           return rv;
       }
   
  -    ap_locale_to_ascii = ap_hdrs_to_ascii; /* TODO: "ISO8859-1" to APR_LOCALE_CHARSET */
  -    ap_locale_from_ascii = ap_hdrs_from_ascii; /* TODO: APR_LOCALE_CHARSET to "ISO8859-1"
*/
  +    rv = ap_xlate_open(&ap_locale_to_ascii, "ISO8859-1", APR_LOCALE_CHARSET, pool);
  +    if (rv) {
  +        ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL,
  +                     "ap_xlate_open() failed");
  +        return rv;
  +    }
  +
  +    rv = ap_xlate_open(&ap_locale_from_ascii, APR_LOCALE_CHARSET, "ISO8859-1", pool);
  +    if (rv) {
  +        ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL,
  +                     "ap_xlate_open() failed");
  +        return rv;
  +    }
   
       rv = ap_MD5InitEBCDIC(ap_hdrs_to_ascii);
       if (rv) {
  
  
  

Mime
View raw message