1541 lines
54 KiB
C
1541 lines
54 KiB
C
/*
|
|
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
* SCR_RdL0.c
|
|
* Main function for reading.
|
|
*
|
|
* Scripts, Beaudet Christophe
|
|
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
*/
|
|
|
|
/*
|
|
*=================================================================================================
|
|
* Includes.
|
|
*=================================================================================================
|
|
*/
|
|
|
|
#include <direct.h>
|
|
#include <memory.h>
|
|
#include "SCR.h"
|
|
#ifdef SCR_DM_ProtectedVersion
|
|
#include <crtdbg.h>
|
|
#endif /* SCR_DM_ProtectedVersion */
|
|
|
|
/*ANNECY CB*/
|
|
char gsz_Version[100];
|
|
char gsz_Version1[100];
|
|
char gc_NoAsk = 0;
|
|
/*END ANNECY*/
|
|
|
|
extern int SCR_g_iParseHeader; /*MP: BINARY*/
|
|
/*
|
|
*=================================================================================================
|
|
* Init and close.
|
|
*=================================================================================================
|
|
*/
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To initialize script parser.
|
|
* Initialize all modules one by one.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void SCR_fn_v_RdL0_Init(void)
|
|
{
|
|
/*ANNECY CB*/
|
|
char szTemp[255];
|
|
FILE *hIni;
|
|
int i, j;
|
|
hIni = fopen("version.ini", "rt");
|
|
if(hIni == NULL)
|
|
hIni = fopen("x:\\cpa\\exe\\main\\version.ini", "rt");
|
|
if(hIni)
|
|
{
|
|
*gsz_Version1 = '\0';
|
|
fgets(gsz_Version, 49, hIni);
|
|
i = 0;
|
|
while((gsz_Version[i] != ',') && (gsz_Version[i] != '\0') && (gsz_Version[i] != '\n'))
|
|
i++;
|
|
if(gsz_Version[i] == ',')
|
|
{
|
|
gsz_Version[i] = '\0';
|
|
i++; j = 0;
|
|
while((gsz_Version[i] != '\0') && (gsz_Version[i] != '\n'))
|
|
gsz_Version1[j++] = gsz_Version[i++];
|
|
gsz_Version1[j] = '\0';
|
|
}
|
|
else
|
|
gsz_Version[i] = '\0';
|
|
|
|
*szTemp = '\0';
|
|
fgets(szTemp, 254, hIni);
|
|
if(!strcmpi(szTemp, "PasDeConfirmation"))
|
|
gc_NoAsk = 1;
|
|
else
|
|
gc_NoAsk = 0;
|
|
fclose(hIni);
|
|
}
|
|
else
|
|
*gsz_Version = '\0';
|
|
/*END ANNECY*/
|
|
|
|
#ifdef SCR_DM_ProtectedVersion
|
|
_CrtSetDbgFlag((_CRTDBG_LEAK_CHECK_DF) | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG));
|
|
#endif /* SCR_DM_ProtectedVersion */
|
|
fn_v_Anl_InitModule();
|
|
fn_v_Cxt_InitModule();
|
|
fn_v_Err_InitModule();
|
|
fn_v_File_InitModule();
|
|
fn_v_Link_InitModule();
|
|
fn_v_Mem_InitModule();
|
|
fn_v_Ntfy_InitModule();
|
|
fn_v_Sect_InitModule();
|
|
fn_v_Vars_InitModule();
|
|
}
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To close script parser.
|
|
* Close all modules one by one.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void SCR_fn_v_RdL0_Close(void)
|
|
{
|
|
fn_v_Anl_CloseModule();
|
|
fn_v_Cxt_CloseModule();
|
|
fn_v_Err_CloseModule();
|
|
fn_v_File_CloseModule();
|
|
fn_v_Link_CloseModule();
|
|
fn_v_Ntfy_CloseModule();
|
|
fn_v_Sect_CloseModule();
|
|
fn_v_Vars_CloseModule();
|
|
fn_v_Mem_CloseModule();
|
|
}
|
|
|
|
/*
|
|
*=================================================================================================
|
|
* Functions for registering sections.
|
|
*=================================================================================================
|
|
*/
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To register a callback.
|
|
* _p_szSectionName : Name of section to register.
|
|
* _pfn_eCallback : Address of callback.
|
|
* _cForSection : Is it a section callback (<>0) , or a file one (0) ?
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void SCR_fn_v_RdL0_RegisterCallback
|
|
(
|
|
char *_p_szSectionName,
|
|
SCR_tdpfn_Anl_Callback _pfn_eCallback,
|
|
char _cForSection
|
|
)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_tdst_Anl_Callback *p_stCallback;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_D(_p_szSectionName != NULL);
|
|
SCR_M_Dbg_Assert_D(_pfn_eCallback != NULL);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
/*
|
|
* We first search the callback. Error if already here.
|
|
*/
|
|
p_stCallback = fnp_st_Anl_SearchCallback(_p_szSectionName, _cForSection);
|
|
if(p_stCallback)
|
|
{
|
|
if(p_stCallback->pfn_eCallback == _pfn_eCallback)
|
|
SCR_RETURN(;);
|
|
sprintf(g_st_Err_GlobalError.a_szBufferTmp1, "Section is \"%s\".", _p_szSectionName);
|
|
*g_st_Err_GlobalError.a_szBufferTmp2 = '\0';
|
|
SCR_M_Err_RaiseError(SCR_EI_Err_AlreadyRegistered);
|
|
}
|
|
|
|
/*
|
|
* Else we register the new callback.
|
|
*/
|
|
fnp_st_Anl_AddCallback(_p_szSectionName, _pfn_eCallback, _cForSection);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(;)
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To delete an already registered callback.
|
|
* _p_szSectionName : Name of section of callback to delete.
|
|
* _cForSection : Is it a section callback (<>0) , or a file one (0) ?
|
|
* _cMatch : Exact string or string contains.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void SCR_fn_v_RdL0_DeleteRegisterCallback
|
|
(
|
|
char *_p_szSectionName,
|
|
char _cForSection,
|
|
char _cMatch
|
|
)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_tdst_Anl_Callback *p_stCallback;
|
|
unsigned int uiPos;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_D(_p_szSectionName != NULL);
|
|
SCR_M_Dbg_Assert_D
|
|
(
|
|
(_cMatch == SCR_CDR_c_RdL0_Match)
|
|
|| (_cMatch == SCR_CDR_c_RdL0_Contains)
|
|
|| (_cMatch == SCR_CDR_c_RdL0_NotContains)
|
|
);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
/*
|
|
* We parsed all the array to search a name to correspond to the parameter
|
|
* and to the matching choice.
|
|
*/
|
|
uiPos = 0;
|
|
SCR_M_DyAr_GetNextElement(SCR_tdst_Anl_Callback, uiPos, p_stCallback, SCR_g_st_Anl_ArrayCallbacks);
|
|
while(p_stCallback)
|
|
{
|
|
/* It must be the same type of callback */
|
|
if(p_stCallback->cForSection == _cForSection)
|
|
{
|
|
switch(_cMatch)
|
|
{
|
|
/* Found name must be exactly the same */
|
|
case SCR_CDR_c_RdL0_Match:
|
|
if(!strcmpi(p_stCallback->a_szSectionName, _p_szSectionName))
|
|
fn_v_Anl_DeleteCallback(p_stCallback);
|
|
break;
|
|
|
|
/* Found name must have inside it the parameter */
|
|
case SCR_CDR_c_RdL0_Contains:
|
|
if(strstri(p_stCallback->a_szSectionName, _p_szSectionName))
|
|
fn_v_Anl_DeleteCallback(p_stCallback);
|
|
break;
|
|
|
|
/* Found name not must have inside it the parameter */
|
|
case SCR_CDR_c_RdL0_NotContains:
|
|
if(!strstri(p_stCallback->a_szSectionName, _p_szSectionName))
|
|
fn_v_Anl_DeleteCallback(p_stCallback);
|
|
break;
|
|
}
|
|
}
|
|
uiPos++;
|
|
SCR_M_DyAr_GetNextElement(SCR_tdst_Anl_Callback, uiPos, p_stCallback, SCR_g_st_Anl_ArrayCallbacks);
|
|
}
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(;)
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To get an already registered callback.
|
|
* _p_szSectionName : Name of section to get.
|
|
* _cForSection : Is it a section callback (<>0) , or a file one (0) ?
|
|
* Returns address of structure or NULL.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
SCR_tdst_Anl_Callback *SCR_fnp_st_RdL0_GetRegisterCallback
|
|
(
|
|
char *_p_szSectionName,
|
|
char _cForSection
|
|
)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_D(_p_szSectionName != NULL);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
/*
|
|
* Search and return address.
|
|
*/
|
|
SCR_RETURN(fnp_st_Anl_SearchCallback(_p_szSectionName, _cForSection));
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(NULL)
|
|
|
|
/*
|
|
*=================================================================================================
|
|
* Functions for registering files.
|
|
*=================================================================================================
|
|
*/
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To register a file. All file is parsed.
|
|
* _p_szFileName : Additionnal directorie.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void SCR_fn_v_RdL0_OpenFile(char *_p_szFileName)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_tdst_Cxt_Description *p_stContext;
|
|
int iRead;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_D(_p_szFileName != NULL);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
/*
|
|
* One more context.
|
|
*/
|
|
p_stContext = fnp_st_Cxt_Add();
|
|
|
|
/*
|
|
* Open the file.
|
|
*/
|
|
p_stContext->p_stOpenFile = fnp_st_File_OpenFile(_p_szFileName);
|
|
|
|
/*
|
|
* Place file to its SCR_BEGINing.
|
|
* Parse to the end.
|
|
*/
|
|
SCR_M_Anl_CxtFileToPos
|
|
(
|
|
p_stContext,
|
|
p_stContext->p_stOpenFile->stParsingInfos.stPosition
|
|
);
|
|
do
|
|
{
|
|
iRead = fn_i_Anl_LineToContext(p_stContext);
|
|
/* MP: BINARY start */
|
|
if(p_stContext->eParseType == SCR_EPT_Cxt_BeginSection)
|
|
{
|
|
if( p_stContext->p_stOpenFile->stFile.bBinaryMode )
|
|
{
|
|
long l=fn_l_Bin_ToEndSection( p_stContext );
|
|
p_stContext->stPosition.lAfterSeekInFile+=l;
|
|
p_stContext->p_stOpenFile->stFile.lToEndSection=0;
|
|
}
|
|
}
|
|
/* MP: BINARY end */
|
|
} while(iRead != EOF);
|
|
|
|
/*
|
|
* Delete context. It's finish...
|
|
*/
|
|
fn_v_Cxt_DeleteLast();
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(;)
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To delete an open file.
|
|
* _p_szFileName : Additionnal directorie.
|
|
* _cMatch : Exact string or string contains.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void SCR_fn_v_RdL0_DeleteOpenFile
|
|
(
|
|
char *_p_szFileName,
|
|
char _cMatch
|
|
)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_tdst_File_Open *p_stOpenFile;
|
|
unsigned int uiPos;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_D(_p_szFileName != NULL);
|
|
SCR_M_Dbg_Assert_D
|
|
(
|
|
(_cMatch == SCR_CDR_c_RdL0_Match)
|
|
|| (_cMatch == SCR_CDR_c_RdL0_Contains)
|
|
|| (_cMatch == SCR_CDR_c_RdL0_NotContains)
|
|
);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
/*
|
|
* We parsed all the array to search a name to correspond to the parameter
|
|
* and to the matching choice.
|
|
*/
|
|
uiPos = 0;
|
|
SCR_M_DyAr_GetNextElement(SCR_tdst_File_Open, uiPos, p_stOpenFile, SCR_g_st_File_ArrayOpen);
|
|
while(p_stOpenFile)
|
|
{
|
|
switch(_cMatch)
|
|
{
|
|
/* Found name must be exactly the same */
|
|
case SCR_CDR_c_RdL0_Match:
|
|
if(!strcmpi(p_stOpenFile->stFile.a_szFileName, _p_szFileName))
|
|
fn_v_File_DeleteOpen(p_stOpenFile);
|
|
break;
|
|
|
|
/* Found name must have inside it the parameter */
|
|
case SCR_CDR_c_RdL0_Contains:
|
|
if(strstri(p_stOpenFile->stFile.a_szFileName, _p_szFileName))
|
|
fn_v_File_DeleteOpen(p_stOpenFile);
|
|
break;
|
|
|
|
/* Found name not must have inside it the parameter */
|
|
case SCR_CDR_c_RdL0_NotContains:
|
|
if(!strstri(p_stOpenFile->stFile.a_szFileName, _p_szFileName))
|
|
fn_v_File_DeleteOpen(p_stOpenFile);
|
|
break;
|
|
}
|
|
uiPos++;
|
|
SCR_M_DyAr_GetNextElement(SCR_tdst_File_Open, uiPos, p_stOpenFile, SCR_g_st_File_ArrayOpen);
|
|
}
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(;)
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To get an already registered callback.
|
|
* _p_szFileName : Name of file to get.
|
|
* Returns address of structure or NULL.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
SCR_tdst_File_Open *SCR_fnp_st_RdL0_GetOpenFile(char *_p_szFileName)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_tdx_Hash_Key xHashKey;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_D(_p_szFileName != NULL);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
/*
|
|
* Compute hash key code for that file.
|
|
* Search and return address.
|
|
*/
|
|
xHashKey = SCR_fn_x_Hash_ComputeHashKeyForString(_p_szFileName);
|
|
SCR_RETURN(fnp_st_File_SearchOpenWithPath(_p_szFileName, xHashKey));
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(NULL)
|
|
|
|
/*
|
|
*=================================================================================================
|
|
* Functions for registering paths.
|
|
*=================================================================================================
|
|
*/
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To register a priority path.
|
|
* _p_szPathName : Name of path to register.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void SCR_fn_v_RdL0_SetPriorityPath(char *_p_szPathName)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
if(_p_szPathName)
|
|
fn_v_File_ClearPath(_p_szPathName, SCR_g_a_sz_File_PriorityPath);
|
|
else
|
|
*SCR_g_a_sz_File_PriorityPath = '\0';
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(;)
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To register a path. You can specify multiple paths with ';' between them.
|
|
* _p_szPathName : Name of path to register.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void SCR_fn_v_RdL0_RegisterPath
|
|
(
|
|
char *_p_szPathName
|
|
)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
char *p_szTemp;
|
|
char a_szCopy[_MAX_PATH];
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_D(_p_szPathName != NULL);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
/*
|
|
* Search for multiple paths in the parameter.
|
|
*/
|
|
p_szTemp = strchr(_p_szPathName, ';');
|
|
while(p_szTemp)
|
|
{
|
|
*p_szTemp = '\0';
|
|
|
|
/* Clear and add the isolated path */
|
|
fn_v_File_ClearPath(_p_szPathName, a_szCopy);
|
|
fnp_st_File_AddPath(a_szCopy);
|
|
|
|
if(p_szTemp)
|
|
{
|
|
*p_szTemp = ';';
|
|
_p_szPathName = p_szTemp + 1;
|
|
p_szTemp = strchr(_p_szPathName, ';');
|
|
}
|
|
}
|
|
|
|
/* Clear and add the isolated path */
|
|
if(!p_szTemp)
|
|
p_szTemp = _p_szPathName;
|
|
fn_v_File_ClearPath(p_szTemp, a_szCopy);
|
|
fnp_st_File_AddPath(a_szCopy);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(;)
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To delete one or more registered path.
|
|
* _p_szPathName : Name of path to delete.
|
|
* _cMatch : Exact string or string contains.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void SCR_fn_v_RdL0_DeleteRegisterPath
|
|
(
|
|
char *_p_szPathName,
|
|
char _cMatch
|
|
)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_tdst_File_Path *p_stPath;
|
|
unsigned int uiPos;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_D(_p_szPathName != NULL);
|
|
SCR_M_Dbg_Assert_D
|
|
(
|
|
(_cMatch == SCR_CDR_c_RdL0_Match)
|
|
|| (_cMatch == SCR_CDR_c_RdL0_Contains)
|
|
|| (_cMatch == SCR_CDR_c_RdL0_NotContains)
|
|
);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
/*
|
|
* We parsed all the array to search a name to correspond to the parameter
|
|
* and to the matching choice.
|
|
*/
|
|
uiPos = 0;
|
|
SCR_M_DyAr_GetNextElement(SCR_tdst_File_Path, uiPos, p_stPath, SCR_g_st_File_ArrayPaths);
|
|
while(p_stPath)
|
|
{
|
|
switch(_cMatch)
|
|
{
|
|
/* Found name must be exactly the same */
|
|
case SCR_CDR_c_RdL0_Match:
|
|
if(!strcmpi(p_stPath->a_szPathName, _p_szPathName))
|
|
fn_v_File_DeletePath(p_stPath);
|
|
break;
|
|
|
|
/* Found name must have inside it the parameter */
|
|
case SCR_CDR_c_RdL0_Contains:
|
|
if(strstri(p_stPath->a_szPathName, _p_szPathName))
|
|
fn_v_File_DeletePath(p_stPath);
|
|
break;
|
|
|
|
/* Found name not must have inside it the parameter */
|
|
case SCR_CDR_c_RdL0_NotContains:
|
|
if(!strstri(p_stPath->a_szPathName, _p_szPathName))
|
|
fn_v_File_DeletePath(p_stPath);
|
|
break;
|
|
}
|
|
uiPos++;
|
|
SCR_M_DyAr_GetNextElement(SCR_tdst_File_Path, uiPos, p_stPath, SCR_g_st_File_ArrayPaths);
|
|
}
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(;)
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To get an already registered path.
|
|
* _p_szPathName : Name of path to get.
|
|
* Returns address of structure or NULL.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
SCR_tdst_File_Path *SCR_fnp_st_RdL0_GetRegisterPath(char *_p_szPathName)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
char a_szCopy[_MAX_PATH];
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_D(_p_szPathName != NULL);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
/*
|
|
* Make a copy of path and clear it.
|
|
*/
|
|
fn_v_File_ClearPath(_p_szPathName, a_szCopy);
|
|
|
|
/*
|
|
* Search and return address.
|
|
*/
|
|
SCR_RETURN(fnp_st_File_SearchPath(a_szCopy));
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(NULL)
|
|
|
|
/*
|
|
*=================================================================================================
|
|
* Functions to manage open sections.
|
|
*=================================================================================================
|
|
*/
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To delete one or more open sections.
|
|
* _p_szSectionName : Name of section to delete.
|
|
* _cMatch : Exact string or string contains.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void SCR_fn_v_RdL0_DeleteOpenSection
|
|
(
|
|
char *_p_szSectionName,
|
|
char _cMatch
|
|
)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_tdst_Sect_Open *p_stSection;
|
|
unsigned int uiPos;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_D(_p_szSectionName != NULL);
|
|
SCR_M_Dbg_Assert_D
|
|
(
|
|
(_cMatch == SCR_CDR_c_RdL0_Match)
|
|
|| (_cMatch == SCR_CDR_c_RdL0_Contains)
|
|
|| (_cMatch == SCR_CDR_c_RdL0_NotContains)
|
|
);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
/*
|
|
* We parsed all the array to search a name to correspond to the parameter
|
|
* and to the matching choice.
|
|
*/
|
|
uiPos = 0;
|
|
SCR_M_DyAr_GetNextElement(SCR_tdst_Sect_Open, uiPos, p_stSection, SCR_g_st_Sect_ArrayOpen);
|
|
while(p_stSection)
|
|
{
|
|
switch(_cMatch)
|
|
{
|
|
/* Found name must be exactly the same */
|
|
case SCR_CDR_c_RdL0_Match:
|
|
if(!strcmpi(p_stSection->stBuffers.a_szBufferCompleteName, _p_szSectionName))
|
|
fn_v_Sect_DeleteOpen(p_stSection);
|
|
break;
|
|
|
|
/* Found name must have inside it the parameter */
|
|
case SCR_CDR_c_RdL0_Contains:
|
|
if(strstri(p_stSection->stBuffers.a_szBufferCompleteName, _p_szSectionName))
|
|
fn_v_Sect_DeleteOpen(p_stSection);
|
|
break;
|
|
|
|
/* Found name must not have inside it the parameter */
|
|
case SCR_CDR_c_RdL0_NotContains:
|
|
if(!strstri(p_stSection->stBuffers.a_szBufferCompleteName, _p_szSectionName))
|
|
fn_v_Sect_DeleteOpen(p_stSection);
|
|
break;
|
|
}
|
|
uiPos++;
|
|
SCR_M_DyAr_GetNextElement(SCR_tdst_Sect_Open, uiPos, p_stSection, SCR_g_st_Sect_ArrayOpen);
|
|
}
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(;)
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To get an open section.
|
|
* _p_szSectionName : Name of section to get.
|
|
* _uiLineInFile : Line in file where there's the section (0 to ignore).
|
|
* Returns address of structure, or NULL.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
SCR_tdst_Sect_Open *SCR_fnp_st_RdL0_GetOpenSection
|
|
(
|
|
char *_p_szSectionName,
|
|
unsigned int _uiLineInFile
|
|
)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_tdx_Hash_Key xHashKey;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_D(_p_szSectionName != NULL);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Sect_ComputeHashKey(xHashKey, _p_szSectionName);
|
|
SCR_RETURN(fnp_st_Sect_SearchOpen(_p_szSectionName, _uiLineInFile, xHashKey));
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(NULL)
|
|
|
|
/*
|
|
*=================================================================================================
|
|
* Functions for registering variables.
|
|
*=================================================================================================
|
|
*/
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To register a global variable.
|
|
* _p_szName : Name of variable to register.
|
|
* _p_szValue : Value of variable.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void SCR_fn_v_RdL0_RegisterVariable
|
|
(
|
|
char *_p_szName,
|
|
char *_p_szValue
|
|
)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_tdst_Vars_Description *p_stVar;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_D(_p_szName != NULL);
|
|
SCR_M_Dbg_Assert_D(_p_szValue != NULL);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
/*
|
|
* We first search the variable.
|
|
* If it not exist yet, we create it else we change the value.
|
|
*/
|
|
p_stVar = fnp_st_Vars_Search(_p_szName);
|
|
if(p_stVar)
|
|
strcpy(p_stVar->a_szVarValue, _p_szValue);
|
|
else
|
|
p_stVar = fnp_st_Vars_Add(_p_szName, _p_szValue);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(;)
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To delete an already registered variable.
|
|
* _p_szName : Name of variable to delete.
|
|
* _cMatch : Exact string or string contains.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void SCR_fn_v_RdL0_DeleteRegisterVariable
|
|
(
|
|
char *_p_szName,
|
|
char _cMatch
|
|
)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_tdst_Vars_Description *p_stVar;
|
|
unsigned int uiPos;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_D(_p_szName != NULL);
|
|
SCR_M_Dbg_Assert_D
|
|
(
|
|
(_cMatch == SCR_CDR_c_RdL0_Match)
|
|
|| (_cMatch == SCR_CDR_c_RdL0_Contains)
|
|
|| (_cMatch == SCR_CDR_c_RdL0_NotContains)
|
|
);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
/*
|
|
* We parsed all the array to search a name to correspond to the parameter
|
|
* and to the matching choice.
|
|
*/
|
|
uiPos = 0;
|
|
SCR_M_DyAr_GetNextElement(SCR_tdst_Vars_Description, uiPos, p_stVar, SCR_g_st_Vars_Array);
|
|
while(p_stVar)
|
|
{
|
|
switch(_cMatch)
|
|
{
|
|
/* Found name must be exactly the same */
|
|
case SCR_CDR_c_RdL0_Match:
|
|
if(!strcmpi(p_stVar->a_szVarName, _p_szName))
|
|
fn_v_Vars_Delete(p_stVar);
|
|
break;
|
|
|
|
/* Found name must have inside it the parameter */
|
|
case SCR_CDR_c_RdL0_Contains:
|
|
if(strstri(p_stVar->a_szVarName, _p_szName))
|
|
fn_v_Vars_Delete(p_stVar);
|
|
break;
|
|
|
|
/* Found name must not have inside it the parameter */
|
|
case SCR_CDR_c_RdL0_NotContains:
|
|
if(!strstri(p_stVar->a_szVarName, _p_szName))
|
|
fn_v_Vars_Delete(p_stVar);
|
|
break;
|
|
}
|
|
uiPos++;
|
|
SCR_M_DyAr_GetNextElement(SCR_tdst_Vars_Description, uiPos, p_stVar, SCR_g_st_Vars_Array);
|
|
}
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(;)
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To get an already registered variable.
|
|
* _p_szName : Name of variable to get.
|
|
* Returns address of structure or NULL.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
SCR_tdst_Vars_Description *SCR_fnp_st_RdL0_GetRegisterVariable(char *_p_szName)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_D(_p_szName != NULL);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
/*
|
|
* Search and return address.
|
|
*/
|
|
SCR_RETURN(fnp_st_Vars_Search(_p_szName));
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(NULL)
|
|
|
|
/*
|
|
*=================================================================================================
|
|
* Functions for parsing.
|
|
*=================================================================================================
|
|
*/
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To analyse a section.
|
|
* _p_szSectionName : Name of section to analyse.
|
|
* _uwDynamicFlags : Dynamic flags for parsing.
|
|
* Returns static result of context.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
SCR_tdst_Cxt_Values *SCR_fnp_st_RdL0_AnalyseSection
|
|
(
|
|
char *_p_szSectionName,
|
|
unsigned short _uwDynamicFlags
|
|
)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_tdst_Cxt_Description *p_stContext;
|
|
char a_szFileName[_MAX_PATH];
|
|
char a_szSectionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_D(_p_szSectionName != NULL);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
/*
|
|
* Compute file name and complete section name (cause of eventual replacment
|
|
* characters like '*').
|
|
* a_szFileName : Complete file name (with specified path).
|
|
* a_szCompleteName : Complete file name + Section name.
|
|
*/
|
|
fn_v_File_ComputeFileSectionName
|
|
(
|
|
_p_szSectionName,
|
|
a_szFileName,
|
|
a_szSectionName
|
|
);
|
|
|
|
/*
|
|
* Special flag to check if section is here before analyse.
|
|
*/
|
|
if(_uwDynamicFlags & SCR_CDF_uw_Anl_WarnIfNotHere)
|
|
{
|
|
char *p_szTemp;
|
|
|
|
if(a_szSectionName[0] == '\0')
|
|
p_szTemp = a_szFileName;
|
|
else
|
|
p_szTemp = a_szSectionName;
|
|
|
|
if(!SCR_fn_c_RdL0_IsSectionExists(p_szTemp))
|
|
{
|
|
sprintf
|
|
(
|
|
g_st_Err_GlobalError.a_szBufferOut,
|
|
"Automatic reference : Section %s not found\n",
|
|
p_szTemp
|
|
);
|
|
fn_v_Err_UpdateLogFile();
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Add one open context.
|
|
*/
|
|
p_stContext = fnp_st_Cxt_Add();
|
|
|
|
/*
|
|
* Open the file.
|
|
*/
|
|
|
|
/* MP: BINARY */
|
|
SCR_g_iParseHeader=0;
|
|
if( a_szSectionName[0]==0 ) /* for file*/
|
|
{
|
|
SCR_g_iParseHeader=1;
|
|
}
|
|
|
|
p_stContext->p_stOpenFile = fnp_st_File_OpenFile(a_szFileName);
|
|
|
|
|
|
SCR_M_Dbg_Assert_P(p_stContext->p_stOpenFile != NULL);
|
|
|
|
/*
|
|
* Update values.
|
|
*/
|
|
if(p_stContext->cFileValuesValid)
|
|
{
|
|
memcpy
|
|
(
|
|
&p_stContext->p_stOpenFile->stFileValues,
|
|
&p_stContext->stFileValues,
|
|
sizeof(SCR_tdst_Cxt_Values)
|
|
);
|
|
p_stContext->cFileValuesValid = 0;
|
|
}
|
|
else
|
|
{
|
|
memcpy
|
|
(
|
|
&p_stContext->stFileValues,
|
|
&p_stContext->p_stOpenFile->stFileValues,
|
|
sizeof(SCR_tdst_Cxt_Values)
|
|
);
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
* Place context to the file or the section to prepare the analyse.
|
|
* If a_szSectionName[0] == '\0', there's no section name (ans so only a file name).
|
|
* This means that we want to parse a whole file.
|
|
*/
|
|
|
|
if(a_szSectionName[0] == '\0')
|
|
fn_v_Anl_ContextToFile(p_stContext);
|
|
else
|
|
fn_v_Anl_ContextToSection(p_stContext, a_szSectionName);
|
|
|
|
|
|
/*
|
|
* Parsing.
|
|
*/
|
|
fn_v_Anl_ParseCurrentSection(_uwDynamicFlags);
|
|
|
|
/*
|
|
* Delete last context (it's not really deleted, but current context is decreased).
|
|
*/
|
|
fn_v_Cxt_DeleteLast();
|
|
|
|
/*
|
|
* We force the file to be open (cause of references, this file can have been closed).
|
|
* We force the file to be to its previous position.
|
|
*/
|
|
if(SCR_M_Cxt_GetCurrentContext() >= 0)
|
|
{
|
|
/* Get actual context */
|
|
p_stContext = fnp_st_Cxt_Compute(0);
|
|
/* Force the file to be open */
|
|
fn_v_File_ForceOpenFile(p_stContext->p_stOpenFile);
|
|
/* Restore position of file before the parsing */
|
|
SCR_M_Anl_CxtFileToPos
|
|
(
|
|
p_stContext,
|
|
p_stContext->stPosition
|
|
);
|
|
}
|
|
/*
|
|
* Else we close all the files.
|
|
*/
|
|
else
|
|
fn_v_File_CloseAllHandles();
|
|
|
|
/*
|
|
* At the end of a manual analyse, we must stop recurs exit of sections.
|
|
*/
|
|
g_iExitBeforeLevel = -1;
|
|
|
|
/*
|
|
* Return static result of parsing context.
|
|
*/
|
|
p_stContext = fnp_st_Cxt_Compute(1);
|
|
if(p_stContext->p_stOpenSection)
|
|
SCR_RETURN(&p_stContext->p_stOpenSection->stSectionValues);
|
|
SCR_RETURN(NULL);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(NULL)
|
|
|
|
/*
|
|
*=================================================================================================
|
|
* Values.
|
|
*=================================================================================================
|
|
*/
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To set some results of a relative position.
|
|
* _iOffset : Offset of context.
|
|
* _p_stContextValues : To set context values (can be NULL).
|
|
* _p_stFileValues : To set file values (can be NULL).
|
|
* _p_stSectionValues : To set section values (can be NULL).
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void SCR_fn_v_RdL0_SetValues
|
|
(
|
|
int _iOffset,
|
|
SCR_tdst_Cxt_Values *_p_stContextValues,
|
|
SCR_tdst_Cxt_Values *_p_stFileValues,
|
|
SCR_tdst_Cxt_Values *_p_stSectionValues
|
|
)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_tdst_Cxt_Description *p_stContext;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_D
|
|
(
|
|
(_p_stContextValues != NULL)
|
|
|| (_p_stFileValues != NULL)
|
|
|| (_p_stSectionValues != NULL)
|
|
);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
/*
|
|
* Compute context to set results.
|
|
*/
|
|
p_stContext = fnp_st_Cxt_Compute(_iOffset);
|
|
|
|
/*
|
|
* Set values.
|
|
*/
|
|
if(_p_stContextValues)
|
|
{
|
|
memcpy
|
|
(
|
|
&p_stContext->stContextValues,
|
|
_p_stContextValues,
|
|
sizeof(SCR_tdst_Cxt_Values)
|
|
);
|
|
}
|
|
if(_p_stFileValues)
|
|
{
|
|
SCR_M_Dbg_Assert_D(_iOffset <= 0);
|
|
SCR_M_Dbg_Assert_D(p_stContext->p_stOpenFile != NULL);
|
|
SCR_M_Dbg_AssertStruct_P(SCR_tdst_File_Open, p_stContext->p_stOpenFile);
|
|
memcpy
|
|
(
|
|
&p_stContext->p_stOpenFile->stFileValues,
|
|
_p_stFileValues,
|
|
sizeof(SCR_tdst_Cxt_Values)
|
|
);
|
|
}
|
|
if(_p_stSectionValues)
|
|
{
|
|
SCR_M_Dbg_Assert_D(_iOffset <= 0);
|
|
SCR_M_Dbg_Assert_D(p_stContext->p_stOpenSection != NULL);
|
|
SCR_M_Dbg_AssertStruct_P(SCR_tdst_Sect_Open, p_stContext->p_stOpenSection);
|
|
memcpy
|
|
(
|
|
&p_stContext->p_stOpenSection->stSectionValues,
|
|
_p_stSectionValues,
|
|
sizeof(SCR_tdst_Cxt_Values)
|
|
);
|
|
}
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(;)
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To get some results of a relative position.
|
|
* _iOffset : Offset of context.
|
|
* _p_stContextValues : To receive context values (can be NULL).
|
|
* _p_stFileValues : To receive file values (can be NULL).
|
|
* _p_stSectionValues : To receive section values (can be NULL).
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void SCR_fn_v_RdL0_GetValues
|
|
(
|
|
int _iOffset,
|
|
SCR_tdst_Cxt_Values *_p_stContextValues,
|
|
SCR_tdst_Cxt_Values *_p_stFileValues,
|
|
SCR_tdst_Cxt_Values *_p_stSectionValues
|
|
)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_tdst_Cxt_Description *p_stContext;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_D
|
|
(
|
|
(_p_stContextValues != NULL)
|
|
|| (_p_stFileValues != NULL)
|
|
|| (_p_stSectionValues != NULL)
|
|
);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
/*
|
|
* Compute context to get results.
|
|
*/
|
|
p_stContext = fnp_st_Cxt_Compute(_iOffset);
|
|
|
|
/*
|
|
* Set values.
|
|
*/
|
|
if(_p_stContextValues)
|
|
{
|
|
memcpy
|
|
(
|
|
_p_stContextValues,
|
|
&p_stContext->stContextValues,
|
|
sizeof(SCR_tdst_Cxt_Values)
|
|
);
|
|
}
|
|
if(_p_stFileValues)
|
|
{
|
|
SCR_M_Dbg_Assert_D(_iOffset <= 0);
|
|
SCR_M_Dbg_Assert_D(p_stContext->p_stOpenFile != NULL);
|
|
SCR_M_Dbg_AssertStruct_P(SCR_tdst_File_Open, p_stContext->p_stOpenFile);
|
|
memcpy
|
|
(
|
|
_p_stFileValues,
|
|
&p_stContext->p_stOpenFile->stFileValues,
|
|
sizeof(SCR_tdst_Cxt_Values)
|
|
);
|
|
}
|
|
if(_p_stSectionValues)
|
|
{
|
|
SCR_M_Dbg_Assert_D(_iOffset <= 0);
|
|
SCR_M_Dbg_Assert_D(p_stContext->p_stOpenSection != NULL);
|
|
SCR_M_Dbg_AssertStruct_P(SCR_tdst_Sect_Open, p_stContext->p_stOpenSection);
|
|
memcpy
|
|
(
|
|
_p_stSectionValues,
|
|
&p_stContext->p_stOpenSection->stSectionValues,
|
|
sizeof(SCR_tdst_Cxt_Values)
|
|
);
|
|
}
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(;)
|
|
|
|
/*
|
|
*=================================================================================================
|
|
* Errors.
|
|
*=================================================================================================
|
|
*/
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To register an error callback.
|
|
* _pfn_Callback : Callback to register.
|
|
* _uwMode : Additional mode to process errors.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
SCR_tdpfn_Err_Callback SCR_fnp_fn_RdL0_RegisterErrorCallback
|
|
(
|
|
SCR_tdpfn_Err_Callback _pfn_Callback,
|
|
unsigned short _uwMode
|
|
)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_tdpfn_Err_Callback pfn_Last = SCR_g_pfn_Err_Callback;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_g_pfn_Err_Callback = _pfn_Callback;
|
|
SCR_g_uw_Err_Mode = _uwMode;
|
|
SCR_RETURN(pfn_Last);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(NULL)
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To get the last error.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
SCR_tdst_Err_GlobalError *SCR_fnp_st_RdL0_GetLastError(void)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
if(g_st_Err_GlobalError.eErrorId == SCR_EI_Err_None)
|
|
SCR_RETURN(NULL);
|
|
SCR_RETURN(&g_st_Err_GlobalError);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(NULL)
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To clear the last error.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void SCR_fn_v_RdL0_ClearError(void)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
g_st_Err_GlobalError.eErrorId = SCR_EI_Err_None;
|
|
g_i_Err_GlobalReturn = 0;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(;)
|
|
|
|
/*
|
|
*=================================================================================================
|
|
* A lot of things...
|
|
*=================================================================================================
|
|
*/
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* _p_szSectionName : Additionnal directory.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
char SCR_fn_c_RdL0_IsSectionExists(char *_p_szSectionName)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
char a_szFileName[_MAX_PATH];
|
|
char *p_szSection;
|
|
SCR_tdst_File_Open *p_stOpen, *p_stNewOpen = NULL;
|
|
SCR_tdst_File_Open stOpenFile;
|
|
SCR_tdx_Hash_Key xHashKey;
|
|
int iRes;
|
|
long lCurrentPos;
|
|
SCR_FILE xSaveHandle;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_D(_p_szSectionName != NULL);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
/*
|
|
* Isolate file name.
|
|
*/
|
|
p_szSection = strchr(_p_szSectionName, SCR_CC_c_Cfg_NameSeparator);
|
|
if(p_szSection)
|
|
*p_szSection = '\0';
|
|
strcpy(a_szFileName, _p_szSectionName);
|
|
if(p_szSection)
|
|
*p_szSection = SCR_CC_c_Cfg_NameSeparator;
|
|
|
|
/*
|
|
* Determin if file is already open.
|
|
*/
|
|
xHashKey = SCR_fn_x_Hash_ComputeHashKeyForString(a_szFileName);
|
|
p_stOpen = p_stNewOpen = fnp_st_File_SearchOpenWithPath(a_szFileName, xHashKey);
|
|
|
|
if(p_stOpen)
|
|
{
|
|
/*
|
|
* No section specified (only a file name). Success.
|
|
*/
|
|
if(!p_szSection)
|
|
SCR_RETURN(1);
|
|
|
|
/*
|
|
* Section description already present.
|
|
*/
|
|
iRes = fnp_st_Anl_SearchSectionDes(p_stOpen, _p_szSectionName, 0, 0) != NULL ? 1 : 0;
|
|
if(iRes)
|
|
SCR_RETURN(1);
|
|
|
|
/*
|
|
* We save actual handle and position of the open file.
|
|
*/
|
|
xSaveHandle = p_stOpen->stFile.p_stHandle->xHandle;
|
|
if(p_stOpen->stFile.p_stHandle->xHandle)
|
|
lCurrentPos = SCR_M_ftell(&p_stOpen->stFile);
|
|
else
|
|
lCurrentPos = p_stOpen->lSeekWhenClosed;
|
|
|
|
/*
|
|
* Open the file to parse it in totality.
|
|
*/
|
|
SCR_fn_v_RdL0_OpenFile(a_szFileName);
|
|
iRes = fnp_st_Anl_SearchSectionDes(p_stOpen, _p_szSectionName, 0, 0) != NULL ? 1 : 0;
|
|
|
|
/*
|
|
* Restore context (handle and previous pos).
|
|
*/
|
|
SCR_M_File_Seek(&p_stOpen->stFile, lCurrentPos, SEEK_SET);
|
|
if(p_stOpen->stFile.p_stHandle->xHandle != xSaveHandle)
|
|
SCR_M_File_Close(&p_stOpen->stFile);
|
|
p_stOpen->stFile.p_stHandle->xHandle = xSaveHandle;
|
|
|
|
SCR_RETURN((char) iRes);
|
|
}
|
|
else /****************************************************************************************/
|
|
{
|
|
/*
|
|
* We try to open the file (depending on paths).
|
|
*/
|
|
stOpenFile.lSeekWhenClosed = 0;
|
|
SCR_M_Dbg_UpdateSizeOf_P(SCR_tdst_File_Open, &stOpenFile);
|
|
SCR_fn_v_File_InitFileDes(&stOpenFile.stFile, a_szFileName, (SCR_FILE) 0);
|
|
iRes = (int) fn_c_File_TryToOpen(&stOpenFile);
|
|
SCR_fn_v_File_CloseFileDes(&stOpenFile.stFile);
|
|
|
|
/*
|
|
* Failed : File does not exist, so section does not exist too.
|
|
*/
|
|
if(!iRes)
|
|
SCR_RETURN(0);
|
|
|
|
/*
|
|
* Success : If no section name specified (only a file name), section exists (cause file exists).
|
|
*/
|
|
if(!p_szSection)
|
|
SCR_RETURN(1);
|
|
|
|
/*
|
|
* Else we open the file to parse it.
|
|
*/
|
|
SCR_fn_v_RdL0_OpenFile(a_szFileName);
|
|
p_stOpen = SCR_fnp_st_RdL0_GetOpenFile(a_szFileName);
|
|
iRes = fnp_st_Anl_SearchSectionDes(p_stOpen, _p_szSectionName, 0, 0) ? 1 : 0;
|
|
SCR_fn_v_RdL0_DeleteOpenFile(a_szFileName, SCR_CDR_c_RdL0_Match);
|
|
|
|
SCR_RETURN((char) iRes);
|
|
}
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(0)
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To be sure that a directorie exists, we create all sub one if necessary.
|
|
* Thanks to DFM for the code.
|
|
* _p_szStartPath : Starting directory to test.
|
|
* _p_szFileName : Additionnal directory.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void SCR_fn_v_RdL0_ValidatePath(char *_p_szStartPath, char *_p_szFileName)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
char a_szCurrentDir[_MAX_PATH];
|
|
char a_szCompleteFileName[_MAX_PATH];
|
|
char *p_szCompleteFileName, *p_szTemp;
|
|
char cMemo1, cMemo2;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_D(_p_szStartPath != NULL);
|
|
SCR_M_Dbg_Assert_D(_p_szFileName != NULL);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
/* Unix style convert */
|
|
while(strchr(_p_szStartPath, '/'))
|
|
*strchr(_p_szStartPath,'/') = '\\';
|
|
while(strchr(_p_szFileName,'/'))
|
|
*strchr(_p_szFileName,'/') = '\\';
|
|
|
|
/* Compute complete name */
|
|
if(_p_szStartPath[strlen(_p_szStartPath) - 1] == '\\')
|
|
sprintf(a_szCompleteFileName, "%s%s", _p_szStartPath, _p_szFileName);
|
|
else
|
|
sprintf(a_szCompleteFileName, "%s\\%s", _p_szStartPath, _p_szFileName);
|
|
|
|
p_szCompleteFileName = a_szCompleteFileName;
|
|
|
|
/* Get current directory to restore it at the end of the analyse */
|
|
getcwd(a_szCurrentDir, _MAX_PATH);
|
|
|
|
/* Is it an absolute path ? */
|
|
if(p_szCompleteFileName[0] && p_szCompleteFileName[1] == ':')
|
|
{
|
|
cMemo1 = p_szCompleteFileName[2];
|
|
p_szCompleteFileName[2] = '\\';
|
|
cMemo2 = p_szCompleteFileName[3];
|
|
p_szCompleteFileName[3] = '\0';
|
|
|
|
if(chdir(p_szCompleteFileName) == -1)
|
|
{
|
|
sprintf(g_st_Err_GlobalError.a_szBufferTmp1, "Path is \"%s\".\n", p_szCompleteFileName);
|
|
*g_st_Err_GlobalError.a_szBufferTmp2 = '\0';
|
|
SCR_M_Err_RaiseError(SCR_EI_Err_CreatePath);
|
|
}
|
|
|
|
p_szCompleteFileName[2] = cMemo1;
|
|
p_szCompleteFileName[3] = cMemo2;
|
|
}
|
|
|
|
/* Get and create directories */
|
|
while((p_szTemp = strchr(p_szCompleteFileName,'\\')) != NULL)
|
|
{
|
|
*p_szTemp = '\0';
|
|
if(*p_szCompleteFileName != '\0')
|
|
{
|
|
if(chdir(p_szCompleteFileName) == -1)
|
|
{
|
|
mkdir(p_szCompleteFileName);
|
|
if(chdir(p_szCompleteFileName) == -1)
|
|
{
|
|
sprintf(g_st_Err_GlobalError.a_szBufferTmp1, "Path is \"%s\".\n", p_szCompleteFileName);
|
|
*g_st_Err_GlobalError.a_szBufferTmp2 = '\0';
|
|
SCR_M_Err_RaiseError(SCR_EI_Err_CreatePath);
|
|
}
|
|
}
|
|
p_szCompleteFileName += strlen(p_szCompleteFileName) + 1;
|
|
*p_szTemp = '\\';
|
|
}
|
|
else
|
|
chdir("\\");
|
|
}
|
|
if(chdir(a_szCurrentDir) == -1)
|
|
{
|
|
sprintf(g_st_Err_GlobalError.a_szBufferTmp1, "Path is \"%s\".\n", a_szCurrentDir);
|
|
*g_st_Err_GlobalError.a_szBufferTmp2 = '\0';
|
|
SCR_M_Err_RaiseError(SCR_EI_Err_CreatePath);
|
|
}
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(;)
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To get the number of parameters passed to a callback.
|
|
* _a_szParams : Parameters to test.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
unsigned char SCR_fn_uc_RdL0_GetNumberOfParameters(char *_a_szParams[])
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
unsigned char ucIndex;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_D(_a_szParams != NULL);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
/*
|
|
* Count until a NULL parameter.
|
|
*/
|
|
ucIndex = 0;
|
|
while(_a_szParams[ucIndex])
|
|
ucIndex++;
|
|
SCR_M_Dbg_Assert_D(ucIndex < SCR_CV_ui_Cfg_MaxNumPars);
|
|
SCR_RETURN(ucIndex);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(0)
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To split a complete file/section in three parts (first, action and id).
|
|
* _p_szSource : Name to split.
|
|
* _p_szFirstPart : To receive the first part of the complete name.
|
|
* _p_szActionPart : To receive action part of section name.
|
|
* _p_szIdPart : To receive id part of section name.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void SCR_fn_v_RdL0_SplitSectionName
|
|
(
|
|
char *_p_szSource,
|
|
char *_p_szFirstPart,
|
|
char *_p_szActionPart,
|
|
char *_p_szIdPart
|
|
)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
char a_szBuffer[SCR_CV_ui_Cfg_MaxLenName];
|
|
char *p_szTemp, *p_szTemp1;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_D(_p_szSource != NULL);
|
|
SCR_M_Dbg_Assert_D((_p_szFirstPart != NULL) || (_p_szActionPart != NULL) || (_p_szIdPart != NULL));
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
/*
|
|
* Init dest buffer.
|
|
*/
|
|
strcpy(a_szBuffer, _p_szSource);
|
|
_p_szSource = a_szBuffer;
|
|
if(_p_szFirstPart)
|
|
*_p_szFirstPart = '\0';
|
|
if(_p_szActionPart)
|
|
*_p_szActionPart = '\0';
|
|
if(_p_szIdPart)
|
|
*_p_szIdPart = '\0';
|
|
|
|
/* Get position for action and id part */
|
|
p_szTemp = strrchr(_p_szSource, SCR_CC_c_Cfg_SectionIdMark);
|
|
p_szTemp1 = strrchr(_p_szSource, SCR_CC_c_Cfg_NameSeparator);
|
|
if(p_szTemp && p_szTemp1 && (p_szTemp < p_szTemp1)) /* If subsection without id part, but parent section with */
|
|
p_szTemp = NULL;
|
|
|
|
/*
|
|
* Id part.
|
|
*/
|
|
if((p_szTemp) && (_p_szIdPart))
|
|
strcpy(_p_szIdPart, p_szTemp + 1);
|
|
|
|
/*
|
|
* First part.
|
|
*/
|
|
if(p_szTemp1)
|
|
{
|
|
*p_szTemp1 = '\0';
|
|
if(_p_szFirstPart)
|
|
strcpy(_p_szFirstPart, _p_szSource);
|
|
_p_szSource = p_szTemp1 + 1;
|
|
}
|
|
|
|
/*
|
|
* Action part.
|
|
*/
|
|
if(_p_szActionPart)
|
|
{
|
|
if(p_szTemp) /* Break to id part */
|
|
*p_szTemp = '\0';
|
|
strcpy(_p_szActionPart, _p_szSource);
|
|
}
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(;)
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To split a complete path in register / no register.
|
|
* _p_szSourcePath : Path name to split.
|
|
* _p_szRegister : The complete register path (can be NULL).
|
|
* _p_szNoRegister : The rest of the string (can be NULL).
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void SCR_fn_v_RdL0_SplitCompletePath
|
|
(
|
|
char *_p_szSourcePath,
|
|
char *_p_szRegister,
|
|
char *_p_szNoRegister
|
|
)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
char a_szBuffer[SCR_CV_ui_Cfg_MaxLenName];
|
|
char *p_szTemp, *p_szLastTemp, *p_szSource;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_D(_p_szRegister || _p_szNoRegister);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
strcpy(a_szBuffer, _p_szSourcePath);
|
|
p_szSource = a_szBuffer;
|
|
|
|
/* Init dest strings */
|
|
if(_p_szRegister)
|
|
*_p_szRegister = '\0';
|
|
if(_p_szNoRegister)
|
|
*_p_szNoRegister = '\0';
|
|
|
|
/* Check for all paths */
|
|
do
|
|
{
|
|
p_szTemp = strchr(p_szSource, '\\');
|
|
if(p_szTemp)
|
|
*p_szTemp = '\0';
|
|
|
|
if(SCR_fnp_st_RdL0_GetRegisterPath(p_szSource))
|
|
{
|
|
while(p_szTemp && (SCR_fnp_st_RdL0_GetRegisterPath(p_szSource)))
|
|
{
|
|
p_szLastTemp = p_szTemp;
|
|
*p_szTemp = '\\';
|
|
p_szTemp = strchr(p_szTemp + 1, '\\');
|
|
if(p_szTemp)
|
|
*p_szTemp = '\0';
|
|
}
|
|
|
|
*p_szLastTemp = '\0';
|
|
if(p_szTemp)
|
|
*p_szTemp = '\\';
|
|
|
|
if(_p_szRegister)
|
|
{
|
|
strcat(_p_szRegister, p_szSource);
|
|
if(p_szTemp)
|
|
strcat(_p_szRegister, "\\");
|
|
}
|
|
p_szSource = p_szLastTemp + 1;
|
|
if(!p_szTemp)
|
|
{
|
|
if(_p_szNoRegister)
|
|
strcpy(_p_szNoRegister, p_szSource);
|
|
if(_p_szRegister && *(_p_szRegister + strlen(_p_szRegister) - 1) == '\\')
|
|
*(_p_szRegister + strlen(_p_szRegister) - 1) = '\0';
|
|
SCR_RETURN(;);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(p_szTemp)
|
|
*p_szTemp = '\\';
|
|
if(_p_szNoRegister)
|
|
strcpy(_p_szNoRegister, p_szSource);
|
|
if(_p_szRegister && *(_p_szRegister + strlen(_p_szRegister) - 1) == '\\')
|
|
*(_p_szRegister + strlen(_p_szRegister) - 1) = '\0';
|
|
SCR_RETURN(;);
|
|
}
|
|
} while(p_szTemp);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(;)
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To compute a complete file/section in three parts (first, action and id).
|
|
* _p_szDest : To receive the name.
|
|
* _p_szFirstPart : First part of the complete name (can be NULL).
|
|
* _p_szActionPart : Action part of section name.
|
|
* _p_szIdPart : Id part of section name (can be NULL).
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void SCR_fn_v_RdL0_ComputeSectionName
|
|
(
|
|
char *_p_szDest,
|
|
char *_p_szFirstPart,
|
|
char *_p_szActionPart,
|
|
char *_p_szIdPart
|
|
)
|
|
SCR_BEGIN
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_D(_p_szDest != NULL);
|
|
SCR_M_Dbg_Assert_D(_p_szActionPart != NULL);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
*_p_szDest = '\0';
|
|
if(_p_szFirstPart)
|
|
{
|
|
strcpy(_p_szDest, _p_szFirstPart);
|
|
strcat(_p_szDest, SCR_CC_sz_Cfg_NameSeparator);
|
|
}
|
|
strcat(_p_szDest, _p_szActionPart);
|
|
if((_p_szIdPart) && (*_p_szIdPart != '\0'))
|
|
{
|
|
strcat(_p_szDest, SCR_CC_sz_Cfg_SectionIdMark);
|
|
strcat(_p_szDest, _p_szIdPart);
|
|
}
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_CEND(;)
|