1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "ap_config.h"
19 #if APR_CHARSET_EBCDIC
21 #include "apr_strings.h"
24 #include "http_core.h"
25 #include "util_ebcdic.h"
27 /* we know core's module_index is 0 */
28 #undef APLOG_MODULE_INDEX
29 #define APLOG_MODULE_INDEX AP_CORE_MODULE_INDEX
31 apr_status_t ap_init_ebcdic(apr_pool_t *pool)
35 rv = apr_xlate_open(&ap_hdrs_to_ascii, "ISO-8859-1", APR_DEFAULT_CHARSET, pool);
37 ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, APLOGNO(00040)
38 "apr_xlate_open() failed");
42 rv = apr_xlate_open(&ap_hdrs_from_ascii, APR_DEFAULT_CHARSET, "ISO-8859-1", pool);
44 ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, APLOGNO(00041)
45 "apr_xlate_open() failed");
49 rv = apr_MD5InitEBCDIC(ap_hdrs_to_ascii);
51 ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, APLOGNO(00042)
52 "apr_MD5InitEBCDIC() failed");
56 rv = apr_base64init_ebcdic(ap_hdrs_to_ascii, ap_hdrs_from_ascii);
58 ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, APLOGNO(00043)
59 "apr_base64init_ebcdic() failed");
63 rv = apr_SHA1InitEBCDIC(ap_hdrs_to_ascii);
65 ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, APLOGNO(00044)
66 "apr_SHA1InitEBCDIC() failed");
73 void ap_xlate_proto_to_ascii(char *buffer, apr_size_t len)
75 apr_size_t inbytes_left, outbytes_left;
77 inbytes_left = outbytes_left = len;
78 apr_xlate_conv_buffer(ap_hdrs_to_ascii, buffer, &inbytes_left,
79 buffer, &outbytes_left);
82 void ap_xlate_proto_from_ascii(char *buffer, apr_size_t len)
84 apr_size_t inbytes_left, outbytes_left;
86 inbytes_left = outbytes_left = len;
87 apr_xlate_conv_buffer(ap_hdrs_from_ascii, buffer, &inbytes_left,
88 buffer, &outbytes_left);
91 int ap_rvputs_proto_in_ascii(request_rec *r, ...)
97 apr_size_t written = 0;
101 s = va_arg(va, const char *);
105 ascii_s = apr_pstrmemdup(r->pool, s, len);
106 ap_xlate_proto_to_ascii(ascii_s, len);
107 if (ap_rputs(ascii_s, r) < 0) {
117 #endif /* APR_CHARSET_EBCDIC */