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
, 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 *****************************************************************************/
50 AROS_LIBBASE_EXT_DECL(struct Library
*,IFFParseBase
)
52 struct ContextNode
*cn
;
57 DEBUG_WRITECHUNKBYTES(dprintf("WriteChunkBytes: iff 0x%lx buf 0x%lx size %d\n",
60 /* Get the top contextnode */
63 /* Is the numBytes known for this chunk ? */
64 if (cn
->cn_Size
!= IFFSIZE_UNKNOWN
)
66 /* We must truncate attempts to write larger than the chunksize */
67 placeleft
= cn
->cn_Size
- cn
->cn_Scan
;
68 if (numBytes
> placeleft
)
74 /* Actually write the chunk */
75 byteswritten
= WriteStream(iff
, buf
, numBytes
, IPB(IFFParseBase
));
80 cn
->cn_Scan
+= byteswritten
;
83 DEBUG_WRITECHUNKBYTES(dprintf("WriteChunkBytes: return %ld\n", byteswritten
));
84 return (byteswritten
);
87 } /* WriteChunkBytes */