tinflate.c: Allow to read source in stream mode using d->readSource().

This commit is contained in:
Paul Sokolovsky 2016-08-05 02:19:13 +03:00
parent 7e817c502a
commit f99e297389
2 changed files with 9 additions and 2 deletions

View file

@ -43,6 +43,10 @@ typedef struct {
struct TINF_DATA;
typedef struct TINF_DATA {
const unsigned char *source;
/* If source above is NULL, this function will be used to read
next byte from source stream */
unsigned char (*readSource)(struct TINF_DATA *data);
unsigned int tag;
unsigned int bitcount;

View file

@ -166,9 +166,12 @@ static void tinf_build_tree(TINF_TREE *t, const unsigned char *lengths, unsigned
* -- decode functions -- *
* ---------------------- */
static unsigned char tinf_read_src_byte(TINF_DATA *d)
unsigned char tinf_read_src_byte(TINF_DATA *d)
{
return *d->source++;
if (d->source) {
return *d->source++;
}
return d->readSource(d);
}
/* get one bit from source stream */