view src/lib/base64.h @ 608:debb8468514e HEAD

SEARCH CHARSET now works properly with message bodies, and in general body searching works more correctly by decoding base64/qp data. Non-text MIME parts are currently not included in search, that could be made optional. Also the body is parsed separately for each keyword, that could be optimized. Changed base64_decode() behaviour so that it can accept non-base64 data as well, ie. line feeds etc.
author Timo Sirainen <tss@iki.fi>
date Wed, 13 Nov 2002 13:08:18 +0200
parents a75b7a269674
children 553f050c8313
line wrap: on
line source

#ifndef __BASE64_H
#define __BASE64_H

/* Translates binary data into base64. Allocates memory from data stack. */
const char *base64_encode(const unsigned char *data, size_t size);

/* Translates base64 data into binary. dest must be large enough, and may be
   same as src. Returns size of the binary data, or -1 if error occured.
   Any CR, LF characters are ignored, as well as whitespace at beginning or
   end of line.

   This function may be called multiple times for parsing same base64 stream.
   The *size is updated at return to contain the amount of data actually
   parsed - the rest of the data should be passed again to this function. */
ssize_t base64_decode(const char *src, size_t *size, unsigned char *dest);

/* max. buffer size required for base64_decode(), not including trailing \0 */
#define MAX_BASE64_DECODED_SIZE(size) \
	((size) / 4 * 3 + 3)

#endif