/****************************************************************************************


		MCStatusCode.h

		Copyright: (c) 2001 Eovia Corp. All rights reserved.

		when		who			what & why
		==========	==========	======================================================
		10/17/99	Ian			Added some more resource errors.
		8/1/99		Greg		removed warning (on Mac at least)
		7/9/99		Ian			Added kFontError.

*****************************************************************************************/

#ifndef __MCSTATUSCODE__
#define __MCSTATUSCODE__

#include "MCBasicTypes.h"

//
//  MCCOMErrs are 32 bit values layed out as follows:
//
//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
//  +-+-----------------------------+-------------------------------+
//  |S|            Module           |           Code                |
//  +-+-----------------------------+-------------------------------+
//
//  where
//
//		S - success = 0; failure = 1
//
//      Module bits define the module that the error was generated in
//
//      Code - is the module's status code
//
			// MCCore module code = 0x0001 

			// MC Com Support module code = 0x0002 

			// MCF module code = 0x0003

			// MCImage module code = 0x0004

			// Muse module code = 0x0005

			// Kwak module code = 0x0006


//
// Severity values
//

#define MCSEVERITY_SUCCESS    0
#define MCSEVERITY_ERROR      1

//
// Generic test for success on any status value (non-negative numbers
// indicate success).
//

#define MCSUCCEEDED(__Status) ((long)(__Status) >= 0)

//
// and the inverse
//

#define MCFAILED(__Status) ((long)(__Status)<0)

//
// Generic test for error on any status value.
//

#define MCIS_ERROR(__Status) ((unsigned long)(__Status) >> 31 == MCSEVERITY_ERROR)

//
// Return the code
//
#define MCCOMERR_CODE(__COMErr)    ((__COMErr) & 0xFFFF)

//
//  Return the facility
//

#define MCCOMERR_MODULE(__COMErr)  (((__COMErr) >> 16) & 0x7fff)

//
//  Return the severity
//

#define MCCOMERR_SEVERITY(__COMErr)  (((__COMErr) >> 31) & 0x1)

//
// Create an HRESULT value from component pieces
//

#define MAKE_MCCOMErr(__severity, __facility, __code) \
	((MCErr) (((unsigned long)(__severity)<<31) | ((unsigned long)(__facility)<<16) | ((unsigned long)(__code))) )

// ---------------------- HRESULT value definitions -----------------
//
// MCCOMErr definitions
//

// Error codes

//  Unexpected failure
#define MC_E_UNEXPECTED                     0x8001FFFFL

//  Not implemented
#define MC_E_NOTIMPL                        0x80014001L

//  Ran out of memory
#define MC_E_OUTOFMEMORY                    0x8001000EL

//  One or more arguments are invalid
#define MC_E_INVALIDARG                     0x80010057L

//  No such interface supported
#define MC_E_NOINTERFACE                    0x80014002L

//  Invalid pointer
#define MC_E_POINTER                        0x80014003L

//  Invalid handle
#define MC_E_HANDLE                         0x80010006L

//  Operation aborted
#define MC_E_ABORT                          0x80014004L

//  Unspecified error
#define MC_E_FAIL                           0x80014005L

//  General access denied error
#define MC_E_ACCESSDENIED                   0x80010005L

//  The system cannot find the file specified.
#define MC_ERROR_FILE_NOT_FOUND             0x80010002L


//
//
// Success codes
//

#define MC_S_OK				(0x00000000L)
#define MC_S_FALSE			(0x00000001L)


//
//
// MCCore module code = 0x0001
//

#define MCCoreModule 0x0001
#define ExtensionModule 0x0002	// use this to define your own error codes

enum
{
	kNoErr					= MC_S_OK,
	kUnknownError			= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 1), //-1,
	kMemAllocError			= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 2), //-2,
	kCrashError				= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 4), //-4,
	kNilPointerError		= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 5), //-5,
	kNotImplementedError	= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 6), //-6,
	kDoubleDeleteError		= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 9), //-9,
	kOutOfRangeError		= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 10), //-10
	kUnmappedSystemError	= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 11),  //-11 //A call to a system function returned an error that couldn't be mapped to an MCCore error.
//	
//Arnaud: made a single enum because gcc wasn't happy comparing constants between the two
//};
//
//enum
//{
	kfontNotDeclared		= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 65), //-65,
	kFontError				= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 66),
	kmemFullErr				= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 108), //-108,
	kuserBreak				= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 490), //-490,
	kparamErr				= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 50), //-50,	
	//-- File errors:
	kdskFulErr				= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 34), //-34,	// Disk is full
	kioErr					= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 36), //-36,	// disk/io error
	kopenErr				= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 38), //-38,	// open error
	keofErr					= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 39), //-39,	// End of file error
	ktmfoErr				= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 42), //-42,	// too many files open
	kfnfErr					= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 43), //-43,	// file not found
	kfLckdErr				= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 45), //-45,	// file is locked
	kvLckdErr				= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 46), //-46,	// volume is locked
	kfBsyErr				= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 47), //-47,	// File is busy (delete)
	kopWrErr				= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 49), //-49,	// file already open with with write permission
	kvolOffLinErr			= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 53), //-53,	// volume not available (offline)
	kpermErr				= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 54), //-54,	// permissions error (on file open)
	knoAssocErr				= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 55), //-55,	// no application associated with file

	//-- Resource Errors
	kresNotFound			= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 192), //-192, // Resource not found
	kresAttrErr				= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 198), //-198, // attribute inconsistent with operation
	krmvResFailed			= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 196), //-196, // RemoveResource failed
	kaddResFailed			= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 194), //-194, // AddResource failed

	knoTypeErr				= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 102), //-102,	// No object of that type in scrap
	kuserCanceledErr 		= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 128), //-128,
	kAbortThreadException	= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 129),

	kErrRevertFNF			= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 30006), //-30006,    
	kErrFileChanged			= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 30007), //-30007,     
	kErrSaveAgain			= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 30008), //-30008,        
	kErrNotMyType			= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 30009), //-30009, 
	kErrNotImplemented		= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 30010), //-30010,
	kErrMissingClass		= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 30011), //-30011 
	kErrInvalidXML			= MAKE_MCCOMErr(MCSEVERITY_ERROR, MCCoreModule, 30012) //-30012 
 };

#endif