926 lines
41 KiB
C
926 lines
41 KiB
C
/* ##H_FILE#
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
FILE : CpaError.h
|
|
|
|
DESCRIPTION : Main functions of the ERM module
|
|
CREATION DATE : 08/96
|
|
VERSION : 1.00/Pierrick Crepy/ Creation
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
*/
|
|
#ifndef __CpaErrors_H__
|
|
#define __CpaErrors_H__
|
|
|
|
/* ##CONSTANTE#--------------------------------------------------------------------------
|
|
Constantes declaration
|
|
---------------------------------------------------------------------------------------*/
|
|
/* The format is XXX Va.b.c with Xxx is the Tag of the module */
|
|
#define C_szErmVersion "ERM V5.1.0"
|
|
/* the complete and clear name of the module */
|
|
#define C_szErmFullName "Error Manager"
|
|
/*The format is "Mmm dd yyyy".You can use __DATE__ but be careful that you have the control of the compilation*/
|
|
#define C_szErmDate "SEP 06 1997"
|
|
/* break the compatibility with the old syntax with the identification opf the module.*/
|
|
|
|
/* For DLLs who are using this module : */
|
|
#undef CPA_EXPORT
|
|
#if defined(CPA_WANTS_IMPORT)
|
|
#define CPA_EXPORT __declspec(dllimport)
|
|
#elif defined(CPA_WANTS_EXPORT)
|
|
#define CPA_EXPORT __declspec(dllexport)
|
|
#else
|
|
#define CPA_EXPORT
|
|
#endif
|
|
|
|
#define __MULTI_THREAD_ERROR_MANAGEMENT__
|
|
#ifndef FINAL_VERSION
|
|
#define __DEBUG_ERROR__
|
|
#endif /* FINAL_VERSION */
|
|
#ifndef U64
|
|
#define __ERROR_STRINGS__ /* allow to print a explaination texte of the error.*/
|
|
#endif /*u64*/
|
|
|
|
/* old place for the other general define */
|
|
#ifndef FINAL_VERSION
|
|
#define __FATAL_ERR_ERM__
|
|
#define __WARNING1_ERR_ERM__
|
|
#define __WARNING2_ERR_ERM__
|
|
#define __WARNING3_ERR_ERM__
|
|
#endif /* FINAL_VERSION */
|
|
|
|
|
|
/* ##INCLUDE#----------------------------------------------------------------------------
|
|
Includes Files
|
|
---------------------------------------------------------------------------------------*/
|
|
#ifdef WIN32
|
|
#include <stdio.h>
|
|
#ifdef __ERROR_STRINGS__
|
|
/*lint -save -e537 : Repeated include file*/
|
|
#include <string.h>
|
|
#include <windows.h>
|
|
/*lint -restore*/
|
|
#endif /*__ERROR_STRINGS__*/
|
|
#endif/*WIN32*/
|
|
|
|
#ifdef U64
|
|
#include "cpa_std.h"
|
|
#endif /* U64 */
|
|
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
/* ##TYPEDEF#----------------------------------------------------------------------------
|
|
Types definition ENUM
|
|
---------------------------------------------------------------------------------------*/
|
|
/* error of the Erm Module*/
|
|
typedef enum e_uwErmErrNumber_{
|
|
E_uwErmFatalErr,
|
|
#ifdef __FATAL_ERR_ERM__
|
|
/*----------------------*/
|
|
E_uwErmTooManyModulesErr,
|
|
E_uwErmStringErrTooLittle,
|
|
#endif /*__FATAL_ERR_ERM__*/
|
|
E_uwErmStartOfWarning,
|
|
#ifdef __WARNING1_ERR_ERM__
|
|
/*----------------------*/
|
|
E_uwErm_M_InitErrMsgCallAgain,
|
|
#endif /*__WARNING1_ERR_ERM__*/
|
|
#ifdef __WARNING2_ERR_ERM__
|
|
/*----------------------*/
|
|
#endif /*__WARNING2_ERR_ERM__*/
|
|
#ifdef __WARNING3_ERR_ERM__
|
|
/*----------------------*/
|
|
#endif /*__WARNING3_ERR_ERM__*/
|
|
E_uwErmErrNumber
|
|
}e_uwErmErrNumber;
|
|
|
|
/* ##CONSTANTE#--------------------------------------------------------------------------
|
|
Constantes declaration
|
|
---------------------------------------------------------------------------------------*/
|
|
/* no error*/
|
|
#define C_uwErmNoErr (0)
|
|
/*nb maximum of the managed module*/
|
|
/*XB*/
|
|
#ifndef U64
|
|
#define C_ucNbOfMaxModule (255)
|
|
#else /* !U64 */
|
|
#define C_ucNbOfMaxModule (15)
|
|
#endif /* !U64 */
|
|
/*End XB*/
|
|
/*size of a error string*/
|
|
#define C_ucSizeOfErrTxt (512)
|
|
#define C_uwNbOfErrTxtNeededAtTheSameTime (4)
|
|
/*size of the string for the result of Erm_M_GetModuleInformation*/
|
|
#define C_ucSizeOfModuleInformation (200)
|
|
#define C_ucErmOpenInfoWindow (0xFF)
|
|
#define C_ucErmNoOpenInfoWindow (0)
|
|
#define C_lErmNoDebugData (0xFFFFFFFF)
|
|
#define C_ucNeverStopForDebug (0)
|
|
#define C_ucAllowStopForDebug (0xFF)
|
|
#define C_ucErmDefaultChannel (0)
|
|
#ifdef __MULTI_THREAD_ERROR_MANAGEMENT__
|
|
#define C_ucErmNbOfErrorChannel (3)
|
|
#endif /*__MULTI_THREAD_ERROR_MANAGEMENT__*/
|
|
/*initial value of every module id*/
|
|
#define C_ucModuleNotInitialized (0xff)
|
|
/*name of the file used to print debug & statistic informtion*/
|
|
#define C_szErrorLogFileName "Error.log"
|
|
#define C_ucErmVersionAccessId 0
|
|
#define C_ucErmFullNameAccessId 1
|
|
#define C_ucErmDateAccessId 2
|
|
|
|
#ifdef WIN32
|
|
/* Message send to display Message Box*/
|
|
#define WM_MESSAGEBOX WM_USER
|
|
/* Param of the message WM_MESSAGEBOX*/
|
|
#define C_uiWinCm_RequestMessageBox 0x0024
|
|
#define C_hNoWindowTreatment 0
|
|
#endif
|
|
|
|
/* ##TYPEDEF#----------------------------------------------------------------------------
|
|
Types definition STRUCTURE
|
|
---------------------------------------------------------------------------------------*/
|
|
/* ##-########################### */
|
|
/* tdstErrorMsg;*/
|
|
/* ############################## */
|
|
#ifdef __ERROR_STRINGS__
|
|
typedef struct tdstErrorMsg_{
|
|
unsigned short uwErrorId;
|
|
char *szErrorText;
|
|
}tdstErrorMsg;
|
|
#endif /*__ERROR_STRINGS__*/
|
|
|
|
#ifdef WIN32
|
|
/* ##-########################### */
|
|
/* tdstMsgBox */
|
|
/* ############################## */
|
|
typedef struct tdstMsgBox_
|
|
{
|
|
char * szText;
|
|
char * szTitle;
|
|
unsigned int uiStyle;
|
|
int iResult;
|
|
} tdstMsgBox;
|
|
#endif
|
|
|
|
/* ##-########################### */
|
|
/* tdstLastErrorInfo;*/
|
|
/* ############################## */
|
|
typedef struct tdstLastErrorInfo_{
|
|
unsigned short uwLastErr;
|
|
unsigned char ucLastFailedModuleId;
|
|
#ifdef __DEBUG_ERROR__
|
|
long lDebugData;
|
|
#endif /*__DEBUG_ERROR__*/
|
|
#ifdef __MULTI_THREAD_ERROR_MANAGEMENT__
|
|
unsigned long ulChannelId;
|
|
#endif /*__MULTI_THREAD_ERROR_MANAGEMENT__*/
|
|
#ifdef __ERROR_STRINGS__
|
|
/*File name of the file raising the last error*/
|
|
char * szLastErrFileName;
|
|
/*Line in the File name of the file raising the last error*/
|
|
unsigned short uwLastErrLineNumber;
|
|
#endif /*__ERROR_STRINGS__*/
|
|
}tdstLastErrorInfo;
|
|
|
|
|
|
/* ##GLOBVAR#----------------------------------------------------------------------------
|
|
Globale variable declaration
|
|
---------------------------------------------------------------------------------------*/
|
|
#undef __CPAERROR_EXTERN
|
|
#ifndef __DeclareGlobalVariableInCpaError_h__
|
|
#define __CPAERROR_EXTERN extern /*external declaration*/
|
|
#else
|
|
#define __CPAERROR_EXTERN /*replace by nothing : we have to declare*/
|
|
#endif /*__DeclareGlobalVariableInCpaError_h__*/
|
|
|
|
/* ##-########################### */
|
|
/* g_ucErmModuleId*/
|
|
/* ############################## */
|
|
__CPAERROR_EXTERN CPA_EXPORT unsigned char g_ucErmModuleId /*number of identification of the Erm module*/
|
|
#if defined(__DeclareGlobalVariableInCpaError_h__) && !defined(CPA_WANTS_IMPORT)
|
|
= C_ucModuleNotInitialized
|
|
#endif /*__DeclareGlobalVariableInCpaError_h__*/
|
|
;
|
|
|
|
#ifdef __ERROR_STRINGS__
|
|
|
|
/* ##-########################### */
|
|
/* g_a_szErmInformationModule*/
|
|
/* ############################## */
|
|
__CPAERROR_EXTERN CPA_EXPORT char * g_a_szErmInformationModule []
|
|
#if defined(__DeclareGlobalVariableInCpaError_h__) && !defined(CPA_WANTS_IMPORT)
|
|
= {C_szErmVersion, C_szErmFullName, C_szErmDate}
|
|
#endif /*__DeclareGlobalVariableInCpaError_h__*/
|
|
;
|
|
|
|
/* ##-########################### */
|
|
/* g_a_stErmTabErr*/
|
|
/* ############################## */
|
|
__CPAERROR_EXTERN CPA_EXPORT struct tdstErrorMsg_ g_a_stErmTabErr [] /* Obliged syntax 'a_sz'+[Abbreviation of ModuleName]+'TabErr'*/
|
|
#if defined(__DeclareGlobalVariableInCpaError_h__) && !defined(CPA_WANTS_IMPORT)
|
|
={
|
|
#ifdef __FATAL_ERR_ERM__
|
|
/*----------------------------*/
|
|
E_uwErmTooManyModulesErr,"There are too many Modules (>255)",
|
|
E_uwErmStringErrTooLittle,"The string variable for The Error message is too short, please change C_ucSizeOfErrTxt",
|
|
#endif /*__FATAL_ERR_ERM__*/
|
|
#ifdef __WARNING1_ERR_ERM__
|
|
/*----------------------------*/
|
|
E_uwErm_M_InitErrMsgCallAgain, "Erm_M_InitErrMsg was called for a module already initialized",
|
|
#endif /*__WARNING1_ERR_ERM__*/
|
|
#ifdef __WARNING2_ERR_ERM__
|
|
/*----------------------------*/
|
|
#endif /*__WARNING2_ERR_ERM__*/
|
|
#ifdef __WARNING3_ERR_ERM__
|
|
/*----------------------------*/
|
|
#endif /*__WARNING3_ERR_ERM__*/
|
|
0xFFFF, "\0"/*fin*/
|
|
}
|
|
#endif /*__DeclareGlobalVariableInCpaError_h__*/
|
|
;
|
|
|
|
#endif /*__ERROR_STRINGS__*/
|
|
|
|
|
|
/*Interne general informations*/
|
|
|
|
/* ##-########################### */
|
|
/* g_ucErmNbOfModule*/
|
|
/* ############################## */
|
|
__CPAERROR_EXTERN unsigned char g_ucErmNbOfModule
|
|
#if defined(__DeclareGlobalVariableInCpaError_h__) && !defined(CPA_WANTS_IMPORT)
|
|
=0
|
|
#endif /*defined(__DeclareGlobalVariableInCpaError_h__) && !defined(CPA_WANTS_IMPORT)*/
|
|
;
|
|
|
|
#ifdef __ERROR_STRINGS__
|
|
/* ##-################################ */
|
|
/* g_a_a_szErmModuleInformationTab*/
|
|
/* ################################### */
|
|
__CPAERROR_EXTERN char * * g_a_a_szErmModuleInformationTab [C_ucNbOfMaxModule];
|
|
#endif /*__ERROR_STRINGS__*/
|
|
|
|
|
|
#ifdef __DeclareGlobalVariableInCpaError_h__
|
|
#ifdef __ERROR_STRINGS__
|
|
/* ##-########################### */
|
|
/* g_a_p_stErmGeneralTabErr*/
|
|
/* ############################## */
|
|
tdstErrorMsg * g_a_p_stErmGeneralTabErr [C_ucNbOfMaxModule];
|
|
#endif /*__ERROR_STRINGS__*/
|
|
#endif /*__DeclareGlobalVariableInCpaError_h__*/
|
|
|
|
#ifdef __MULTI_THREAD_ERROR_MANAGEMENT__
|
|
__CPAERROR_EXTERN tdstLastErrorInfo g_stErmTheLastErrorInfo [C_ucErmNbOfErrorChannel];
|
|
#else /* not __MULTI_THREAD_ERROR_MANAGEMENT__*/
|
|
__CPAERROR_EXTERN tdstLastErrorInfo g_stErmTheLastErrorInfo;
|
|
#endif /* __MULTI_THREAD_ERROR_MANAGEMENT__*/
|
|
|
|
|
|
|
|
/* ##MACRO#----------------------------------------------------------------------------
|
|
MACRO definition
|
|
---------------------------------------------------------------------------------------*/
|
|
|
|
#ifdef __ERROR_STRINGS__
|
|
/* */
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_GetModuleInformation version ERROR_STRINGS
|
|
DESCRIPTION : Get module information (sprintf)
|
|
C_ucSizeOfModuleInformation is usualy use for the size
|
|
of the szModuleFullName parameter
|
|
INPUT : Module full name
|
|
Module Id
|
|
OUTPUT Module full name
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_GetModuleInformation(szModuleFullName, ucModuleId) \
|
|
{ \
|
|
sprintf (szModuleFullName, "%s : '%s' of %s", \
|
|
g_a_a_szErmModuleInformationTab[ucModuleId][C_ucErmVersionAccessId], \
|
|
g_a_a_szErmModuleInformationTab[ucModuleId][C_ucErmFullNameAccessId], \
|
|
g_a_a_szErmModuleInformationTab[ucModuleId][C_ucErmDateAccessId]); \
|
|
}
|
|
#else /*__ERROR_STRINGS__*/
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_GetModuleInformation version NO ERROR_STRINGS
|
|
DESCRIPTION : Get module information (sprintf)
|
|
INPUT : Module full name
|
|
Module Id
|
|
OUTPUT Module full name = empty string
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_GetModuleInformation(szModuleFullName, ucModuleId) *((char *)szModuleFullName) ='\0'
|
|
#endif /*__ERROR_STRINGS__*/
|
|
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_ucGiveModuleId
|
|
DESCRIPTION : Give Module Id from module name
|
|
INPUT : Module name
|
|
OUTPUT : Module Id
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_ucGiveModuleId(ModuleName) (g_uc##ModuleName##ModuleId)
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_MessageBox
|
|
DESCRIPTION : C++ message box
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
/*#define Erm_M_MessageBox(P1, P2, P3, P4) ::MessageBox(P1, P2, P3, P4)*/
|
|
|
|
#else
|
|
|
|
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_MessageBox
|
|
DESCRIPTION : C message box
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
/*#define Erm_M_MessageBox(P1, P2, P3, P4) MessageBox(P1, P2, P3, P4)*/
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_lGetDebugData
|
|
DESCRIPTION : Get bug data
|
|
INPUT : Channel id
|
|
OUTPUT : debug data
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_lGetDebugData(ulChannelId) (Erm_M_p_stFindstMyLastErrorInfo(ulChannelId))->lDebugData
|
|
|
|
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_uwCheckError
|
|
DESCRIPTION : Function check error
|
|
INPUT : Module Name
|
|
Channel id
|
|
OUTPUT : Last error info
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_uwCheckError(ModuleName, ulChannelId) Erm_fn_uwCheckError(g_uc## ModuleName ##ModuleId, ulChannelId)
|
|
|
|
|
|
#ifdef __MULTI_THREAD_ERROR_MANAGEMENT__
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_p_stFindstMyLastErrorInfo version MULTI_THREAD_ERROR_MANAGEMENT
|
|
DESCRIPTION : Find structure last error info
|
|
INPUT : Channel Id
|
|
OUTPUT : Last error info structure
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_p_stFindstMyLastErrorInfo(ulChannelId) Erm_fn_p_stFindstMyLastErrorInfo(ulChannelId)
|
|
|
|
|
|
#else /* not __MULTI_THREAD_ERROR_MANAGEMENT__*/
|
|
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_p_stFindstMyLastErrorInfo version no MULTI_THREAD_ERROR_MANAGEMENT
|
|
DESCRIPTION : Find structure last error info
|
|
INPUT : Channel Id
|
|
OUTPUT : Last error info structure
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_p_stFindstMyLastErrorInfo(ulChannelId) (&g_stErmTheLastErrorInfo)
|
|
#endif /*__MULTI_THREAD_ERROR_MANAGEMENT__*/
|
|
|
|
|
|
#ifdef __MULTI_THREAD_ERROR_MANAGEMENT__
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_AffectUlChannelId version MULTI_THREAD_ERROR_MANAGEMENT
|
|
DESCRIPTION : Affect param1 with param2
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_AffectUlChannelId(A, B) ((A) = (B))
|
|
|
|
|
|
#else /* not __MULTI_THREAD_ERROR_MANAGEMENT__*/
|
|
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_AffectUlChannelId version no MULTI_THREAD_ERROR_MANAGEMENT
|
|
DESCRIPTION : Do nothing
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_AffectUlChannelId(A, B)
|
|
#endif /*__MULTI_THREAD_ERROR_MANAGEMENT__*/
|
|
|
|
|
|
#ifdef __DEBUG_ERROR__
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_DebugAffect version DEBUG_ERROR
|
|
DESCRIPTION : Affect param1 with param2
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_DebugAffect(A, B) ((A) = (B))
|
|
|
|
|
|
#else /* not __DEBUG_ERROR__*/
|
|
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_DebugAffect version no DEBUG_ERROR
|
|
DESCRIPTION : Do nothing
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_DebugAffect(A, B)
|
|
#endif /*__DEBUG_ERROR__*/
|
|
|
|
|
|
#ifdef __ERROR_STRINGS__
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_AffectLastErrorInfo version ERROR_STRINGS
|
|
DESCRIPTION : Affect last error info ( +affect string)
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_AffectLastErrorInfo(stMyLastErrorInfo, ModuleName, uwErrNum, ulMyChannelId, lMyDebugData, ucModuleId, p_cFileName, uwLineNumber)\
|
|
{ \
|
|
stMyLastErrorInfo.uwLastErr = (uwErrNum); \
|
|
stMyLastErrorInfo.ucLastFailedModuleId = (ucModuleId); \
|
|
Erm_M_DebugAffect(stMyLastErrorInfo.lDebugData, (long)lMyDebugData); \
|
|
Erm_M_AffectUlChannelId(stMyLastErrorInfo.ulChannelId, ulMyChannelId); \
|
|
stMyLastErrorInfo.szLastErrFileName = p_cFileName; \
|
|
stMyLastErrorInfo.uwLastErrLineNumber = uwLineNumber; \
|
|
}
|
|
|
|
|
|
#else /*no __ERROR_STRINGS__*/
|
|
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_AffectLastErrorInfo version no ERROR_STRINGS
|
|
DESCRIPTION : Affect last error info
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_AffectLastErrorInfo(stMyLastErrorInfo, ModuleName, uwErrNum, ulMyChannelId, lMyDebugData, ucModuleId, p_cFileName, uwLineNumber)\
|
|
{ \
|
|
stMyLastErrorInfo.uwLastErr = (uwErrNum); \
|
|
stMyLastErrorInfo.ucLastFailedModuleId = (ucModuleId); \
|
|
Erm_M_DebugAffect(stMyLastErrorInfo.lDebugData, (long)lMyDebugData); \
|
|
Erm_M_AffectUlChannelId(stMyLastErrorInfo.ulChannelId, ulMyChannelId); \
|
|
}
|
|
#endif /*__ERROR_STRINGS__*/
|
|
|
|
|
|
#ifdef __DEBUG_ERROR__
|
|
/* ##M===================================================================================
|
|
NAME : DebugIf version no DEBUG_ERROR
|
|
DESCRIPTION : macro using if
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define DebugIf(Condition, Action) \
|
|
if (Condition) { \
|
|
Action; \
|
|
}
|
|
|
|
|
|
#else /*__DEBUG_ERROR__*/
|
|
|
|
/* ##M===================================================================================
|
|
NAME : DebugIf version DEBUG_ERROR
|
|
DESCRIPTION : Do nothing
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define DebugIf(cond, action)
|
|
#endif /*__DEBUG_ERROR__*/
|
|
|
|
|
|
#ifdef __ERROR_STRINGS__
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_szGetLastErrorString version ERROR_STRINGS
|
|
DESCRIPTION : Get last error string
|
|
INPUT : one structure Last error info
|
|
OUTPUT : Error string
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_szGetLastErrorString(A) Erm_fn_szGetLastErrorString(&A)
|
|
|
|
|
|
#else /*__ERROR_STRINGS__ not defined*/
|
|
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_szGetLastErrorString version no ERROR_STRINGS
|
|
DESCRIPTION : Get last error string
|
|
INPUT : one structure Last error info
|
|
OUTPUT : Error string = ""
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_szGetLastErrorString(A) ""
|
|
#endif /*__ERROR_STRINGS__ */
|
|
|
|
|
|
#ifdef __ERROR_STRINGS__
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_PrintSeparationBegin version ERROR_STRINGS
|
|
DESCRIPTION : print /n and one line of=
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_PrintSeparationBegin() Erm_fn_v_Printsz ("\n=========================================================================================\n")
|
|
|
|
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_PrintSeparationEnd version ERROR_STRINGS
|
|
DESCRIPTION : one line of= and print /n
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_PrintSeparationEnd() Erm_fn_v_Printsz ("=========================================================================================\n\n")
|
|
|
|
|
|
#else /*__ERROR_STRINGS__ not defined*/
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_PrintLine version no ERROR_STRINGS
|
|
DESCRIPTION : do nothing
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_PrintLine()
|
|
|
|
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_PrintSeparationBegin version no ERROR_STRINGS
|
|
DESCRIPTION : do nothing
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_PrintSeparationBegin() /*do nothing*/
|
|
|
|
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_PrintSeparationEnd version no ERROR_STRINGS
|
|
DESCRIPTION : do nothing
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_PrintSeparationEnd() /*do nothing*/
|
|
#endif /*__ERROR_STRINGS__ */
|
|
|
|
|
|
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_UpdateLastError
|
|
DESCRIPTION : update last error
|
|
INPUT : Id of start of warnings
|
|
Module Id
|
|
Channel Id
|
|
Error number
|
|
Debug Data
|
|
Open Info Window flag
|
|
Stop For Debug flag
|
|
Personnal message
|
|
File Name
|
|
Line number
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
/* Oliv' */
|
|
#ifndef U64
|
|
#define Erm_M_UpdateLastError(ModuleName, ulChannelId, uwErrNum, lDebugData, ucOpenInfoWindow, ucStopForDebug, szPersonalMsg) \
|
|
Erm_fn_v_UpdateLastError((unsigned short)E_uw##ModuleName##StartOfWarning, (unsigned char)g_uc##ModuleName##ModuleId,\
|
|
ulChannelId, uwErrNum, lDebugData, ucOpenInfoWindow, ucStopForDebug, szPersonalMsg,\
|
|
__FILE__, __LINE__)
|
|
#else /* U64 */
|
|
#define Erm_M_UpdateLastError(ModuleName, ulChannelId, uwErrNum, lDebugData, ucOpenInfoWindow, ucStopForDebug, szPersonalMsg) \
|
|
Erm_fn_v_UpdateLastError((unsigned short)E_uw##ModuleName##StartOfWarning, (unsigned char)g_uc##ModuleName##ModuleId,\
|
|
ulChannelId, uwErrNum, lDebugData, ucOpenInfoWindow, ucStopForDebug, szPersonalMsg)
|
|
#endif /* U64 */
|
|
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_ClearLastError
|
|
DESCRIPTION : clear last error
|
|
INPUT : Channel Id
|
|
File Name
|
|
Line Number
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
/* Oliv' */
|
|
#ifndef U64
|
|
#define Erm_M_ClearLastError(ulMyChannelId) Erm_fn_ClearLastError(ulMyChannelId, __FILE__, __LINE__)
|
|
#else /* U64 */
|
|
#define Erm_M_ClearLastError(ulMyChannelId) Erm_fn_ClearLastError(ulMyChannelId)
|
|
#endif /* U64 */
|
|
|
|
/*check error*/
|
|
#ifdef __ERROR_STRINGS__
|
|
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_bIsInitErrMsgDoneYet version ERROR_STRINGS
|
|
DESCRIPTION : return TRUE If err message as been initialize
|
|
INPUT : module abreviation
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_bIsInitErrMsgDoneYet(ModuleAbreviation) \
|
|
(g_uc ## ModuleAbreviation ## ModuleId != C_ucModuleNotInitialized)
|
|
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_InitErrMsg version ERROR_STRINGS
|
|
DESCRIPTION : initialize erm message
|
|
INPUT : module abreviation
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_InitErrMsg(ModuleAbreviation) \
|
|
{ \
|
|
if (g_uc ## ModuleAbreviation ## ModuleId == C_ucModuleNotInitialized) \
|
|
g_uc ## ModuleAbreviation ## ModuleId = Erm_fn_ucInitErrMsg (g_a_sz ## ModuleAbreviation ## InformationModule, g_a_st ## ModuleAbreviation ##TabErr);\
|
|
else \
|
|
Erm_M_UpdateLastError (Erm, C_ucErmDefaultChannel, E_uwErm_M_InitErrMsgCallAgain, C_lErmNoDebugData, C_ucErmOpenInfoWindow, C_ucAllowStopForDebug, NULL);\
|
|
}
|
|
|
|
#else /* no ERROR_STRINGS */
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_InitErrMsg version no ERROR_STRINGS
|
|
DESCRIPTION : initialize erm message
|
|
INPUT : module abreviation
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
/*XB 16/02/99*/
|
|
#ifdef __WARNING1_ERR_ERM__
|
|
/*End XB*/
|
|
#define Erm_M_InitErrMsg(ModuleAbreviation) \
|
|
{ \
|
|
if (g_uc ## ModuleAbreviation ## ModuleId == C_ucModuleNotInitialized) \
|
|
g_uc ## ModuleAbreviation ## ModuleId = Erm_fn_ucInitErrMsg (); \
|
|
else \
|
|
Erm_M_UpdateLastError (Erm, C_ucErmDefaultChannel, E_uwErm_M_InitErrMsgCallAgain, C_lErmNoDebugData, C_ucErmOpenInfoWindow, C_ucNeverStopForDebug, NULL);\
|
|
}
|
|
/*XB 16/02/99*/
|
|
#else /* __WARNING1_ERR_ERM__ */
|
|
#define Erm_M_InitErrMsg(ModuleAbreviation) \
|
|
{ \
|
|
if (g_uc ## ModuleAbreviation ## ModuleId == C_ucModuleNotInitialized) \
|
|
g_uc ## ModuleAbreviation ## ModuleId = Erm_fn_ucInitErrMsg (); \
|
|
}
|
|
#endif /* __WARNING1_ERR_ERM__ */
|
|
/*End XB*/
|
|
#endif /*__ERROR_STRINGS__*/
|
|
|
|
|
|
#ifdef __FATAL_ERR_ERM__
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_CheckLenOfTxt version FATAL_ERR_ERM
|
|
DESCRIPTION : check lenght of a string
|
|
INPUT : string
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_CheckLenOfTxt(szTxt) \
|
|
{ \
|
|
if (strlen(szTxt)>C_ucSizeOfErrTxt-1 /*-1 for the '\0'*/){ \
|
|
Erm_M_UpdateLastError (Erm, C_ucErmDefaultChannel, E_uwErmStringErrTooLittle, C_lErmNoDebugData, C_ucErmOpenInfoWindow, C_ucAllowStopForDebug, NULL);\
|
|
} \
|
|
}
|
|
#else /*__FATAL_ERR_ERM__*/
|
|
/* ##M===================================================================================
|
|
NAME : Erm_M_CheckLenOfTxt version FATAL_ERR_ERM
|
|
DESCRIPTION : Do nothing
|
|
INPUT : string
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
#define Erm_M_CheckLenOfTxt(szTxt)
|
|
#endif /*__FATAL_ERR_ERM__*/
|
|
|
|
|
|
/* #########################################################*/
|
|
/**/
|
|
/* PROTOTYPES*/
|
|
/**/
|
|
/* #########################################################*/
|
|
#ifdef __ERROR_STRINGS__
|
|
/* ##F===================================================================================
|
|
NAME : Erm_fn_ucInitErrMsg version no ERROR_STRINGS
|
|
DESCRIPTION : Init error Message
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
unsigned char Erm_fn_ucInitErrMsg (char ** a_szModuleName, struct tdstErrorMsg_ * a_stTabErr);
|
|
|
|
#else /* no ERROR_STRINGS */
|
|
/* ##F===================================================================================
|
|
NAME : Erm_fn_ucInitErrMsg version no ERROR_STRINGS
|
|
DESCRIPTION : Init error Message
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
unsigned char Erm_fn_ucInitErrMsg ();
|
|
#endif /* __ERROR_STRINGS__ */
|
|
|
|
|
|
#ifdef __ERROR_STRINGS__
|
|
/* ##F===================================================================================
|
|
NAME : Erm_fn_szGetLastErrorString version ERROR_STRINGS
|
|
DESCRIPTION : Get last error string
|
|
INPUT : one structure Last error info
|
|
OUTPUT : Error string
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
extern CPA_EXPORT char * Erm_fn_szGetLastErrorString (struct tdstLastErrorInfo_ *p_stMyLastErrorInfo);
|
|
#endif /* no __ERROR_STRINGS__*/
|
|
|
|
|
|
/* ##F===================================================================================
|
|
NAME : Erm_fn_uwCheckError
|
|
DESCRIPTION : Check error
|
|
INPUT : Module Id
|
|
Channel Id
|
|
OUTPUT : Last error info
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
extern CPA_EXPORT unsigned short Erm_fn_uwCheckError(unsigned char ucModuleId, unsigned long ulChannelId);
|
|
|
|
|
|
#ifdef __MULTI_THREAD_ERROR_MANAGEMENT__
|
|
/* ##F===================================================================================
|
|
NAME : Erm_fn_p_stFindstMyLastErrorInfo
|
|
DESCRIPTION : Find structure ladt error info
|
|
INPUT : Channel Id
|
|
OUTPUT : Last error info structure
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
extern CPA_EXPORT tdstLastErrorInfo *Erm_fn_p_stFindstMyLastErrorInfo(unsigned long ulChannelId);
|
|
#endif /*__MULTI_THREAD_ERROR_MANAGEMENT__*/
|
|
|
|
/* ##F===================================================================================
|
|
NAME : Erm_fn_ClearLastError
|
|
DESCRIPTION : Clear last error
|
|
INPUT : Channel Id
|
|
File Name
|
|
Line Number
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
/* Oliv' */
|
|
#ifndef U64
|
|
extern CPA_EXPORT void Erm_fn_ClearLastError(unsigned long ulChannelId, char * p_cFileName, unsigned short uwLineNumber);
|
|
#else /* U64 */
|
|
extern CPA_EXPORT void Erm_fn_ClearLastError(unsigned long ulChannelId);
|
|
#endif /* U64 */
|
|
|
|
/* ##F===================================================================================
|
|
NAME : Erm_fn_v_ClearLogFile
|
|
DESCRIPTION : Clear log file
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
extern CPA_EXPORT void Erm_fn_v_ClearLogFile(void);
|
|
|
|
|
|
/* ##F===================================================================================
|
|
NAME : Erm_fn_v_Printsz
|
|
DESCRIPTION : Print String in log file
|
|
INPUT : string to be print
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
extern CPA_EXPORT void Erm_fn_v_Printsz(char *szTxt);
|
|
|
|
|
|
/* ##F===================================================================================
|
|
NAME : Erm_fn_v_PrintErrMsg
|
|
DESCRIPTION : Print Message in file log
|
|
INPUT : string1 to be print
|
|
string2 to be print
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
extern CPA_EXPORT void Erm_fn_v_PrintErrMsg(char *p_cTxt1, char *p_cTxt2);
|
|
|
|
|
|
/* ##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
|
|
=======================================================================================*/
|
|
extern CPA_EXPORT void Erm_fn_v_PrintErrMsgWithPersonalMsg(char *p_cTxt1, char *p_cTxt2, char *p_cTxt3);
|
|
|
|
|
|
/* ##F===================================================================================
|
|
NAME : Erm_fn_vPrintNameOfAllModules
|
|
DESCRIPTION : Print Name Of All Modules
|
|
INPUT : File name
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
extern CPA_EXPORT void Erm_fn_vPrintNameOfAllModules(char *szFileName);
|
|
|
|
|
|
/* ##F===================================================================================
|
|
NAME : Erm_fn_v_UpdateLastError
|
|
DESCRIPTION : Update Last Error
|
|
INPUT : Id of start of warnings
|
|
Module Id
|
|
Channel Id
|
|
Error number
|
|
Debug Data
|
|
Open Info Window flag
|
|
Stop For Debug flag
|
|
Personnal message
|
|
File Name
|
|
Line number
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
/* Oliv' */
|
|
#ifndef U64
|
|
extern CPA_EXPORT void Erm_fn_v_UpdateLastError(unsigned short uwStartOfWarningsId, unsigned char ucModuleId, unsigned long ulChannelId, unsigned short uwErrNum, long lDebugData, unsigned char ucOpenInfoWindow, unsigned char ucStopForDebug, char *szPersonalMsg, char * p_cFileName, unsigned short uwLineNumber);
|
|
#else /* U64 */
|
|
extern CPA_EXPORT void Erm_fn_v_UpdateLastError(unsigned short uwStartOfWarningsId, unsigned char ucModuleId, unsigned long ulChannelId, unsigned short uwErrNum, long lDebugData, unsigned char ucOpenInfoWindow, unsigned char ucStopForDebug, char *szPersonalMsg);
|
|
#endif /* U64 */
|
|
|
|
#ifdef WIN32
|
|
/* ##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
|
|
=======================================================================================*/
|
|
extern CPA_EXPORT void Erm_fn_vSetWndHdl4Request(HWND 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
|
|
=======================================================================================*/
|
|
extern CPA_EXPORT HWND Erm_fn_hGetWndHdl4Request();
|
|
|
|
/* ##F===================================================================================
|
|
NAME : Erm_fn_iMessageBox
|
|
DESCRIPTION : Display a message box
|
|
+ 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
|
|
=======================================================================================*/
|
|
extern CPA_EXPORT int Erm_fn_iMessageBox(char * _szText,char * _szTitle,unsigned int _uiStyle);
|
|
#endif
|
|
|
|
/* ##F===================================================================================
|
|
NAME : Erm_fn_vSetCallBackForExit
|
|
DESCRIPTION : Set the call back use before exit after an error occur
|
|
INPUT : Pointer on the callback
|
|
=========================================================================================
|
|
CREATION : Carlos Torres 12/01/98
|
|
=======================================================================================*/
|
|
void Erm_fn_vSetCallBackForExit(void (*_p_fn_ExitAppliCallBack)());
|
|
|
|
/* ##F#===================================================================================
|
|
NAME : Erm_fn_v_PrintModuleList
|
|
DESCRIPTION : Actually do nothimg
|
|
=========================================================================================
|
|
CREATION : Pierrick Crepy
|
|
=======================================================================================*/
|
|
void Erm_fn_v_PrintModuleList();
|
|
|
|
#ifdef __cplusplus
|
|
};
|
|
#endif /* __cplusplus */
|
|
|
|
#endif /*__CpaErrors_H__*/
|
|
|