#ifndef LIBRARIES_DATAMASTER_H
#define LIBRARIES_DATAMASTER_H

/*
** $Filename: libraries/datamaster.h $
** $Release: 2.0 $
** $Revision: 2.0 $
**
** datamaster.library definitions
**
** (C) Copyright 1995-1997 Alexis Nasr, Dirk Stöcker
** All Rights Reserved
*/

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

#define DATAMASTERNAME  "datamaster.library"

/************************************************************************
*									*
* Headers of recognizers						*
*									*
* Recognizer files have a special ID in it's body. Set one of the	*
* following defines as the only one in it's own C source file and link	*
* the resulting object files as first to final file.			*
*									*
************************************************************************/

#define RECOHEADER	{0x70, 0xFF, 0x4E, 0x75, \
		 	 0x44, 0x41, 0x54, 0x41, 0x52, 0x45, 0x43, 0x4F}
#define RECOHEADER2	{0x44, 0x41, 0x54, 0x41, 0x52, 0x45, 0x43, 0x4F}

/************************************************************************
*									*
* Library base structure						*
*									*
************************************************************************/

struct DatamasterBase
{
  struct Library	dmb_LibNode;
  LONG	dmb_SegList;

  LONG	dmb_RecoAdr;    /* (internal) adr of array of recognizer segments. */
  WORD	dmb_RecoNb;     /* number of  recognizers */
  WORD	dmb_Flags;      /* see below */
  LONG	dmb_LockNest;   /* count of LockCbases.Can only modify prefs if it is ZERO...means no user NOW. */

  LONG	dmb_DosBase;
  LONG	dmb_UtilBase;
  LONG	dmb_ReqBase;    /* may be ZERO... */
  LONG	dmb_ResBase2;
  LONG	dmb_ResBase3;
};

/************************************************************************
*									*
* Flags for dmb_Flags							*
*									*
************************************************************************/

#define DMFLAGF_PrefsNow    (1<<0)  /* prefs are changing NOW!! please wait!!! */

/************************************************************************
*									*
* Tags for external Recognizer						*
*									*
* Tags marked with '*' ***MUST*** be present!				*
*									*
************************************************************************/

#define DMR_TagBase	(TAG_USER+0x444D) /* DataMaster Recognizer */

#define DMR_Check	   (DMR_TagBase+ 0) /* pointer to checkroutine */
#define DMR_Flags	   (DMR_TagBase+ 1) /* * see defs */
#define DMR_Name	   (DMR_TagBase+ 2) /* * THAT one is used,*NOT* filename,so don't change it in new versions of recognizer :) */
#define DMR_Descr	   (DMR_TagBase+ 3) /* $VER-like description (60 chars string max) */
#define DMR_Version	   (DMR_TagBase+ 4) /* recoversion: Ver<<16+Rev (high W=ver/low W=rev) */
#define DMR_DMVersion	   (DMR_TagBase+ 5) /* needed version of library */
#define DMR_Pattern	   (DMR_TagBase+ 6)
#define DMR_Pri		   (DMR_TagBase+ 7) /* PRI_xxx predefined values */
#define DMR_RecoNumber	   (DMR_TagBase+ 8) /* Obsolete
#define DMR_InitRoutine	   (DMR_TagBase+ 9) /* optional init routine (libs needed etc) */
#define DMR_ExitRoutine	   (DMR_TagBase+10) /* optional exit routine (libs needed etc) */

/* additions in version 2.0 */

#define DMR_HookName       	(DMR_TagBase+11) 
#define	DMR_Class	   	(DMR_TagBase+12)
#define DMR_SubTypesTable	(DMR_TagBase+13)
#define	DMR_CheckRoutineHook	(DMR_TagBase+14)


/************************************************************************
*									*
* Flag bits								*
*									*
* These are used for DMR_Flags tag and for TestFile/TestData Mode       *
*									*
************************************************************************/

#define RECOB_Internal		0  /* won't be Unloadseg'd ;-) */
#define RECOB_CheckPatt		1  /* means the PatternTag valid */
#define RECOB_CheckData		2  /* means the CheckTag valid */
#define RECOB_XPKLoad		3  /* used for TestFile */
#define RECOB_Disabled		4  /* NOT USED YET */
#define RECOB_GetName		5  /* (obsolete name)
#define RECOB_SubType		5  /* means DMR_Check() returns d0=string (& NOT d0=TRUE/FALSE) */
#define RECOB_Private		6
#define RECOB_DupString		7  /* used with GetName flag: means the string is ALLOCATED by the recognizer */
#define RECOB_PattPriority	8

#define RECOF_Internal		(1L<<0)
#define RECOF_CheckPatt		(1L<<1)
#define RECOF_CheckData		(1L<<2)
#define RECOF_XPKLoad		(1L<<3)
#define RECOF_Disabled		(1L<<4)
#define RECOF_GetName		(1L<<5)
#define RECOF_SubType		(1L<<5)
#define RECOF_Private		(1L<<6)
#define RECOF_DupString		(1L<<7)
#define RECOF_PattPriority	(1L<<8)


/************************************************************************
*									*
* priority definitions							*
*									*
************************************************************************/

#define PRI_FREQUENT		 10
#define PRI_SINGLE		  5
#define PRI_GROUPED		  1
#define PRI_GROUPEDSLOW		 -5
#define PRI_RARE		-10
#define PRI_HOOKNAME		-100


/************************************************************************
*									*
* Class bits (v2.0)							*
*									*
************************************************************************/

#define	DMCLASSB_UNKNOWN	0
#define	DMCLASSB_GRAPHICS	1
#define	DMCLASSB_ANIMATION	2
#define	DMCLASSB_MUSIC		3
#define	DMCLASSB_SAMPLE		4
#define	DMCLASSB_PACKED		5
#define	DMCLASSB_SYSTEM		6
#define	DMCLASSB_MISC		7
#define	DMCLASSB_LINK		8
#define	DMCLASSB_ASCII		9

#define	DMCLASSF_UNKNOWN	(1L<<0)
#define	DMCLASSF_GRAPHICS	(1L<<1)
#define	DMCLASSF_ANIMATION	(1L<<2)
#define	DMCLASSF_MUSIC		(1L<<3)
#define	DMCLASSF_SAMPLE		(1L<<4)
#define	DMCLASSF_PACKED		(1L<<5)
#define	DMCLASSF_SYSTEM		(1L<<6)
#define	DMCLASSF_MISC		(1L<<7)
#define	DMCLASSF_LINK		(1L<<8)
#define	DMCLASSF_ASCII		(1L<<9)

/************************************************************************
*									*
* RecoList structures							*
*									*
* WARNING!								*
* The RecoList structure has *changed*. It must ONLY be used now with	*
* dmQueryRecoListNew() and dmQueryRecoNamesNew().			*
* DO NOT USE the old corresponding functions!				*
* The SIZE of RecoList structure is not defined !			*
*									*
************************************************************************/

struct RecoList {	/* access ONLY rl_NumRecos & rl_RecoList array */
	ULONG	rl_OwnSize;
	UWORD	rl_NumRecos;	/* number of recognizers */
	APTR *	rl_RecoList;	/* array of addresses of names/recos */
};

/* old recolist (for internal compatibility. NEVER USE IT ANYMORE) */

struct RecoListOld { 
	UWORD	orl_NumRecos;
	APTR	orl_RecoList[128];
	ULONG	orl_Null;
};

/************************************************************************
*									*
* DM_Handle structure							*
*									*
* It is <<PRIVATE>> and WILL change in the future!			*
* You can only access the non-private fields.				*
*									*
************************************************************************/

struct DM_Handle {
	STRPTR	dmh_String;
	ULONG	dmh_Size;	/* PRIVATE */
	ULONG	dmh_OwnSize;	/* PRIVATE */
	STRPTR	dmh_SubType;	/* (v2.0) additional SubType string, if available. */
	ULONG	dmh_SubTypeSize;/* PRIVATE */
};

#endif  /* LIBRARIES_DATAMASTER_H */
