home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / at-inc-bin.lha / os-include / libraries / iffparse.h < prev    next >
C/C++ Source or Header  |  1993-10-15  |  8KB  |  263 lines

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