442 lines
21 KiB
C
442 lines
21 KiB
C
/* ##H_FILE#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
FILE : PrivErm.h
|
|
|
|
DESCRIPTION : Module : Error Manager (Erm)
|
|
This a private header file in witch there are all the traget(define) that
|
|
you can change as you like inside of the library.
|
|
Without any problem for the outside.
|
|
|
|
-> __STOP_ON_ERROR_RAISED__ : this define will open
|
|
a window in order to ask you if you want to stop and debug
|
|
-> __LOG_FILE_ERROR__ : write every error (independently of its type).
|
|
-> __ENABLE_DISPLAY_ERROR_WINDOW__ Display errors on the screen in a window
|
|
-> __TRACE_CLEAR__ : this define will open a information window for
|
|
every call of ClearLastError (if __ENABLE_DISPLAY_ERROR_WINDOW__ is defined)
|
|
|
|
CREATION DATE : 08/97
|
|
VERSION : 1.00/Crepy Pierrick/ Creation
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
/* ##CONSTANTE#--------------------------------------------------------------------------
|
|
Constantes declaration
|
|
---------------------------------------------------------------------------------------*/
|
|
|
|
/*this define will open a window in order to ask you if you want to stop and debug.*/
|
|
#define __STOP_ON_ERROR_RAISED__
|
|
|
|
/* write every error (independently of its type)*/
|
|
#define __LOG_FILE_ERROR__
|
|
|
|
/*Display errors on the screen in a window*/
|
|
#define __ENABLE_DISPLAY_ERROR_WINDOW__
|
|
|
|
/*this define will open a information window for every call of ClearLastError (if __ENABLE_DISPLAY_ERROR_WINDOW__ is defined)*/
|
|
/*#define __TRACE_CLEAR__*/
|
|
|
|
#if !defined(__DEBUG_ERROR__)
|
|
/* yes you can define __STOP_ON_ERROR_RAISED__ without __DEBUG_ERROR__ and _DEBUG*/
|
|
#undef __STOP_ON_ERROR_RAISED__
|
|
#endif /*!defined(__DEBUG_ERROR__)*/
|
|
|
|
#if !defined(__ERROR_STRINGS__)
|
|
#undef __LOG_FILE_ERROR__
|
|
/*Display errors on the screen in a window*/
|
|
#undef __ENABLE_DISPLAY_ERROR_WINDOW__
|
|
/*this define will open a information window for every call of ClearLastError (if __ENABLE_DISPLAY_ERROR_WINDOW__ is defined)*/
|
|
#undef __TRACE_CLEAR__
|
|
#endif /*!defined(__ERROR_STRINGS__)*/
|
|
|
|
#if !defined(_DEBUG)
|
|
/* yes you can define __STOP_ON_ERROR_RAISED__ without __DEBUG_ERROR__ and _DEBUG*/
|
|
#undef __STOP_ON_ERROR_RAISED__
|
|
/*#undef __LOG_FILE_ERROR__ */
|
|
/*Display errors on the screen in a window*/
|
|
#undef __ENABLE_DISPLAY_ERROR_WINDOW__
|
|
/*this define will open a information window for every call of ClearLastError (if __ENABLE_DISPLAY_ERROR_WINDOW__ is defined)*/
|
|
#undef __TRACE_CLEAR__
|
|
#endif /*!defined(_DEBUG)*/
|
|
|
|
|
|
/* macro definition*/
|
|
|
|
#ifdef __ENABLE_DISPLAY_ERROR_WINDOW__
|
|
|
|
/* ##M#===================================================================================
|
|
NAME : Erm_M_PrintInfoWindow version asm
|
|
DESCRIPTION : Print two string in a window
|
|
INPUT : string1 to print
|
|
string2 to print
|
|
=========================================================================================
|
|
CREATION : Crepy Pierrick
|
|
=======================================================================================*/
|
|
/*
|
|
#define Erm_M_PrintInfoWindow(szTxt1, szTxt2) \
|
|
{ \
|
|
char *szMyTxt; \
|
|
szMyTxt = Erm_fn_p_cGiveNewErrorString(); \
|
|
sprintf(szMyTxt, "%s\n%s\n", szTxt1, szTxt2); \
|
|
Erm_M_CheckLenOfTxtWithoutUpdate(szMyTxt); \
|
|
Erm_M_MessageBox(NULL, (LPCTSTR) szMyTxt, "Erm Information Window", MB_TOPMOST| MB_ICONEXCLAMATION | MB_OK);\
|
|
Erm_fn_vFreeErrorString(szMyTxt); \
|
|
}
|
|
*/
|
|
|
|
|
|
/*##M#===================================================================================
|
|
NAME : Erm_M_PrintInfoWindow version asm
|
|
DESCRIPTION : Print three string in a window
|
|
INPUT : string1 to print
|
|
string2 to print
|
|
string3 to print
|
|
=========================================================================================
|
|
CREATION : Crepy Pierrick
|
|
=======================================================================================*/
|
|
/*
|
|
#define Erm_M_PrintInfoWindowWithPersonalMsg(szTxt1, szTxt2, szTxt3) \
|
|
{ \
|
|
char *szMyTxt; \
|
|
szMyTxt=Erm_fn_p_cGiveNewErrorString(); \
|
|
szMyTxt [C_ucSizeOfErrTxt]; \
|
|
sprintf(szMyTxt, "%s\n%s\n%s\n", szTxt1, szTxt2, szTxt3); \
|
|
Erm_M_CheckLenOfTxtWithoutUpdate(szMyTxt); \
|
|
Erm_M_MessageBox(NULL, (LPCTSTR) szMyTxt, "Erm Information Window", MB_TOPMOST| MB_ICONEXCLAMATION | MB_OK);\
|
|
Erm_fn_vFreeErrorString(szMyTxt); \
|
|
}
|
|
*/
|
|
|
|
|
|
/* ##M#===================================================================================
|
|
NAME : Erm_M_PrintInfoWindow
|
|
DESCRIPTION : Print two string in a window
|
|
INPUT : string1 to print
|
|
string2 to print
|
|
=========================================================================================
|
|
CREATION : Crepy Pierrick
|
|
=======================================================================================*/
|
|
#define Erm_M_PrintInfoWindow(szTxt1, szTxt2) Erm_fn_PrintInfoWindow(szTxt1, szTxt2)
|
|
|
|
|
|
/* ##M#===================================================================================
|
|
NAME : Erm_M_PrintInfoWindowWithPersonalMsg
|
|
DESCRIPTION : Print three string in a window
|
|
INPUT : string1 to print
|
|
string2 to print
|
|
string3 to print
|
|
=========================================================================================
|
|
CREATION : Crepy Pierrick
|
|
=======================================================================================*/
|
|
#define Erm_M_PrintInfoWindowWithPersonalMsg(szTxt1, szTxt2, szTxt3) Erm_fn_PrintInfoWindowWithPersonalMsg(szTxt1, szTxt2, szTxt3)
|
|
|
|
#else /* no __ENABLE_DISPLAY_ERROR_WINDOW__*/
|
|
|
|
|
|
/* ##M#===================================================================================
|
|
NAME : Erm_M_PrintInfoWindow version no __ENABLE_DISPLAY_ERROR_WINDOW__
|
|
DESCRIPTION : Do nothing
|
|
INPUT : string1
|
|
string2
|
|
=========================================================================================
|
|
CREATION : Crepy Pierrick
|
|
=======================================================================================*/
|
|
#define Erm_M_PrintInfoWindow(szTxt1, szTxt2)
|
|
|
|
|
|
/* ##M#===================================================================================
|
|
NAME : Erm_M_PrintInfoWindowWithPersonalMsg version no __ENABLE_DISPLAY_ERROR_WINDOW__
|
|
DESCRIPTION : Do nothing
|
|
INPUT : string1
|
|
string2
|
|
string3
|
|
=========================================================================================
|
|
CREATION : Crepy Pierrick
|
|
=======================================================================================*/
|
|
#define Erm_M_PrintInfoWindowWithPersonalMsg(szTxt1, szTxt2, szTxt3)
|
|
#endif /*__ENABLE_DISPLAY_ERROR_WINDOW__*/
|
|
|
|
|
|
|
|
#ifdef __TRACE_CLEAR__
|
|
#ifdef __ENABLE_DISPLAY_ERROR_WINDOW__
|
|
|
|
/* ##M#===================================================================================
|
|
NAME : Erm_M_PrintTraceClearWindow version TRACE_CLEAR & ENABLE_DISPLAY_ERROR_WINDOW
|
|
DESCRIPTION : Message box with "request for clearance of the last error"
|
|
=========================================================================================
|
|
CREATION : Crepy Pierrick
|
|
=======================================================================================*/
|
|
#define Erm_M_PrintTraceClearWindow() \
|
|
{ \
|
|
Erm_fn_iMessageBox("Explicit request for clearance of the last error", "Erm Information Window", MB_TOPMOST| MB_ICONEXCLAMATION | MB_OK);\
|
|
}
|
|
|
|
/* ##M#===================================================================================
|
|
NAME : Erm_M_PrintTraceUnUsefullClearWindow version TRACE_CLEAR & ENABLE_DISPLAY_ERROR_WINDOW
|
|
DESCRIPTION : Message box with "request for clearance of all error"
|
|
=========================================================================================
|
|
CREATION : Crepy Pierrick
|
|
=======================================================================================*/
|
|
#define Erm_M_PrintTraceUnUsefullClearWindow() \
|
|
{ \
|
|
Erm_fn_iMessageBox("Explicit request for clearance of the last error\nBut there is no error !", "Erm Information Window", MB_TOPMOST| MB_ICONEXCLAMATION | MB_OK);\
|
|
}
|
|
|
|
#else /* no __ENABLE_DISPLAY_ERROR_WINDOW__ */
|
|
|
|
/* ##M#===================================================================================
|
|
NAME : Erm_M_PrintTraceClearWindow version TRACE_CLEAR & no ENABLE_DISPLAY_ERROR_WINDOW
|
|
DESCRIPTION : Do Nothing
|
|
=========================================================================================
|
|
CREATION : Crepy Pierrick
|
|
=======================================================================================*/
|
|
#define Erm_M_PrintTraceClearWindow()
|
|
|
|
|
|
/* ##M#===================================================================================
|
|
NAME : Erm_M_PrintTraceUnUsefullClearWindow version TRACE_CLEAR & no ENABLE_DISPLAY_ERROR_WINDOW
|
|
DESCRIPTION : Do nothing
|
|
=========================================================================================
|
|
CREATION : Crepy Pierrick
|
|
=======================================================================================*/
|
|
#define Erm_M_PrintTraceUnUsefullClearWindow()
|
|
|
|
#endif /*__ENABLE_DISPLAY_ERROR_WINDOW__*/
|
|
|
|
#else /*__TRACE_CLEAR__*/
|
|
|
|
/* ##M#===================================================================================
|
|
NAME : Erm_M_PrintTraceClearWindow version no TRACE_CLEAR & no ENABLE_DISPLAY_ERROR_WINDOW
|
|
DESCRIPTION : Do Nothing
|
|
=========================================================================================
|
|
CREATION : Crepy Pierrick
|
|
=======================================================================================*/
|
|
#define Erm_M_PrintTraceClearWindow()
|
|
|
|
|
|
/* ##M#===================================================================================
|
|
NAME : Erm_M_PrintTraceUnUsefullClearWindow version no TRACE_CLEAR & no ENABLE_DISPLAY_ERROR_WINDOW
|
|
DESCRIPTION : Do nothing
|
|
=========================================================================================
|
|
CREATION : Crepy Pierrick
|
|
=======================================================================================*/
|
|
#define Erm_M_PrintTraceUnUsefullClearWindow()
|
|
|
|
#endif /*__TRACE_CLEAR__*/
|
|
|
|
|
|
|
|
#ifdef __ENABLE_DISPLAY_ERROR_WINDOW__
|
|
#ifndef WATCOM
|
|
/* ##M#===================================================================================
|
|
NAME : Erm_M_StopForDebug version no WATCOM & ENABLE_DISPLAY_ERROR_WINDOW
|
|
DESCRIPTION : Allow stop for debug
|
|
INPUT : string
|
|
File Name
|
|
Line number
|
|
=========================================================================================
|
|
CREATION : Crepy Pierrick
|
|
=======================================================================================*/
|
|
#define Erm_M_StopForDebug(szTxt ,p_cFileName, uwLineNumber) \
|
|
{ \
|
|
char *szMyDbTxt; \
|
|
szMyDbTxt = Erm_fn_p_cGiveNewErrorString(); \
|
|
sprintf (szMyDbTxt, "%s\nStop in '%s' source file (line:%d).\nDo you want to stop for debug ?", szTxt ,p_cFileName, uwLineNumber);\
|
|
Erm_M_CheckLenOfTxtWithoutUpdate(szMyDbTxt); \
|
|
if (Erm_fn_iMessageBox(szMyDbTxt, "Erm Information Window", MB_TOPMOST| MB_ICONEXCLAMATION |MB_YESNO)==IDYES)\
|
|
{ \
|
|
__asm \
|
|
{ \
|
|
int 3h \
|
|
} \
|
|
} \
|
|
Erm_fn_vFreeErrorString(szMyDbTxt); \
|
|
}
|
|
|
|
#else /* WATCOM */
|
|
|
|
/* ##M#===================================================================================
|
|
NAME : Erm_M_StopForDebug version WATCOM & ENABLE_DISPLAY_ERROR_WINDOW
|
|
DESCRIPTION : Allow stop for debug
|
|
INPUT : string
|
|
File Name
|
|
Line number
|
|
=========================================================================================
|
|
CREATION : Crepy Pierrick
|
|
=======================================================================================*/
|
|
void Watcom_Interupt3h(void);
|
|
#pragma aux Watcom_Interupt3h = "int 0x03" value [eax] modify [eax];
|
|
|
|
#define Erm_M_StopForDebug(szTxt ,p_cFileName, uwLineNumber) \
|
|
{ \
|
|
char *szMyDbTxt; \
|
|
szMyDbTxt= Erm_fn_p_cGiveNewErrorString(); \
|
|
sprintf (szMyDbTxt, "%s\nStop in '%s' source file (line:%d).\nDo you want to stop for debug ?", szTxt, p_cFileName, uwLineNumber);\
|
|
Erm_M_CheckLenOfTxtWithoutUpdate(szMyDbTxt); \
|
|
if (Erm_fn_iMessageBox(szMyDbTxt, "Erm Information Window", MB_TOPMOST| MB_ICONEXCLAMATION |MB_YESNO)==IDYES)\
|
|
{ \
|
|
Watcom_Interupt3h();/*Interruption*/ \
|
|
} \
|
|
Erm_fn_vFreeErrorString(szMyDbTxt); \
|
|
}
|
|
#endif /* _VISUAL*/
|
|
|
|
#else /*__ENABLE_DISPLAY_ERROR_WINDOW__*/
|
|
|
|
/* ##M#===================================================================================
|
|
NAME : Erm_M_StopForDebug version no ENABLE_DISPLAY_ERROR_WINDOW
|
|
DESCRIPTION : Do nothing
|
|
INPUT : string
|
|
File Name
|
|
Line number
|
|
=========================================================================================
|
|
CREATION : Crepy Pierrick
|
|
=======================================================================================*/
|
|
#define Erm_M_StopForDebug(szTxt, p_cFileName, uwLineNumber)
|
|
#endif /*__ENABLE_DISPLAY_ERROR_WINDOW__*/
|
|
|
|
|
|
#ifdef __TRACE_CLEAR__
|
|
/* ##M#===================================================================================
|
|
NAME : Erm_M_StopForDebugForTraceClear version TRACE_CLEAR
|
|
DESCRIPTION : Do Stop for debug
|
|
INPUT : string
|
|
File Name
|
|
Line number
|
|
=========================================================================================
|
|
CREATION : Crepy Pierrick
|
|
=======================================================================================*/
|
|
#define Erm_M_StopForDebugForTraceClear(szTxt ,p_cFileName, uwLineNumber) Erm_M_StopForDebug(szTxt ,p_cFileName, uwLineNumber)
|
|
|
|
#else /*__TRACE_CLEAR__*/
|
|
|
|
/* ##M#===================================================================================
|
|
NAME : Erm_M_StopForDebugForTraceClear version no TRACE_CLEAR
|
|
DESCRIPTION : Do nothing
|
|
INPUT : string
|
|
File Name
|
|
Line number
|
|
=========================================================================================
|
|
CREATION : Crepy Pierrick
|
|
=======================================================================================*/
|
|
#define Erm_M_StopForDebugForTraceClear(szTxt ,p_cFileName, uwLineNumber)
|
|
|
|
#endif /*__TRACE_CLEAR__*/
|
|
|
|
|
|
|
|
#ifdef __ENABLE_DISPLAY_ERROR_WINDOW__
|
|
/* ##M#===================================================================================
|
|
NAME : Erm_M_CheckLenOfTxtWithoutUpdate version ENABLE_DISPLAY_ERROR_WINDOW
|
|
DESCRIPTION : Check lenght of text
|
|
INPUT : string
|
|
=========================================================================================
|
|
CREATION : Crepy Pierrick
|
|
=======================================================================================*/
|
|
/*this macro sould be use in the macro because Erm_M_CheckLenOfTxt use Erm_M_update and Erm_M_update have to test the overflow string*/
|
|
#define Erm_M_CheckLenOfTxtWithoutUpdate(szTxt) \
|
|
{ \
|
|
if (strlen(szTxt)>C_ucSizeOfErrTxt-1 /*-1 for the '\0'*/) \
|
|
{ \
|
|
Erm_fn_iMessageBox("The string for The Error message is too short, please change C_ucSizeOfErrTxt", "Erm Information Window", MB_TOPMOST| MB_ICONEXCLAMATION | MB_OK);\
|
|
Erm_fn_v_PrintErrMsg("Error in the Erm:","The string for The Error message is too short, please change C_ucSizeOfErrTxt");\
|
|
} \
|
|
}
|
|
#else /*__ENABLE_DISPLAY_ERROR_WINDOW__*/
|
|
/* ##M#===================================================================================
|
|
NAME : Erm_M_CheckLenOfTxtWithoutUpdate version no ENABLE_DISPLAY_ERROR_WINDOW
|
|
DESCRIPTION : Do nothing
|
|
INPUT : string
|
|
=========================================================================================
|
|
CREATION : Crepy Pierrick
|
|
=======================================================================================*/
|
|
#define Erm_M_CheckLenOfTxtWithoutUpdate(szTxt)
|
|
#endif /*__ENABLE_DISPLAY_ERROR_WINDOW__*/
|
|
|
|
|
|
#ifdef __STOP_ON_ERROR_RAISED__
|
|
/* ##M#===================================================================================
|
|
NAME : Erm_M_AnErrorWasRaised version STOP_ON_ERROR_RAISED
|
|
DESCRIPTION : Function an error was raised
|
|
=========================================================================================
|
|
CREATION : Crepy Pierrick
|
|
=======================================================================================*/
|
|
#define Erm_M_AnErrorWasRaised() Erm_fn_vAnErrorWasRaised ()
|
|
#else /*__STOP_ON_ERROR_RAISED__*/
|
|
/* ##M#===================================================================================
|
|
NAME : Erm_M_AnErrorWasRaised version no STOP_ON_ERROR_RAISED
|
|
DESCRIPTION : Do nothing
|
|
=========================================================================================
|
|
CREATION : Crepy Pierrick
|
|
=======================================================================================*/
|
|
#define Erm_M_AnErrorWasRaised()
|
|
#endif /*__STOP_ON_ERROR_RAISED__*/
|
|
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_Error_Exit
|
|
DESCRIPTION : Do an error was raised and exit
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
MODIFICATION : Carlos Torres 12/01/98 -> Call a callback before exit
|
|
=======================================================================================*/
|
|
#define Erm_M_Error_Exit(){ \
|
|
Erm_M_AnErrorWasRaised(); \
|
|
if(p_fn_ExitAppliCallBack) \
|
|
p_fn_ExitAppliCallBack(); \
|
|
exit(-1); \
|
|
}
|
|
|
|
/* ##FUNCDEF#----------------------------------------------------------------------------
|
|
Functions definition
|
|
---------------------------------------------------------------------------------------*/
|
|
/* prototype definition*/
|
|
#ifdef __STOP_ON_ERROR_RAISED__
|
|
/* ##F#===================================================================================
|
|
NAME : Erm_fn_vAnErrorWasRaised version STOP_ON_ERROR_RAISED
|
|
DESCRIPTION : Call when an error was raised
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
void Erm_fn_vAnErrorWasRaised(void);
|
|
#endif /*__STOP_ON_ERROR_RAISED__*/
|
|
|
|
|
|
|
|
#ifdef __ENABLE_DISPLAY_ERROR_WINDOW__
|
|
/* ##F#===================================================================================
|
|
NAME : Erm_fn_PrintInfoWindow version ENABLE_DISPLAY_ERROR_WINDOW
|
|
DESCRIPTION : Print Info in window
|
|
INPUT : string1 to print
|
|
string2 to print
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
void Erm_fn_PrintInfoWindow(char *,char *);
|
|
|
|
|
|
/* ##F#===================================================================================
|
|
NAME : Erm_fn_PrintInfoWindowWithPersonalMsg version ENABLE_DISPLAY_ERROR_WINDOW
|
|
DESCRIPTION : Print Info in window
|
|
INPUT : string1 to print
|
|
string2 to print
|
|
string3 to print
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
void Erm_fn_PrintInfoWindowWithPersonalMsg(char *,char *,char *);
|
|
|
|
#endif /*__ENABLE_DISPLAY_ERROR_WINDOW__*/
|
|
|
|
|
|
/* ##GLOBVAR#----------------------------------------------------------------------------
|
|
Globale variable declaration
|
|
---------------------------------------------------------------------------------------*/
|
|
|
|
/* Thread Id to request message box*/
|
|
#ifdef WIN32
|
|
extern HWND g_hWndHdl4Request;
|
|
#endif
|
|
|
|
/*CallBack de fermeture de l'appli */
|
|
extern void (*p_fn_ExitAppliCallBack)();
|
|
|
|
|