Mercurial > sci
diff base64.h @ 1:5afdb14df924
sci: add support for storing results
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 08 Jun 2021 08:40:01 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/base64.h Tue Jun 08 08:40:01 2021 +0200 @@ -0,0 +1,53 @@ +/* + * 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 */