summaryrefslogtreecommitdiff
path: root/encoding/apr_base64.c
diff options
context:
space:
mode:
authorcovener <covener@13f79535-47bb-0310-9956-ffa450edef68>2022-06-28 13:30:22 +0000
committercovener <covener@13f79535-47bb-0310-9956-ffa450edef68>2022-06-28 13:30:22 +0000
commite4f230321945bc1d641764044d0603a6af2fec32 (patch)
tree69bc5685ee1743392f2d41f21577d4e6fe512e8c /encoding/apr_base64.c
parent5542c58919e291c75afd20ed6b0ed71d2dc80abd (diff)
downloadlibapr-e4f230321945bc1d641764044d0603a6af2fec32.tar.gz
detab
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902319 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'encoding/apr_base64.c')
-rw-r--r--encoding/apr_base64.c100
1 files changed, 50 insertions, 50 deletions
diff --git a/encoding/apr_base64.c b/encoding/apr_base64.c
index f5c2786ad..4315d0c37 100644
--- a/encoding/apr_base64.c
+++ b/encoding/apr_base64.c
@@ -26,7 +26,7 @@
#include "apr_base64.h"
#if APR_CHARSET_EBCDIC
#include "apr_xlate.h"
-#endif /* APR_CHARSET_EBCDIC */
+#endif /* APR_CHARSET_EBCDIC */
/* Above APR_BASE64_ENCODE_MAX length the encoding can't fit in an int >= 0 */
#define APR_BASE64_ENCODE_MAX 1610612733
@@ -141,7 +141,7 @@ APR_DECLARE(int) apr_base64_decode(char *bufplain, const char *bufcoded)
inbytes_left = outbytes_left = len;
apr_xlate_conv_buffer(xlate_to_ebcdic, bufplain, &inbytes_left,
bufplain, &outbytes_left);
-#endif /* APR_CHARSET_EBCDIC */
+#endif /* APR_CHARSET_EBCDIC */
bufplain[len] = '\0';
return len;
}
@@ -151,7 +151,7 @@ APR_DECLARE(int) apr_base64_decode(char *bufplain, const char *bufcoded)
* - on EBCDIC machines, the conversion of the output to ebcdic is left out
*/
APR_DECLARE(int) apr_base64_decode_binary(unsigned char *bufplain,
- const char *bufcoded)
+ const char *bufcoded)
{
int nbytesdecoded;
register const unsigned char *bufin;
@@ -168,24 +168,24 @@ APR_DECLARE(int) apr_base64_decode_binary(unsigned char *bufplain,
bufin = (const unsigned char *) bufcoded;
while (nprbytes >= 4) {
- *(bufout++) =
- (unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4);
- *(bufout++) =
- (unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2);
- *(bufout++) =
- (unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]);
- bufin += 4;
- nprbytes -= 4;
+ *(bufout++) =
+ (unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4);
+ *(bufout++) =
+ (unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2);
+ *(bufout++) =
+ (unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]);
+ bufin += 4;
+ nprbytes -= 4;
}
/* Note: (nprbytes == 1) would be an error, so just ignore that case */
if (nprbytes > 1) {
- *(bufout++) =
- (unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4);
+ *(bufout++) =
+ (unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4);
}
if (nprbytes > 2) {
- *(bufout++) =
- (unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2);
+ *(bufout++) =
+ (unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2);
}
return nbytesdecoded - (int)((4u - nprbytes) & 3u);
@@ -223,30 +223,30 @@ APR_DECLARE(int) apr_base64_encode(char *encoded, const char *string, int len)
p = encoded;
for (i = 0; i < len - 2; i += 3) {
- *p++ = basis_64[(os_toascii[string[i]] >> 2) & 0x3F];
- *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4) |
- ((int) (os_toascii[string[i + 1]] & 0xF0) >> 4)];
- *p++ = basis_64[((os_toascii[string[i + 1]] & 0xF) << 2) |
- ((int) (os_toascii[string[i + 2]] & 0xC0) >> 6)];
- *p++ = basis_64[os_toascii[string[i + 2]] & 0x3F];
+ *p++ = basis_64[(os_toascii[string[i]] >> 2) & 0x3F];
+ *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4) |
+ ((int) (os_toascii[string[i + 1]] & 0xF0) >> 4)];
+ *p++ = basis_64[((os_toascii[string[i + 1]] & 0xF) << 2) |
+ ((int) (os_toascii[string[i + 2]] & 0xC0) >> 6)];
+ *p++ = basis_64[os_toascii[string[i + 2]] & 0x3F];
}
if (i < len) {
- *p++ = basis_64[(os_toascii[string[i]] >> 2) & 0x3F];
- if (i == (len - 1)) {
- *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4)];
- *p++ = '=';
- }
- else {
- *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4) |
- ((int) (os_toascii[string[i + 1]] & 0xF0) >> 4)];
- *p++ = basis_64[((os_toascii[string[i + 1]] & 0xF) << 2)];
- }
- *p++ = '=';
+ *p++ = basis_64[(os_toascii[string[i]] >> 2) & 0x3F];
+ if (i == (len - 1)) {
+ *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4)];
+ *p++ = '=';
+ }
+ else {
+ *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4) |
+ ((int) (os_toascii[string[i + 1]] & 0xF0) >> 4)];
+ *p++ = basis_64[((os_toascii[string[i + 1]] & 0xF) << 2)];
+ }
+ *p++ = '=';
}
*p++ = '\0';
return (unsigned int)(p - encoded);
-#endif /* APR_CHARSET_EBCDIC */
+#endif /* APR_CHARSET_EBCDIC */
}
/* This is the same as apr_base64_encode() except on EBCDIC machines, where
@@ -262,25 +262,25 @@ APR_DECLARE(int) apr_base64_encode_binary(char *encoded,
p = encoded;
for (i = 0; i < len - 2; i += 3) {
- *p++ = basis_64[(string[i] >> 2) & 0x3F];
- *p++ = basis_64[((string[i] & 0x3) << 4) |
- ((int) (string[i + 1] & 0xF0) >> 4)];
- *p++ = basis_64[((string[i + 1] & 0xF) << 2) |
- ((int) (string[i + 2] & 0xC0) >> 6)];
- *p++ = basis_64[string[i + 2] & 0x3F];
+ *p++ = basis_64[(string[i] >> 2) & 0x3F];
+ *p++ = basis_64[((string[i] & 0x3) << 4) |
+ ((int) (string[i + 1] & 0xF0) >> 4)];
+ *p++ = basis_64[((string[i + 1] & 0xF) << 2) |
+ ((int) (string[i + 2] & 0xC0) >> 6)];
+ *p++ = basis_64[string[i + 2] & 0x3F];
}
if (i < len) {
- *p++ = basis_64[(string[i] >> 2) & 0x3F];
- if (i == (len - 1)) {
- *p++ = basis_64[((string[i] & 0x3) << 4)];
- *p++ = '=';
- }
- else {
- *p++ = basis_64[((string[i] & 0x3) << 4) |
- ((int) (string[i + 1] & 0xF0) >> 4)];
- *p++ = basis_64[((string[i + 1] & 0xF) << 2)];
- }
- *p++ = '=';
+ *p++ = basis_64[(string[i] >> 2) & 0x3F];
+ if (i == (len - 1)) {
+ *p++ = basis_64[((string[i] & 0x3) << 4)];
+ *p++ = '=';
+ }
+ else {
+ *p++ = basis_64[((string[i] & 0x3) << 4) |
+ ((int) (string[i + 1] & 0xF0) >> 4)];
+ *p++ = basis_64[((string[i + 1] & 0xF) << 2)];
+ }
+ *p++ = '=';
}
*p++ = '\0';