home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / TRSICAT.LZX / CATS_CD2_TRSI / Reference_Library / Devices / iffp / iff.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-21  |  3.6 KB  |  145 lines

  1. /* 
  2.  *
  3.  * iff.h:    General Definitions for IFFParse modules
  4.  *
  5.  * 6/27/91
  6.  */
  7.  
  8. #ifndef IFFP_IFF_H
  9. #define IFFP_IFF_H
  10.  
  11. #include "iffp/compiler.h"
  12.  
  13. #ifndef EXEC_TYPES_H
  14. #include <exec/types.h>
  15. #endif
  16. #ifndef EXEC_MEMORY_H
  17. #include <exec/memory.h>
  18. #endif
  19. #ifndef UTILITY_TAGITEM_H
  20. #include <utility/tagitem.h>
  21. #endif
  22. #ifndef UTILITY_HOOKS_H
  23. #include <utility/hooks.h>
  24. #endif
  25. #ifndef LIBRARIES_IFFPARSE_H
  26. #include <libraries/iffparse.h>
  27. #endif
  28.  
  29. #include <stdio.h>
  30. #include <stdlib.h>
  31. #include <string.h>
  32.  
  33. #ifndef MYDEBUG_H
  34. #include "iffp/debug.h"
  35. #endif
  36.  
  37. #ifndef NO_PROTOS
  38. #include <clib/exec_protos.h>
  39. #include <clib/iffparse_protos.h>
  40. #endif
  41.  
  42. #ifndef MAX
  43. #define    MAX(a,b)    ((a) > (b) ? (a) : (b))
  44. #endif
  45. #ifndef MIN
  46. #define    MIN(a,b)    ((a) < (b) ? (a) : (b))
  47. #endif
  48. #ifndef ABS
  49. #define    ABS(x)        ((x) < 0 ? -(x) : (x))
  50. #endif
  51.  
  52.  
  53. #define CkErr(expression)  {if (!error) error = (expression);}
  54. #define ChunkMoreBytes(cn)    (cn->cn_Size - cn->cn_Scan)
  55. #define IS_ODD(a)        (a & 1)
  56.  
  57. #define IFF_OKAY    0L
  58. #define    CLIENT_ERROR    1L
  59. #define NOFILE          5L
  60.  
  61. #define message printf
  62.  
  63. /* Generic Chunk ID's we may encounter */
  64. #define    ID_ANNO        MAKE_ID('A','N','N','O')
  65. #define    ID_AUTH        MAKE_ID('A','U','T','H')
  66. #define    ID_CHRS        MAKE_ID('C','H','R','S')
  67. #define    ID_Copyright    MAKE_ID('(','c',')',' ')
  68. #define    ID_CSET        MAKE_ID('C','S','E','T')
  69. #define    ID_FVER        MAKE_ID('F','V','E','R')
  70. #define    ID_NAME        MAKE_ID('N','A','M','E')
  71. #define ID_TEXT        MAKE_ID('T','E','X','T')
  72. #define ID_BODY        MAKE_ID('B','O','D','Y')
  73.  
  74.  
  75. /* Used to keep track of allocated IFFHandle, and whether file is
  76.  * clipboard or not, filename, copied chunks, etc.
  77.  * This structure is included in the beginning of every
  78.  * form-specific info structure used by the example modules.
  79.  */
  80. struct ParseInfo {
  81.     /* general parse.c related */
  82.     struct  IFFHandle *iff;        /* to be alloc'd with AllocIFF */
  83.     UBYTE    *filename;        /* current filename of this ui */
  84.     LONG    *propchks;        /* properties to get */
  85.     LONG    *collectchks;        /* properties to collect */
  86.     LONG    *stopchks;        /* stop on these (like BODY) */
  87.     BOOL    opened;            /* this iff has been opened */
  88.     BOOL    clipboard;        /* file is clipboard */
  89.     BOOL    hunt;            /* we are parsing a complex file */
  90.     BOOL    Reserved1;        /* must be zero for now */        
  91.  
  92.     /* for copychunks.c - for read/modify/write programs
  93.      * and programs that need to keep parsed chunk info
  94.      * around after closing file.
  95.      * Deallocated by freechunklist();
  96.      */
  97.     struct Chunk *copiedchunks;
  98.  
  99.     /* application may hang its own list of new chunks here
  100.      * just to keep it with the frame.
  101.      */
  102.     struct Chunk *newchunks;
  103.  
  104.     ULONG    Reserved[8];
  105.     };
  106.  
  107.  
  108. /*
  109.  * Used by some modules to save or pass a singly linked list of chunks
  110.  */
  111. struct Chunk {
  112.     struct  Chunk *ch_Next;
  113.     long    ch_Type;
  114.     long    ch_ID;
  115.         long    ch_Size;
  116.         void    *ch_Data;
  117. };
  118.  
  119.  
  120. #ifndef NO_PROTOS
  121. /* parse.c */
  122. LONG openifile(struct ParseInfo *,UBYTE *,ULONG);
  123. void closeifile(struct ParseInfo *);
  124. LONG parseifile(struct ParseInfo *,
  125.         LONG, LONG, LONG *, LONG *, LONG *);
  126. LONG getcontext(struct IFFHandle *);
  127. LONG nextcontext(struct IFFHandle *);
  128. LONG currentchunkis(struct IFFHandle *, LONG type, LONG id);
  129. LONG contextis(struct IFFHandle *, LONG type, LONG id);
  130. UBYTE *findpropdata(struct IFFHandle *iff, LONG type, LONG id);
  131. void initiffasstdio(struct IFFHandle *);
  132. UBYTE *IFFerr(LONG);
  133. LONG chkcnt(LONG *);
  134. long PutCk(struct IFFHandle *iff, long id, long size, void *data);
  135.  
  136. /* copychunks.c */
  137. struct Chunk *copychunks(struct IFFHandle *iff,
  138.                  LONG *propchks, LONG *collectchks, ULONG memtype);
  139. void freechunklist(struct Chunk *first);
  140. struct Chunk *findchunk(struct Chunk *first, long type, long id);
  141. long writechunklist(struct IFFHandle *iff, struct Chunk *first);
  142. #endif /* NO_PROTOS */
  143.  
  144. #endif /* IFFP_IFF_H */
  145.