home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / TRSICAT.LZX / CATS_CD2_TRSI / Inc&AD2.1 / includes / libraries / iffparse.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-11  |  6.3 KB  |  203 lines

  1. #ifndef IFF_IFFPARSE_H
  2. #define IFF_IFFPARSE_H
  3. /*
  4. **    $VER: iffparse.h 33.1 (20.11.90)
  5. **    Includes Release 38.56
  6. **
  7. **    Structure definitions for the all new good nifty IFF code.
  8. **
  9. **    (C) Copyright 1989-1992 Commodore-Amiga Inc., Stuart Ferguson, and
  10. **    Leo L. Schwab
  11. **        All Rights Reserved
  12. */
  13.  
  14. #ifndef EXEC_TYPES_H
  15. #include <exec/types.h>
  16. #endif
  17. #ifndef EXEC_LISTS_H
  18. #include <exec/lists.h>
  19. #endif
  20. #ifndef EXEC_PORTS_H
  21. #include <exec/ports.h>
  22. #endif
  23. #ifndef DEVICES_CLIPBOARD_H
  24. #include <devices/clipboard.h>
  25. #endif
  26.  
  27. /*
  28.  * Struct associated with an active IFF stream.
  29.  * "iff_Stream" is a value used by the client's read/write/seek functions -
  30.  * it will not be accessed by the library itself and can have any value
  31.  * (could even be a pointer or a BPTR).
  32.  */
  33. struct IFFHandle {
  34.     ULONG    iff_Stream;
  35.     ULONG    iff_Flags;
  36.     LONG    iff_Depth;    /*  Depth of context stack.  */
  37.     /*  There are private fields hiding here.  */
  38. };
  39.  
  40. /*
  41.  * Bit masks for "iff_Flags" field.
  42.  */
  43. #define IFFF_READ    0L            /* read mode - default */
  44. #define IFFF_WRITE    1L            /* write mode */
  45. #define IFFF_RWBITS    (IFFF_READ | IFFF_WRITE)    /* read/write bits */
  46. #define IFFF_FSEEK    (1L<<1)            /* forward seek only */
  47. #define IFFF_RSEEK    (1L<<2)            /* random seek */
  48. #define    IFFF_RESERVED    0xFFFF0000L        /* Don't touch these bits. */
  49.  
  50. /*
  51.  * When the library calls your stream handler, you'll be passed a pointer
  52.  * to this structure as the "message packet".
  53.  */
  54. struct IFFStreamCmd {
  55.     LONG    sc_Command;    /*  Operation to be performed (IFFCMD_)    */
  56.     APTR    sc_Buf;        /*  Pointer to data buffer        */
  57.     LONG    sc_NBytes;    /*  Number of bytes to be affected    */
  58. };
  59.  
  60. /*
  61.  * A node associated with a context on the iff_Stack.  Each node
  62.  * represents a chunk, the stack representing the current nesting
  63.  * of chunks in the open IFF file.  Each context node has associated
  64.  * local context items in the (private) LocalItems list.  The ID, type,
  65.  * size and scan values describe the chunk associated with this node.
  66.  */
  67. struct ContextNode {
  68.     struct MinNode    cn_Node;
  69.     LONG        cn_ID;
  70.     LONG        cn_Type;
  71.     LONG        cn_Size;    /*  Size of this chunk           */
  72.     LONG        cn_Scan;    /*  # of bytes read/written so far */
  73.     /*  There are private fields hiding here.  */
  74. };
  75.  
  76. /*
  77.  * Local context items live in the ContextNode's.  Each class is identified
  78.  * by its lci_Ident code and has a (private) purge vector for when the
  79.  * parent context node is popped.
  80.  */
  81. struct LocalContextItem {
  82.     struct MinNode    lci_Node;
  83.     ULONG        lci_ID,
  84.             lci_Type,
  85.             lci_Ident;
  86.     /*  There are private fields hiding here.  */
  87. };
  88.  
  89. /*
  90.  * StoredProperty: a local context item containing the data stored
  91.  * from a previously encountered property chunk.
  92.  */
  93. struct StoredProperty {
  94.     LONG    sp_Size;
  95.     UBYTE    *sp_Data;
  96. };
  97.  
  98. /*
  99.  * Collection Item: the actual node in the collection list at which
  100.  * client will look.  The next pointers cross context boundaries so
  101.  * that the complete list is accessable.
  102.  */
  103. struct CollectionItem {
  104.     struct CollectionItem    *ci_Next;
  105.     LONG            ci_Size;
  106.     UBYTE            *ci_Data;
  107. };
  108.  
  109. /*
  110.  * Structure returned by OpenClipboard().  You may do CMD_POSTs and such
  111.  * using this structure.  However, once you call OpenIFF(), you may not
  112.  * do any more of your own I/O to the clipboard until you call CloseIFF().
  113.  */
  114. struct ClipboardHandle {
  115.     struct IOClipReq    cbh_Req;
  116.     struct MsgPort        cbh_CBport;
  117.     struct MsgPort        cbh_SatisfyPort;
  118. };
  119.  
  120. /*
  121.  * IFF return codes.  Most functions return either zero for success or
  122.  * one of these codes.    The exceptions are the read/write functions which
  123.  * return positive values for number of bytes or records read or written,
  124.  * or a negative error code.  Some of these codes are not errors per sae,
  125.  * but valid conditions such as EOF or EOC (End of Chunk).
  126.  */
  127. #define    IFFERR_EOF        -1L    /*  Reached logical end of file    */
  128. #define IFFERR_EOC        -2L    /*  About to leave context    */
  129. #define    IFFERR_NOSCOPE        -3L    /*  No valid scope for property    */
  130. #define    IFFERR_NOMEM        -4L    /*  Internal memory alloc failed*/
  131. #define    IFFERR_READ        -5L    /*  Stream read error        */
  132. #define    IFFERR_WRITE        -6L    /*  Stream write error        */
  133. #define    IFFERR_SEEK        -7L    /*  Stream seek error        */
  134. #define    IFFERR_MANGLED        -8L    /*  Data in file is corrupt    */
  135. #define    IFFERR_SYNTAX        -9L    /*  IFF syntax error        */
  136. #define    IFFERR_NOTIFF        -10L    /*  Not an IFF file        */
  137. #define    IFFERR_NOHOOK        -11L    /*  No call-back hook provided    */
  138. #define IFF_RETURN2CLIENT    -12L    /*  Client handler normal return*/
  139.  
  140. #define    MAKE_ID(a,b,c,d)    \
  141.     ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  142.  
  143. /*
  144.  * Universal IFF identifiers.
  145.  */
  146. #define    ID_FORM            MAKE_ID('F','O','R','M')
  147. #define    ID_LIST            MAKE_ID('L','I','S','T')
  148. #define    ID_CAT            MAKE_ID('C','A','T',' ')
  149. #define    ID_PROP            MAKE_ID('P','R','O','P')
  150. #define    ID_NULL            MAKE_ID(' ',' ',' ',' ')
  151.  
  152. /*
  153.  * Ident codes for universally recognized local context items.
  154.  */
  155. #define IFFLCI_PROP        MAKE_ID('p','r','o','p')
  156. #define IFFLCI_COLLECTION    MAKE_ID('c','o','l','l')
  157. #define IFFLCI_ENTRYHANDLER    MAKE_ID('e','n','h','d')
  158. #define IFFLCI_EXITHANDLER    MAKE_ID('e','x','h','d')
  159.  
  160. /*
  161.  * Control modes for ParseIFF() function.
  162.  */
  163. #define IFFPARSE_SCAN        0L
  164. #define IFFPARSE_STEP        1L
  165. #define IFFPARSE_RAWSTEP    2L
  166.  
  167. /*
  168.  * Control modes for StoreLocalItem().
  169.  */
  170. #define IFFSLI_ROOT        1L    /*  Store in default context       */
  171. #define IFFSLI_TOP        2L    /*  Store in current context       */
  172. #define IFFSLI_PROP        3L    /*  Store in topmost FORM or LIST  */
  173.  
  174. /*
  175.  * "Flag" for writing functions.  If you pass this value in as a size
  176.  * to PushChunk() when writing a file, the parser will figure out the
  177.  * size of the chunk for you.  (Chunk sizes >= 2**31 are forbidden by the
  178.  * IFF specification, so this works.)
  179.  */
  180. #define    IFFSIZE_UNKNOWN        -1L
  181.  
  182. /*
  183.  * Possible call-back command values.  (Using 0 as the value for IFFCMD_INIT
  184.  * was, in retrospect, probably a bad idea.)
  185.  */
  186. #define    IFFCMD_INIT    0    /*  Prepare the stream for a session    */
  187. #define    IFFCMD_CLEANUP    1    /*  Terminate stream session        */
  188. #define    IFFCMD_READ    2    /*  Read bytes from stream        */
  189. #define    IFFCMD_WRITE    3    /*  Write bytes to stream        */
  190. #define    IFFCMD_SEEK    4    /*  Seek on stream            */
  191. #define    IFFCMD_ENTRY    5    /*  You just entered a new context    */
  192. #define    IFFCMD_EXIT    6    /*  You're about to leave a context    */
  193. #define    IFFCMD_PURGELCI    7    /*  Purge a LocalContextItem        */
  194.  
  195. /*  Backward compatibility.  Don't use these in new code.  */
  196. #define    IFFSCC_INIT    IFFCMD_INIT
  197. #define    IFFSCC_CLEANUP    IFFCMD_CLEANUP
  198. #define    IFFSCC_READ    IFFCMD_READ
  199. #define    IFFSCC_WRITE    IFFCMD_WRITE
  200. #define    IFFSCC_SEEK    IFFCMD_SEEK
  201.  
  202. #endif
  203.