home *** CD-ROM | disk | FTP | other *** search
/ Global Amiga Experience / globalamigaexperience.iso / compressed / development / clusterdemo.dms / clusterdemo.adf / Modules.lha / modules / txt / IFFParse.def < prev    next >
Text File  |  1994-05-25  |  12KB  |  374 lines

  1. |##########|
  2. |#MAGIC   #|CLABLMDG
  3. |#PROJECT #|""
  4. |#PATHS   #|"StdProject"
  5. |#FLAGS   #|xx-x-x-xx---x-x-----------------
  6. |#USERSW  #|--------------------------------
  7. |#USERMASK#|--------------------------------
  8. |#SWITCHES#|xx---xxxxx-xx---
  9. |##########|
  10. (* $A- *)
  11. DEFINITION MODULE IFFParse;
  12.  
  13. FROM Exec      IMPORT MinNode,LibraryPtr,MsgPort;
  14. FROM System    IMPORT Regs,SysStringPtr;
  15. FROM Utility   IMPORT HookPtr;
  16. FROM Clipboard IMPORT IOClipboardPtr;
  17.  
  18. TYPE
  19. |
  20. | IFF return codes.  Most functions return either zero for success or
  21. | one of these codes.   The exceptions are the read/write functions which
  22. | return positive values for number of bytes or records read or written,
  23. | or a negative error code.  Some of these codes are not errors per sae,
  24. | but valid conditions such as EOF or EOC (End of Chunk).
  25.  
  26.   IFFErr = (normalReturn = -12, noHook, notIFF, syntax, mangled, seek,
  27.         write,read, noMem, noScope, eoc, eof, ok);
  28.  
  29. |       eof                            Reached logical end of file
  30. |       eoc                            About to leave context
  31. |       noScope                        No valid scope for property
  32. |       noMem                          Internal memory alloc failed
  33. |       read                           Stream read error
  34. |       write                          Stream write error
  35. |       seek                           Stream seek error
  36. |       mangled                        Data in file is corrupt
  37. |       syntax                         IFF syntax error
  38. |       notIFF                         Not an IFF file
  39. |       noHook                         No call-back hook provided
  40. |       normalReturn                   Client handler normal return
  41.  
  42.  
  43. |
  44. | Universal IFF identifiers.
  45. CONST
  46.   IDFORM              = $464F524D;  | "FORM"
  47.   IDLIST              = $4C495354;  | "LIST"
  48.   IDCAT               = $43415420;  | "CAT "
  49.   IDPROP              = $50524F50;  | "PROP"
  50.   IDNULL              = $20202020;  | "NULL"
  51.  
  52. |
  53. | Ident codes for universally recognized local context items.
  54.  
  55.   IFFLCIPROP          = $70726F70;  | "prop"
  56.   IFFLCICOLLECTION    = $636F6C6C;  | "coll"
  57.   IFFLCIENTRYHANDLER  = $656E6864;  | "enhd"
  58.   IFFLCIEXITHANDLER   = $65786864;  | "exhd"
  59.  
  60.  
  61. TYPE
  62. |
  63. | Control modes for ParseIFF() function.
  64.  
  65.   ParseIFFMode  = (scan, step, rawStep, dummy = 31);
  66.  
  67. |
  68. | Control modes for StoreLocalItem().
  69.  
  70.  
  71.   StoreLocalItemMode    = (root = 1, top, prop, dummy = 31);
  72.  
  73. |
  74. | "Flag" for writing functions.  If you pass this value in as a size
  75. | to PushChunk() when writing a file, the parser will figure out the
  76. | size of the chunk for you.  (Chunk sizes >= 2**31 are forbidden by the
  77. | IFF specification, so this works.)
  78.  
  79. CONST   IFFSizeUnknown          = -1;
  80.  
  81. TYPE
  82. |
  83. | Possible call-back command values.  (Using 0 as the value for IFFCMD_INIT
  84. | was, in retrospect, probably a bad idea.)
  85.  
  86.   IFFCmd      = (init, cleanup, read, write, seek, entry, exit, purgeLCI);
  87.  
  88. |       init          |  Prepare the stream for a session
  89. |       cleanup       |  Terminate stream session
  90. |       read          |  Read bytes from stream
  91. |       write         |  Write bytes to stream
  92. |       seek          |  Seek on stream
  93. |       entry         |  You just entered a new context
  94. |       exit          |  You're about to leave a context
  95. |       purgeLCI      |  Purge a LocalContextItem
  96.  
  97. |
  98. | Struct associated with an active IFF stream.
  99. | "iff_Stream" is a value used by the client's read/write/seek functions -
  100. | it will not be accessed by the library itself and can have any value
  101. | (could even be a pointer or a BPTR).
  102. |
  103.  
  104. | Bit masks for "iff_Flags" field.
  105.  
  106.   IFFFlags      = (read, write, fseek, rseek,
  107.            reserved1 = 16,reserved16 = 31);
  108.   IFFFlagSet    = SET OF IFFFlags;
  109.  
  110.   IFFHandlePtr  = POINTER TO IFFHandle;
  111.   IFFHandle     = RECORD
  112.             stream      : ANYPTR;
  113.             flags       : IFFFlagSet;
  114.             depth       : LONGINT;   |  Depth of context stack.
  115.           END;
  116.  
  117. |
  118. | When the library calls your stream handler, you'll be passed a pointer
  119. | to this structure as the "message packet".
  120.  
  121.   IFFStreamCmdPtr = POINTER TO IFFStreamCmd;
  122.   IFFStreamCmd    = RECORD
  123.               command : IFFCmd;  |  Operation to be performed
  124.               buf     : ANYPTR;  |  Pointer to data buffer
  125.               nBytes  : LONGINT; |  Number of bytes to be affected
  126.             END;
  127.  
  128. |
  129. | A node associated with a context on the iff_Stack.  Each node
  130. | represents a chunk, the stack representing the current nesting
  131. | of chunks in the open IFF file.  Each context node has associated
  132. | local context items in the (private) LocalItems list.  The ID, type,
  133. | size and scan values describe the chunk associated with this node.
  134.  
  135.   ContextNodePtr= POINTER TO ContextNode;
  136.   ContextNode   = RECORD
  137.             node        : MinNode;
  138.             iD          : LONGINT;
  139.             type        : LONGINT;
  140.             size        : LONGINT;  |  Size of this chunk
  141.             scan        : LONGINT;  |  # of bytes read/written so
  142.                         |  far
  143.           END;
  144.  
  145. |
  146. | Local context items live in the ContextNode's.  Each class is identified
  147. | by its lci_Ident code and has a (private) purge vector for when the
  148. | parent context node is popped.
  149.  
  150.   LocalContextItemPtr = POINTER TO LocalContextItem;
  151.   LocalContextItem    = RECORD
  152.               node        : MinNode;
  153.               iD,
  154.               type,
  155.               ident       : LONGCARD;
  156.             END;
  157.  
  158. |
  159. | StoredProperty: a local context item containing the data stored
  160. | from a previously encountered property chunk.
  161.  
  162.   StoredPropertyPtr = POINTER TO StoredProperty;
  163.   StoredProperty    = RECORD
  164.             size       : LONGINT;
  165.             data       : ANYPTR;
  166.               END;
  167.  
  168. |
  169. | Collection Item: the actual node in the collection list at which
  170. | client will look.  The next pointers cross context boundaries so
  171. | that the complete list is accessable.
  172.  
  173.   CollectionItemPtr = POINTER TO CollectionItem;
  174.   CollectionItem    = RECORD
  175.             next       : CollectionItemPtr;
  176.             size       : LONGINT;
  177.             data       : ANYPTR;
  178.               END;
  179.  
  180. |
  181. | Structure returned by OpenClipboard().  You may do CMD_POSTs and such
  182. | using this structure.  However, once you call OpenIFF(), you may not
  183. | do any more of your own I/O to the clipboard until you call CloseIFF().
  184.  
  185. ClipboardHandlePtr = POINTER TO ClipboardHandle;
  186. ClipboardHandle    = RECORD
  187.                req         : IOClipboardPtr;
  188.                cBPort      : MsgPort;
  189.                satisfyPort : MsgPort;
  190.              END;
  191.  
  192. VAR
  193.   IFFParseBase  : LibraryPtr;
  194.  
  195.  
  196. LIBRARY IFFParseBase BY -30
  197.   PROCEDURE AllocIFF() : IFFHandlePtr;
  198.  
  199. LIBRARY IFFParseBase BY -36
  200.   PROCEDURE OpenIFF(iff    IN A0: IFFHandlePtr;
  201.             rwMode IN D0: IFFFlagSet): IFFErr;
  202.  
  203. LIBRARY IFFParseBase BY -42
  204.   PROCEDURE ParseIFF(iff     IN A0: IFFHandlePtr;
  205.              control IN D0: ParseIFFMode): IFFErr;
  206.  
  207. LIBRARY IFFParseBase BY -48
  208.   PROCEDURE CloseIFF(iff IN A0: IFFHandlePtr);
  209.  
  210. LIBRARY IFFParseBase BY -54
  211.   PROCEDURE FreeIFF(iff IN A0: IFFHandlePtr);
  212.  
  213. LIBRARY IFFParseBase BY -60
  214.   PROCEDURE ReadChunkBytes(iff  IN A0: IFFHandlePtr;
  215.                buf  IN A1: ANYPTR;
  216.                size IN D0: LONGINT): LONGINT;
  217.  
  218. LIBRARY IFFParseBase BY -66
  219.   PROCEDURE WriteChunkBytes(iff  IN A0: IFFHandlePtr;
  220.                 buf  IN A1: ANYPTR;
  221.                 size IN D0: LONGINT): IFFErr;
  222.  
  223. LIBRARY IFFParseBase BY -72
  224.   PROCEDURE ReadChunkRecords(iff            IN A0: IFFHandlePtr;
  225.                  buf            IN A1: ANYPTR;
  226.                  bytesPerRecord IN D0: LONGINT;
  227.                  nRecords       IN D1: LONGINT): LONGINT;
  228.  
  229. LIBRARY IFFParseBase BY -78
  230.   PROCEDURE WriteChunkRecords(iff            IN A0: IFFHandlePtr;
  231.                   buf            IN A1: ANYPTR;
  232.                   bytesPerRecord IN D0: LONGINT;
  233.                   nRecords       IN D1: LONGINT): IFFErr;
  234.  
  235. LIBRARY IFFParseBase BY -84
  236.   PROCEDURE PushChunk(iff  IN A0: IFFHandlePtr;
  237.               type IN D0: LONGINT;
  238.               id   IN D1: LONGINT;
  239.               size IN D2: LONGINT): IFFErr;
  240.  
  241. LIBRARY IFFParseBase BY -90
  242.   PROCEDURE PopChunk(iff IN A0: IFFHandlePtr): IFFErr;
  243.  
  244. LIBRARY IFFParseBase BY -102
  245.   PROCEDURE EntryHandler(iff      IN A0: IFFHandlePtr;
  246.              type     IN D0: LONGINT;
  247.              id       IN D1: LONGINT;
  248.              position IN D2: LONGINT;
  249.              handler  IN A1: HookPtr;
  250.              object   IN A2: ANYPTR): IFFErr;
  251.  
  252. LIBRARY IFFParseBase BY -108
  253.   PROCEDURE ExitHandler(iff      IN A0: IFFHandlePtr;
  254.              type     IN D0: LONGINT;
  255.              id       IN D1: LONGINT;
  256.              position IN D2: LONGINT;
  257.              handler  IN A1: HookPtr;
  258.              object   IN A2: ANYPTR): IFFErr;
  259.  
  260. LIBRARY IFFParseBase BY -114
  261.   PROCEDURE PropChunk(iff  IN A0: IFFHandlePtr;
  262.               type IN D0: LONGINT;
  263.               id   IN D1: LONGINT): IFFErr;
  264.  
  265. LIBRARY IFFParseBase BY -120
  266.   PROCEDURE PropChunks(    iff       IN A0: IFFHandlePtr;
  267.                VAR propArray IN A1: ARRAY OF LONGINT;
  268.                nProps    IN D0: LONGINT): IFFErr;
  269.  
  270. LIBRARY IFFParseBase BY -126
  271.   PROCEDURE StopChunk(iff  IN A0: IFFHandlePtr;
  272.               type IN D0: LONGINT;
  273.               id   IN D1: LONGINT): IFFErr;
  274.  
  275. LIBRARY IFFParseBase BY -132
  276.   PROCEDURE StopChunks(    iff       IN A0: IFFHandlePtr;
  277.                VAR propArray IN A1: ARRAY OF LONGINT;
  278.                nProps    IN D0: LONGINT): IFFErr;
  279.  
  280. LIBRARY IFFParseBase BY -138
  281.   PROCEDURE CollectionChunk(iff  IN A0: IFFHandlePtr;
  282.                 type IN D0: LONGINT;
  283.                 id   IN D1: LONGINT): IFFErr;
  284.  
  285. LIBRARY IFFParseBase BY -144
  286.   PROCEDURE CollectionChunks(    iff       IN A0: IFFHandlePtr;
  287.                  VAR propArray IN A1: ARRAY OF LONGINT;
  288.                  nProps    IN D0: LONGINT): IFFErr;
  289.  
  290. LIBRARY IFFParseBase BY -150
  291.   PROCEDURE StopOnExit(iff  IN A0: IFFHandlePtr;
  292.                type IN D0: LONGINT;
  293.                id   IN D1: LONGINT): IFFErr;
  294.  
  295. LIBRARY IFFParseBase BY -156
  296.   PROCEDURE FindProp(iff  IN A0: IFFHandlePtr;
  297.              type IN D0: LONGINT;
  298.              id   IN D1: LONGINT): StoredPropertyPtr;
  299.  
  300. LIBRARY IFFParseBase BY -162
  301.   PROCEDURE FindCollection(iff  IN A0: IFFHandlePtr;
  302.                type IN D0: LONGINT;
  303.                id   IN D1: LONGINT): CollectionItemPtr;
  304.  
  305. LIBRARY IFFParseBase BY -168
  306.   PROCEDURE FindPropContext(iff IN A0: IFFHandlePtr): ContextNodePtr;
  307.  
  308. LIBRARY IFFParseBase BY -174
  309.   PROCEDURE CurrentChunk(iff IN A0: IFFHandlePtr): ContextNodePtr;
  310.  
  311. LIBRARY IFFParseBase BY -180
  312.   PROCEDURE ParentChunk(contextNode IN A0: ContextNodePtr): ContextNodePtr;
  313.  
  314. LIBRARY IFFParseBase BY -186
  315.   PROCEDURE AllocLocalItem(type     IN D0: LONGINT;
  316.                id       IN D1: LONGINT;
  317.                ident    IN D2: LONGINT;
  318.                dataSize IN D3: LONGINT): LocalContextItemPtr;
  319.  
  320. LIBRARY IFFParseBase BY -192
  321.   PROCEDURE LocalItemData(localItem IN A0: LocalContextItemPtr): ANYPTR;
  322.  
  323. LIBRARY IFFParseBase BY -198
  324.   PROCEDURE SetLocalItemPurge(localItem IN A0: LocalContextItemPtr;
  325.                   purgeHook IN A1: HookPtr);
  326.  
  327. LIBRARY IFFParseBase BY -204
  328.   PROCEDURE FreeLocalItem(localItem IN A0: LocalContextItemPtr);
  329.  
  330. LIBRARY IFFParseBase BY -210
  331.   PROCEDURE FindLocalItem(iff   IN A0: IFFHandlePtr;
  332.               type  IN D0: LONGINT;
  333.               id    IN D1: LONGINT;
  334.               ident IN D2: LONGINT): LocalContextItemPtr;
  335.  
  336. LIBRARY IFFParseBase BY -216
  337.   PROCEDURE StoreLocalItem(iff       IN A0: IFFHandlePtr;
  338.                localItem IN A1: LocalContextItemPtr;
  339.                position  IN D0: StoreLocalItemMode): IFFErr;
  340.  
  341. LIBRARY IFFParseBase BY -222
  342.   PROCEDURE StoreItemInContext(iff         IN A0: IFFHandlePtr;
  343.                    localItem   IN A1: LocalContextItemPtr;
  344.                    contextNode IN A2: ContextNodePtr);
  345.  
  346. LIBRARY IFFParseBase BY -228
  347.   PROCEDURE InitIFF(iff        IN A0: IFFHandlePtr;
  348.             flags      IN D0: LONGINT;
  349.             streamHook IN A1: HookPtr);
  350.  
  351. LIBRARY IFFParseBase BY -234
  352.   PROCEDURE InitIFFasDOS(iff IN A0: IFFHandlePtr);
  353.  
  354. LIBRARY IFFParseBase BY -240
  355.   PROCEDURE InitIFFasClip(iff IN A0: IFFHandlePtr);
  356.  
  357. LIBRARY IFFParseBase BY -246
  358.   PROCEDURE OpenClipboard(unitNum IN D0: LONGINT): ClipboardHandlePtr;
  359.  
  360. LIBRARY IFFParseBase BY -252
  361.   PROCEDURE CloseClipboard(clipboard IN A0: ClipboardHandlePtr);
  362.  
  363. LIBRARY IFFParseBase BY -258
  364.   PROCEDURE GoodID(id IN D0: LONGINT): LONGINT;
  365.  
  366. LIBRARY IFFParseBase BY -264
  367.   PROCEDURE GoodType(type IN D0: LONGINT): LONGINT;
  368.  
  369. LIBRARY IFFParseBase BY -270
  370.   PROCEDURE IDtoStr(    id  IN D0: LONGINT;
  371.             VAR buf IN A0: STRING): SysStringPtr;
  372.  
  373. END IFFParse.
  374.