Mercurial > sci
view base64.h @ 2:5fa3d2f479b2
sci: initial upload support
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 10 Jun 2021 10:39:21 +0200 |
parents | 5afdb14df924 |
children |
line wrap: on
line source
/* * base64.h -- base64 encoding and decoding * * Copyright (c) 2013-2021 David Demelier <markand@malikania.fr> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef BASE64_H #define BASE64_H #include <stddef.h> #if defined(__cplusplus) extern "C" { #endif #define B64_ENCODE_LENGTH(x) (4 * ((x) / 3 + 1)) #define B64_DECODE_LENGTH(x) (3 * ((x) / 4)) int b64_isbase64(unsigned char ch); int b64_isvalid(unsigned char ch); unsigned char b64_lookup(unsigned char value); unsigned char b64_rlookup(unsigned char ch); size_t b64_encode(const char *src, size_t srcsz, char *dst, size_t dstsz); size_t b64_decode(const char *src, size_t srcsz, char *dst, size_t dstsz); #if defined(__cplusplus) } #endif #endif /* !BASE64_H */