home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / m2 / CycloneModules.lha / modules / txt / IFFParseD.def < prev    next >
Text File  |  1996-11-26  |  7KB  |  218 lines

  1. (*$ Implementation- *)
  2. DEFINITION MODULE IFFParseD;
  3. (* 24-Aug-96/Stefan Tiemann for Cyclone *)
  4. (* Converted from C-Includes: iffparse.h 39.1 (1.6.92), Includes Release 40.15 *)
  5.  
  6.  
  7. IMPORT ED: ExecD;
  8. IMPORT CL: Clipboard;
  9. FROM SYSTEM IMPORT ADDRESS, CAST;
  10.  
  11. CONST
  12.  iffparseName= "iffparse.library";
  13.  
  14. TYPE
  15. (* bit masks for "iff_Flags" (IFFHandle.flags) field *)
  16.  IFFFlags=(
  17.   // read                 (* read mode - default    *)
  18.   write,                  (* write mode           *)
  19.   // rwbits (read|write)   (* read/write bits       *)
  20.   fseek,                (* forward seek only       *)
  21.   rseek,                   (* random seek       *)
  22.   iff3, iff4, iff5, iff6, iff7, iff8, iff9, iff10, iff11, iff12, iff13, iff14,
  23.   iff15, iff16, iff17, iff18, iff19, iff20, iff21, iff22, iff23, iff24,
  24.   iff25, iff26, iff27, iff28, iff29, iff30, iff31);
  25. IFFFlagSet= SET OF IFFFlags;
  26.  
  27. (* Structure associated with an active IFF stream.
  28.  * "iff_Stream" is a value used by the client's read/write/seek functions -
  29.  * it will not be accessed by the library itself and can have any value
  30.  * (could even be a pointer or a BPTR).
  31.  *
  32.  * This structure can only be allocated by iffparse.library
  33.  *)
  34. IFFHandle= RECORD
  35.  stream: ADDRESS;
  36.  flags: IFFFlagSet;
  37.  depth: LONGINT;    (*  Depth of context stack *)
  38. END;
  39. IFFHandlePtr= POINTER TO IFFHandle;
  40.  
  41.  
  42. (*****************************************************************************)
  43.  
  44.  
  45. (* When the library calls your stream handler, you'll be passed a pointer
  46.  * to this structure as the "message packet".
  47.  *)
  48. IFFStreamCmd= RECORD
  49.  command: LONGINT;    (* Operation to be performed (IFFCMD_) *)
  50.  buf: ADDRESS;       (* Pointer to data buffer           *)
  51.  nBytes: LONGINT;    (* Number of bytes to be affected      *)
  52. END;
  53. IFFStreamCmdPtr= POINTER TO IFFStreamCmd;
  54.  
  55. (*****************************************************************************)
  56.  
  57.  
  58. (* A node associated with a context on the iff_Stack. Each node
  59.  * represents a chunk, the stack representing the current nesting
  60.  * of chunks in the open IFF file. Each context node has associated
  61.  * local context items in the (private) LocalItems list.  The ID, type,
  62.  * size and scan values describe the chunk associated with this node.
  63.  *
  64.  * This structure can only be allocated by iffparse.library
  65.  *)
  66.  ContextNode= RECORD
  67.   node: ED.MinNode;
  68.   id: LONGINT;
  69.   type: LONGINT;
  70.   size: LONGINT;    (*  Size of this chunk           *)
  71.   scan: LONGINT;    (*  # of bytes read/written so far *)
  72.  END;
  73.  ContextNodePtr= POINTER TO ContextNode;
  74.  
  75.  
  76. (*****************************************************************************)
  77.  
  78.  
  79. (* Local context items live in the ContextNode's.  Each class is identified
  80.  * by its lci_Ident code and has a (private) purge vector for when the
  81.  * parent context node is popped.
  82.  *
  83.  * This structure can only be allocated by iffparse.library
  84.  *)
  85.  LocalContextItem= RECORD
  86.   node: ED.MinNode;
  87.   id: LONGCARD;
  88.   type: LONGCARD;
  89.   ident: LONGCARD;
  90.  END;
  91.  LocalContextItemPtr= POINTER TO LocalContextItem;
  92.  
  93.  
  94. (*****************************************************************************)
  95.  
  96.  
  97. (* StoredProperty: a local context item containing the data stored
  98.  * from a previously encountered property chunk.
  99.  *)
  100.  StoredProperty= RECORD
  101.   size: LONGINT;
  102.   data: ADDRESS;
  103.  END;
  104.  StoredPropertyPtr= POINTER TO StoredProperty;
  105.  
  106.  
  107. (*****************************************************************************)
  108.  
  109.  
  110. (* Collection Item: the actual node in the collection list at which
  111.  * client will look. The next pointers cross context boundaries so
  112.  * that the complete list is accessable.
  113.  *)
  114.  CollectionItemPtr= POINTER TO CollectionItem;
  115.  CollectionItem= RECORD
  116.   next: CollectionItemPtr;;
  117.   size: LONGINT;
  118.   data: ADDRESS;
  119.  END;
  120.  
  121.  
  122. (*****************************************************************************)
  123.  
  124.  
  125. (* Structure returned by OpenClipboard(). You may do CMD_POSTs and such
  126.  * using this structure. However, once you call OpenIFF(), you may not
  127.  * do any more of your own I/O to the clipboard until you call CloseIFF().
  128.  *)
  129.  ClipboardHandle= RECORD
  130.   req: CL.IOClipReq;
  131.   cbPort: ED.MsgPort;
  132.   satisfyPort: ED.MsgPort;
  133.  END;
  134.  ClipboardHandlePtr= POINTER TO ClipboardHandle;
  135.  
  136.  
  137. CONST
  138. (*****************************************************************************)
  139. (* IFF return codes. Most functions return either zero for success or
  140.  * one of these codes. The exceptions are the read/write functions which
  141.  * return positive values for number of bytes or records read or written,
  142.  * or a negative error code. Some of these codes are not errors per sae,
  143.  * but valid conditions such as EOF or EOC (End of Chunk).
  144.  *)
  145.  ifferrEof=      -1;    (* Reached logical end of file    *)
  146.  ifferrEoc=      -2;    (* About to leave context    *)
  147.  ifferrNoscope=  -3;    (* No valid scope for property    *)
  148.  ifferrNomem=      -4;    (* Internal memory alloc failed *)
  149.  ifferrRead=      -5;    (* Stream read error        *)
  150.  ifferrWrite=      -6;    (* Stream write error        *)
  151.  ifferrSeek=      -7;    (* Stream seek error        *)
  152.  ifferrMangled=  -8;    (* Data in file is corrupt    *)
  153.  ifferrSyntax=      -9;    (* IFF syntax error        *)
  154.  ifferrNotiff=      -10;    (* Not an IFF file        *)
  155.  ifferrNohook=      -11;    (* No call-back hook provided    *)
  156.  iffReturn2client= -12;    (* Client handler normal return *)
  157.  
  158.  
  159. (*****************************************************************************)
  160.  
  161.  
  162. (* Universal IFF identifiers *)
  163.  idFORM    = CAST(LONGINT,'FORM');
  164.  idLIST    = CAST(LONGINT,'LIST');
  165.  idCAT    = CAST(LONGINT,'CAT ');
  166.  idPROP    = CAST(LONGINT,'PROP');
  167.  idNULL    = CAST(LONGINT,'    ');
  168.  
  169. (* Identifier codes for universally recognized local context items *)
  170.  ifflciPROP        = CAST(LONGINT,'prop');
  171.  ifflciCOLLECTION    = CAST(LONGINT,'coll');
  172.  ifflciENTRYHANDLER    = CAST(LONGINT,'enhd');
  173.  ifflciEXITHANDLER    = CAST(LONGINT,'exhd');
  174.  
  175.  
  176. (*****************************************************************************)
  177.  
  178.  
  179. (* Control modes for ParseIFF() function *)
  180.  iffparseScan= 0;
  181.  iffparseStep= 1;
  182.  iffparseRawstep= 2;
  183.  
  184.  
  185. (*****************************************************************************)
  186.  
  187.  
  188. (* Control modes for StoreLocalItem() function *)
  189.  iffsliRoot=  1;  (* Store in default context      *)
  190.  iffsliTop=   2;  (* Store in current context      *)
  191.  iffsliProp=  3;  (* Store in topmost FORM or LIST *)
  192.  
  193.  
  194. (*****************************************************************************)
  195.  
  196.  
  197. (* Magic value for writing functions. If you pass this value in as a size
  198.  * to PushChunk() when writing a file, the parser will figure out the
  199.  * size of the chunk for you. If you know the size, is it better to
  200.  * provide as it makes things faster.
  201.  *)
  202.  iffsizeUnknown= -1;
  203.  
  204.  
  205. (*****************************************************************************)
  206.  
  207.  
  208. (* Possible call-back command values *)
  209.  iffcmdInit= 0;    (* Prepare the stream for a session *)
  210.  iffcmdCleanup= 1;(* Terminate stream session        *)
  211.  iffcmdRead=    2;    (* Read bytes from stream        *)
  212.  iffcmdWrite= 3;    (* Write bytes to stream        *)
  213.  iffcmdSeek=    4;    (* Seek on stream            *)
  214.  iffcmdEntry= 5;    (* You just entered a new context   *)
  215.  iffcmdExit=    6;    (* You're about to leave a context  *)
  216.  iffcmdPurgecli= 7;(* Purge a LocalContextItem        *)
  217.  
  218. END IFFParseD.