|
Packit |
90a5c9 |
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
Packit |
90a5c9 |
* contributor license agreements. See the NOTICE file distributed with
|
|
Packit |
90a5c9 |
* this work for additional information regarding copyright ownership.
|
|
Packit |
90a5c9 |
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
Packit |
90a5c9 |
* (the "License"); you may not use this file except in compliance with
|
|
Packit |
90a5c9 |
* the License. You may obtain a copy of the License at
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* Unless required by applicable law or agreed to in writing, software
|
|
Packit |
90a5c9 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
Packit |
90a5c9 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
Packit |
90a5c9 |
* See the License for the specific language governing permissions and
|
|
Packit |
90a5c9 |
* limitations under the License.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#include "ap_config.h"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#if APR_CHARSET_EBCDIC
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#include "apr_strings.h"
|
|
Packit |
90a5c9 |
#include "httpd.h"
|
|
Packit |
90a5c9 |
#include "http_log.h"
|
|
Packit |
90a5c9 |
#include "http_core.h"
|
|
Packit |
90a5c9 |
#include "util_ebcdic.h"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* we know core's module_index is 0 */
|
|
Packit |
90a5c9 |
#undef APLOG_MODULE_INDEX
|
|
Packit |
90a5c9 |
#define APLOG_MODULE_INDEX AP_CORE_MODULE_INDEX
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
apr_status_t ap_init_ebcdic(apr_pool_t *pool)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
apr_status_t rv;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
rv = apr_xlate_open(&ap_hdrs_to_ascii, "ISO-8859-1", APR_DEFAULT_CHARSET, pool);
|
|
Packit |
90a5c9 |
if (rv) {
|
|
Packit |
90a5c9 |
ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, APLOGNO(00040)
|
|
Packit |
90a5c9 |
"apr_xlate_open() failed");
|
|
Packit |
90a5c9 |
return rv;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
rv = apr_xlate_open(&ap_hdrs_from_ascii, APR_DEFAULT_CHARSET, "ISO-8859-1", pool);
|
|
Packit |
90a5c9 |
if (rv) {
|
|
Packit |
90a5c9 |
ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, APLOGNO(00041)
|
|
Packit |
90a5c9 |
"apr_xlate_open() failed");
|
|
Packit |
90a5c9 |
return rv;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
rv = apr_MD5InitEBCDIC(ap_hdrs_to_ascii);
|
|
Packit |
90a5c9 |
if (rv) {
|
|
Packit |
90a5c9 |
ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, APLOGNO(00042)
|
|
Packit |
90a5c9 |
"apr_MD5InitEBCDIC() failed");
|
|
Packit |
90a5c9 |
return rv;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
rv = apr_base64init_ebcdic(ap_hdrs_to_ascii, ap_hdrs_from_ascii);
|
|
Packit |
90a5c9 |
if (rv) {
|
|
Packit |
90a5c9 |
ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, APLOGNO(00043)
|
|
Packit |
90a5c9 |
"apr_base64init_ebcdic() failed");
|
|
Packit |
90a5c9 |
return rv;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
rv = apr_SHA1InitEBCDIC(ap_hdrs_to_ascii);
|
|
Packit |
90a5c9 |
if (rv) {
|
|
Packit |
90a5c9 |
ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, APLOGNO(00044)
|
|
Packit |
90a5c9 |
"apr_SHA1InitEBCDIC() failed");
|
|
Packit |
90a5c9 |
return rv;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return APR_SUCCESS;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
void ap_xlate_proto_to_ascii(char *buffer, apr_size_t len)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
apr_size_t inbytes_left, outbytes_left;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
inbytes_left = outbytes_left = len;
|
|
Packit |
90a5c9 |
apr_xlate_conv_buffer(ap_hdrs_to_ascii, buffer, &inbytes_left,
|
|
Packit |
90a5c9 |
buffer, &outbytes_left);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
void ap_xlate_proto_from_ascii(char *buffer, apr_size_t len)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
apr_size_t inbytes_left, outbytes_left;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
inbytes_left = outbytes_left = len;
|
|
Packit |
90a5c9 |
apr_xlate_conv_buffer(ap_hdrs_from_ascii, buffer, &inbytes_left,
|
|
Packit |
90a5c9 |
buffer, &outbytes_left);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
int ap_rvputs_proto_in_ascii(request_rec *r, ...)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
va_list va;
|
|
Packit |
90a5c9 |
const char *s;
|
|
Packit |
90a5c9 |
char *ascii_s;
|
|
Packit |
90a5c9 |
apr_size_t len;
|
|
Packit |
90a5c9 |
apr_size_t written = 0;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
va_start(va, r);
|
|
Packit |
90a5c9 |
while (1) {
|
|
Packit |
90a5c9 |
s = va_arg(va, const char *);
|
|
Packit |
90a5c9 |
if (s == NULL)
|
|
Packit |
90a5c9 |
break;
|
|
Packit |
90a5c9 |
len = strlen(s);
|
|
Packit |
90a5c9 |
ascii_s = apr_pstrmemdup(r->pool, s, len);
|
|
Packit |
90a5c9 |
ap_xlate_proto_to_ascii(ascii_s, len);
|
|
Packit |
90a5c9 |
if (ap_rputs(ascii_s, r) < 0) {
|
|
Packit |
90a5c9 |
va_end(va);
|
|
Packit |
90a5c9 |
return -1;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
written += len;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
va_end(va);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return written;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
#endif /* APR_CHARSET_EBCDIC */
|