/* HRGTool Librarie Header File */
/* $Id$ */

#ifndef HRG_HRGTOOL_H
#define HRG_HRGTOOL_H

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

#ifndef DOS_DOS_H
#include <dos/dos.h>
#endif

#ifndef INTUITION_INTUITION_H
#include <intuition/intuition.h>
#endif

#ifndef WORKBENCH_STARTUP_H
#include <workbench/startup.h>
#endif

#define ERR_NOMEM -1
#define ERR_FAILED -2


#define HRCMQ_MAXLEN 3407820

#define HREX_ERROR	-1
#define HREX_ISFILE	1
#define HREX_ISDIR	2
#define HREX_NOTFOUND 0

#define hrDeleteExtNode(mp,nd) hrFreeVecPart(mp,nd)

/* Definition fuer die DoWildHook Daten */

#define DOWILD_CONTINUE 0	/* Kein Fehler, naechstes File suchen */
#define DOWILD_STOPDIR  1	/* Dieses Dir abbrechen */
#define DOWILD_BREAK		2	/* Alles abbrechen	*/

/* Definition fuer das (simple) Buffered FileIO */

struct HRBFile
{
	BPTR	file;
	UBYTE *buffer;
	ULONG buffsize;
	ULONG index;
	ULONG count;
	WORD	ungetchar;
};

#define HRBMODE_READ	1	/* Mehr gibt es noch nicht ;) */

/* Definition fuer hrOpenTimer()/hrCloseTimer() */

struct HRTimer
{
	struct timerequest *TimerIO;
	struct MsgPort *TimerMP;
	struct Message *TimerMSG;
};

/* Definition fuer hrParseToolType()/hrParseWBArgs() */

#define	HTAT_END				0
#define	HTAT_NUMBER			1
#define	HTAT_STRING			2
#define	HTAT_SWITCH			3
#define	HTAT_STRARRAY		4

struct	HTArgs
{
	ULONG		Type;
	STRPTR	ToolName;
	ULONG		Value;
};


struct	HRTOLibs
{
	struct	Library **LibBase;	/* Pointer to Var for Library Base */
	STRPTR	LibName;			/* Name of Library */
	ULONG		LibVersion;		/* Minimal VERSION (NULL don't cares) */
	ULONG		LibRevision;	/* Minimal REVISION (NULL don't cares) */
	ULONG		LibFlags;		/* Action on Open/Close of Library */
};

#define HROLF_ALERT		1	/* Use Alert to Show Open Error */
#define HROLF_INFORM		2	/* Use Inform Requester to show Open Error */
#define HROLF_SKIP		4	/* Skip the failed Library */
#define HROLF_REQUEST	8	/* Ask User by Requester to find Library */


/* Interne Strukturen (NON-PUBLIC) */

struct WndLock
{
	ULONG NestCount;
	struct Requester req;
};

struct HRResList
{
	struct Library **Libs;
	struct ResMPNode *First;
};

struct ResMPNode
{
	struct ResMPNode *Succ;
	struct ResMPNode *Pred;
	struct MemoryPool *mp;
};

struct MemBlock
{
	struct MemBlock *Succ;
	struct MemBlock *Pred;
	ULONG  MemType;
	ULONG  BytesUsed;
};

struct MemPart
{
	struct MemPart *Succ;
	struct MemPart *Pred;
	struct MemBlock *Block;
	ULONG  Size;
};

struct BlockList
{
	struct MemBlock *Head;
	struct MemBlock *Tail;
	struct MemBlock *TailPred;
};

struct PartList
{
	struct MemPart *Head;
	struct MemPart *Tail;
	struct MemPart *TailPred;
};

struct MemoryPool
{
	struct BlockList Blocks;
	struct PartList  Parts;
	ULONG  BlockSize;
};

#endif

