Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / kwsys / Base64.h.in
blob66329a253bcbc5f300586cee65ea19938fe9771c
1 /*=========================================================================
3 Program: KWSys - Kitware System Library
4 Module: $RCSfile: Base64.h.in,v $
6 Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved.
7 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the above copyright notices for more information.
13 =========================================================================*/
14 #ifndef @KWSYS_NAMESPACE@_Base64_h
15 #define @KWSYS_NAMESPACE@_Base64_h
17 #include <@KWSYS_NAMESPACE@/Configure.h>
19 /* Redefine all public interface symbol names to be in the proper
20 namespace. These macros are used internally to kwsys only, and are
21 not visible to user code. Use kwsysHeaderDump.pl to reproduce
22 these macros after making changes to the interface. */
23 #if !defined(KWSYS_NAMESPACE)
24 # define kwsys_ns(x) @KWSYS_NAMESPACE@##x
25 # define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
26 #endif
27 #define kwsysBase64 kwsys_ns(Base64)
28 #define kwsysBase64_Decode kwsys_ns(Base64_Decode)
29 #define kwsysBase64_Decode3 kwsys_ns(Base64_Decode3)
30 #define kwsysBase64_Encode kwsys_ns(Base64_Encode)
31 #define kwsysBase64_Encode1 kwsys_ns(Base64_Encode1)
32 #define kwsysBase64_Encode2 kwsys_ns(Base64_Encode2)
33 #define kwsysBase64_Encode3 kwsys_ns(Base64_Encode3)
35 #if defined(__cplusplus)
36 extern "C"
38 #endif
40 /**
41 * Encode 3 bytes into a 4 byte string.
43 kwsysEXPORT void kwsysBase64_Encode3(const unsigned char *src,
44 unsigned char *dest);
46 /**
47 * Encode 2 bytes into a 4 byte string.
49 kwsysEXPORT void kwsysBase64_Encode2(const unsigned char *src,
50 unsigned char *dest);
52 /**
53 * Encode 1 bytes into a 4 byte string.
55 kwsysEXPORT void kwsysBase64_Encode1(const unsigned char *src,
56 unsigned char *dest);
58 /**
59 * Encode 'length' bytes from the input buffer and store the encoded
60 * stream into the output buffer. Return the length of the encoded
61 * buffer (output). Note that the output buffer must be allocated by
62 * the caller (length * 1.5 should be a safe estimate). If 'mark_end'
63 * is true than an extra set of 4 bytes is added to the end of the
64 * stream if the input is a multiple of 3 bytes. These bytes are
65 * invalid chars and therefore they will stop the decoder thus
66 * enabling the caller to decode a stream without actually knowing how
67 * much data to expect (if the input is not a multiple of 3 bytes then
68 * the extra padding needed to complete the encode 4 bytes will stop
69 * the decoding anyway).
71 kwsysEXPORT unsigned long kwsysBase64_Encode(const unsigned char *input,
72 unsigned long length,
73 unsigned char *output,
74 int mark_end);
76 /**
77 * Decode 4 bytes into a 3 byte string. Returns the number of bytes
78 * actually decoded.
80 kwsysEXPORT int kwsysBase64_Decode3(const unsigned char *src,
81 unsigned char *dest);
83 /**
84 * Decode bytes from the input buffer and store the decoded stream
85 * into the output buffer until 'length' bytes have been decoded.
86 * Return the real length of the decoded stream (which should be equal
87 * to 'length'). Note that the output buffer must be allocated by the
88 * caller. If 'max_input_length' is not null, then it specifies the
89 * number of encoded bytes that should be at most read from the input
90 * buffer. In that case the 'length' parameter is ignored. This
91 * enables the caller to decode a stream without actually knowing how
92 * much decoded data to expect (of course, the buffer must be large
93 * enough).
95 kwsysEXPORT unsigned long kwsysBase64_Decode(const unsigned char *input,
96 unsigned long length,
97 unsigned char *output,
98 unsigned long max_input_length);
100 #if defined(__cplusplus)
101 } /* extern "C" */
102 #endif
104 /* If we are building a kwsys .c or .cxx file, let it use these macros.
105 Otherwise, undefine them to keep the namespace clean. */
106 #if !defined(KWSYS_NAMESPACE)
107 # undef kwsys_ns
108 # undef kwsysEXPORT
109 # undef kwsysBase64
110 # undef kwsysBase64_Decode
111 # undef kwsysBase64_Decode3
112 # undef kwsysBase64_Encode
113 # undef kwsysBase64_Encode1
114 # undef kwsysBase64_Encode2
115 # undef kwsysBase64_Encode3
116 #endif
118 #endif