Add Bocfel interpreter
[projects/chimara/chimara.git] / interpreters / bocfel / iff.h
1 #ifndef ZTERP_IFF_H
2 #define ZTERP_IFF_H
3
4 #include <stdint.h>
5
6 #include "io.h"
7
8 typedef struct zterp_iff zterp_iff;
9
10 /* Translate an IFF tag into the corresponding 32-bit integer. */
11 #define STRID(s) ( \
12     (((uint32_t)(s)[0]) << 24) | \
13     (((uint32_t)(s)[1]) << 16) | \
14     (((uint32_t)(s)[2]) <<  8) | \
15     (((uint32_t)(s)[3]) <<  0)   \
16     )
17
18 /* Reverse of above. */
19 #define IDSTR(n) ((char[5]){ \
20     ((uint32_t)n >> 24) & 0xff, \
21     ((uint32_t)n >> 16) & 0xff, \
22     ((uint32_t)n >>  8) & 0xff, \
23     ((uint32_t)n >>  0) & 0xff, \
24     })
25
26
27 void zterp_iff_free(zterp_iff *);
28 zterp_iff *zterp_iff_parse(zterp_io *, const char [4]);
29 int zterp_iff_find(zterp_iff *, const char [4], uint32_t *);
30
31 #endif