	IFND	LIBRARIES_ERRORMSG_I
LIBRARIES_ERRORMSG_I	SET	1
**
**	$Filename: libraries/errormsg.i $
**	$Revision: 4.01 $
**
**	errormsg.library definitions
**
**	(C) Copyright 1994 Frédéric Delacroix
**	All Rights Reserved
**

	IFND	EXEC_TYPES_I
	include	exec/types.i
	ENDC

	IFND	EXEC_LISTS_I
	include	exec/lists.i
	ENDC

	IFND	EXEC_LIBRARIES_I
	include	exec/libraries.i
	ENDC

	IFND	EXEC_SEMAPHORES_I
	include	exec/semaphores.i
	ENDC

	IFND	UTILITY_TAGITEM_I
	include	utility/tagitem.i
	ENDC

	STRUCTURE	ErrorMsgBase,LIB_SIZE
	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
	APTR	emb_RexxSysLibBase	; pointer to RexxSysLibBase (or NULL if
					; it couldn't be opened), new for V2.0
	APTR	emb_ExecBase	; pointer to ExecBase, new for V3.02

; This is private (subject to changes):
	APTR	emb_Locale
	APTR	emb_Catalog
	STRUCT	emb_FaultSemaphore,SS_SIZE
	STRUCT	emb_FaultCache,MLH_SIZE
	STRUCT	emb_FaultBuffer,100

	LABEL	emb_SIZEOF	; This one is none of your business :-)

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

ERMSYS_INVALID	EQU	-1	; internal use
ERMSYS_DOS	EQU	0	; messages from dos.library
ERMSYS_EXEC	EQU	1	; messages from exec.library
ERMSYS_GRAPHICS	EQU	2	; messages from graphics.library
ERMSYS_INTUITION	EQU	3	; messages from intuition.library
ERMSYS_IFFPARSE	EQU	4	; messages from iffparse.library

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

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

; new for V3:
ERMSYS_MUI	EQU	28

; new for V3.04:
ERMSYS_XFD	EQU	29

; new for V4.00:
ERMSYS_GADTOOLSBOX	EQU	30

; new for V4.01:
ERMSYS_GUIFRONT	EQU	31
ERMSYS_XPK	EQU	32

ERMSYS_LAST	EQU	ERMSYS_XPK	; (for now!)

*************************************************************************
* 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), some are recognized as a special
; case (like ERMSYS_MUI/ERMSUB_MUIAutoError).

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

; Values for ERMSYS_DOS:
; Special note: passing 0 as the error code when using ERMSYS_DOS/
; ERMSUB_IoErr will tell errormsg.library to get the error from IoErr()
; itself.

ERMSUB_IoErr	EQU	-132		; internally implemented as a cached
ERMSUB_MatchFirst	EQU	ERMSUB_IoErr	; call to Fault()
ERMSUB_MatchNext	EQU	ERMSUB_IoErr	; (value is _LVOIoErr)
ERMSUB_Fault	EQU	ERMSUB_IoErr

MIN_DOS_ERROR	EQU	100	; Only these codes are supported,
MAX_DOS_ERROR	EQU	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"
ERMSUB_NoMemory	EQU	-198	; (equals _LVOAllocMem)

; This value is new for V3.02. With ERMSYS_EXEC/ERMSUB_NoLibrary, you can
; alert the user when a library has failed to open. The Code parameter is
; a bit special then: it is a flag mask. By setting bits in this mask, you
; tell errormsg.library you wish to have a message with arguments (the library
; name and version) in it. See below for supported value, and for
; DisplayErrorMsgA() additionnal tag handling.
; This value can of course also be used for opening devices and resources.
; (You should not provide a version number for resources)
ERMSUB_NoLibrary	EQU	-552	; (equals _LVOOpenLibrary)


; Values for ERMSYS_GRAPHICS:
; note: these two are only usable as of V39 of the OS (Release 3.0)
ERMSUB_MakeVPort	EQU	-216	; (equals _LVOMakeVPort)
ERMSUB_MrgCop	EQU	-210	; (_LVOMrgCop)


; Values for ERMSYS_INTUITION:
; note: returned through the SA_ErrorCode TagItem
ERMSUB_OpenScreen	EQU	-198	; (_LVOOpenScreen)
ERMSUB_OpenScreenTagList	EQU	ERMSUB_OpenScreen


; Values for ERMSYS_COMMODITIES:
ERMSUB_CxBroker	EQU	-36	; (_LVOCxBroker)
ERMSUB_CxObjError	EQU	-66	; _LVOCxObjError


; New for V3: this subsystem ID is valid only for ERMSYS_MUI, providing it
; to GetErrorMsgA() and providing a pointer to the base of muimaster.library
; instead of a code in D0 will tell errormsg.library to call MUI_Error
; automagically. This base must be valid ! errormsg.library currently checks
; if the LN_NAME field points to the good name, but don't count on it as it
; can (and will if the library base is incorrect) cause (luckily harmless)
; Enforcer hits.
; If you provide the error code yourself, use ERMSUB_Generic instead.

ERMSUB_MUIAutoError	EQU	-66	; (_LVOMUI_Error)


; New for V4.00, values defined for ERMSYS_GADTOOLSBOX:

; Use this one for errors returned by GTX_LoadGUIA()
ERMSUB_LoadGUI	EQU	-264		; (_LVOGTX_LoadGUIA)

; This one is used to identify errors returned by the function
; SetupScreen() in the generated source:
ERMSUB_SetupScreen	EQU	1

; And this one for errors issued by the functions OpenxxxWindow():
ERMSUB_OpenAWindow	EQU	2


; Values for ERMSYS_GUIFRONT, new for V4.01:

; This is for error codes returned by GF_CreateGUIA() via the
; GUI_ExtendedError tag.
ERMSUB_CreateGUIA	EQU	-60	; (_LVOGF_CreateGUIA)


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


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


****************************************************************************
* Some flags                                                               *
****************************************************************************
; Tell GetErrorMsgA() (and thus DisplayErrorMsgA() too) to return a message
; with a place (%s) for the library name when ERMSYS_EXEC/ERMSUB_NoLibrary
; is used (the code argument is then a mask made of these flags).
	BITDEF	EXEC,NOLIB_USENAME,0

; Tell errormsg.library to return a message with a place (%ld) for the
; library version number when ERMSYS_EXEC/ERMSUB_NoLibrary is used. Secify
; only together with EXECF_NOLIB_USENAME (in the code argument too).
	BITDEF	EXEC,NOLIB_USEVERSION,1

; Like it says !
	BITDEF	EXEC,NOLIB_PRIVATE1,31


****************************************************************************
* Tag values                                                               *
****************************************************************************
EMT_Dummy	EQU	TAG_USER

; Tag Values for GetErrorMsgA():

EMT_Error	EQU	EMT_Dummy+1
EMT_Length	EQU	EMT_Dummy+2
EMT_ForceCopy	EQU	EMT_Dummy+4

; Tag values for DisplayMsgA():

EMT_Window	EQU	EMT_Dummy+20
EMT_Title	EQU	EMT_Dummy+21
EMT_GadFmt	EQU	EMT_Dummy+22
EMT_IDCMPPtr	EQU	EMT_Dummy+23

; new for V3.01: DisplayMessageA() (so DisplayErrorMsgA() too) can use
; MUI_RequestA() instead of EasyRequestArgs(). See autodocs for details.
EMT_MUIBase	EQU	EMT_Dummy+24
EMT_MUIAppObject	EQU	EMT_Dummy+25
EMT_MUIWinObject	EQU	EMT_Dummy+26

; new tags for DisplayErrorMsgA() in V3.02.
; these tag are only checked for ERMSYS_EXEC/ERMSUB_NoLibrary sys/subsystem
; pair, and only when using DisplayErrorMsgA(). If you use GetErrorMsgA()
; and then DisplayMessageA(), you must provide these arguments by hand. The
; tags are quite self-explanatory, they are described in the DisplayErrorMsgA()
; autodoc.
EMT_LibName	EQU	EMT_Dummy+40
EMT_LibVersion	EQU	EMT_Dummy+41

****************************************************************************
ERRORMSGNAME	MACRO
	dc.b	'errormsg.library',0	;beware ! lower-case !
	ENDM

	ENDC	; ERRORMSG_I
