diff options
Diffstat (limited to 'encoding/apr_base64.c')
-rw-r--r-- | encoding/apr_base64.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/encoding/apr_base64.c b/encoding/apr_base64.c index d553631dc..82e6e23d1 100644 --- a/encoding/apr_base64.c +++ b/encoding/apr_base64.c @@ -188,6 +188,18 @@ APR_DECLARE(int) apr_base64_decode_binary(unsigned char *bufplain, return nbytesdecoded; } +APR_DECLARE(char *) apr_pbase64_decode(apr_pool_t *p, const char *bufcoded) +{ + char *decoded; + int l; + + decoded = (char *) apr_palloc(p, 1 + apr_base64_decode_len(bufcoded)); + l = apr_base64_decode(decoded, bufcoded); + decoded[l] = '\0'; /* make binary sequence into string */ + + return decoded; +} + static const char basis_64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; @@ -267,3 +279,15 @@ APR_DECLARE(int) apr_base64_encode_binary(char *encoded, *p++ = '\0'; return (int)(p - encoded); } + +APR_DECLARE(char *) apr_pbase64_encode(apr_pool_t *p, const char *string) +{ + char *encoded; + int l = strlen(string); + + encoded = (char *) apr_palloc(p, 1 + apr_base64_encode_len(l)); + l = apr_base64_encode(encoded, string, l); + encoded[l] = '\0'; /* make binary sequence into string */ + + return encoded; +} |