home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / text / tex / pastex / source / driver / util / iff / iff.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-06  |  5.0 KB  |  196 lines

  1. /* 
  2.  *
  3.  * iff.h:    General Definitions for IFFParse modules
  4.  *
  5.  * 10/20/91
  6.  * 39.5 - 11/92 - allow a conditional USE_AMIGA_IO define to cause
  7.  *   inclusion of Amiga-specific prototypes rather than standard C
  8.  *   stdlib.h and stdio.h (you must change makefile also - see notes below)
  9.  *   Added include of exec/libraries.h
  10.  */
  11.  
  12. #ifndef IFFP_IFF_H
  13. #define IFFP_IFF_H
  14.  
  15. #include "compiler.h"
  16.  
  17. #ifndef EXEC_TYPES_H
  18. #include <exec/types.h>
  19. #endif
  20. #ifndef EXEC_MEMORY_H
  21. #include <exec/memory.h>
  22. #endif
  23. #ifndef EXEC_LIBRARIES_H
  24. #include <exec/libraries.h>
  25. #endif
  26. #ifndef UTILITY_TAGITEM_H
  27. #include <utility/tagitem.h>
  28. #endif
  29. #ifndef UTILITY_HOOKS_H
  30. #include <utility/hooks.h>
  31. #endif
  32. #ifndef LIBRARIES_IFFPARSE_H
  33. #include <libraries/iffparse.h>
  34. #endif
  35.  
  36. #include <string.h>
  37.  
  38. /* If you define this, change your link to use Amiga startup code
  39.  * like astartup.obj, and to link with library amiga.lib first
  40.  */
  41. #ifdef USE_AMIGA_IO
  42. #include <clib/alib_stdio_protos.h>
  43. #else
  44. #include <stdio.h>
  45. #include <stdlib.h>
  46. #endif
  47.  
  48. #ifndef MYDEBUG_H
  49. #include "debug.h"
  50. #endif
  51.  
  52. #ifndef NO_PROTOS
  53. #include <clib/exec_protos.h>
  54. #include <clib/utility_protos.h>
  55. #include <clib/iffparse_protos.h>
  56. #endif
  57. #ifndef NO_SAS_PRAGMAS
  58. extern struct ExecBase *SysBase;
  59. #include <pragmas/exec_pragmas.h>
  60. extern struct Library *IFFParseBase;
  61. #include <pragmas/iffparse_pragmas.h>
  62. extern struct DosLibrary *DOSBase;
  63. #include <pragmas/dos_pragmas.h>
  64. #endif
  65.  
  66. #ifndef MAX
  67. #define    MAX(a,b)    ((a) > (b) ? (a) : (b))
  68. #endif
  69. #ifndef MIN
  70. #define    MIN(a,b)    ((a) < (b) ? (a) : (b))
  71. #endif
  72. #ifndef ABS
  73. #define    ABS(x)        ((x) < 0 ? -(x) : (x))
  74. #endif
  75.  
  76. /* Locale stuff */
  77. #if defined(I_DONT_NEED_THIS_LOCALE_STUFF)
  78.  
  79. #ifndef LOCALESTR_IFFP_H
  80. #define CATCOMP_NUMBERS
  81. #include "iffpstrings.h"
  82. #endif
  83.  
  84. #ifndef CATCOMP_ARRAY
  85. struct CatCompArrayType
  86. {
  87.     LONG   cca_ID;
  88.     STRPTR cca_Str;
  89. };
  90. extern struct  CatCompArrayType CatCompArray[];
  91. #endif
  92.  
  93. #define SI(i)  GetString(i)
  94.  
  95. #endif // I_DONT_NEED_....
  96.  
  97.  
  98. #define CkErr(expression)  {if (!error) error = (expression);}
  99. #define ChunkMoreBytes(cn)    (cn->cn_Size - cn->cn_Scan)
  100. #define IS_ODD(a)        (a & 1)
  101.  
  102. #define IFF_OKAY    0L
  103. #define    CLIENT_ERROR    1L
  104. #define NOFILE          5L
  105.  
  106. #define message printf
  107.  
  108. /* Generic Chunk ID's we may encounter */
  109. #define    ID_ANNO        MAKE_ID('A','N','N','O')
  110. #define    ID_AUTH        MAKE_ID('A','U','T','H')
  111. #define    ID_CHRS        MAKE_ID('C','H','R','S')
  112. #define    ID_Copyright    MAKE_ID('(','c',')',' ')
  113. #define    ID_CSET        MAKE_ID('C','S','E','T')
  114. #define    ID_FVER        MAKE_ID('F','V','E','R')
  115. #define    ID_NAME        MAKE_ID('N','A','M','E')
  116. #define ID_TEXT        MAKE_ID('T','E','X','T')
  117. #define ID_BODY        MAKE_ID('B','O','D','Y')
  118.  
  119.  
  120. /* Used to keep track of allocated IFFHandle, and whether file is
  121.  * clipboard or not, filename, copied chunks, etc.
  122.  * This structure is included in the beginning of every
  123.  * form-specific info structure used by the example modules.
  124.  */
  125. struct ParseInfo {
  126.     /* general parse.c related */
  127.     struct  IFFHandle *iff;        /* to be alloc'd with AllocIFF */
  128.     UBYTE    *filename;        /* current filename of this ui */
  129.     LONG    *propchks;        /* properties to get */
  130.     LONG    *collectchks;        /* properties to collect */
  131.     LONG    *stopchks;        /* stop on these (like BODY) */
  132.     BOOL    opened;            /* this iff has been opened */
  133.     BOOL    clipboard;        /* file is clipboard */
  134.     BOOL    hunt;            /* we are parsing a complex file */
  135.     BOOL    Reserved1;        /* must be zero for now */        
  136.  
  137.     /* for copychunks.c - for read/modify/write programs
  138.      * and programs that need to keep parsed chunk info
  139.      * around after closing file.
  140.      * Deallocated by freechunklist();
  141.      */
  142.     struct Chunk *copiedchunks;
  143.  
  144.     /* application may hang its own list of new chunks here
  145.      * just to keep it with the frame.
  146.      */
  147.     struct Chunk *newchunks;
  148.  
  149.     ULONG    Reserved[8];
  150.     };
  151.  
  152.  
  153. /*
  154.  * Used by some modules to save or pass a singly linked list of chunks
  155.  */
  156. struct Chunk {
  157.     struct  Chunk *ch_Next;
  158.     long    ch_Type;
  159.     long    ch_ID;
  160.         long    ch_Size;
  161.         void    *ch_Data;
  162. };
  163.  
  164.  
  165. #ifndef NO_PROTOS
  166. /* parse.c */
  167. LONG openifile(struct ParseInfo *pi,UBYTE *filename, ULONG iffopenmode);
  168. void closeifile(struct ParseInfo *pi);
  169. LONG parseifile(struct ParseInfo *pi,LONG groupid,LONG grouptype,
  170.     LONG *propchks,LONG *collectchks,LONG *stopchks);
  171. LONG getcontext(struct IFFHandle *iff);
  172. LONG nextcontext(struct IFFHandle *iff);
  173. LONG currentchunkis(struct IFFHandle *iff, LONG type, LONG id);
  174. LONG contextis(struct IFFHandle *iff, LONG type, LONG id);
  175. UBYTE *findpropdata(struct IFFHandle *iff, LONG type, LONG id);
  176. void initiffasstdio(struct IFFHandle *iff);
  177. LONG chkcnt(LONG *taggedarray);
  178. long PutCk(struct IFFHandle *iff, long id, long size, void *data);
  179.  
  180. /* iffpstrings.c */
  181. UBYTE *openScreenErr(ULONG errorcode);
  182. UBYTE *IFFerr(LONG error);
  183. void OpenStrings(void);
  184. void CloseStrings(void);
  185. UBYTE *GetString(ULONG id);
  186.  
  187. /* copychunks.c */
  188. struct Chunk *copychunks(struct IFFHandle *iff,
  189.                  LONG *propchks, LONG *collectchks, ULONG memtype);
  190. void freechunklist(struct Chunk *first);
  191. struct Chunk *findchunk(struct Chunk *first, long type, long id);
  192. long writechunklist(struct IFFHandle *iff, struct Chunk *first);
  193. #endif /* NO_PROTOS */
  194.  
  195. #endif /* IFFP_IFF_H */
  196.