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
, WriteChunkBytes
,
16 AROS_LHA(struct IFFHandle
*, iff
, A0
),
17 AROS_LHA(APTR
, buf
, A1
),
18 AROS_LHA(LONG
, numBytes
, D0
),
21 struct Library
*, IFFParseBase
, 11, IFFParse
)
24 Writes given number of bytes in the supplied buffer into the
25 current chunk. Attempts to write past the endo of the chunk will
29 iff - pointer to IFFHandle struct.
30 buf - buffer with data to write.
31 numBytes - number of bytes to write.
34 actual - (positive) number of bytes actually written.
35 (negative) IFFERR_#? indicating unsuccesfull write.
43 PushChunk(), PopChunk(), WriteChunkRecords()
47 *****************************************************************************/
51 struct ContextNode
*cn
;
56 DEBUG_WRITECHUNKBYTES(dprintf("WriteChunkBytes: iff 0x%lx buf 0x%lx size %d\n",
59 /* Get the top contextnode */
62 /* Is the numBytes known for this chunk ? */
63 if (cn
->cn_Size
!= IFFSIZE_UNKNOWN
)
65 /* We must truncate attempts to write larger than the chunksize */
66 placeleft
= cn
->cn_Size
- cn
->cn_Scan
;
67 if (numBytes
> placeleft
)
73 /* Actually write the chunk */
74 byteswritten
= WriteStream(iff
, buf
, numBytes
, IPB(IFFParseBase
));
79 cn
->cn_Scan
+= byteswritten
;
82 DEBUG_WRITECHUNKBYTES(dprintf("WriteChunkBytes: return %ld\n", byteswritten
));
83 return (byteswritten
);
86 } /* WriteChunkBytes */