#ifndef	LIBRARIES_ERRORMSG_H
#define	LIBRARIES_ERRORMSG_H
/*
**	$Filename: libraries/errormsg.h $
**	$Release: 1 $
**	$Revision: 1.0 $
**
**	errormsg.library definitions
**
**	(C) Copyright 1994 Frédéric Delacroix
**	All Rights Reserved
*/

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

#ifndef	EXEC_LISTS_H
#include <exec/lists.h>
#endif

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

#ifndef	EXEC_SEMAPHORES_H
#include <exec/semaphores.h>
#endif

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

struct ErrorMsgBase {
   struct Library LibNode;
   ULONG emb_SegList;	/* pointer to seglist (PRIVATE) */

/* These remain valid as long as errormsg.library is open, they are readable
   by your application... */
   APTR emb_DOSBase;	/* pointer to DOSBase */
   APTR emb_IntuitionBase;	/* pointer to IntuitionBase */
   APTR emb_LocaleBase;	/* pointer to LocaleBase */
   APTR emb_UtilityBase;	/* pointer to UtilityBase */

/* This is private (subject to changes): */
   APTR emb_Locale;
   APTR emb_Catalog;
   struct SignalSemaphore emb_FaultSemaphore;
   struct MinList emb_FaultCache;
   UBYTE FaultBuffer[100];
};

/************************************************************************
* System ID values							*
*************************************************************************
These IDs are to be passed as the "System" argument: */

#define ERMSYS_INVALID	-1L	/* internal use */
#define ERMSYS_DOS	0L	/* messages from dos.library */
#define ERMSYS_EXEC	1L	/* messages from exec.library */
#define ERMSYS_GRAPHICS	2L	/* messages from graphics.library */
#define ERMSYS_INTUITION	3L	/* messages from intuition.library */
#define ERMSYS_IFFPARSE	4L	/* messages from iffparse.library */

#define ERMSYS_AUDIO	5L	/* messages from audio.device */
#define ERMSYS_GAMEPORT	6L	/* messages from gameport.device */
#define ERMSYS_NARRATOR	7L	/* messages from narrator.device */
#define ERMSYS_PARALLEL	8L	/* messages from parallel.device */
#define ERMSYS_PRINTER	9L	/* messages from printer.device */
#define ERMSYS_SCSIDISK	10L	/* messages from scsidisk.device */
#define ERMSYS_SERIAL	11L	/* messages from serial.device */
#define ERMSYS_TRACKDISK	12L	/* messages from trackdisk.device */
#define ERMSYS_CLIPBOARD	13L	/* etc... */
#define ERMSYS_CONSOLE	14L
#define ERMSYS_INPUT	15L
#define ERMSYS_KEYBOARD	16L
#define ERMSYS_TIMER	17L

#define	ERMSYS_AMIGAGUIDE	18L
#define	ERMSYS_ARP	19L
#define	ERMSYS_COMMODITIES	20L
#define	ERMSYS_ERRORMSG	21L	/* yes, we can diagnostic our own errors */
#define	ERMSYS_EXPANSION	22L
#define	ERMSYS_GADTOOLS	23L
#define	ERMSYS_POWERPACKER	24L
#define	ERMSYS_TRANSLATOR	25L
#define	ERMSYS_DATATYPES	26L
#define	ERMSYS_DISKFONT	27L

/************************************************************************
* Subsystem ID values							*
*************************************************************************
These values were chosen so that they look significant: they are equal
to _LVO offsets for libraries, and CMD_ for devices... It's probably
just as good to implement them as that in your program... A warning
however: some _LVO are not recognized (for example, ERMSUB_MatchFirst
is the same value as ERMSUB_IoErr).

Another note: they may be ignored for some systems... */
#define ERMSUB_Generic	0L	/* This is for systems that do not support
	specific subsystem values. Providing this will protect you from
	future changes... */

/* Values for ERMSYS_DOS: */
#define ERMSUB_IoErr	-132L	/* internally implemented as a cached */
#define ERMSUB_MatchFirst	ERMSUB_IoErr	/* call to Fault() */
#define ERMSUB_MatchNext	ERMSUB_IoErr	/* (value is _LVOIoErr) */
#define ERMSUB_Fault	ERMSUB_IoErr
#define	MIN_DOS_ERROR	100	/* Only these codes are supported, */
#define	MAX_DOS_ERROR	310	/* to prevent "Error code..." to be stored
				   in memory hundreds of times... */

/* Values for ERMSYS_EXEC:
for this value, you may pass the memory requirements (MEMF_...) as the
error code for a more precise message, or 0 for a standard out of mem.
ex: GetErrorMsg(ERMSYS_EXEC,ERMSUB_NoMemory,MEMF_CHIP!MEMF_CLEAR) will
return "Not enough CHIP memory" */
#define ERMSUB_NoMemory	-198L	/* (equals _LVOAllocMem) */

/* Values for ERMSYS_GRAPHICS:
note: these two are only usable as of V39 of the OS (Release 3.0) */
#define ERMSUB_MakeVPort	-216L	/* (equals _LVOMakeVPort) */
#define ERMSUB_MrgCop	-210L	/* (_LVOMrgCop) */

/* Values for ERMSYS_INTUITION:
note: returned through the SA_ErrorCode TagItem */
#define ERMSUB_OpenScreen	-198L	/* (_LVOOpenScreen) */
#define ERMSUB_OpenScreenTagList	ERMSUB_OpenScreen

/* Values for ERMSYS_COMMODITIES: */
#define	ERMSUB_CxBroker	-36L	/* (_LVOCxBroker) */
#define	ERMSUB_CxObjError	-66L	/* (_LVOCxObjError) */

/* No values are defined for the other systems yet, just provide
ERMSUB_Generic as the subsystem code. Note: narrator.device does not
use the standard error codes that are defined in exec/errors.h */

/***************************************************************************
* Errors that may be returned by errormsg.library itself (returned through *
* the EMT_Error tag):                                                      *
***************************************************************************/
#define	ERMERR_Unsupported_System	1L
#define	ERMERR_Unsupported_SubSystem	2L
#define	ERMERR_Unknown_Code	3L
#define	ERMERR_NoMemory	4L

/***************************************************************************
* Tag values                                                               *
***************************************************************************/
#define EMT_Dummy	TAG_USER

/* Tag values for GetErrorMsgA(): */

#define EMT_Error	EMT_Dummy+1
#define EMT_Length	EMT_Dummy+2
#define EMT_ForceCopy	EMT_Dummy+4

/* Tag values for DisplayMsgA(): */

#define EMT_Window	EMT_Dummy+20
#define EMT_Title	EMT_Dummy+21
#define EMT_GadFmt	EMT_Dummy+22
#define EMT_IDCMPPtr	EMT_Dummy+23

/**************************************************************************/
#define ErrorMsgName	"errormsg.library"

#endif
