/*
 * Part of DNS zone file validator `validns`.
 *
 * Copyright 2025-2026 OARC, Inc.
 * Copyright 2011-2025 Anton Berezin <tobez@tobez.org>
 * Modified BSD license.
 * (See LICENSE file in the distribution.)
 *
 */
#ifndef _BASE64_H_
#define _BASE64_H_ 1

#include "mempool.h"

int decode_base64(void* dst, char* src, size_t dstsize);
int encode_base64(const unsigned char* src, int n, char* out, int max);

static inline char *encode_base64_temp(const unsigned char *src, int n)
{
    int   max = 4 * ((n + 2) / 3) + 1;
    char *out = getmem_temp(max);
    int   l   = encode_base64(src, n, out, max);
    out[l] = '\0';
    return out;
}

#endif
