251 lines
8.3 KiB
C
251 lines
8.3 KiB
C
#include "Erm/CpaError.h"
|
|
|
|
#include "..\PrivErm.h"
|
|
|
|
int Erm_fn_iMessageBox(char * _szText,char * _szTitle,unsigned int _uiStyle);
|
|
void Erm_fn_vSetWndHdl4Request(HWND hWin);
|
|
HWND Erm_fn_hGetWndHdl4Request();
|
|
void Erm_fn_vAnErrorWasRaised();
|
|
|
|
HWND g_hWndHdl4Request = C_hNoWindowTreatment;
|
|
|
|
/* ##F===================================================================================
|
|
NAME : Erm_fn_iMessageBox
|
|
DESCRIPTION : Display a message box sending
|
|
+ sending a message to the window application
|
|
+ or build a message box
|
|
INPUT : Text to display in the box
|
|
Title
|
|
Style (ex : MB_OK | MB_ICONSTOP )
|
|
OUTPUT : Result of the message box, depends on style
|
|
=========================================================================================
|
|
CREATION : Carlos Torres
|
|
=======================================================================================*/
|
|
int Erm_fn_iMessageBox(char * _szText,char * _szTitle,unsigned int _uiStyle) {
|
|
/* Send a display box request message*/
|
|
if (g_hWndHdl4Request != C_hNoWindowTreatment) {
|
|
tdstMsgBox stMsgBox;
|
|
|
|
stMsgBox.szText = _szText;
|
|
stMsgBox.szTitle = _szTitle;
|
|
stMsgBox.uiStyle = _uiStyle;
|
|
|
|
/* request the display of a message box + block until treatment of message*/
|
|
SendMessage(g_hWndHdl4Request,WM_MESSAGEBOX,C_uiWinCm_RequestMessageBox, (LPARAM)&stMsgBox);
|
|
|
|
return stMsgBox.iResult;
|
|
}
|
|
/* display a message box*/
|
|
else
|
|
return MessageBox(NULL,_szText,_szTitle,_uiStyle);
|
|
}
|
|
|
|
/* ##F===================================================================================
|
|
NAME : Erm_fn_vSetWndHdl4Request
|
|
DESCRIPTION : set Window Handle that receive the request
|
|
(it is used to send message for creating message box)
|
|
INPUT : Window Handle
|
|
=========================================================================================
|
|
LAST MODIFICATION : Carlos Torres / 04/12/1997
|
|
=======================================================================================*/
|
|
void Erm_fn_vSetWndHdl4Request(HWND hWin) {
|
|
g_hWndHdl4Request = hWin;
|
|
}
|
|
|
|
/* ##F===================================================================================
|
|
NAME : Erm_fn_hGetWndHdl4Request
|
|
DESCRIPTION : get window handle use for message box request
|
|
(it is used to send message for creating message box)
|
|
OUTPUT : Thread Id
|
|
=========================================================================================
|
|
LAST MODIFICATION : Carlos Torres / 04/12/1997
|
|
=======================================================================================*/
|
|
HWND Erm_fn_hGetWndHdl4Request() {
|
|
return g_hWndHdl4Request;
|
|
}
|
|
|
|
/* ##F#===================================================================================
|
|
NAME : Erm_fn_vAnErrorWasRaised
|
|
DESCRIPTION : Call when an error was raised
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
void Erm_fn_vAnErrorWasRaised()
|
|
{
|
|
#ifdef __STOP_ON_ERROR_RAISED__
|
|
#if defined(_DEBUG)
|
|
#ifdef __ENABLE_DISPLAY_ERROR_WINDOW__
|
|
if (Erm_fn_iMessageBox("Do you want to Debug ?", "Erm Information Window", MB_TOPMOST| MB_ICONEXCLAMATION |MB_YESNO)==IDYES)
|
|
#endif /*__ENABLE_DISPLAY_ERROR_WINDOW__*/
|
|
{
|
|
#ifndef WATCOM
|
|
__asm
|
|
{
|
|
int 3h
|
|
}
|
|
#else /* WATCOM*/
|
|
/*This management for Watcon is new since ERM V5.0.7*/
|
|
Watcom_Interupt3h();/*Interruption*/
|
|
#endif /*WATCOM*/
|
|
}
|
|
#endif /*_DEBUG*/
|
|
#endif /*__STOP_ON_ERROR_RAISED__*/
|
|
}/*Erm_fn_vAnErrorWasRaised*/
|
|
|
|
|
|
|
|
|
|
/* ##F#===================================================================================
|
|
NAME : Erm_fn_v_ClearLogFile
|
|
DESCRIPTION : Clear log file
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#ifndef _FIRE_DEADCODE_U64_
|
|
void Erm_fn_v_ClearLogFile()
|
|
{
|
|
#ifdef __LOG_FILE_ERROR__
|
|
FILE *hpErmLogFile;
|
|
DWORD dwError;
|
|
|
|
remove (C_szErrorLogFileName);/*lint !e534*/
|
|
hpErmLogFile = fopen( C_szErrorLogFileName, "w" );
|
|
#ifdef _DEBUG
|
|
dwError = GetLastError();
|
|
if ( dwError && dwError != ERROR_ALREADY_EXISTS)
|
|
{
|
|
LPVOID lpMsgBuf;
|
|
FormatMessage(
|
|
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
|
NULL,
|
|
GetLastError(),
|
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language*/
|
|
(LPTSTR) &lpMsgBuf,
|
|
0,
|
|
NULL
|
|
);/*lint !e534*/
|
|
|
|
/* Display the string.*/
|
|
Erm_fn_iMessageBox(lpMsgBuf, C_szErrorLogFileName, MB_OK|MB_ICONINFORMATION );
|
|
/* Free the buffer.*/
|
|
LocalFree( lpMsgBuf );
|
|
}
|
|
#endif /*_DEBUG*/
|
|
if (hpErmLogFile)
|
|
fclose(hpErmLogFile);
|
|
#endif /*__LOG_FILE_ERROR__*/
|
|
}/*Erm_fn_v_ClearLogFile*/
|
|
#endif /* _FIRE_DEADCODE_U64_ */
|
|
|
|
|
|
|
|
/* ##F#===================================================================================
|
|
NAME : Erm_fn_v_Printsz
|
|
DESCRIPTION : Print String in log file
|
|
INPUT : string to be print
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
void Erm_fn_v_Printsz(char *szTxt)
|
|
{
|
|
#if !defined(U64)
|
|
#ifdef __LOG_FILE_ERROR__
|
|
FILE *hpErmLogFile;
|
|
|
|
hpErmLogFile = fopen( C_szErrorLogFileName, "a" );
|
|
if (hpErmLogFile)
|
|
{
|
|
fprintf (hpErmLogFile, szTxt);
|
|
fclose(hpErmLogFile);
|
|
}
|
|
#endif /*__LOG_FILE_ERROR__*/
|
|
#else /* U64 */
|
|
M_PrintfN64((szTxt));
|
|
#endif /* U64 */
|
|
}/*lint !e715*/
|
|
|
|
|
|
|
|
/* ##F#===================================================================================
|
|
NAME : Erm_fn_v_PrintErrMsg
|
|
DESCRIPTION : Print Message in file log
|
|
INPUT : string1 to be print
|
|
string2 to be print
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
void Erm_fn_v_PrintErrMsg(char *p_cTxt1, char *p_cTxt2)
|
|
{
|
|
#ifdef __LOG_FILE_ERROR__
|
|
FILE *hpErmLogFile;
|
|
|
|
hpErmLogFile = fopen( C_szErrorLogFileName, "a" );
|
|
if (hpErmLogFile)
|
|
{
|
|
fprintf (hpErmLogFile, "%s%s\n\n", p_cTxt1, p_cTxt2);
|
|
fclose(hpErmLogFile);
|
|
}
|
|
#endif /*__LOG_FILE_ERROR__*/
|
|
}/*lint !e715*/
|
|
|
|
|
|
|
|
/* ##F#===================================================================================
|
|
NAME : Erm_fn_v_PrintErrMsgWithPersonalMsg
|
|
DESCRIPTION : Print Message in file log
|
|
INPUT : string1 to be print
|
|
string2 to be print
|
|
string3 to be print on a new line
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
void Erm_fn_v_PrintErrMsgWithPersonalMsg(char *p_cTxt1, char *p_cTxt2, char *p_cTxt3)
|
|
{
|
|
#ifdef __LOG_FILE_ERROR__
|
|
FILE *hpErmLogFile;
|
|
|
|
hpErmLogFile = fopen( C_szErrorLogFileName, "a" );
|
|
if (hpErmLogFile)
|
|
{
|
|
fprintf (hpErmLogFile, "%s%s\n%s\n\n", p_cTxt1, p_cTxt2, p_cTxt3);
|
|
fclose(hpErmLogFile);
|
|
}
|
|
#endif /*__LOG_FILE_ERROR__*/
|
|
}/*lint !e715*/
|
|
|
|
|
|
|
|
/* ##F#===================================================================================
|
|
NAME : Erm_fn_vPrintNameOfAllModules
|
|
DESCRIPTION : Print Name Of All Modules
|
|
INPUT : File name
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#ifndef _FIRE_DEADCODE_U64_
|
|
void Erm_fn_vPrintNameOfAllModules(char *szFileName)
|
|
{
|
|
#ifdef __LOG_FILE_ERROR__
|
|
unsigned char ucI;
|
|
char szModuleInfo[C_ucSizeOfModuleInformation];
|
|
FILE *hpErmLogFile;
|
|
|
|
hpErmLogFile = fopen( szFileName, "a" );
|
|
if (hpErmLogFile)
|
|
{
|
|
fprintf (hpErmLogFile, "\nList of all initialized modules:\n");
|
|
for (ucI=0; ucI<g_ucErmNbOfModule; ucI++)
|
|
{
|
|
Erm_M_GetModuleInformation (szModuleInfo, ucI);
|
|
fprintf (hpErmLogFile, "\t\\->%d\t:%s\n", ucI, szModuleInfo);/*the fprintf is not used with multiple parametrer because U64, then we use sprintf*/
|
|
}
|
|
fprintf (hpErmLogFile, "\n");
|
|
fclose(hpErmLogFile);
|
|
}
|
|
#endif /*__LOG_FILE_ERROR__*/
|
|
}
|
|
#endif /* _FIRE_DEADCODE_U64_ */
|
|
|
|
|
|
|