// EdIRIAWd.cpp : implementation file
//

#include "stdafx.h"

#include "Defines.hpp"

#ifdef D_ED_IR_ACTIVE

#include "EdIRIAWd.hpp"
#include "EdIRDict.hpp"

#include "incSCR.h"
#include "ACP_base.h"
#include "incITF.h"
#include "incGam.h"
#include "incAI.h"

#include "ai_intf.hpp"	//for g_pclAIInterface

static CString							gs_csCurrentLanguage;

static const CString				gs_c_csMetaActionSectionName				=AI_ALL_METAACTIONS;
static const CString				gs_c_csMetaActionSubSectionName			=AI_ONE_METAACTION;
static CPA_EdIR_Dictionary	*gs_pclMetaActionDictionnary				=NULL;

static const CString				gs_c_csProcedureSectionName					=AI_ALL_PROCEDURES;
static const CString				gs_c_csProcedureSubSectionName			=AI_ONE_PROCEDURE;
static CPA_EdIR_Dictionary	*gs_pclProcedureDictionnary					=NULL;

static const CString				gs_c_csFunctionSectionName					=AI_ALL_FUNCTIONS;
static const CString				gs_c_csFunctionSubSectionName				=AI_ONE_FUNCTION;
static CPA_EdIR_Dictionary	*gs_pclFunctionDictionnary					=NULL;

static const CString				gs_c_csConditionSectionName					=AI_ALL_CONDITIONS;
static const CString				gs_c_csConditionSubSectionName			=AI_ONE_CONDITION;
static CPA_EdIR_Dictionary	*gs_pclConditionDictionnary					=NULL;

static const CString				gs_c_csKeyWordSectionName						=AI_ALL_KEYWORDS;
static const CString				gs_c_csKeyWordSubSectionName				=AI_ONE_KEYWORD;
static CPA_EdIR_Dictionary	*gs_pclKeyWordDictionnary						=NULL;

static const CString				gs_c_csFieldSectionName							=AI_ALL_FIELDS;
static const CString				gs_c_csFieldSubSectionName					=AI_ONE_FIELD;
static CPA_EdIR_Dictionary	*gs_pclFieldDictionnary							=NULL;

static const CString				gs_c_csDsgVarTypeSectionName				=AI_ALL_DSGVAR_TYPES;
static const CString				gs_c_csDsgVarTypeSubSectionName			=AI_ONE_DSGVAR_TYPE;
static CPA_EdIR_Dictionary	*gs_pclDsgVarTypeDictionnary				=NULL;

static const CString				gs_c_csDsgVarSaveTypeSectionName		=AI_ALL_DSGVAR_SAVE_TYPES;
static const CString				gs_c_csDsgVarSaveTypeSubSectionName	=AI_ONE_DSGVAR_SAVE_TYPE;
static CPA_EdIR_Dictionary	*gs_pclDsgVarSaveTypeDictionnary		=NULL;

static const CString				gs_c_csDsgVarInitTypeSectionName		=AI_ALL_DSGVAR_INIT_TYPES;
static const CString				gs_c_csDsgVarInitTypeSubSectionName	=AI_ONE_DSGVAR_INIT_TYPE;
static CPA_EdIR_Dictionary	*gs_pclDsgVarInitTypeDictionnary		=NULL;

typedef	long td_fn_lFindIdFromScriptName(char *);
typedef BOOL td_fn_bIdIsValid(long);

#ifndef M_MAKECHAR
#define M_MAKECHAR(a) ((char *)(LPCTSTR(a)))
#endif //M_MAKECHAR

#define M_REGISTER_CALLBACK(a,b)	SCR_fn_v_RdL0_RegisterCallback(M_MAKECHAR(a),(b),SCR_CRC_c_RdL0_ForSection);
#define M_ISALNUM(c)							(isalnum((c&255)) || (c)=='_')

#define C_NB_LANGUAGES						2

enum SCR_tde_Anl_ReturnValue_	fn_tdeCallBackLoadAllMetaActions(struct SCR_tdst_File_Description_ *,char *,char *[],enum SCR_tde_Anl_Action_);
enum SCR_tde_Anl_ReturnValue_	fn_tdeCallBackLoadOneMetaAction(struct SCR_tdst_File_Description_ *,char *,char *[],enum SCR_tde_Anl_Action_);

enum SCR_tde_Anl_ReturnValue_	fn_tdeCallBackLoadAllProcedures(struct SCR_tdst_File_Description_ *,char *,char *[],enum SCR_tde_Anl_Action_);
enum SCR_tde_Anl_ReturnValue_	fn_tdeCallBackLoadOneProcedure(struct SCR_tdst_File_Description_ *,char *,char *[],enum SCR_tde_Anl_Action_);

enum SCR_tde_Anl_ReturnValue_	fn_tdeCallBackLoadAllFunctions(struct SCR_tdst_File_Description_ *,char *,char *[],enum SCR_tde_Anl_Action_);
enum SCR_tde_Anl_ReturnValue_	fn_tdeCallBackLoadOneFunction(struct SCR_tdst_File_Description_ *,char *,char *[],enum SCR_tde_Anl_Action_);

enum SCR_tde_Anl_ReturnValue_	fn_tdeCallBackLoadAllConditions(struct SCR_tdst_File_Description_ *,char *,char *[],enum SCR_tde_Anl_Action_);
enum SCR_tde_Anl_ReturnValue_	fn_tdeCallBackLoadOneCondition(struct SCR_tdst_File_Description_ *,char *,char *[],enum SCR_tde_Anl_Action_);

enum SCR_tde_Anl_ReturnValue_	fn_tdeCallBackLoadAllKeyWords(struct SCR_tdst_File_Description_ *,char *,char *[],enum SCR_tde_Anl_Action_);
enum SCR_tde_Anl_ReturnValue_	fn_tdeCallBackLoadOneKeyWord(struct SCR_tdst_File_Description_ *,char *,char *[],enum SCR_tde_Anl_Action_);

enum SCR_tde_Anl_ReturnValue_	fn_tdeCallBackLoadAllFields(struct SCR_tdst_File_Description_ *,char *,char *[],enum SCR_tde_Anl_Action_);
enum SCR_tde_Anl_ReturnValue_	fn_tdeCallBackLoadOneField(struct SCR_tdst_File_Description_ *,char *,char *[],enum SCR_tde_Anl_Action_);

enum SCR_tde_Anl_ReturnValue_	fn_tdeCallBackLoadAllDsgVarTypes(struct SCR_tdst_File_Description_ *,char *,char *[],enum SCR_tde_Anl_Action_);
enum SCR_tde_Anl_ReturnValue_	fn_tdeCallBackLoadOneDsgVarType(struct SCR_tdst_File_Description_ *,char *,char *[],enum SCR_tde_Anl_Action_);

enum SCR_tde_Anl_ReturnValue_	fn_tdeCallBackLoadAllDsgVarSaveTypes(struct SCR_tdst_File_Description_ *,char *,char *[],enum SCR_tde_Anl_Action_);
enum SCR_tde_Anl_ReturnValue_	fn_tdeCallBackLoadOneDsgVarSaveType(struct SCR_tdst_File_Description_ *,char *,char *[],enum SCR_tde_Anl_Action_);

enum SCR_tde_Anl_ReturnValue_	fn_tdeCallBackLoadAllDsgVarInitTypes(struct SCR_tdst_File_Description_ *,char *,char *[],enum SCR_tde_Anl_Action_);
enum SCR_tde_Anl_ReturnValue_	fn_tdeCallBackLoadOneDsgVarInitType(struct SCR_tdst_File_Description_ *,char *,char *[],enum SCR_tde_Anl_Action_);

//ANNECY CB
CString	_gcsGlob_;
//END

/****************************************************************************/
void fn_vInitTranslation()
{
	//Gets Current Language
	gs_csCurrentLanguage=g_pclAIInterface->M_GetMainWorld()->GetInterface()->fn_csGetCurrentLanguage();

	//Registers callback
	M_REGISTER_CALLBACK(gs_c_csMetaActionSectionName,fn_tdeCallBackLoadAllMetaActions);
	M_REGISTER_CALLBACK(gs_c_csMetaActionSubSectionName,fn_tdeCallBackLoadOneMetaAction);

	M_REGISTER_CALLBACK(gs_c_csProcedureSectionName,fn_tdeCallBackLoadAllProcedures);
	M_REGISTER_CALLBACK(gs_c_csProcedureSubSectionName,fn_tdeCallBackLoadOneProcedure);

	M_REGISTER_CALLBACK(gs_c_csFunctionSectionName,fn_tdeCallBackLoadAllFunctions);
	M_REGISTER_CALLBACK(gs_c_csFunctionSubSectionName,fn_tdeCallBackLoadOneFunction);

	M_REGISTER_CALLBACK(gs_c_csConditionSectionName,fn_tdeCallBackLoadAllConditions);
	M_REGISTER_CALLBACK(gs_c_csConditionSubSectionName,fn_tdeCallBackLoadOneCondition);

	M_REGISTER_CALLBACK(gs_c_csKeyWordSectionName,fn_tdeCallBackLoadAllKeyWords);
	M_REGISTER_CALLBACK(gs_c_csKeyWordSubSectionName,fn_tdeCallBackLoadOneKeyWord);

	M_REGISTER_CALLBACK(gs_c_csFieldSectionName,fn_tdeCallBackLoadAllFields);
	M_REGISTER_CALLBACK(gs_c_csFieldSubSectionName,fn_tdeCallBackLoadOneField);

	M_REGISTER_CALLBACK(gs_c_csDsgVarTypeSectionName,fn_tdeCallBackLoadAllDsgVarTypes);
	M_REGISTER_CALLBACK(gs_c_csDsgVarTypeSubSectionName,fn_tdeCallBackLoadOneDsgVarType);

	M_REGISTER_CALLBACK(gs_c_csDsgVarSaveTypeSectionName,fn_tdeCallBackLoadAllDsgVarSaveTypes);
	M_REGISTER_CALLBACK(gs_c_csDsgVarSaveTypeSubSectionName,fn_tdeCallBackLoadOneDsgVarSaveType);

	M_REGISTER_CALLBACK(gs_c_csDsgVarInitTypeSectionName,fn_tdeCallBackLoadAllDsgVarInitTypes);
	M_REGISTER_CALLBACK(gs_c_csDsgVarInitTypeSubSectionName,fn_tdeCallBackLoadOneDsgVarInitType);

	fn_vWriteAILangue();

	//Analyses the script
	CString csFileName=AI_MULTI_LANGUAGE_SCRIPT;
		
	SCR_tdst_Cxt_Values *p_stValues ;
	p_stValues=SCR_fnp_st_RdL0_AnalyseSection(M_MAKECHAR(csFileName),SCR_CDF_uw_Anl_Normal);
}

/****************************************************************************/
//ANNECY CB
long fn_lGetIdFromEditorName(CPA_EdIR_Dictionary *pclDictionnnary,CString &csWord,CString &csLanguage)
//long fn_lGetIdFromEditorName(CPA_EdIR_Dictionary *pclDictionnnary,CString csWord,CString csLanguage)
//END
{
//ANNECY CB
//	CString	csLang;
//	if(csLanguage!="")
	if(((LPCSTR) csLanguage)[0] != '\0')
		return pclDictionnnary->m_fn_lGetId(csWord,csLanguage);
//		csLang=csLanguage;
//	else
//		csLang=gs_csCurrentLanguage;
//	return pclDictionnnary->m_fn_lGetId(csWord,csLang);
	return pclDictionnnary->m_fn_lGetId(csWord,gs_csCurrentLanguage);
//END ANNECY
}

/****************************************************************************/
CString fn_csGetEditorNameFromId(CPA_EdIR_Dictionary *pclDictionnnary,long lId,CString csLanguage)
{
	CString	csLang;
	if(csLanguage!="")
		csLang=csLanguage;
	else
		csLang=gs_csCurrentLanguage;

	return pclDictionnnary->m_fn_csGetWord(lId,csLang);
}

/****************************************************************************/
SCR_tde_Anl_ReturnValue fn_tdeCallBackLoadAllWords(CPA_EdIR_Dictionary **ppclDictionnnary,
																									 char *szPars[],
																									 SCR_tde_Anl_Action eType)
{
	if(eType==SCR_EA_Anl_BeginSection)
	{
		ASSERT(szPars[0]!=NULL);
		ASSERT(szPars[1]==NULL);

		(*ppclDictionnnary)=new CPA_EdIR_Dictionary(atoi(szPars[0]),C_NB_LANGUAGES);
	}

	return SCR_ERV_Anl_NormalReturn;
}

/****************************************************************************/
SCR_tde_Anl_ReturnValue fn_tdeCallBackLoadOneWord(CPA_EdIR_Dictionary						*pclDictionnnary,
																										td_fn_lFindIdFromScriptName	fn_lFindIdFromScriptName,
																										td_fn_bIdIsValid						fn_bIdIsValid,
																										char												*szAction,
																										char												*szPars[],
																										SCR_tde_Anl_Action					eType)
{
	static CString	csScriptName=C_INVALID_SCRIPTNAME;
	static long			lId=C_INVALID_ID;

	if(eType==SCR_EA_Anl_BeginSection)
	{
		csScriptName=szAction;
		lId=fn_lFindIdFromScriptName(szAction);

		ASSERT(M_SCRIPTNAME_IS_VALID(csScriptName));
		ASSERT(fn_bIdIsValid(lId));
	}
	else
	if(eType==SCR_EA_Anl_Entry)
	{
		ASSERT(szPars[0]!=NULL);
		ASSERT(szPars[1]==NULL);

		CString	csLanguage=szAction;
		CString	csName=szPars[0];
		pclDictionnnary->m_fn_vAddEntry(csScriptName,lId,csName,csLanguage);
	}
	else
	if(eType==SCR_EA_Anl_EndSection)
	{
		csScriptName=C_INVALID_SCRIPTNAME;
		lId=C_INVALID_ID;
	}

	return SCR_ERV_Anl_NormalReturn;
}

/*==========================================================================*/
/*===                                                                    ===*/
/*                      TRANSLATIONS                                        */
/*===                                                                    ===*/
/*==========================================================================*/

/****************************************************************************/
CString fn_csGetTranslation(CString csWord,CString csLanguage)
{
	CString	csLang;
	if(csLanguage!="")
		csLang=csLanguage;
	else
		csLang=gs_csCurrentLanguage;

	CString	csTranslatedWord;
	csTranslatedWord=gs_pclMetaActionDictionnary->m_fn_csTranslate(csWord,csLang);
	if(M_WORD_IS_INVALID(csTranslatedWord))
		csTranslatedWord=gs_pclProcedureDictionnary->m_fn_csTranslate(csWord,csLang);
	if(M_WORD_IS_INVALID(csTranslatedWord))
		csTranslatedWord=gs_pclFunctionDictionnary->m_fn_csTranslate(csWord,csLang);
	if(M_WORD_IS_INVALID(csTranslatedWord))
		csTranslatedWord=gs_pclConditionDictionnary->m_fn_csTranslate(csWord,csLang);
	if(M_WORD_IS_INVALID(csTranslatedWord))
		csTranslatedWord=gs_pclKeyWordDictionnary->m_fn_csTranslate(csWord,csLang);
	if(M_WORD_IS_INVALID(csTranslatedWord))
		csTranslatedWord=gs_pclFieldDictionnary->m_fn_csTranslate(csWord,csLang);
	if(M_WORD_IS_INVALID(csTranslatedWord))
		csTranslatedWord=gs_pclDsgVarTypeDictionnary->m_fn_csTranslate(csWord,csLang);
	if(M_WORD_IS_INVALID(csTranslatedWord))
		csTranslatedWord=gs_pclDsgVarSaveTypeDictionnary->m_fn_csTranslate(csWord,csLang);
	if(M_WORD_IS_INVALID(csTranslatedWord))
		csTranslatedWord=gs_pclDsgVarInitTypeDictionnary->m_fn_csTranslate(csWord,csLang);

	return csTranslatedWord;
}

/**********************************************************************************/
long fn_lDictSkipRightAlphaNumChar(CString csString,long lIndex)
{
	long	lResultIndex=lIndex;
	long	lStringLen=csString.GetLength();

	if(lIndex<lStringLen)
	{
		while(lResultIndex<=lStringLen-1 && M_ISALNUM(csString[int(lResultIndex)] & 255))
			lResultIndex++;
	}

	return lResultIndex;
}

/**********************************************************************************/
long fn_lDictSkipRightNonAlphaNumChar(CString csString,long lIndex)
{
	long	lResultIndex=lIndex;
	long	lStringLen=csString.GetLength();

	if(lIndex<lStringLen)
	{
		while(lResultIndex<=lStringLen-1 && !M_ISALNUM(csString[int(lResultIndex)] & 255))
			lResultIndex++;
	}

	return lResultIndex;
}

/*************************************************************************/
CString fn_csDictGetNextWord(CString csString,long &lIndex)
{
	long	lWordStartIndex=fn_lDictSkipRightNonAlphaNumChar(csString,lIndex);
	long	lWordEndIndex=fn_lDictSkipRightAlphaNumChar(csString,lWordStartIndex);

	lIndex=lWordEndIndex;

	return csString.Mid(lWordStartIndex,lWordEndIndex-lWordStartIndex);
}

/*************************************************************************/
CString fn_csDictGetNextNonWord(CString csString,long &lIndex)
{
	long	lWordStartIndex=lIndex;
	long	lWordEndIndex=fn_lDictSkipRightNonAlphaNumChar(csString,lIndex);

	lIndex=lWordEndIndex;

	return csString.Mid(lWordStartIndex,lWordEndIndex-lWordStartIndex);
}

/****************************************************************************/
CString fn_csTranslateText(CString csText,CString csLanguage)
{
	CString	csTranslation;

	long		lIndex=0;
	CString	csNonWord=fn_csDictGetNextNonWord(csText,lIndex);
	CString	csWord=fn_csDictGetNextWord(csText,lIndex);
	while(csWord!="")
	{
		csTranslation+=csNonWord;

		CString	csTranslatedWord=fn_csGetTranslation(csWord,csLanguage);
		if(M_WORD_IS_INVALID(csTranslatedWord))
			csTranslation+=csWord;
		else
			csTranslation+=csTranslatedWord;

		csNonWord=fn_csDictGetNextNonWord(csText,lIndex);
		csWord=fn_csDictGetNextWord(csText,lIndex);
	}

	if(csNonWord!="")
		csTranslation+=csNonWord;

	return csTranslation;
}

/*==========================================================================*/
/*===                                                                    ===*/
/*                      FAST TRANSLATIONS                                   */
/*===                                                                    ===*/
/*==========================================================================*/

/****************************************************************************/
CString fn_csGetFastTranslation(CString csWord)
{
	CString	csTranslatedWord;
	csTranslatedWord=gs_pclMetaActionDictionnary->m_fn_csFastTranslate(csWord);
	if(M_WORD_IS_INVALID(csTranslatedWord))
		csTranslatedWord=gs_pclProcedureDictionnary->m_fn_csFastTranslate(csWord);
	if(M_WORD_IS_INVALID(csTranslatedWord))
		csTranslatedWord=gs_pclFunctionDictionnary->m_fn_csFastTranslate(csWord);
	if(M_WORD_IS_INVALID(csTranslatedWord))
		csTranslatedWord=gs_pclConditionDictionnary->m_fn_csFastTranslate(csWord);
	if(M_WORD_IS_INVALID(csTranslatedWord))
		csTranslatedWord=gs_pclKeyWordDictionnary->m_fn_csFastTranslate(csWord);
	if(M_WORD_IS_INVALID(csTranslatedWord))
		csTranslatedWord=gs_pclFieldDictionnary->m_fn_csFastTranslate(csWord);
	if(M_WORD_IS_INVALID(csTranslatedWord))
		csTranslatedWord=gs_pclDsgVarTypeDictionnary->m_fn_csFastTranslate(csWord);
	if(M_WORD_IS_INVALID(csTranslatedWord))
		csTranslatedWord=gs_pclDsgVarSaveTypeDictionnary->m_fn_csFastTranslate(csWord);
	if(M_WORD_IS_INVALID(csTranslatedWord))
		csTranslatedWord=gs_pclDsgVarInitTypeDictionnary->m_fn_csFastTranslate(csWord);

	return csTranslatedWord;
}

/****************************************************************************/
void fn_vInitFastTranslation(CString csLanguage1,CString csLanguage2)
{
	gs_pclMetaActionDictionnary->m_fn_vInitFastTranslation(csLanguage1,csLanguage2);
	gs_pclProcedureDictionnary->m_fn_vInitFastTranslation(csLanguage1,csLanguage2);
	gs_pclFunctionDictionnary->m_fn_vInitFastTranslation(csLanguage1,csLanguage2);
	gs_pclConditionDictionnary->m_fn_vInitFastTranslation(csLanguage1,csLanguage2);
	gs_pclKeyWordDictionnary->m_fn_vInitFastTranslation(csLanguage1,csLanguage2);
	gs_pclFieldDictionnary->m_fn_vInitFastTranslation(csLanguage1,csLanguage2);
	gs_pclDsgVarTypeDictionnary->m_fn_vInitFastTranslation(csLanguage1,csLanguage2);
	gs_pclDsgVarSaveTypeDictionnary->m_fn_vInitFastTranslation(csLanguage1,csLanguage2);
	gs_pclDsgVarInitTypeDictionnary->m_fn_vInitFastTranslation(csLanguage1,csLanguage2);
}

/****************************************************************************/
CString fn_csFastTranslateText(CString csText,CString csLanguage1,CString csLanguage2)
{
	CString	csLang;
	if(csLanguage2!="")
		csLang=csLanguage2;
	else
		csLang=gs_csCurrentLanguage;

	//Init Fast Translation
	fn_vInitFastTranslation(csLanguage1,csLang);

	//Translate
	CString	csTranslation;

	long		lIndex=0;
	CString	csNonWord=fn_csDictGetNextNonWord(csText,lIndex);
	CString	csWord=fn_csDictGetNextWord(csText,lIndex);
	while(csWord!="")
	{
		csTranslation+=csNonWord;

		CString	csTranslatedWord=fn_csGetFastTranslation(csWord);
		if(M_WORD_IS_INVALID(csTranslatedWord))
			csTranslation+=csWord;
		else
			csTranslation+=csTranslatedWord;

		csNonWord=fn_csDictGetNextNonWord(csText,lIndex);
		csWord=fn_csDictGetNextWord(csText,lIndex);
	}

	if(csNonWord!="")
		csTranslation+=csNonWord;

	return csTranslation;
}

/*==========================================================================*/
/*===                                                                    ===*/
/*                      METAACTIONS                                         */
/*===                                                                    ===*/
/*==========================================================================*/

/****************************************************************************/
long fn_lGetNbMetaActions()
{
	return gs_pclMetaActionDictionnary->m_fn_lGetNbEntries();
}

/****************************************************************************/
//ANNECY CB
long fn_lGetMetaActionIdFromEditorName(CString &csWord,CString csLanguage)
//long fn_lGetMetaActionIdFromEditorName(CString csWord,CString csLanguage)
//END
{
	return fn_lGetIdFromEditorName(gs_pclMetaActionDictionnary,csWord,csLanguage);
}
//ANNECY CB
long fn_lGetMetaActionIdFromEditorName(char *csWord,CString csLanguage)
{
	_gcsGlob_ = csWord;
	return fn_lGetMetaActionIdFromEditorName(_gcsGlob_, csLanguage);
}
//END

/****************************************************************************/
CString fn_csGetMetaActionEditorNameFromId(long lId,CString csLanguage)
{
	return fn_csGetEditorNameFromId(gs_pclMetaActionDictionnary,lId,csLanguage);
}

/****************************************************************************/
SCR_tde_Anl_ReturnValue fn_tdeCallBackLoadAllMetaActions(SCR_tdst_File_Description *pfFile,
																												 char *szAction,
																												 char *szPars[],
																												 SCR_tde_Anl_Action eType)
{
	return fn_tdeCallBackLoadAllWords(&gs_pclMetaActionDictionnary,szPars,eType);
}

/****************************************************************************/
BOOL fn_bIsMetaActionIdValid(long lId)
{
	return M_IsMetaActionIdValid(lId);
}

/****************************************************************************/
SCR_tde_Anl_ReturnValue fn_tdeCallBackLoadOneMetaAction(SCR_tdst_File_Description *pfFile,
																												char *szAction,
																												char *szPars[],
																												SCR_tde_Anl_Action eType)
{
	return fn_tdeCallBackLoadOneWord(gs_pclMetaActionDictionnary,
																	 (td_fn_lFindIdFromScriptName *)fn_eFindMetaActionIdFromScriptName,
																	 fn_bIsMetaActionIdValid,
																	 szAction,szPars,eType);
}

/*==========================================================================*/
/*===                                                                    ===*/
/*                      PROCEDURE                                           */
/*===                                                                    ===*/
/*==========================================================================*/

/****************************************************************************/
long fn_lGetNbProcedures()
{
	return gs_pclProcedureDictionnary->m_fn_lGetNbEntries();
}

/****************************************************************************/
//ANNECY CB
long fn_lGetProcedureIdFromEditorName(CString &csWord,CString csLanguage)
//long fn_lGetProcedureIdFromEditorName(CString csWord,CString csLanguage)
//END
{
	return fn_lGetIdFromEditorName(gs_pclProcedureDictionnary,csWord,csLanguage);
}
//ANNECY CB
long fn_lGetProcedureIdFromEditorName(char *csWord,CString csLanguage)
{
	_gcsGlob_ = csWord;
	return fn_lGetProcedureIdFromEditorName(_gcsGlob_,csLanguage);
}
//END

CString fn_csGetProcedureEditorNameFromId(long lId,CString csLanguage)
{
	return fn_csGetEditorNameFromId(gs_pclProcedureDictionnary,lId,csLanguage);
}

/****************************************************************************/
SCR_tde_Anl_ReturnValue fn_tdeCallBackLoadAllProcedures(SCR_tdst_File_Description *pfFile,
																												char *szAction,
																												char *szPars[],
																												SCR_tde_Anl_Action eType)
{
	return fn_tdeCallBackLoadAllWords(&gs_pclProcedureDictionnary,szPars,eType);
}

/****************************************************************************/
BOOL fn_bIsProcedureIdValid(long lId)
{
	return M_IsProcedureIdValid(lId);
}

/****************************************************************************/
SCR_tde_Anl_ReturnValue fn_tdeCallBackLoadOneProcedure(SCR_tdst_File_Description *pfFile,
																											 char *szAction,
																											 char *szPars[],
																											 SCR_tde_Anl_Action eType)
{
	return fn_tdeCallBackLoadOneWord(gs_pclProcedureDictionnary,
																	 (td_fn_lFindIdFromScriptName *)fn_eFindProcedureIdFromScriptName,
																	 fn_bIsProcedureIdValid,
																	 szAction,szPars,eType);
}

/*==========================================================================*/
/*===                                                                    ===*/
/*                      FUNCTIONS                                           */
/*===                                                                    ===*/
/*==========================================================================*/

/****************************************************************************/
long fn_lGetNbFunctions()
{
	return gs_pclFunctionDictionnary->m_fn_lGetNbEntries();
}

/****************************************************************************/
//ANNECY CB
long fn_lGetFunctionIdFromEditorName(CString &csWord,CString csLanguage)
//long fn_lGetFunctionIdFromEditorName(CString csWord,CString csLanguage)
//END
{
	return fn_lGetIdFromEditorName(gs_pclFunctionDictionnary,csWord,csLanguage);
}
//ANNECY CB
long fn_lGetFunctionIdFromEditorName(char *csWord,CString csLanguage)
{
	_gcsGlob_ = csWord;
	return fn_lGetFunctionIdFromEditorName(_gcsGlob_,csLanguage);
}
//END

/****************************************************************************/
CString fn_csGetFunctionEditorNameFromId(long lId,CString csLanguage)
{
	return fn_csGetEditorNameFromId(gs_pclFunctionDictionnary,lId,csLanguage);
}

/****************************************************************************/
SCR_tde_Anl_ReturnValue fn_tdeCallBackLoadAllFunctions(SCR_tdst_File_Description *pfFile,
																											 char *szAction,
																											 char *szPars[],
																											 SCR_tde_Anl_Action eType)
{
	return fn_tdeCallBackLoadAllWords(&gs_pclFunctionDictionnary,szPars,eType);
}

/****************************************************************************/
BOOL fn_bIsFunctionIdValid(long lId)
{
	return M_IsFuncIdValid(lId);
}

/****************************************************************************/
SCR_tde_Anl_ReturnValue fn_tdeCallBackLoadOneFunction(SCR_tdst_File_Description *pfFile,
																											char *szAction,
																											char *szPars[],
																											SCR_tde_Anl_Action eType)
{
	return fn_tdeCallBackLoadOneWord(gs_pclFunctionDictionnary,
																	 (td_fn_lFindIdFromScriptName *)fn_eFindFunctionIdFromScriptName,
																	 fn_bIsFunctionIdValid,
																	 szAction,szPars,eType);
}

/*==========================================================================*/
/*===                                                                    ===*/
/*                      CONDITIONS                                          */
/*===                                                                    ===*/
/*==========================================================================*/

/****************************************************************************/
long fn_lGetNbConditions()
{
	return gs_pclConditionDictionnary->m_fn_lGetNbEntries();
}

/****************************************************************************/
//ANNECY CB
long fn_lGetConditionIdFromEditorName(CString &csWord,CString csLanguage)
//long fn_lGetConditionIdFromEditorName(CString csWord,CString csLanguage)
//END
{
	return fn_lGetIdFromEditorName(gs_pclConditionDictionnary,csWord,csLanguage);
}
//ANNECY CB
long fn_lGetConditionIdFromEditorName(char *csWord,CString csLanguage)
{
	_gcsGlob_ = csWord;
	return fn_lGetConditionIdFromEditorName(_gcsGlob_,csLanguage);
}
//END

/****************************************************************************/
CString fn_csGetConditionEditorNameFromId(long lId,CString csLanguage)
{
	return fn_csGetEditorNameFromId(gs_pclConditionDictionnary,lId,csLanguage);
}

/****************************************************************************/
SCR_tde_Anl_ReturnValue fn_tdeCallBackLoadAllConditions(SCR_tdst_File_Description *pfFile,
																												char *szAction,
																												char *szPars[],
																												SCR_tde_Anl_Action eType)
{
	return fn_tdeCallBackLoadAllWords(&gs_pclConditionDictionnary,szPars,eType);
}

/****************************************************************************/
BOOL fn_bIsConditionIdValid(long lId)
{
	return M_IsConditionIdValid(lId);
}

/****************************************************************************/
SCR_tde_Anl_ReturnValue fn_tdeCallBackLoadOneCondition(SCR_tdst_File_Description *pfFile,
																											 char *szAction,
																											 char *szPars[],
																											 SCR_tde_Anl_Action eType)
{
	return fn_tdeCallBackLoadOneWord(gs_pclConditionDictionnary,
																	 (td_fn_lFindIdFromScriptName *)fn_eFindConditionIdFromScriptName,
																	 fn_bIsConditionIdValid,
																	 szAction,szPars,eType);
}

/*==========================================================================*/
/*===                                                                    ===*/
/*                      KEYWORDS                                            */
/*===                                                                    ===*/
/*==========================================================================*/

/****************************************************************************/
long fn_lGetNbKeyWords()
{
	return gs_pclKeyWordDictionnary->m_fn_lGetNbEntries();
}

/****************************************************************************/
//ANNECY CB
long fn_lGetKeyWordIdFromEditorName(CString &csWord,CString csLanguage)
//long fn_lGetKeyWordIdFromEditorName(CString csWord,CString csLanguage)
//END
{
	return fn_lGetIdFromEditorName(gs_pclKeyWordDictionnary,csWord,csLanguage);
}
//ANNECY CB
long fn_lGetKeyWordIdFromEditorName(char *csWord,CString csLanguage)
{
	_gcsGlob_ = csWord;
	return fn_lGetKeyWordIdFromEditorName(_gcsGlob_,csLanguage);
}
//END

/****************************************************************************/
CString fn_csGetKeyWordEditorNameFromId(long lId,CString csLanguage)
{
	return fn_csGetEditorNameFromId(gs_pclKeyWordDictionnary,lId,csLanguage);
}

/****************************************************************************/
SCR_tde_Anl_ReturnValue fn_tdeCallBackLoadAllKeyWords(SCR_tdst_File_Description *pfFile,
																											char *szAction,
																											char *szPars[],
																											SCR_tde_Anl_Action eType)
{
	return fn_tdeCallBackLoadAllWords(&gs_pclKeyWordDictionnary,szPars,eType);
}

/****************************************************************************/
BOOL	fn_bIsKeyWordIdValid(long lId)
{
	return M_IsKeyWordIdValid(lId);
}

/****************************************************************************/
SCR_tde_Anl_ReturnValue fn_tdeCallBackLoadOneKeyWord(SCR_tdst_File_Description *pfFile,
																										 char *szAction,
																										 char *szPars[],
																										 SCR_tde_Anl_Action eType)
{
	return fn_tdeCallBackLoadOneWord(gs_pclKeyWordDictionnary,
																	 (td_fn_lFindIdFromScriptName *)fn_eFindKeyWordIdFromScriptName,
																	 fn_bIsKeyWordIdValid,
																	 szAction,szPars,eType);
}

/*==========================================================================*/
/*===                                                                    ===*/
/*                      OPERATORS                                           */
/*===                                                                    ===*/
/*==========================================================================*/

/****************************************************************************/
long fn_lGetNbOperators()
{
	return fn_eGetNbOperator();
}

/****************************************************************************/
//ANNECY CB
long fn_lGetOperatorIdFromEditorName(CString &csWord,CString csLanguage)
//long fn_lGetOperatorIdFromEditorName(CString csWord,CString csLanguage)
//END
{
	long	lId=fn_eFindOperatorIdFromEditorName(M_MAKECHAR(csWord));

	if(M_IsOperatorIdValid(lId))
		return lId;
	else
		return C_INVALID_ID;
}
//ANNECY CB
long fn_lGetOperatorIdFromEditorName(char *csWord,CString csLanguage)
{
	_gcsGlob_ = csWord;
	return fn_lGetOperatorIdFromEditorName(_gcsGlob_,csLanguage);
}
//END

/****************************************************************************/
CString fn_csGetOperatorEditorNameFromId(long lId,CString csLanguage)
{
	return szFindOperatorEditorNameFromId((tdeOperatorId)lId);
}

/*==========================================================================*/
/*===                                                                    ===*/
/*                      FIELDS                                              */
/*===                                                                    ===*/
/*==========================================================================*/

/****************************************************************************/
long fn_lGetNbFields()
{
	return gs_pclFieldDictionnary->m_fn_lGetNbEntries();
}

/****************************************************************************/
//ANNECY CB
long fn_lGetFieldIdFromEditorName(CString &csWord,CString csLanguage)
//long fn_lGetFieldIdFromEditorName(CString csWord,CString csLanguage)
//END
{
	return fn_lGetIdFromEditorName(gs_pclFieldDictionnary,csWord,csLanguage);
}
//ANNECY CB
long fn_lGetFieldIdFromEditorName(char *csWord,CString csLanguage)
{
	_gcsGlob_ = csWord;
	return fn_lGetFieldIdFromEditorName(_gcsGlob_,csLanguage);
}
//END

/****************************************************************************/
CString fn_csGetFieldEditorNameFromId(long lId,CString csLanguage)
{
	return fn_csGetEditorNameFromId(gs_pclFieldDictionnary,lId,csLanguage);
}

/****************************************************************************/
SCR_tde_Anl_ReturnValue fn_tdeCallBackLoadAllFields(SCR_tdst_File_Description *pfFile,
																										char *szAction,
																										char *szPars[],
																										SCR_tde_Anl_Action eType)
{
	return fn_tdeCallBackLoadAllWords(&gs_pclFieldDictionnary,szPars,eType);
}

/****************************************************************************/
BOOL fn_bIsFieldIdValid(long lId)
{
	return M_IsFieldIdValid(lId);
}

/****************************************************************************/
SCR_tde_Anl_ReturnValue fn_tdeCallBackLoadOneField(SCR_tdst_File_Description *pfFile,
																									 char *szAction,
																									 char *szPars[],
																									 SCR_tde_Anl_Action eType)
{
	return fn_tdeCallBackLoadOneWord(gs_pclFieldDictionnary,
																	 (td_fn_lFindIdFromScriptName *)fn_eFindFieldIdFromScriptName,
																	 fn_bIsFieldIdValid,
																	 szAction,szPars,eType);
}

/*==========================================================================*/
/*===                                                                    ===*/
/*                      DSG VAR TYPES                                       */
/*===                                                                    ===*/
/*==========================================================================*/

/****************************************************************************/
long fn_lGetNbDsgVarTypes()
{
	return gs_pclDsgVarTypeDictionnary->m_fn_lGetNbEntries();
}

/****************************************************************************/
//ANNECY CB
long fn_lGetDsgVarTypeIdFromEditorName(CString &csWord,CString csLanguage)
//long fn_lGetDsgVarTypeIdFromEditorName(CString csWord,CString csLanguage)
//END
{
	return fn_lGetIdFromEditorName(gs_pclDsgVarTypeDictionnary,csWord,csLanguage);
}
//ANNECY CB
long fn_lGetDsgVarTypeIdFromEditorName(char *csWord,CString csLanguage)
{
	_gcsGlob_ = csWord;
	return fn_lGetDsgVarTypeIdFromEditorName(_gcsGlob_,csLanguage);
}
//END

/****************************************************************************/
CString fn_csGetDsgVarTypeEditorNameFromId(long lId,CString csLanguage)
{
	return fn_csGetEditorNameFromId(gs_pclDsgVarTypeDictionnary,lId,csLanguage);
}

/****************************************************************************/
SCR_tde_Anl_ReturnValue fn_tdeCallBackLoadAllDsgVarTypes(SCR_tdst_File_Description *pfFile,
																												 char *szAction,
																												 char *szPars[],
																												 SCR_tde_Anl_Action eType)
{
	return fn_tdeCallBackLoadAllWords(&gs_pclDsgVarTypeDictionnary,szPars,eType);
}

/****************************************************************************/
BOOL fn_bIsDsgVarTypeIdValid(long lId)
{
	return M_IsDsgVarTypeIdValid(lId);
}

/****************************************************************************/
SCR_tde_Anl_ReturnValue fn_tdeCallBackLoadOneDsgVarType(SCR_tdst_File_Description *pfFile,
																												char *szAction,
																												char *szPars[],
																												SCR_tde_Anl_Action eType)
{
	return fn_tdeCallBackLoadOneWord(gs_pclDsgVarTypeDictionnary,
																	 (td_fn_lFindIdFromScriptName *)fn_eFindDsgVarTypeIdFromScriptName,
																	 fn_bIsDsgVarTypeIdValid,
																	 szAction,szPars,eType);
}

/*==========================================================================*/
/*===                                                                    ===*/
/*                      DSG VAR SAVE TYPES                                  */
/*===                                                                    ===*/
/*==========================================================================*/

/****************************************************************************/
long fn_lGetNbDsgVarSaveTypes()
{
	return gs_pclDsgVarSaveTypeDictionnary->m_fn_lGetNbEntries();
}

/****************************************************************************/
//ANNECY CB
long fn_lGetDsgVarSaveTypeIdFromEditorName(CString &csWord,CString csLanguage)
//long fn_lGetDsgVarSaveTypeIdFromEditorName(CString csWord,CString csLanguage)
//END
{
	return fn_lGetIdFromEditorName(gs_pclDsgVarSaveTypeDictionnary,csWord,csLanguage);
}
//ANNECY CB
long fn_lGetDsgVarSaveTypeIdFromEditorName(char *csWord,CString csLanguage)
{
	_gcsGlob_ = csWord;
	return fn_lGetDsgVarSaveTypeIdFromEditorName(_gcsGlob_,csLanguage);
}
//END

/****************************************************************************/
CString fn_csGetDsgVarSaveTypeEditorNameFromId(long lId,CString csLanguage)
{
	return fn_csGetEditorNameFromId(gs_pclDsgVarSaveTypeDictionnary,lId,csLanguage);
}

/****************************************************************************/
SCR_tde_Anl_ReturnValue fn_tdeCallBackLoadAllDsgVarSaveTypes(SCR_tdst_File_Description *pfFile,
																														 char *szAction,
																														 char *szPars[],
																														 SCR_tde_Anl_Action eType)
{
	return fn_tdeCallBackLoadAllWords(&gs_pclDsgVarSaveTypeDictionnary,szPars,eType);
}

/****************************************************************************/
BOOL fn_bIsDsgVarSaveTypeIdValid(long lId)
{
	return (unsigned char)lId<fn_ucGetSaveTypeNumber();
}

/****************************************************************************/
SCR_tde_Anl_ReturnValue fn_tdeCallBackLoadOneDsgVarSaveType(SCR_tdst_File_Description *pfFile,
																														char *szAction,
																														char *szPars[],
																														SCR_tde_Anl_Action eType)
{
	return fn_tdeCallBackLoadOneWord(gs_pclDsgVarSaveTypeDictionnary,
																	 (td_fn_lFindIdFromScriptName *)fn_ucFindSaveTypeNumberFromScriptName,
																	 fn_bIsDsgVarSaveTypeIdValid,
																	 szAction,szPars,eType);
}

/*==========================================================================*/
/*===                                                                    ===*/
/*                      DGS VAR INIT TYPES                                  */
/*===                                                                    ===*/
/*==========================================================================*/

/****************************************************************************/
long fn_lGetNbDsgVarInitTypes()
{
	return gs_pclDsgVarInitTypeDictionnary->m_fn_lGetNbEntries();
}

/****************************************************************************/
//ANNECY CB
long fn_lGetDsgVarInitTypeIdFromEditorName(CString &csWord,CString csLanguage)
//long fn_lGetDsgVarInitTypeIdFromEditorName(CString csWord,CString csLanguage)
//END
{
	return fn_lGetIdFromEditorName(gs_pclDsgVarInitTypeDictionnary,csWord,csLanguage);
}
//ANNECY CB
long fn_lGetDsgVarInitTypeIdFromEditorName(char *csWord,CString csLanguage)
{
	_gcsGlob_ = csWord;
	return fn_lGetDsgVarInitTypeIdFromEditorName(_gcsGlob_,csLanguage);
}
//END

/****************************************************************************/
CString fn_csGetDsgVarInitTypeEditorNameFromId(long lId,CString csLanguage)
{
	return fn_csGetEditorNameFromId(gs_pclDsgVarInitTypeDictionnary,lId,csLanguage);
}

/****************************************************************************/
SCR_tde_Anl_ReturnValue fn_tdeCallBackLoadAllDsgVarInitTypes(SCR_tdst_File_Description *pfFile,
																														 char *szAction,
																														 char *szPars[],
																														 SCR_tde_Anl_Action eType)
{
	return fn_tdeCallBackLoadAllWords(&gs_pclDsgVarInitTypeDictionnary,szPars,eType);
}

/****************************************************************************/
BOOL fn_bIsDsgVarInitTypeIdValid(long lId)
{
	return (unsigned char)lId<fn_ucGetInitTypeNumber();
}

/****************************************************************************/
SCR_tde_Anl_ReturnValue fn_tdeCallBackLoadOneDsgVarInitType(SCR_tdst_File_Description *pfFile,
																														char *szAction,
																														char *szPars[],
																														SCR_tde_Anl_Action eType)
{
	return fn_tdeCallBackLoadOneWord(gs_pclDsgVarInitTypeDictionnary,
																	 (td_fn_lFindIdFromScriptName *)fn_ucFindInitTypeNumberFromScriptName,
																	 fn_bIsDsgVarInitTypeIdValid,
																	 szAction,szPars,eType);
}

#endif //D_ED_IR_ACTIVE
