home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 348.lha / chatterbox_v1.0 / sources / iff.h < prev    next >
C/C++ Source or Header  |  1990-02-14  |  3KB  |  85 lines

  1. #ifndef IFF_H
  2. #define IFF_H
  3. /*----------------------------------------------------------------------*/
  4. /* IFF.H  defs for IFF-85 Interchange Format Files.            1/22/86     */
  5. /*                                                                        */
  6. /* By Jerry Morrison and Steve Shaw, Electronic Arts.                    */
  7. /* This software is in the public domain.                                */
  8. /*----------------------------------------------------------------------*/
  9.  
  10. /* cut down for my stuff - karl */
  11.  
  12. #ifndef COMPILER_H
  13. #include "compiler.h"
  14. #endif
  15.  
  16. #ifndef LIBRARIES_DOS_H
  17. #include <libraries/dos.h>
  18. #endif
  19.  
  20. typedef LONG ID;    /* An ID is four printable ASCII chars but
  21.              * stored as a LONG for efficient copy & compare.*/
  22.  
  23. /* Four-character IDentifier builder.*/
  24. #define MakeID(a,b,c,d)  ( (LONG)(a)<<24L | (LONG)(b)<<16L | (c)<<8 | (d) )
  25.  
  26. /* Standard group IDs.  A chunk with one of these IDs contains a
  27.    SubTypeID followed by zero or more chunks.*/
  28. #define ID_FORM MakeID('F','O','R','M')
  29. #define ID_PROP MakeID('P','R','O','P')
  30. #define ID_LIST MakeID('L','I','S','T')
  31. #define ID_CAT  MakeID('C','A','T',' ')
  32. #define ID_FILLER MakeID(' ',' ',' ',' ')
  33. /* The IDs "FOR1".."FOR9", "LIS1".."LIS9", & "CAT1".."CAT9" are reserved
  34.  * for future standardization.*/
  35.  
  36. /* Pseudo-ID used internally by chunk reader and writer.*/
  37. #define NULL_CHUNK 0L           /* No current chunk.*/
  38.  
  39.  
  40. /* ---------- Chunk ----------------------------------------------------*/
  41.  
  42. /* All chunks start with a type ID and a count of the data bytes that 
  43.    follow--the chunk's "logicl size" or "data size". If that number is odd,
  44.    a 0 pad byte is written, too. */
  45. typedef struct {
  46.     ID      ckID;
  47.     LONG  ckSize;
  48.     } ChunkHeader;
  49.  
  50. typedef struct {
  51.     ID      ckID;
  52.     LONG  ckSize;
  53.     UBYTE ckData[ 1 /*REALLY: ckSize*/ ];
  54.     } Chunk;
  55.  
  56. /* Need to know whether a value is odd so can word-align.*/
  57. #define IS_ODD(a)   ((a) & 1)
  58.  
  59. /* This macro rounds up to an even number. */
  60. #define WordAlign(size)   ((size+1)&~1)
  61.  
  62. /* ALL CHUNKS MUST BE PADDED TO EVEN NUMBER OF BYTES.
  63.  * ChunkPSize computes the total "physical size" of a padded chunk from
  64.  * its "data size" or "logical size". */
  65. #define ChunkPSize(dataSize)  (WordAlign(dataSize) + sizeof(ChunkHeader))
  66.  
  67. /* The Grouping chunks (LIST, FORM, PROP, & CAT) contain concatenations of
  68.  * chunks after a subtype ID that identifies the content chunks.
  69.  * "FORM type XXXX", "LIST of FORM type XXXX", "PROPerties associated
  70.  * with FORM type XXXX", or "conCATenation of XXXX".*/
  71. typedef struct {
  72.     ID      ckID;
  73.     LONG  ckSize;    /* this ckSize includes "grpSubID".*/
  74.     ID    grpSubID;
  75.     } GroupHeader;
  76.  
  77. typedef struct {
  78.     ID      ckID;
  79.     LONG  ckSize;
  80.     ID    grpSubID;
  81.     UBYTE grpData[ 1 /*REALLY: ckSize-sizeof(grpSubID)*/ ];
  82.     } GroupChunk;
  83.  
  84. #endif
  85.