From: Jeff Trawick Date: Thu, 25 Apr 2002 22:12:51 +0000 (+0000) Subject: get mod_proxy to build on EBCDIC machines X-Git-Tag: 2.0.36~77 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d439ef140b86dd6e7fd44b4420d0e58fec41000f;p=apache get mod_proxy to build on EBCDIC machines git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94808 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/proxy/proxy_ftp.c b/modules/proxy/proxy_ftp.c index 3e599e0571..193722b0b2 100644 --- a/modules/proxy/proxy_ftp.c +++ b/modules/proxy/proxy_ftp.c @@ -147,6 +147,9 @@ static int ftp_check_globbingchars(const char *path) static int ftp_check_string(const char *x) { int i, ch = 0; +#if APR_CHARSET_EBCDIC + char buf[1]; +#endif for (i = 0; x[i] != '\0'; i++) { ch = x[i]; @@ -157,7 +160,11 @@ static int ftp_check_string(const char *x) #if !APR_CHARSET_EBCDIC if (ch == '\015' || ch == '\012' || (ch & 0x80)) #else /* APR_CHARSET_EBCDIC */ - if (ch == '\r' || ch == '\n' || (os_toascii[ch] & 0x80)) + if (ch == '\r' || ch == '\n') + return 0; + buf[0] = ch; + ap_xlate_proto_to_ascii(buf); + if (buf[0] & 0x80) #endif /* APR_CHARSET_EBCDIC */ return 0; } diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index ff6b9bdfa2..da07414cab 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -93,7 +93,27 @@ PROXY_DECLARE(int) ap_proxy_hex2c(const char *x) i += ch - ('a' - 10); return i; #else /*APR_CHARSET_EBCDIC*/ - return (1 == sscanf(x, "%2x", &i)) ? os_toebcdic[i&0xFF] : 0; + /* we assume that the hex value refers to an ASCII character + * so convert to EBCDIC so that it makes sense locally; + * + * example: + * + * client specifies %20 in URL to refer to a space char; + * at this point we're called with EBCDIC "20"; after turning + * EBCDIC "20" into binary 0x20, we then need to assume that 0x20 + * represents an ASCII char and convert 0x20 to EBCDIC, yielding + * 0x40 + */ + char buf[1]; + + if (1 == sscanf(x, "%2x", &i)) { + buf[0] = i & 0xFF; + ap_xlate_proto_from_ascii(buf, 1); + return buf[0]; + } + else { + return 0; + } #endif /*APR_CHARSET_EBCDIC*/ } @@ -116,10 +136,16 @@ PROXY_DECLARE(void) ap_proxy_c2hex(int ch, char *x) x[2] = '0' + i; #else /*APR_CHARSET_EBCDIC*/ static const char ntoa[] = { "0123456789ABCDEF" }; + char buf[1]; + ch &= 0xFF; + + buf[0] = ch; + ap_xlate_proto_to_ascii(buf, 1); + x[0] = '%'; - x[1] = ntoa[(os_toascii[ch]>>4)&0x0F]; - x[2] = ntoa[os_toascii[ch]&0x0F]; + x[1] = ntoa[(buf[0] >> 4) & 0x0F]; + x[2] = ntoa[buf[0] & 0x0F]; x[3] = '\0'; #endif /*APR_CHARSET_EBCDIC*/ }