rpm  4.10.0
rpmbase64.h
Go to the documentation of this file.
00001 /* base64 encoder/decoder based on public domain implementation
00002  * by Chris Venter */
00003 
00004 #include <sys/types.h>
00005 
00006 #ifdef __cplusplus
00007 extern "C" {
00008 #endif
00009 
00010 /* returns malloced base64 encoded string
00011  * lines are split with \n characters to be nearest lower multiple of linelen
00012  * if linelen/4 == 0 lines are not split
00013  * if linelen < 0 default line length (64) is used
00014  * the returned string is empty when len == 0
00015  * returns NULL on failures
00016  */
00017 char *rpmBase64Encode(const void *data, size_t len, int linelen);
00018 
00019 /* decodes from zero terminated base64 encoded string to a newly malloced buffer
00020  * ignores whitespace characters in the input string
00021  * return values:
00022  *  0 - OK
00023  *  1 - input is NULL
00024  *  2 - invalid length
00025  *  3 - invalid characters on input
00026  *  4 - malloc failed
00027  */
00028 int rpmBase64Decode(const char *in, void **out, size_t *outlen);
00029 
00030 /* counts CRC24 and base64 encodes it in a malloced string
00031  * returns NULL on failures
00032  */
00033 char *rpmBase64CRC(const unsigned char *data, size_t len);
00034 
00035 #ifdef __cplusplus
00036 }
00037 #endif