2 Copyright © 1995-2007, 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 *****************************************************************************/
51 struct ContextNode
*cn
;
56 DEBUG_READCHUNKBYTES(dprintf("ReadChunkBytes: iff %p buf %p bytes %ld\n",
59 /* Get pointer to current contextnode */
62 lefttoread
= cn
->cn_Size
- cn
->cn_Scan
;
64 /* If numBytes > lefttoread then we must truncate the readoperation */
65 if (numBytes
> lefttoread
)
66 numBytes
= lefttoread
;
68 DEBUG_READCHUNKBYTES(dprintf("ReadChunkBytes: cn %p cn_Size %ld cn_Scan %ld numBytes %ld\n",
69 cn
, cn
->cn_Size
, cn
->cn_Scan
, numBytes
));
71 bytesread
= ReadStream
81 cn
->cn_Scan
+= bytesread
;
83 DEBUG_READCHUNKBYTES(dprintf("ReadChunkBytes: return %ld\n", bytesread
));
85 /* Return number of bytes actually read (or error )*/
89 } /* ReadChunkBytes */