summaryrefslogtreecommitdiff
path: root/base64.h
diff options
context:
space:
mode:
Diffstat (limited to 'base64.h')
-rw-r--r--base64.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/base64.h b/base64.h
new file mode 100644
index 0000000..8533af1
--- /dev/null
+++ b/base64.h
@@ -0,0 +1,13 @@
+#include <gnutls/gnutls.h>
+
+static inline void base64_decode(unsigned char *host, char **decoded_host)
+{
+ gnutls_datum_t result;
+ gnutls_base64_decode2(&(gnutls_datum_t){
+ host,
+ strlen((const char *)host)
+ }, &result);
+ *decoded_host = malloc(result.size + 1);
+ strlcpy(*decoded_host, (const char *)result.data, result.size + 1);
+ gnutls_free(result.data);
+}