1/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2 file Copyright.txt or https://cmake.org/licensing#kwsys for details. */ 3#ifndef @KWSYS_NAMESPACE@_Base64_h 4#define @KWSYS_NAMESPACE@_Base64_h 5 6#include <@KWSYS_NAMESPACE@/Configure.h> 7 8#include <stddef.h> /* size_t */ 9 10/* Redefine all public interface symbol names to be in the proper 11 namespace. These macros are used internally to kwsys only, and are 12 not visible to user code. Use kwsysHeaderDump.pl to reproduce 13 these macros after making changes to the interface. */ 14#if !defined(KWSYS_NAMESPACE) 15# define kwsys_ns(x) @KWSYS_NAMESPACE@##x 16# define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT 17#endif 18#if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS 19# define kwsysBase64 kwsys_ns(Base64) 20# define kwsysBase64_Decode kwsys_ns(Base64_Decode) 21# define kwsysBase64_Decode3 kwsys_ns(Base64_Decode3) 22# define kwsysBase64_Encode kwsys_ns(Base64_Encode) 23# define kwsysBase64_Encode1 kwsys_ns(Base64_Encode1) 24# define kwsysBase64_Encode2 kwsys_ns(Base64_Encode2) 25# define kwsysBase64_Encode3 kwsys_ns(Base64_Encode3) 26#endif 27 28#if defined(__cplusplus) 29extern "C" { 30#endif 31 32/** 33 * Encode 3 bytes into a 4 byte string. 34 */ 35kwsysEXPORT void kwsysBase64_Encode3(const unsigned char* src, 36 unsigned char* dest); 37 38/** 39 * Encode 2 bytes into a 4 byte string. 40 */ 41kwsysEXPORT void kwsysBase64_Encode2(const unsigned char* src, 42 unsigned char* dest); 43 44/** 45 * Encode 1 bytes into a 4 byte string. 46 */ 47kwsysEXPORT void kwsysBase64_Encode1(const unsigned char* src, 48 unsigned char* dest); 49 50/** 51 * Encode 'length' bytes from the input buffer and store the encoded 52 * stream into the output buffer. Return the length of the encoded 53 * buffer (output). Note that the output buffer must be allocated by 54 * the caller (length * 1.5 should be a safe estimate). If 'mark_end' 55 * is true than an extra set of 4 bytes is added to the end of the 56 * stream if the input is a multiple of 3 bytes. These bytes are 57 * invalid chars and therefore they will stop the decoder thus 58 * enabling the caller to decode a stream without actually knowing how 59 * much data to expect (if the input is not a multiple of 3 bytes then 60 * the extra padding needed to complete the encode 4 bytes will stop 61 * the decoding anyway). 62 */ 63kwsysEXPORT size_t kwsysBase64_Encode(const unsigned char* input, 64 size_t length, unsigned char* output, 65 int mark_end); 66 67/** 68 * Decode 4 bytes into a 3 byte string. Returns the number of bytes 69 * actually decoded. 70 */ 71kwsysEXPORT int kwsysBase64_Decode3(const unsigned char* src, 72 unsigned char* dest); 73 74/** 75 * Decode bytes from the input buffer and store the decoded stream 76 * into the output buffer until 'length' bytes have been decoded. 77 * Return the real length of the decoded stream (which should be equal 78 * to 'length'). Note that the output buffer must be allocated by the 79 * caller. If 'max_input_length' is not null, then it specifies the 80 * number of encoded bytes that should be at most read from the input 81 * buffer. In that case the 'length' parameter is ignored. This 82 * enables the caller to decode a stream without actually knowing how 83 * much decoded data to expect (of course, the buffer must be large 84 * enough). 85 */ 86kwsysEXPORT size_t kwsysBase64_Decode(const unsigned char* input, 87 size_t length, unsigned char* output, 88 size_t max_input_length); 89 90#if defined(__cplusplus) 91} /* extern "C" */ 92#endif 93 94/* If we are building a kwsys .c or .cxx file, let it use these macros. 95 Otherwise, undefine them to keep the namespace clean. */ 96#if !defined(KWSYS_NAMESPACE) 97# undef kwsys_ns 98# undef kwsysEXPORT 99# if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS 100# undef kwsysBase64 101# undef kwsysBase64_Decode 102# undef kwsysBase64_Decode3 103# undef kwsysBase64_Encode 104# undef kwsysBase64_Encode1 105# undef kwsysBase64_Encode2 106# undef kwsysBase64_Encode3 107# endif 108#endif 109 110#endif 111