summaryrefslogtreecommitdiffstats
path: root/hostTools/lzma/decompress/IInOutStreams.h
blob: 69abf39710fc51602e9a4f04fe4ea9cb8e469ec7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef __IINOUTSTREAMS_H
#define __IINOUTSTREAMS_H

#include "Portable.h"

typedef struct ISequentialInStream
{
	unsigned char* data;
	unsigned       remainingBytes;
} ISequentialInStream;

extern ISequentialInStream in_stream;

INLINE void InStreamInit(unsigned char * Adata, unsigned Asize)
    {
        in_stream.data           = Adata;
        in_stream.remainingBytes = Asize;
    }

HRESULT InStreamRead(void *aData, UINT32 aSize, UINT32* aProcessedSize);

#if 0
BYTE InStreamReadByte();
#else
INLINE BYTE InStreamReadByte(ISequentialInStream *in_stream)
    {
        if (in_stream->remainingBytes == 0)
            return 0x0;
        in_stream->remainingBytes--;
        return (BYTE) *in_stream->data++;
    }
#endif



typedef struct ISequentialOutStream
{
	char*       data;
	unsigned    size;
	BOOL        overflow;
	unsigned    total;
} ISequentialOutStream;

extern ISequentialOutStream out_stream;

#define OutStreamInit(Adata, Asize) \
{ \
    out_stream.data = Adata; \
    out_stream.size = Asize; \
    out_stream.overflow = FALSE; \
    out_stream.total = 0; \
}

#define OutStreamSizeSet(newsize) \
    { \
        out_stream.total = newsize; \
        if (out_stream.total > out_stream.size) \
            out_stream.overflow = TRUE; \
    }


#endif