2 * c_iff - a portable IFF-parser
4 * Copyright (C) 2000, 2001 Joerg Dietrich
6 * This is the AROS-version of c_iff.
7 * It is distributed under the AROS Public License.
8 * But I reserve the right to distribute
9 * my own version under other licenses.
13 * readchunkdata.c - read the data of the actual chunk
18 /****** c_iff/ReadChunkData *************************************************
21 * ReadChunkData -- Read some data from the current chunk
24 * Size = ReadChunkData( TheHandle,Buffer,BufferSize )
26 * long ReadChunkData( struct IFFHandle *,char *,size_t )
29 * Reads some data from the current chunk into Buffer.
30 * If BufferSize is greater than the chunksize, the whole chunk
31 * is copied into the Buffer otherwise BufferSize bytes are copied.
34 * TheHandle - IFFHandle to read from
35 * Buffer - the buffer to write to
36 * BufferSize - size of the provided buffer
39 * Size - number of bytes copied to the buffer
40 * Can be 0 when no bytes are copied,
41 * or -1 when an error occured.
46 * To read data from a chunk you have to start this chunk with
48 * Make sure to read or skip the entire chunk!
53 * ReadChunkHeader() SkipChunkData()
55 *****************************************************************************
60 long ReadChunkData(struct IFFHandle
*TheHandle
,
67 if(!(TheHandle
&& Buffer
&& (BufferSize
>0)))
72 BytesToRead
=(BufferSize
>TheHandle
->BytesLeftInChunk
)?TheHandle
->BytesLeftInChunk
:BufferSize
;
74 Ret
=fread(Buffer
, 1, BytesToRead
, TheHandle
->TheFile
);
76 TheHandle
->BytesLeftInChunk
-=Ret
;
78 if(TheHandle
->BytesLeftInChunk
==0)
80 TheHandle
->ChunkID
=INVALID_ID
;