Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:25

0001 /* -*- buffer-read-only: t -*- vi: set ro: */
0002 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
0003 /* base64.h -- Encode binary data using printable characters.
0004    Copyright (C) 2004-2006, 2009-2011 Free Software Foundation, Inc.
0005    Written by Simon Josefsson.
0006 
0007    This program is free software; you can redistribute it and/or modify
0008    it under the terms of the GNU General Public License as published by
0009    the Free Software Foundation; either version 3, or (at your option)
0010    any later version.
0011 
0012    This program is distributed in the hope that it will be useful,
0013    but WITHOUT ANY WARRANTY; without even the implied warranty of
0014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0015    GNU General Public License for more details.
0016 
0017    You should have received a copy of the GNU General Public License
0018    along with this program; if not, write to the Free Software Foundation,
0019    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
0020 
0021 #ifndef BASE64_H
0022 #define BASE64_H
0023 
0024 /* Get size_t. */
0025 #include <cstddef>
0026 
0027 /* Get bool. */
0028 
0029 /* This uses that the expression (n+(k-1))/k means the smallest
0030    integer >= n/k, i.e., the ceiling of n/k.  */
0031 #define BASE64_LENGTH(inlen) ((((inlen) + 2) / 3) * 4)
0032 
0033 struct base64_decode_context {
0034   unsigned int i;
0035   char buf[4];
0036 };
0037 
0038 extern bool isbase64(char ch);
0039 
0040 extern void base64_encode(const char *in, size_t inlen, char *out, size_t outlen);
0041 
0042 extern size_t base64_encode_alloc(const char *in, size_t inlen, char **out);
0043 
0044 extern void base64_decode_ctx_init(struct base64_decode_context *ctx);
0045 
0046 extern bool base64_decode_ctx(
0047     struct base64_decode_context *ctx, const char *in, size_t inlen, char *out, size_t *outlen);
0048 
0049 extern bool base64_decode_alloc_ctx(
0050     struct base64_decode_context *ctx, const char *in, size_t inlen, char **out, size_t *outlen);
0051 
0052 #define base64_decode(in, inlen, out, outlen) base64_decode_ctx(NULL, in, inlen, out, outlen)
0053 
0054 #define base64_decode_alloc(in, inlen, out, outlen) base64_decode_alloc_ctx(NULL, in, inlen, out, outlen)
0055 
0056 #endif /* BASE64_H */