~ubuntu-branches/ubuntu/feisty/apache2/feisty

« back to all changes in this revision

Viewing changes to srclib/apr/misc/unix/charset.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
 
2
 * applicable.
 
3
 *
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * You may obtain a copy of the License at
 
7
 *
 
8
 *     http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
 
 
17
#include "apr.h"
 
18
#include "apr_private.h"
 
19
#include "apr_strings.h"
 
20
#include "apr_portable.h"
 
21
 
 
22
#ifdef HAVE_LANGINFO_H
 
23
#include <langinfo.h>
 
24
#endif
 
25
 
 
26
/*
 
27
 * simple heuristic to determine codepage of source code so that
 
28
 * literal strings (e.g., "GET /\r\n") in source code can be translated
 
29
 * properly
 
30
 *
 
31
 * If appropriate, a symbol can be set at configure time to determine
 
32
 * this.  On EBCDIC platforms, it will be important how the code was
 
33
 * unpacked.
 
34
 */
 
35
 
 
36
APR_DECLARE(const char*) apr_os_default_encoding (apr_pool_t *pool)
 
37
{
 
38
#ifdef __MVS__
 
39
#    ifdef __CODESET__
 
40
        return __CODESET__;
 
41
#    else
 
42
        return "IBM-1047";
 
43
#    endif
 
44
#endif
 
45
 
 
46
    if ('}' == 0xD0) {
 
47
        return "IBM-1047";
 
48
    }
 
49
 
 
50
    if ('{' == 0xFB) {
 
51
        return "EDF04";
 
52
    }
 
53
 
 
54
    if ('A' == 0xC1) {
 
55
        return "EBCDIC"; /* not useful */
 
56
    }
 
57
 
 
58
    if ('A' == 0x41) {
 
59
        return "ISO-8859-1"; /* not necessarily true */
 
60
    }
 
61
 
 
62
    return "unknown";
 
63
}
 
64
 
 
65
 
 
66
APR_DECLARE(const char*) apr_os_locale_encoding (apr_pool_t *pool)
 
67
{
 
68
#if defined(HAVE_NL_LANGINFO) && defined(CODESET)
 
69
    const char *charset;
 
70
 
 
71
    charset = nl_langinfo(CODESET);
 
72
    if (charset && *charset) {
 
73
#ifdef _OSD_POSIX /* Bug workaround - delete as soon as fixed in OSD_POSIX */
 
74
        /* Some versions of OSD_POSIX return nl_langinfo(CODESET)="^[nN]" */
 
75
        /* Ignore the bogus information and use apr_os_default_encoding() */
 
76
        if (charset[0] != '^')
 
77
#endif
 
78
        return charset;
 
79
    }
 
80
#endif
 
81
 
 
82
    return apr_os_default_encoding(pool);
 
83
}