1 /*----------------------------------------------------------------------------
 2 Name:      xmlBlaster/src/c/util/base64.h
 3 Project:   xmlBlaster.org
 4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
 5 Comment:   base64 encode/decode
 6 Author:    "Marcel Ruff" <xmlBlaster@marcelruff.info>
 7 Implementation details derived from http://base64.sourceforge.net/b64.c
 8 by Bob Trower 08/04/01
 9 -----------------------------------------------------------------------------*/
10 #ifndef _XMLBLASTER_BASE64_H
11 #define _XMLBLASTER_BASE64_H
12 
13 #include <util/basicDefs.h> /* for Dll_Export */
14 
15 #ifdef __cplusplus
16 #ifndef XMLBLASTER_C_COMPILE_AS_CPP /* 'g++ -DXMLBLASTER_C_COMPILE_AS_CPP ...' allows to compile the lib as C++ code */
17 extern "C" {
18 #endif
19 #endif
20 
21 /**
22  * Encode binary data to base64 notation.
23  *
24  * @param inLen binary data
25  * @param inBytes binary data
26  * @param lineSize line breaks as per spec, typically 60 characters, -1 switches line breaks off
27  * @return outStr, is NULL if input parameters are null
28  * You need to free(outStr) it after usage.
29  */
30 Dll_Export extern char *Base64EncodeLen(int inLen, const char *inBytes, int lineSize);
31 
32 
33 /**
34  * Encode binary data to base64 notation with max line width = 60 chars.
35  *
36  * @param inLen binary data
37  * @param inBytes binary data
38  * @return outStr, is NULL if input parameters are null
39  * You need to free(outStr) it after usage.
40  */
41 Dll_Export extern char *Base64Encode(int inLen, const char *inBytes);
42 
43 
44 /**
45  * Decode the base64 to the original byte array
46  * discarding padding, line breaks and noise
47  * @param inStr The zero terminated base64 string
48  * @param outLen An out-parameter, is set to the length of the returned bytes
49  * @return the decoded bytes with length 'outLen',
50  *  is additionally guaranteed to be null terminated (but may contain other zeros)
51  */
52 Dll_Export extern char *Base64Decode(const char *inStr, int *outLen);
53 
54 
55 #ifdef __cplusplus
56 #ifndef XMLBLASTER_C_COMPILE_AS_CPP
57 }
58 #endif
59 #endif
60 
61 #endif /* _XMLBLASTER_BASE64_H */


syntax highlighted by Code2HTML, v. 0.9.1