// **************************************************************************
// **************************************************************************
// **************************************************************************
// **                                                                      **
// ** AIFFIO.H                                                      MODULE **
// **                                                                      **
// ** Stub functions to replace Win32's mmioXXX RIFF libraries.            **
// **                                                                      **
// ** Last modified : 17 Jun 1997 by John Brandwood                        **
// **                                                                      **
// **************************************************************************
// **************************************************************************
// **************************************************************************

#ifndef __AIFFIO_h
#define __AIFFIO_h

#ifndef __LFPTYPES_h
 #include "lfptypes.h"
#endif

//
// GLOBAL DATA STRUCTURES AND DEFINITIONS
//

#ifndef MMIOERR_BASE

#define MMIOERR_BASE                256
#define MMIOERR_FILENOTFOUND        (MMIOERR_BASE + 1)
#define MMIOERR_OUTOFMEMORY         (MMIOERR_BASE + 2)
#define MMIOERR_CANNOTOPEN          (MMIOERR_BASE + 3)
#define MMIOERR_CANNOTCLOSE         (MMIOERR_BASE + 4)
#define MMIOERR_CANNOTREAD          (MMIOERR_BASE + 5)
#define MMIOERR_CANNOTWRITE         (MMIOERR_BASE + 6)
#define MMIOERR_CANNOTSEEK          (MMIOERR_BASE + 7)
#define MMIOERR_CANNOTEXPAND        (MMIOERR_BASE + 8)
#define MMIOERR_CHUNKNOTFOUND       (MMIOERR_BASE + 9)
#define MMIOERR_UNBUFFERED          (MMIOERR_BASE + 10)
#define MMIOERR_PATHNOTFOUND        (MMIOERR_BASE + 11)
#define MMIOERR_ACCESSDENIED        (MMIOERR_BASE + 12)
#define MMIOERR_SHARINGVIOLATION    (MMIOERR_BASE + 13)
#define MMIOERR_NETWORKERROR        (MMIOERR_BASE + 14)
#define MMIOERR_TOOMANYOPENFILES    (MMIOERR_BASE + 15)
#define MMIOERR_INVALIDFILE         (MMIOERR_BASE + 16)

#define MMIO_RWMODE     0x00000003      // open file for reading/writing/both
#define MMIO_SHAREMODE  0x00000070      // file sharing mode number
#define MMIO_CREATE     0x00001000      // create new file (or truncate file)
#define MMIO_PARSE      0x00000100      // parse new file returning path
#define MMIO_DELETE     0x00000200      // create new file (or truncate file)
#define MMIO_EXIST      0x00004000      // checks for existence of file
#define MMIO_ALLOCBUF   0x00010000      // mmioOpen() should allocate a buffer
#define MMIO_GETTEMP    0x00020000      // mmioOpen() should retrieve temp name
#define MMIO_DIRTY      0x10000000      // I/O buffer is dirty
#define MMIO_READ       0x00000000      // open file for reading only
#define MMIO_WRITE      0x00000001      // open file for writing only
#define MMIO_READWRITE  0x00000002      // open file for reading and writing
#define MMIO_COMPAT     0x00000000      // compatibility mode
#define MMIO_EXCLUSIVE  0x00000010      // exclusive-access mode
#define MMIO_DENYWRITE  0x00000020      // deny writing to other processes
#define MMIO_DENYREAD   0x00000030      // deny reading to other processes
#define MMIO_DENYNONE   0x00000040      // deny nothing to other processes

#define MMIO_FHOPEN         0x0010      // mmioClose: keep file handle open
#define MMIO_EMPTYBUF       0x0010      // mmioFlush: empty the I/O buffer
#define MMIO_TOUPPER        0x0010      // mmioStringToFOURCC: to u-case
#define MMIO_FINDCHUNK      0x0010      // mmioDescend: find a chunk by ID
#define MMIO_FINDRIFF       0x0020      // mmioDescend: find a LIST chunk
#define MMIO_FINDLIST       0x0040      // mmioDescend: find a RIFF chunk
#define MMIO_CREATERIFF     0x0020      // mmioCreateChunk: make a LIST chunk
#define MMIO_CREATELIST     0x0040      // mmioCreateChunk: make a RIFF chunk

#ifndef SEEK_SET
#define SEEK_SET                 0      // seek to an absolute position
#define SEEK_CUR                 1      // seek relative to current position
#define SEEK_END                 2      // seek relative to end of file
#endif

#define mmioFOURCC(ch0, ch1, ch2, ch3) \
		((DWORD)(BYTE)(ch0)        |   \
		((DWORD)(BYTE)(ch1) <<  8) |   \
		((DWORD)(BYTE)(ch2) << 16) |   \
		((DWORD)(BYTE)(ch3) << 24 ))

#define FOURCC_RIFF     mmioFOURCC('R', 'I', 'F', 'F')
#define FOURCC_LIST     mmioFOURCC('L', 'I', 'S', 'T')

typedef UINT            MMRESULT;       // error return code, 0 means no error
typedef DWORD           FOURCC;         // a four character code
typedef	void *          HMMIO;          // a handle to an open file

typedef struct _MMCKINFO
	{
	FOURCC          ckid;               /// chunk ID
	DWORD           cksize;             /// chunk size
	FOURCC          fccType;            /// form type or list type
	DWORD           dwDataOffset;       /// offset of data portion of chunk
	DWORD           dwFlags;            /// flags used by MMIO functions
	} MMCKINFO;

#endif

#include "mmreg.h"

//
// GLOBAL VARIABLES
//

//
// GLOBAL FUNCTION PROTOTYPES
//

extern	HMMIO               aiffOpen                (
								LPSTR               pszFileName,
								void *              pmmioinfo,
								DWORD               fdwOpen);

extern	MMRESULT            aiffClose               (
								HMMIO               hmmio,
								UINT                fuClose);

extern	LONG                aiffSeek                (
								HMMIO               hmmio,
								LONG                lOffset,
								int                 iOrigin);

extern	LONG                aiffRead                (
								HMMIO               hmmio,
								char *              pch,
								LONG                cch);

extern	LONG                aiffWrite               (
								HMMIO               hmmio,
								const char *        pch,
								LONG                cch);

extern	MMRESULT            aiffDescend             (
								HMMIO               hmmio,
								MMCKINFO *          lpck,
								const MMCKINFO *    lpckParent,
								UINT                iFlags);

extern	MMRESULT            aiffAscend              (
								HMMIO               hmmio,
								MMCKINFO *          lpck,
								UINT                iFlags);

extern	MMRESULT            aiffCreateChunk         (
								HMMIO               hmmio,
								MMCKINFO *          lpck,
								UINT                iFlags);

//
// End of __AIFFIO_h
//

#endif



// **************************************************************************
// **************************************************************************
// **************************************************************************
//	END OF RIFFIO.H
// **************************************************************************
// **************************************************************************
// **************************************************************************