New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / workbench / libs / iffparse / iffparse_intern.h
blob6516c07be68cd2f7085e86e8c136549e55892dcb
1 /*
2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #ifndef IFFPARSE_INTERN_H
7 #define IFFPARSE_INTERN_H
9 /* Include files */
11 #ifndef EXEC_TYPES_H
12 # include <exec/types.h>
13 #endif
14 #ifndef CLIB_ALIB_PROTOS_H
15 # include <clib/alib_protos.h>
16 #endif
17 #ifndef PROTO_EXEC_H
18 # include <proto/exec.h>
19 #endif
20 #ifndef PROTO_DOS_H
21 # include <proto/dos.h>
22 #endif
23 #ifndef PROTO_UTILITY_H
24 # include <proto/utility.h>
25 #endif
26 #ifndef PROTO_IFFPARSE_H
27 # include <proto/iffparse.h>
28 #endif
29 #ifndef LIBRARIES_IFFPARSE_H
30 # include <libraries/iffparse.h>
31 #endif
32 #ifndef EXEC_MEMORY_H
33 # include <exec/memory.h>
34 #endif
35 #ifndef EXEC_LIBRARIES_H
36 # include <exec/libraries.h>
37 #endif
38 #ifndef AROS_LIBCALL_H
39 # include <aros/libcall.h>
40 #endif
41 #ifndef DOS_DOS_H
42 # include <dos/dos.h>
43 #endif
44 #ifndef UTILITY_HOOKS_H
45 # include <utility/hooks.h>
46 #endif
47 #include <stdlib.h>
49 /* Some external stuff (iffparse_init.c) */
52 struct IFFParseBase_intern; /* prerefrence */
54 /* Internal prototypes */
55 LONG ReadStream (struct IFFHandle *, APTR, LONG, struct IFFParseBase_intern *);
56 LONG ReadStreamLong (struct IFFHandle *, APTR, struct IFFParseBase_intern *);
57 LONG WriteStream (struct IFFHandle *, APTR, LONG, struct IFFParseBase_intern *);
58 LONG WriteStreamLong (struct IFFHandle *, APTR, struct IFFParseBase_intern *);
59 VOID PurgeLCI (struct LocalContextItem *, struct IFFParseBase_intern *);
61 LONG PushContextNode (struct IFFHandle *, LONG ,LONG, LONG, LONG, struct IFFParseBase_intern *);
62 VOID PopContextNode (struct IFFHandle *, struct IFFParseBase_intern *);
63 LONG GetChunkHeader (struct IFFHandle *, struct IFFParseBase_intern *);
64 LONG InvokeHandlers (struct IFFHandle *, LONG, LONG, struct IFFParseBase_intern *);
65 LONG SeekStream (struct IFFHandle *, LONG, struct IFFParseBase_intern *);
67 /* Some system entry & exit handlers (hook funcs) ß*/
68 LONG ExitContextFunc(struct Hook *, APTR, APTR);
69 LONG StopFunc (struct Hook *, APTR, APTR);
70 LONG PropFunc (struct Hook *, struct IFFHandle *, APTR);
71 LONG CollectionFunc (struct Hook *, struct IFFHandle *, APTR);
73 /* A system purge hook for purging the LCIs installed by PropChunk and CollectionChunk */
74 IPTR CollectionPurgeFunc (struct Hook *, struct LocalContextItem *, ULONG);
75 IPTR PropPurgeFunc (struct Hook *, struct LocalContextItem *, ULONG);
77 /* Buffer functions */
78 struct BufferList * AllocBuffer (ULONG, struct IFFParseBase_intern *);
79 VOID FreeBuffer (struct BufferList *, struct IFFParseBase_intern *);
81 struct BufferNode * AllocBufferNode (struct BufferList *, struct IFFParseBase_intern *);
83 LONG WriteToBuffer (struct BufferList *, UBYTE *, LONG, struct IFFParseBase_intern *);
84 BOOL SeekBuffer (struct BufferList *, LONG);
86 BOOL BufferToStream (struct BufferList *, struct IFFHandle *, struct IFFParseBase_intern *);
88 /* StreamHandler hooks */
90 IPTR DOSStreamHandler (struct Hook *, struct IFFHandle *, struct IFFStreamCmd *);
91 IPTR ClipStreamHandler (struct Hook *, struct IFFHandle *, struct IFFStreamCmd *);
92 IPTR BufStreamHandler (struct Hook *, struct IFFHandle *, struct IFFStreamCmd *);
94 /* Message port help functions */
96 BOOL InitPort (struct MsgPort *, struct Task *, struct IFFParseBase_intern *);
97 VOID ClosePort (struct MsgPort *, struct IFFParseBase_intern *);
100 /* Buffered stream install/deinstall */
101 LONG InitBufferedStream (struct IFFHandle*, struct IFFParseBase_intern *);
102 LONG ExitBufferedStream (struct IFFHandle*, struct IFFParseBase_intern *);
104 /* Endian conversion */
105 LONG SwitchIfLittleEndian(LONG);
107 /* Private flags */
109 #define IFFF_NEWFILE (1L << 16)
110 #define IFFF_OPEN (1L << 19)
113 The different states the parser can be in.
114 Chose values so that the compiler easily can create a jump table
116 #define IFFSTATE_COMPOSITE 0
117 #define IFFSTATE_PUSHCHUNK 1
118 #define IFFSTATE_ATOMIC 2
119 #define IFFSTATE_SCANEXIT 3
120 #define IFFSTATE_EXIT 4
121 #define IFFSTATE_POPCHUNK 5
123 /* Size of one tile of a buffer to use in buffering of chunks */
124 #define BUFFERNODESIZE 10000
126 /* Size of buffer fake a forward seek with Read()s */
127 #define SEEKBUFSIZE 10000
130 /************************/
131 /* Internal structures */
132 /************************/
134 /* Structure for maintaing a list of buffers for buffering */
135 struct BufferList
137 struct MinList bl_ListHeader;
139 /* The size of each buffer */
140 ULONG bl_BufferNodeSize;
142 /* The current position of the Write/Seek pointer */
144 /* A buffer node */
145 struct BufferNode * bl_CurrentNode;
146 /* An offset pointer into that particular node. */
147 ULONG bl_CurrentOffset;
149 The number of the current buffernode (the number in the list).
150 First buffenode is number 1 (not 0)
152 ULONG bl_CurrentNodeNum;
154 /* Number of bytes written to the bufferlist */
155 ULONG bl_BufferSize;
157 /* Number of nodes in the list */
162 One node in the bufferlist.
163 Contains a pointer to the buffer - tile itself
166 struct BufferNode
168 struct MinNode bn_Node;
169 UBYTE * bn_BufferPtr;
175 Internal version of a ContextNode. Contains a list of
176 LocalContextItems.
178 struct IntContextNode
180 struct ContextNode CN;
181 struct MinList cn_LCIList;
183 /* True if this chunk is a FORM, LIST or CAT */
184 BOOL cn_Composite;
187 #define GetIntCN(cn) ((struct IntContextNode *)(cn))
188 #define GetCN(cn) (&GetIntCN(cn)->CN))
192 Internal version of the IffHandle data structure. Contains quite a bit
193 of useful information, eg the current context etc.
197 struct IntIFFHandle
199 struct IFFHandle IH;
201 /* The default context node is built-in into the iffhandle */
202 struct IntContextNode iff_DefaultCN;
204 /* A linkedlist simulated stack with context nodes */
205 struct MinList iff_CNStack;
207 /* containd the state in which the parser currently is */
208 ULONG iff_CurrentState;
211 The context depth at which we have started buffering.
212 0 if no buffering is needed.
214 ULONG iff_BufferStartDepth;
216 /* Here InitIff store it's parameters */
217 struct Hook * iff_StreamHandler;
220 Entrys to preserve the StreamHandler, stream and the stream flags
221 whenever the buffering streamhandle is inserted
224 struct Hook * iff_PreservedHandler;
225 LONG iff_PreservedFlags;
226 IPTR iff_PreservedStream;
228 #define GetIntIH(ih) ((struct IntIFFHandle *)(ih))
229 #define GetIH(ih) (&GetIntIH(ih)->IH)
232 Internal version of the LocalContextItem structure. Contains
233 the dataSize and a Hook for purging...
236 struct IntLocalContextItem
238 struct LocalContextItem LCI;
240 struct Hook * lci_PurgeHook;
241 UBYTE * lci_UserData;
242 ULONG lci_UserDataSize;
245 #define GetIntLCI(lci) ((struct IntLocalContextItem *)(lci))
246 #define GetLCI(lci) (&GetIntLCI(lci)->LCI)
248 /* LocalItem data in IFFLCI_ENTRY/EXITHANDLER LCIs */
250 struct HandlerInfo
252 struct Hook * hi_Hook;
253 APTR hi_Object;
257 /* LocalItem data inside IFFLCI_PROP LCIs */
258 struct CIPtr
260 struct CollectionItem * FirstCI;
265 /* Usefull macros */
266 #define TopChunk( iff ) (struct ContextNode*)GetIntIH(iff)->iff_CNStack.mlh_Head
267 #define RootChunk(iff) (struct ContextNode*)GetIntIH(iff)->iff_CNStack.mlh_TailPred
269 struct IFFParseBase_intern
271 struct Library lib;
273 struct Hook stophook;
274 struct Hook prophook;
275 struct Hook collectionhook;
276 struct Hook doshook;
277 struct Hook cliphook;
278 struct Hook bufhook;
279 struct Hook collectionpurgehook;
280 struct Hook proppurgehook;
281 struct Hook exitcontexthook;
284 #define IPB(ipb) ((struct IFFParseBase_intern *)ipb)
286 //void dprintf(const char *, ...) __attribute__ ((format (printf, 1, 2)));
287 void dprintf(const char *, ...);
290 #define DEBUG_ALLOCIFF(x) ;
291 #define DEBUG_ALLOCLOCALITEM(x) ;
292 #define DEBUG_ALLOCBUFFER(x) ;
293 #define DEBUG_WRITETOBUFFER(x) ;
294 #define DEBUG_SEEKBUFFER(x) ;
295 #define DEBUG_BUFFERTOSTREAM(x) ;
296 #define DEBUG_INITBUFFEREDSTREAM(x) ;
297 #define DEBUG_EXITBUFFEREDSTREAM(x) ;
298 #define DEBUG_BUFSTREAMHANDLER(x) ;
299 #define DEBUG_DOSSTREAMHANDLER(x) ;
300 #define DEBUG_READCHUNKRECORDS(x) ;
301 #define DEBUG_WRITECHUNKRECORDS(x) ;
302 #define DEBUG_INITIFFAS(x) ;
303 #define DEBUG_INITIFF(x) ;
304 #define DEBUG_SETLOCALEITEMPURGE(x) ;
305 #define DEBUG_PROPHOOKS(x) ;
307 #define DEBUG_COLLECTIONCHUNK(x) ;
308 #define DEBUG_COLLECTIONCHUNKS(x) ;
309 #define DEBUG_FINDCOLLECTION(x) ;
310 #define DEBUG_FINDLOCALITEM(x) ;
311 #define DEBUG_FINDPROP(x) ;
312 #define DEBUG_POPCHUNK(x) ;
313 #define DEBUG_PROPCHUNK(x) ;
314 #define DEBUG_PROPCHUNKS(x) ;
315 #define DEBUG_PUSHCHUNK(x) ;
316 #define DEBUG_READCHUNKBYTES(x) ;
317 #define DEBUG_STOPCHUNK(x) ;
318 #define DEBUG_STOPCHUNKS(x) ;
319 #define DEBUG_STOPONEXIT(x) ;
320 #define DEBUG_STOREITEMINCONTEXT(x) ;
321 #define DEBUG_STORELOCALITEM(x) ;
322 #define DEBUG_WRITECHUNKBYTES(x) ;
324 #define dmkid(id) ((id) >> 24) & 0xff, ((id) >> 16) & 0xff, ((id) >> 8) & 0xff, (id) & 0xff
326 #endif /* IFFPARSE_INTERN_H */