summaryrefslogtreecommitdiff
path: root/encoding
diff options
context:
space:
mode:
authorGraham Leggett <minfrin@apache.org>2013-06-06 12:06:29 +0000
committerGraham Leggett <minfrin@apache.org>2013-06-06 12:06:29 +0000
commitd60e2ae582cce99fdbe56c1d6a51e9fc0165d0d9 (patch)
tree1d9844740138e3362084dfea94fa696fb50a7a65 /encoding
parentf94785ad1511276a3d429cdcfe8cc8640d77f4f3 (diff)
downloadapr-d60e2ae582cce99fdbe56c1d6a51e9fc0165d0d9.tar.gz
Add apr_pbase64_encode() and apr_pbase64_decode() to encode to/from
the pool. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1490248 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'encoding')
-rw-r--r--encoding/apr_base64.c24
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;
+}