You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by br...@apache.org on 2002/11/12 03:55:45 UTC

cvs commit: apr libapr.dsp apr.dsp

brane       2002/11/11 18:55:45

  Modified:    misc/unix Makefile.in
               include  apr_portable.h
               .        libapr.dsp apr.dsp
  Added:       misc/win32 charset.c
               misc/unix charset.c
  Log:
  Introduced apr_os_default_encoding and apr_os_locale_encoding, with
  implementations for Unix and Win32, needed by apr_xlate.
  
  Revision  Changes    Path
  1.1                  apr/misc/win32/charset.c
  
  Index: charset.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #include "apr.h"
  #include "apr_strings.h"
  #include "apr_portable.h"
  
  
  APR_DECLARE(const char*) apr_os_default_encoding (apr_pool_t *pool)
  {
      return apr_psprintf(pool, "CP%u", (unsigned) GetACP());
  }
  
  
  APR_DECLARE(const char*) apr_os_locale_encoding (apr_pool_t *pool)
  {
      LCID locale = GetThreadLocale();
      int len = GetLocaleInfo(locale, LOCALE_IDEFAULTANSICODEPAGE, NULL, 0);
      char *cp = apr_palloc(pool, len + 2);
      if (0 < GetLocaleInfo(locale, LOCALE_IDEFAULTANSICODEPAGE, cp + 2, len))
      {
          /* Fix up the returned number to make a valid codepage name of
            the form "CPnnnn". */
          cp[0] = 'C';
          cp[1] = 'P';
          return cp;
      }
  
      return apr_os_default_encoding(pool);
  }
  
  
  
  1.32      +2 -1      apr/misc/unix/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr/misc/unix/Makefile.in,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- Makefile.in	17 Jul 2002 04:11:33 -0000	1.31
  +++ Makefile.in	12 Nov 2002 02:55:45 -0000	1.32
  @@ -2,7 +2,8 @@
   VPATH = @srcdir@
   
   TARGETS = \
  -	start.lo getopt.lo otherchild.lo errorcodes.lo rand.lo version.lo
  +	start.lo getopt.lo otherchild.lo errorcodes.lo rand.lo version.lo \
  +	charset.lo
   
   # bring in rules.mk for standard functionality
   @INCLUDE_RULES@
  
  
  
  1.1                  apr/misc/unix/charset.c
  
  Index: charset.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #include "apr.h"
  #include "apr_strings.h"
  #include "apr_portable.h"
  
  #ifdef HAVE_LANGINFO_H
  #include <langinfo.h>
  #endif
  
  /*
   * simple heuristic to determine codepage of source code so that
   * literal strings (e.g., "GET /\r\n") in source code can be translated
   * properly
   *
   * If appropriate, a symbol can be set at configure time to determine
   * this.  On EBCDIC platforms, it will be important how the code was
   * unpacked.
   */
  
  APR_DECLARE(const char*) apr_os_default_encoding (apr_pool_t *pool)
  {
  #ifdef __MVS__
  #    ifdef __CODESET__
          return __CODESET__;
  #    else
          return "IBM-1047";
  #    endif
  #endif
  
      if ('}' == 0xD0) {
          return "IBM-1047";
      }
  
      if ('{' == 0xFB) {
          return "EDF04";
      }
  
      if ('A' == 0xC1) {
          return "EBCDIC"; /* not useful */
      }
  
      if ('A' == 0x41) {
          return "ISO8859-1"; /* not necessarily true */
      }
  
      return "unknown";
  }
  
  
  APR_DECLARE(const char*) apr_os_locale_encoding (apr_pool_t *pool)
  {
  #if defined(HAVE_NL_LANGINFO) && defined(HAVE_CODESET)
      const char *charset;
  
      charset = nl_langinfo(CODESET);
      if (charset) {
          return charset;
      }
  #endif
  
      return apr_os_default_encoding(pool);
  }
  
  
  
  1.85      +16 -0     apr/include/apr_portable.h
  
  Index: apr_portable.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_portable.h,v
  retrieving revision 1.84
  retrieving revision 1.85
  diff -u -r1.84 -r1.85
  --- apr_portable.h	10 Nov 2002 08:35:16 -0000	1.84
  +++ apr_portable.h	12 Nov 2002 02:55:45 -0000	1.85
  @@ -503,6 +503,22 @@
   #endif /* APR_HAS_DSO */
   
   
  +/**
  + * Get the name of the system default characer set.
  + * @param pool the pool to allocate the name from, if needed
  + */
  +APR_DECLARE(const char*) apr_os_default_encoding(apr_pool_t *pool);
  +
  +
  +/**
  + * Get the name of the current locale character set.
  + * @param pool the pool to allocate the name from, if needed
  + * @remark Defers to apr_os_default_encoding if the current locale's
  + * data can't be retreved on this system.
  + */
  +APR_DECLARE(const char*) apr_os_locale_encoding(apr_pool_t *pool);
  +
  +
   #ifdef __cplusplus
   }
   #endif
  
  
  
  1.75      +4 -0      apr/libapr.dsp
  
  Index: libapr.dsp
  ===================================================================
  RCS file: /home/cvs/apr/libapr.dsp,v
  retrieving revision 1.74
  retrieving revision 1.75
  diff -u -r1.74 -r1.75
  --- libapr.dsp	27 Oct 2002 03:29:05 -0000	1.74
  +++ libapr.dsp	12 Nov 2002 02:55:45 -0000	1.75
  @@ -196,6 +196,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=.\misc\win32\charset.c
  +# End Source File
  +# Begin Source File
  +
   SOURCE=.\misc\unix\errorcodes.c
   # End Source File
   # Begin Source File
  
  
  
  1.114     +4 -0      apr/apr.dsp
  
  Index: apr.dsp
  ===================================================================
  RCS file: /home/cvs/apr/apr.dsp,v
  retrieving revision 1.113
  retrieving revision 1.114
  diff -u -r1.113 -r1.114
  --- apr.dsp	27 Oct 2002 03:29:05 -0000	1.113
  +++ apr.dsp	12 Nov 2002 02:55:45 -0000	1.114
  @@ -190,6 +190,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=.\misc\win32\charset.c
  +# End Source File
  +# Begin Source File
  +
   SOURCE=.\misc\unix\errorcodes.c
   # End Source File
   # Begin Source File