summaryrefslogtreecommitdiff
path: root/base64.h
blob: 8533af16bd74bf2ac17089a299af072cab8b934d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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);
}