2 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
6 #include "iffparse_intern.h"
8 /*****************************************************************************
11 #include <proto/iffparse.h>
13 AROS_LH3(LONG
, ReadChunkBytes
,
16 AROS_LHA(struct IFFHandle
*, iff
, A0
),
17 AROS_LHA(APTR
, buf
, A1
),
18 AROS_LHA(LONG
, numBytes
, D0
),
21 struct Library
*, IFFParseBase
, 10, IFFParse
)
24 Read a number of bytes from the current chunk into a buffer.
25 Attempts to read past the end of the chunk will be truncated.
28 iff - pointer to IFFHandle struct.
29 buf - pointer to a buffer into which the data will be placed.
30 numBtes - number of bytes to read.
33 actual - (positive) the actual number of bytes read.
34 (negative) IFFERR_#? error code if not succesfull.
43 ReadChunkRecords(), ParseIFF(), WriteChunkBytes()
47 *****************************************************************************/
50 AROS_LIBBASE_EXT_DECL(struct Library
*,IFFParseBase
)
52 struct ContextNode
*cn
;
57 DEBUG_READCHUNKBYTES(dprintf("ReadChunkBytes: iff %p buf %p bytes %ld\n",
60 /* Get pointer to current contextnode */
63 lefttoread
= cn
->cn_Size
- cn
->cn_Scan
;
65 /* If numBytes > lefttoread then we must truncate the readoperation */
66 if (numBytes
> lefttoread
)
67 numBytes
= lefttoread
;
69 DEBUG_READCHUNKBYTES(dprintf("ReadChunkBytes: cn %p cn_Size %ld cn_Scan %ld numBytes %ld\n",
70 cn
, cn
->cn_Size
, cn
->cn_Scan
, numBytes
));
72 bytesread
= ReadStream
82 cn
->cn_Scan
+= bytesread
;
84 DEBUG_READCHUNKBYTES(dprintf("ReadChunkBytes: return %ld\n", bytesread
));
86 /* Return number of bytes actually read (or error )*/
90 } /* ReadChunkBytes */