istream-base64-decoder.c revision 098319673eec04a1721b00f491992a784088abb8
/* Copyright (c) 2013-2014 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "buffer.h"
#include "base64.h"
#include "hex-binary.h"
#include "istream-private.h"
#include "istream-base64.h"
struct base64_decoder_istream {
struct istream_private istream;
};
{
if (size >= 4)
return 1;
/* we have less than one base64 block.
see if there is more data available. */
if (ret <= 0) {
return ret;
}
return 1;
}
static int
{
const unsigned char *data;
if (size == 0)
return 0;
/* can't fit everything to destination buffer.
write as much as we can. */
if (size == 0)
return -2;
}
"Invalid base64 data: 0x%s",
return -1;
}
return pos > 0 ? 1 : 0;
}
{
struct base64_decoder_istream *bstream =
(struct base64_decoder_istream *)stream;
const unsigned char *data;
int ret;
do {
if (ret <= 0) {
/* base64 input with a partial block */
"base64 input ends with a partial block: 0x%s",
}
return ret;
}
/* encode as many blocks as fits into destination buffer */
return ret;
return post_count - pre_count;
}
static void
{
/* seeking backwards - go back to beginning and seek
forward from there. */
}
}
struct istream *
{
struct base64_decoder_istream *bstream;
}