

#ifndef AFC_IFFPARSER_H
#define AFC_IFFPARSER_H


/*  IFFParser.h  $ 19/05/97 FR $  */


#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif

#ifndef EXEC_LIBRARIES_H
#include <exec/libraries.h>
#endif

#ifndef LIBRARIES_IFFPARSE_H
#include <libraries/iffparse.h>
#endif


/* Version and revision */

#define IFFPARSER_VERSION  1L
#define IFFPARSER_REVISION 20L

/* Error codes */

#define IFFPARSER_BASE (ULONG)0x00080000L

#define IFFERR_NOMEMORY        (IFFPARSER_BASE + 0L)
#define IFFERR_IFFLIB          (IFFPARSER_BASE + 1L)
#define IFFERR_ALLOC           (IFFPARSER_BASE + 2L)
#define IFFERR_OPENSAVE        (IFFPARSER_BASE + 3L)
#define IFFERR_OPENIFF         (IFFPARSER_BASE + 4L)
#define IFFERR_INIT            (IFFPARSER_BASE + 5L)
#define IFFERR_PUSH            (IFFPARSER_BASE + 6L)
#define IFFERR_WRITECHUNKBYTES (IFFPARSER_BASE + 7L)
#define IFFERR_POP             (IFFPARSER_BASE + 8L)
#define IFFERR_OPENFILE        (IFFPARSER_BASE + 9L)
#define IFFERR_COLLECTION      (IFFPARSER_BASE + 10L)
#define IFFERR_EXIT            (IFFPARSER_BASE + 11L)


/* Function prototypes */

ULONG id(STRPTR);

/* Class prototype */

class iffparser
{
   public:

   iffparser(void);
   ~iffparser(void);
   void close(void);
   LONG save(STRPTR fname);
   LONG createchunk(ULONG type, ULONG id, ULONG size = IFFSIZE_UNKNOWN);
   LONG writechunk(STRPTR data, ULONG datalen);
   LONG closechunk(void);
   LONG load(STRPTR fname);
   LONG setscan(ULONG type, ULONG id);

/*
   Note: this function works differently from the AmigaE version:

         1 - It does not warns if open !=1
         2 - It returns 0 in case of error
*/

   APTR first(ULONG type, ULONG id);
   APTR addr(void);
   LONG size(void);

/* Note: see first() */

   APTR  succ(void);
   LONG  scan(void);
   LONG  getheader(STRPTR s, STRPTR fname);
   LONG  exit(ULONG type, ULONG id);
   LONG  version(BOOL rev = FALSE);
   ULONG error(void);
};


#endif


