Changed expected test result: we expect a text file without a custom icon
[AROS.git] / tools / dtdesc / c_iff / c_iff.h
blob3479cbb9c0931c2afce7c75ed12ac61ca3e2c5d7
1 #ifndef C_IFF_H
2 #define C_IFF_H 1
4 /*
5 * c_iff - a portable IFF-parser
7 * Copyright (C) 2000, 2001 Joerg Dietrich
9 * This is the AROS-version of c_iff.
10 * It is distributed under the AROS Public License.
11 * But I reserve the right to distribute
12 * my own version under other licenses.
16 * c_iff.h - the public headerfile
20 * defines
24 * Why are TRUE and FALSE not defined in a standard C header?!
26 #ifndef FALSE
27 #define FALSE (0)
28 #endif /* FALSE */
30 #ifndef TRUE
31 #define TRUE (~0)
32 #endif /* TRUE */
35 * typedefs
38 #include <stdint.h>
41 * Do you have a big-endain machine?
42 * Then add it here!
45 #if defined amiga || defined __PPC__
46 #define C_IFF_BIG_ENDIAN
47 #else
48 #undef C_IFF_BIG_ENDIAN
49 #endif
52 * Byte-swapping
53 * Always swap shorts and ints before you write to
54 * or after you read from IFFs.
57 #ifdef C_IFF_BIG_ENDIAN
59 #define Swap16IfLE(x) (x)
61 #define Swap32IfLE(x) (x)
63 #else /* C_IFF_BIG_ENDIAN */
65 #define Swap16IfLE(x) (((((unsigned short) x) & 0xFF00) >> 8) | ((((unsigned short) x) & 0xFF) << 8))
67 #define Swap32IfLE(x) (((((unsigned int) x) & 0xFF000000) >> 24) | \
68 ((((unsigned int) x) & 0xFF0000) >> 8) | \
69 ((((unsigned int) x) & 0xFF00) << 8) | \
70 ((((unsigned int) x) & 0xFF) << 24))
73 #endif /* C_IFF_BIG_ENDIAN */
76 * macro to create an IFF-ID.
79 #define MAKE_ID(a,b,c,d) (((a)<<24) | ((b)<<16) | ((c)<<8) | ((d)))
82 * Some predefined IDs.
85 #define ID_FORM MAKE_ID('F','O','R','M')
88 * This is the invalid ID.
91 #define INVALID_ID (0)
94 * includes
97 #include <stdio.h>
98 #include <stdlib.h>
101 * structs
105 * Struct to chain the open chunks together.
108 struct ChunkNode
110 struct ChunkNode *Previous; /* the previous chunk */
111 long Size; /* size of the chunk */
112 long FilePos; /* position of the size-uint32_t in the file */
116 * struct IFFHandle, the center of c_iff
119 struct IFFHandle
121 FILE *TheFile; /* filehandle of the IFF */
122 uint32_t IFFType; /* type of the IFF */
123 uint32_t ChunkID; /* chunk-ID of the current chunk */
124 long BytesLeftInChunk; /* byte-counter for reading*/
125 int NewIFF; /* marker for a IFF for writing */
126 long IFFSize; /* size of the new IFF */
127 struct ChunkNode *LastNode; /* the current chunk */
131 * prototypes
134 extern struct IFFHandle *OpenIFF(char *Name);
135 extern void CloseIFF(struct IFFHandle *TheHandle);
136 extern int CheckIFF(struct IFFHandle *TheHandle);
137 extern int ReadChunkHeader(struct IFFHandle *TheHandle);
138 extern int SkipChunkData(struct IFFHandle *TheHandle);
139 extern long ReadChunkData(struct IFFHandle *TheHandle,
140 char *Buffer,
141 size_t BufferSize);
143 extern struct IFFHandle *NewIFF(char *Name, uint32_t IFFType);
144 extern int NewChunk(struct IFFHandle *TheHandle, uint32_t ID);
145 extern int NewSubFORM(struct IFFHandle *TheHandle, uint32_t Type);
146 extern void EndChunk(struct IFFHandle *TheHandle);
147 extern long WriteChunkData(struct IFFHandle *TheHandle,
148 char *Buffer,
149 size_t Size);
151 extern void FixIFFSize(struct IFFHandle *TheHandle);
152 extern size_t FileSize(FILE *TheFile);
154 #endif /* C_IFF_H */