x11gfx.hidd: support 32 bit modes
[AROS.git] / tools / dtdesc / c_iff / writechunkdata.c
blob116785b3b81dda539085d5841ef082f99178950c
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 * writechunkdata.c - write data to the actual chunk
16 #include "c_iff.h"
18 /****** c_iff/WriteChunkData ************************************************
20 * NAME
21 * WriteChunkData -- Write some data to the current chunk
23 * SYNOPSIS
24 * Size = WriteChunkData( TheHandle,Buffer,Size )
26 * long WriteChunkData( struct IFFHandle *,char *,size_t )
28 * FUNCTION
29 * Writes Buffer into the current chunk.
31 * INPUTS
32 * TheHandle - IFFHandle to write to
33 * Buffer - the buffer containing the data
34 * Size - number of bytes to be written
36 * RESULT
37 * Size - number of bytes written to the IFF-file
39 * EXAMPLE
41 * NOTES
43 * BUGS
45 * SEE ALSO
46 * NewChunk()
48 *****************************************************************************
50 * Private notes:
53 long WriteChunkData(struct IFFHandle *TheHandle,
54 char *Buffer,
55 size_t Size)
57 long Ret;
58 struct ChunkNode *CN, *PN;
60 if(!(TheHandle && Buffer))
62 return(-1);
65 Ret=fwrite(Buffer, 1, Size, TheHandle->TheFile);
67 if(Ret>0)
69 CN=TheHandle->LastNode;
71 CN->Size+=Ret;
73 PN=CN->Previous;
75 while(PN)
77 PN->Size+=Ret;
79 PN=PN->Previous;
82 TheHandle->IFFSize+=Ret;
85 return(Ret);