MCPcopy Create free account
hub / github.com/apache/httpd / ap_proxy_hex2c

Function ap_proxy_hex2c

modules/proxy/proxy_util.c:118–171  ·  view source on GitHub ↗

already called in the knowledge that the characters are hex digits */

Source from the content-addressed store, hash-verified

116
117/* already called in the knowledge that the characters are hex digits */
118PROXY_DECLARE(int) ap_proxy_hex2c(const char *x)
119{
120 int i;
121
122#if !APR_CHARSET_EBCDIC
123 int ch = x[0];
124
125 if (apr_isdigit(ch)) {
126 i = ch - '0';
127 }
128 else if (apr_isupper(ch)) {
129 i = ch - ('A' - 10);
130 }
131 else {
132 i = ch - ('a' - 10);
133 }
134 i <<= 4;
135
136 ch = x[1];
137 if (apr_isdigit(ch)) {
138 i += ch - '0';
139 }
140 else if (apr_isupper(ch)) {
141 i += ch - ('A' - 10);
142 }
143 else {
144 i += ch - ('a' - 10);
145 }
146 return i;
147#else /*APR_CHARSET_EBCDIC*/
148 /*
149 * we assume that the hex value refers to an ASCII character
150 * so convert to EBCDIC so that it makes sense locally;
151 *
152 * example:
153 *
154 * client specifies %20 in URL to refer to a space char;
155 * at this point we're called with EBCDIC "20"; after turning
156 * EBCDIC "20" into binary 0x20, we then need to assume that 0x20
157 * represents an ASCII char and convert 0x20 to EBCDIC, yielding
158 * 0x40
159 */
160 char buf[1];
161
162 if (1 == sscanf(x, "%2x", &i)) {
163 buf[0] = i & 0xFF;
164 ap_xlate_proto_from_ascii(buf, 1);
165 return buf[0];
166 }
167 else {
168 return 0;
169 }
170#endif /*APR_CHARSET_EBCDIC*/
171}
172
173PROXY_DECLARE(void) ap_proxy_c2hex(int ch, char *x)
174{

Callers 3

decodeencFunction · 0.85
ftp_check_stringFunction · 0.85
ap_proxy_canonenc_exFunction · 0.85

Calls 1

Tested by

no test coverage detected