#ifndef IFF_H
#define IFF_H
/*
   IFF.H  defs for IFF-85 Interchange Format Files.	        	1/22/86

   By Jerry Morrison and Steve Shaw, Electronic Arts.

   Mods and stripping of a lot of stuff by Karl Lehenbauer, 1987, 1988

   This software is in the public domain.
*/

#ifndef LIBRARIES_DOS_H
#include "libraries/dos.h"
#endif

typedef LONG ID;

/* Four-character IDentifier builder.*/
#define MakeID(a,b,c,d)  ( (LONG)(a)<<24L | (LONG)(b)<<16L | (c)<<8 | (d) )

/* Standard group IDs.  A chunk with one of these IDs contains a
   SubTypeID followed by zero or more chunks.*/
#define ID_FORM MakeID('F','O','R','M')
#define ID_PROP MakeID('P','R','O','P')
#define ID_LIST MakeID('L','I','S','T')
#define ID_CAT  MakeID('C','A','T',' ')
#define ID_FILLER MakeID(' ',' ',' ',' ')
#define ID_FNAM MakeID('F','N','A','M')
#define ID_MISC MakeID('M','I','S','C')

/* The IDs "FOR1".."FOR9", "LIS1".."LIS9", & "CAT1".."CAT9" are reserved
 * for future standardization.*/

/* ---------- Chunk ----------------------------------------------------*/

/* All chunks start with a type ID and a count of the data bytes that 
   follow--the chunk's "logicl size" or "data size". If that number is odd,
   a 0 pad byte is written, too. */

typedef struct {
    ID	  ckID;
    LONG  ckSize;
    } ChunkHeader;

typedef struct {
    ID	  ckID;
    LONG  ckSize;
    UBYTE ckData[ 1 /*REALLY: ckSize*/ ];
    } Chunk;

/* define the maximum reasonable chunk size - the real max is around 2^32,
 * but we need some reasonability limit to check for */
#define MAXCHUNKSIZE 900000

/* The Grouping chunks (LIST, FORM, PROP, & CAT) contain concatenations of
 * chunks after a subtype ID that identifies the content chunks.
 * "FORM type XXXX", "LIST of FORM type XXXX", "PROPerties associated
 * with FORM type XXXX", or "conCATenation of XXXX".*/
typedef struct {
    ID	  ckID;
    LONG  ckSize;	/* this ckSize includes "grpSubID".*/
    ID    grpSubID;
    } GroupHeader;

typedef struct {
    ID	  ckID;
    LONG  ckSize;
    ID    grpSubID;
    UBYTE grpData[ 1 /*REALLY: ckSize-sizeof(grpSubID)*/ ];
    } GroupChunk;


#endif IFF_H

