Changed expected test result: we expect a text file without a custom icon
[AROS.git] / tools / dtdesc / c_iff / readchunkdata.c
blobccbc0627c24aef15aab7fc896a20e8e68cc8d6d3
1 /*
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
16 #include "c_iff.h"
18 /****** c_iff/ReadChunkData *************************************************
20 * NAME
21 * ReadChunkData -- Read some data from the current chunk
23 * SYNOPSIS
24 * Size = ReadChunkData( TheHandle,Buffer,BufferSize )
26 * long ReadChunkData( struct IFFHandle *,char *,size_t )
28 * FUNCTION
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.
33 * INPUTS
34 * TheHandle - IFFHandle to read from
35 * Buffer - the buffer to write to
36 * BufferSize - size of the provided buffer
38 * RESULT
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.
43 * EXAMPLE
45 * NOTES
46 * To read data from a chunk you have to start this chunk with
47 * ReadChunkHeader() .
48 * Make sure to read or skip the entire chunk!
50 * BUGS
52 * SEE ALSO
53 * ReadChunkHeader() SkipChunkData()
55 *****************************************************************************
57 * Private notes:
60 long ReadChunkData(struct IFFHandle *TheHandle,
61 char *Buffer,
62 size_t BufferSize)
64 long Ret;
65 size_t BytesToRead;
67 if(!(TheHandle && Buffer && (BufferSize>0)))
69 return(-1);
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;
83 return(Ret);