/*
 *%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 *  SCR_SvL1.c
 *  Functions for saving, level 1.
 *
 *  Scripts, Beaudet Christophe
 *%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 */
 
/*
 *=================================================================================================
 *  Includes.
 *=================================================================================================
 */
 
#include <memory.h>
#include "SCR.h"
 
/*
 *=================================================================================================
 *  Global variables.
 *=================================================================================================
 */
 
char	gs_a_szModifyFileName[_MAX_PATH] = "SCR_Mdf.txt";
 
/*
 *=================================================================================================
 *  Functions.
 *=================================================================================================
 */
 
/*
 *-------------------------------------------------------------------------------------------------
 *  To notify a modification to the script saver.
 *  _p_szSectionName    :   Section modify.
 *  _pfn_vCallback      :   Call back to call by the script saver.
 *  _p_vData            :   Data associated to the notification.
 *  _eAction            :   Real modification action.
 *-------------------------------------------------------------------------------------------------
 */
void SCR_fn_v_SvL1_RegisterNotify
(
    char                    *_p_szSectionName,
    SCR_tdpfn_Ntfy_Callback _pfn_vCallback,
    void                    *_p_vData,
    SCR_tde_Ntfy_Action     _eAction
)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    SCR_tdst_Ntfy_Description   *p_stNotify;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    SCR_M_Dbg_Assert_D(_p_szSectionName != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    /*
     *  Is there already a notification ?
     */
    p_stNotify = SCR_fnp_st_SvL1_GetRegisterNotify(_p_szSectionName);
    if(p_stNotify)
    {
        /* Single replacement */
        if(_eAction == p_stNotify->eAction)
        {
            p_stNotify->pfn_vCallback = _pfn_vCallback;
            p_stNotify->p_vData = _p_vData;
            SCR_RETURN(;);
        }
 
        switch(_eAction)
        {
		/*---------------------------------------------------------------------------------------------*/
		case SCR_EA_Ntfy_AddOrModifySection:
		case SCR_EA_Ntfy_AddOrRebuildSection:
            p_stNotify->pfn_vCallback = _pfn_vCallback;
            p_stNotify->p_vData = _p_vData;
            p_stNotify->eAction = _eAction;
            SCR_RETURN(;);
			break;
 
		/*---------------------------------------------------------------------------------------------*/
        case SCR_EA_Ntfy_AddSection:
            switch(p_stNotify->eAction)
            {
			case SCR_EA_Ntfy_AddOrModifySection:
			case SCR_EA_Ntfy_AddOrRebuildSection:
				p_stNotify->pfn_vCallback = _pfn_vCallback;
				p_stNotify->p_vData = _p_vData;
				p_stNotify->eAction = _eAction;
				SCR_RETURN(;);
 
            case SCR_EA_Ntfy_DeleteSection:
                p_stNotify->pfn_vCallback = _pfn_vCallback;
                p_stNotify->p_vData = _p_vData;
                p_stNotify->eAction = SCR_EA_Ntfy_RebuildSection;
                SCR_RETURN(;);
 
            case SCR_EA_Ntfy_DeleteIfExists:
                p_stNotify->pfn_vCallback = _pfn_vCallback;
                p_stNotify->p_vData = _p_vData;
                p_stNotify->eAction = SCR_EA_Ntfy_AddOrRebuildSection;
                SCR_RETURN(;);
 
            case SCR_EA_Ntfy_RebuildSection:
            case SCR_EA_Ntfy_ModifySection:
				SCR_M_Dbg_Assert_D(0);
            }
            break;
 
		/*---------------------------------------------------------------------------------------------*/
        case SCR_EA_Ntfy_DeleteSection:
        case SCR_EA_Ntfy_DeleteIfExists:
            switch(p_stNotify->eAction)
            {
            case SCR_EA_Ntfy_AddSection:
                SCR_fn_v_SvL1_DeleteRegisterNotify(_p_szSectionName, SCR_CDR_c_RdL0_Match);
                SCR_RETURN(;);
 
			case SCR_EA_Ntfy_DeleteIfExists:
                p_stNotify->pfn_vCallback = _pfn_vCallback;
                p_stNotify->p_vData = _p_vData;
                p_stNotify->eAction = SCR_EA_Ntfy_DeleteIfExists;
                SCR_RETURN(;);
 
			case SCR_EA_Ntfy_AddOrModifySection:
			case SCR_EA_Ntfy_AddOrRebuildSection:
                p_stNotify->pfn_vCallback = _pfn_vCallback;
                p_stNotify->p_vData = _p_vData;
                p_stNotify->eAction = SCR_EA_Ntfy_DeleteIfExists;
                SCR_RETURN(;);
 
            case SCR_EA_Ntfy_ModifySection:
            case SCR_EA_Ntfy_RebuildSection:
                p_stNotify->pfn_vCallback = _pfn_vCallback;
                p_stNotify->p_vData = _p_vData;
                p_stNotify->eAction = _eAction;
                SCR_RETURN(;);
            }
            break;
 
		/*---------------------------------------------------------------------------------------------*/
        case SCR_EA_Ntfy_ModifySection:
            switch(p_stNotify->eAction)
            {
			case SCR_EA_Ntfy_AddOrModifySection:
			case SCR_EA_Ntfy_AddOrRebuildSection:
				p_stNotify->pfn_vCallback = _pfn_vCallback;
				p_stNotify->p_vData = _p_vData;
				p_stNotify->eAction = SCR_EA_Ntfy_AddOrModifySection;
				SCR_RETURN(;);
 
            case SCR_EA_Ntfy_AddSection:
                p_stNotify->pfn_vCallback = _pfn_vCallback;
                p_stNotify->p_vData = _p_vData;
                SCR_RETURN(;);
 
            case SCR_EA_Ntfy_DeleteSection:
            case SCR_EA_Ntfy_DeleteIfExists:
				SCR_M_Dbg_Assert_D(0);
 
            case SCR_EA_Ntfy_RebuildSection:
                p_stNotify->pfn_vCallback = _pfn_vCallback;
                p_stNotify->p_vData = _p_vData;
                SCR_RETURN(;);
            }
            break;
 
		/*---------------------------------------------------------------------------------------------*/
        case SCR_EA_Ntfy_RebuildSection:
            switch(p_stNotify->eAction)
            {
            case SCR_EA_Ntfy_AddSection:
				p_stNotify->pfn_vCallback = _pfn_vCallback;
				p_stNotify->p_vData = _p_vData;
                SCR_RETURN(;);
 
            case SCR_EA_Ntfy_DeleteSection:
            case SCR_EA_Ntfy_DeleteIfExists:
				SCR_M_Dbg_Assert_D(0);
 
			case SCR_EA_Ntfy_AddOrModifySection:
			case SCR_EA_Ntfy_AddOrRebuildSection:
				p_stNotify->pfn_vCallback = _pfn_vCallback;
				p_stNotify->p_vData = _p_vData;
                p_stNotify->eAction = SCR_EA_Ntfy_AddOrRebuildSection;
                SCR_RETURN(;);
 
            case SCR_EA_Ntfy_ModifySection:
                p_stNotify->pfn_vCallback = _pfn_vCallback;
                p_stNotify->p_vData = _p_vData;
                p_stNotify->eAction = _eAction;
                SCR_RETURN(;);
            }
            break;
        }
    }
 
    /*
     *  We add that one.
     */
    fn_v_Ntfy_Add(_p_szSectionName, _pfn_vCallback, _p_vData, _eAction);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(;)
 
/*
 *-------------------------------------------------------------------------------------------------
 *  To delete one or more registered notifications.
 *  _p_szSectionName    :   Name of section name for notify to delete.
 *  _cMatch             :   Exact string or string contains.
 *-------------------------------------------------------------------------------------------------
 */
void SCR_fn_v_SvL1_DeleteRegisterNotify
(
    char *_p_szSectionName, 
    char _cMatch
)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    SCR_tdst_Ntfy_Description   *p_stNotify;
    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_Ntfy_Description, uiPos, p_stNotify, SCR_g_st_Ntfy_Array);
    while(p_stNotify)
    {
        switch(_cMatch)
        {
        /* Found name must be exactly the same */
        case SCR_CDR_c_RdL0_Match:
            if(!strcmpi(p_stNotify->a_szSectionName, _p_szSectionName))
                fn_v_Ntfy_Delete(p_stNotify);
            break;
 
        /* Found name must have inside it the parameter */
        case SCR_CDR_c_RdL0_Contains:
            if(strstri(p_stNotify->a_szSectionName, _p_szSectionName))
                fn_v_Ntfy_Delete(p_stNotify);
            break;
 
        /* Found name must not have inside it the parameter */
        case SCR_CDR_c_RdL0_NotContains:
            if(!strstri(p_stNotify->a_szSectionName, _p_szSectionName))
                fn_v_Ntfy_Delete(p_stNotify);
            break;
        }
        uiPos++;
        SCR_M_DyAr_GetNextElement(SCR_tdst_Ntfy_Description, uiPos, p_stNotify, SCR_g_st_Ntfy_Array);
    }
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(;)
 
/*
 *-------------------------------------------------------------------------------------------------
 *  To get an already registered notification.
 *  _p_szSectionName    :   Name of section name for notify to delete.
 *-------------------------------------------------------------------------------------------------
 */
SCR_tdst_Ntfy_Description *SCR_fnp_st_SvL1_GetRegisterNotify(char *_p_szSectionName)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    SCR_M_Dbg_Assert_D(_p_szSectionName != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    /* 
     *  Search and return address.
     */
    SCR_RETURN(fnp_st_Ntfy_Search(_p_szSectionName));
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(NULL)
 
/*===============================================================================================*/
 
/*
 *-------------------------------------------------------------------------------------------------
 *  To go to the previous line.
 *  _p_stFile   :   File concerned.
 *-------------------------------------------------------------------------------------------------
 */
void SCR_fn_v_SvL1_ToPrevLine(SCR_tdst_File_Description *_p_stFile)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    char    cChar, cCnt;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    SCR_M_Dbg_Assert_D(_p_stFile != NULL);
    SCR_M_Dbg_Assert_D(_p_stFile->d_stFirstPage != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    cCnt = 0;
    do
    {
        if((_p_stFile->iCurPosInPage == 0) && (_p_stFile->d_stCurPage->p_stPrev == NULL))
            break;
        fn_v_Page_ToPrevChar(_p_stFile);
        cChar = _p_stFile->d_stCurPage->d_cBuffer[_p_stFile->iCurPosInPage];
        if(cChar == '\n')
            cCnt++;
    } while(cCnt != 2);
    if(cChar == '\n')
        fn_v_Page_ToNextChar(_p_stFile);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(;)
 
/*
 *-------------------------------------------------------------------------------------------------
 *  To get the current line.
 *  _p_stFile   :   File concerned.
 *	_p_szDest	:	Destination buffer.
 *-------------------------------------------------------------------------------------------------
 */
unsigned int SCR_fn_ui_SvL1_GetLine(SCR_tdst_File_Description *_p_stFile, char *_p_szDest)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	int				iRead;
	unsigned int	uiMemo, uiReturn;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    SCR_M_Dbg_Assert_D(_p_stFile != NULL);
	SCR_M_Dbg_Assert_D(_p_szDest != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 
	uiMemo = SCR_g_ui_Pars_NbRead;
	uiReturn = 0;
	do
	{
		uiReturn++;
		SCR_M_Pars_ReadChar(_p_stFile, iRead);
		if((iRead != '\r') && (iRead != '\n') && (iRead != EOF))
			*_p_szDest++ = (char) iRead;
	} while((iRead != '\n') && (iRead != EOF));
	*_p_szDest = '\0';
	SCR_g_ui_Pars_NbRead = uiMemo;
	SCR_RETURN(uiReturn);
SCR_CEND(0)
 
/*
 *-------------------------------------------------------------------------------------------------
 *  To go to the next line.
 *  _p_stFile   :   File concerned.
 *-------------------------------------------------------------------------------------------------
 */
void SCR_fn_v_SvL1_ToNextLine(SCR_tdst_File_Description *_p_stFile)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    SCR_tdst_Cxt_Description    *p_stContext;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    SCR_M_Dbg_Assert_D(_p_stFile != NULL);
    SCR_M_Dbg_Assert_D(_p_stFile->d_stFirstPage != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	_p_stFile = _p_stFile;
    p_stContext = fnp_st_Cxt_Compute(0);
    fn_i_Anl_LineToContext(p_stContext);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(;)
 
/*
 *-------------------------------------------------------------------------------------------------
 *  To place current position to the next section.
 *  _p_stFile   :   File concerned.
 *-------------------------------------------------------------------------------------------------
 */
void SCR_fn_v_SvL1_ToNextSection(SCR_tdst_File_Description *_p_stFile)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    SCR_tdst_Cxt_Description    *p_stContext;
    int                         iRead;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    SCR_M_Dbg_Assert_D(_p_stFile != NULL);
    SCR_M_Dbg_Assert_D(_p_stFile->d_stFirstPage != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	_p_stFile = _p_stFile;
    p_stContext = fnp_st_Cxt_Compute(0);
    iRead = fn_i_Anl_LineToContext(p_stContext);
    while(iRead != EOF)
    {
        if(p_stContext->eParseType == SCR_EPT_Cxt_BeginSection)
            SCR_RETURN(;);
        iRead = fn_i_Anl_LineToContext(p_stContext);
    }
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(;)
 
/*
 *-------------------------------------------------------------------------------------------------
 *  To place current position to the end of current section.
 *  _p_stFile   :   File concerned.
 *-------------------------------------------------------------------------------------------------
 */
void SCR_fn_v_SvL1_ToEndSection(SCR_tdst_File_Description *_p_stFile)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    SCR_tdst_Cxt_Description    *p_stContext;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    SCR_M_Dbg_Assert_D(_p_stFile != NULL);
    SCR_M_Dbg_Assert_D(_p_stFile->d_stFirstPage != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	_p_stFile = _p_stFile;
    p_stContext = fnp_st_Cxt_Compute(0);
    fn_v_Anl_ContextToEndSection(p_stContext);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(;)
 
/*===============================================================================================*/
 
/*
 *-------------------------------------------------------------------------------------------------
 *  To delete current line.
 *  _p_stFile   :   File concerned.
 *-------------------------------------------------------------------------------------------------
 */
void SCR_fn_v_SvL1_DeleteLine(SCR_tdst_File_Description *_p_stFile)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    SCR_tdst_Page_Description   *p_stPage;
    char                        cChar;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    SCR_M_Dbg_Assert_D(_p_stFile != NULL);
    SCR_M_Dbg_Assert_D(_p_stFile->d_stFirstPage != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    p_stPage = _p_stFile->d_stCurPage;
 
    /* 
     *  To the beginning of line.
     */
    do
    {
        if((_p_stFile->iCurPosInPage == 0) && (_p_stFile->d_stCurPage->p_stPrev == NULL))
            break;
        fn_v_Page_ToPrevChar(_p_stFile);
        cChar = _p_stFile->d_stCurPage->d_cBuffer[_p_stFile->iCurPosInPage];
    } while(cChar != '\n');
    if(cChar == '\n')
        fn_v_Page_ToNextChar(_p_stFile);
 
    /* 
     *  Delete line.
     */
    cChar = _p_stFile->d_stCurPage->d_cBuffer[_p_stFile->iCurPosInPage];
    while((cChar != '\n') && (cChar != 0))
    {
        fn_v_Page_DeleteChar(_p_stFile);
        cChar = _p_stFile->d_stCurPage->d_cBuffer[_p_stFile->iCurPosInPage];
    }
    if(cChar == '\n')
        fn_v_Page_DeleteChar(_p_stFile);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(;)
 
/*
 *-------------------------------------------------------------------------------------------------
 *  To delete current section.
 *  _p_stFile   :   File concerned.
 *-------------------------------------------------------------------------------------------------
 */
void SCR_fn_v_SvL1_DeleteSection(SCR_tdst_File_Description *_p_stFile)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    SCR_tdst_Page_Description   *p_stMemo, *p_stDest;
    int                         iCount, iMemo, iDest;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    SCR_M_Dbg_Assert_D(_p_stFile != NULL);
    SCR_M_Dbg_Assert_D(_p_stFile->d_stFirstPage != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    /* 
     *  Save current position.
     */
    p_stMemo = _p_stFile->d_stCurPage;
    iMemo = _p_stFile->iCurPosInPage;
 
    /* 
     *  Get position of end of section.
     */
    SCR_fn_v_SvL1_ToEndSection(_p_stFile);
    p_stDest = _p_stFile->d_stCurPage;
    iDest = _p_stFile->iCurPosInPage;
 
    /* 
     *  Restore previous position.
     */
    _p_stFile->d_stCurPage = p_stMemo;
    _p_stFile->iCurPosInPage = iMemo;
 
    /* 
     *  Same page ?.
     */
    if(p_stMemo == p_stDest)
        iCount = iDest - iMemo;
    else
    {
        /* Count number of characters to delete */
        iCount = p_stMemo->iNumOfChars - iMemo;         /* First page */
        while(p_stMemo->p_stNext != p_stDest)
        {
            p_stMemo = p_stMemo->p_stNext;
            iCount += p_stMemo->iNumOfChars;
        }
        iCount += iDest;                                /* Last page */
    }
 
    /* 
     *  Delete all characters.
     */
	while(_p_stFile->iCurPosInPage + iCount > _p_stFile->d_stCurPage->iNumOfChars)
	{
		if(_p_stFile->iCurPosInPage == 0)
		{
			iCount -= (_p_stFile->d_stCurPage->iNumOfChars - _p_stFile->iCurPosInPage);
			p_stMemo = _p_stFile->d_stCurPage;
			_p_stFile->d_stCurPage = _p_stFile->d_stCurPage->p_stNext;
			_p_stFile->iCurPosInPage = 0;
			fn_v_Page_Unlink(_p_stFile, p_stMemo);
			fn_v_Page_Free(p_stMemo);
		}
		else
		{
			iCount -= (_p_stFile->d_stCurPage->iNumOfChars - _p_stFile->iCurPosInPage);
			_p_stFile->d_stCurPage->iNumOfChars -= (_p_stFile->d_stCurPage->iNumOfChars - _p_stFile->iCurPosInPage);
			_p_stFile->d_stCurPage = _p_stFile->d_stCurPage->p_stNext;
			_p_stFile->iCurPosInPage = 0;
		}
	}
    while(iCount--)
        fn_v_Page_DeleteChar(_p_stFile);
 
    /* 
     *  Delete section header.
     */
    SCR_fn_v_SvL1_ToPrevLine(_p_stFile);
    SCR_fn_v_SvL1_DeleteLine(_p_stFile);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(;)
 
/*===============================================================================================*/
 
/*
 *-------------------------------------------------------------------------------------------------
 *  To update one notification.
 *  _p_stNotify		:	First notification.
 *	_p_stOpenFile	:	File to update.
 *	_eAction		:	Action to notify.
 *	_eRealAction	:	Just in case of a dual action, only this one will be treat.
 *	_cFileCreated	:	The file has just been created cause it didn't exist.
 *	Return 1 to continue, 0 to stop.
 *-------------------------------------------------------------------------------------------------
 */
char fn_c_SvL1_UpdateWithAction
(
	SCR_tdst_Ntfy_Description	*_p_stNotify, 
	SCR_tdst_File_Open			*_p_stOpenFile,
    SCR_tdst_Cxt_Description    *_p_stContext,
	SCR_tde_Ntfy_Action			_eAction,
	SCR_tde_Ntfy_Action			_eRealAction,
	char						_cFileCreated
)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    char    *p_szLastSep, *p_szFirstSep;
	char	cSectionExists;
	char	a_szTemp[SCR_CV_ui_Cfg_MaxLenName];
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	/*
	 *	Pre-processing for AddOr????.
	 *	For a file, only take care of "_bFileCreated".
	 */
	switch(_p_stNotify->eAction)
	{
	/*-----------------------------------------------------------------------------------*/
	case SCR_EA_Ntfy_AddOrModifySection:
	/*-----------------------------------------------------------------------------------*/
		if(strchr(_p_stNotify->a_szSectionName, SCR_CC_c_Cfg_NameSeparator))
			cSectionExists = SCR_fn_c_RdL0_IsSectionExists(_p_stNotify->a_szSectionName);
		else
		{
			if(_cFileCreated)
				cSectionExists = 0;
			else
				cSectionExists = 1;
		}
 
		if(cSectionExists)
			_p_stNotify->eAction = SCR_EA_Ntfy_ModifySection;
		else
			_p_stNotify->eAction = SCR_EA_Ntfy_AddSection;
		break;
 
	/*-----------------------------------------------------------------------------------*/
	case SCR_EA_Ntfy_AddOrRebuildSection:
	/*-----------------------------------------------------------------------------------*/
		if(strchr(_p_stNotify->a_szSectionName, SCR_CC_c_Cfg_NameSeparator))
			cSectionExists = SCR_fn_c_RdL0_IsSectionExists(_p_stNotify->a_szSectionName);
		else
		{
			if(_cFileCreated)
				cSectionExists = 0;
			else
				cSectionExists = 1;
		}
 
		if(cSectionExists)
			_p_stNotify->eAction = SCR_EA_Ntfy_RebuildSection;
		else
			_p_stNotify->eAction = SCR_EA_Ntfy_AddSection;
		break;
 
	/*-----------------------------------------------------------------------------------*/
	case SCR_EA_Ntfy_DeleteIfExists:
	/*-----------------------------------------------------------------------------------*/
		if(strchr(_p_stNotify->a_szSectionName, SCR_CC_c_Cfg_NameSeparator))
			cSectionExists = SCR_fn_c_RdL0_IsSectionExists(_p_stNotify->a_szSectionName);
		else
		{
			if(_cFileCreated)
				cSectionExists = 0;
			else
				cSectionExists = 1;
		}
 
		if(cSectionExists)
			_p_stNotify->eAction = SCR_EA_Ntfy_DeleteSection;
		else
			_p_stNotify->eAction = SCR_EA_Ntfy_Dummy;
		break;
	}
 
	/*
	 *	End for a dummy action or if action is not the same that real action.
	 */
	if
	(
		(_p_stNotify->eAction == SCR_EA_Ntfy_Dummy)
	||	(_p_stNotify->eAction != _eRealAction)
	)
	{
		return 1;
	}
 
    /*
     *  We place file to good section.
     *  For an SCR_EA_Ntfy_AddSection, we place file to parent section.
     */
    p_szFirstSep = strchr(_p_stNotify->a_szSectionName, SCR_CC_c_Cfg_NameSeparator);
    p_szLastSep = strrchr(_p_stNotify->a_szSectionName, SCR_CC_c_Cfg_NameSeparator);
    if(_p_stNotify->eAction == SCR_EA_Ntfy_AddSection)
    {
        /* We compute parent section name */
        if(p_szFirstSep == p_szLastSep)
            p_szFirstSep = NULL;	/* Parent section name is the file */
        else
            *p_szLastSep = '\0';    /* Parent section name is a section */
    }
 
    /* Really place file to good position */
    if(p_szFirstSep == NULL)
        fn_v_Anl_ContextToFile(_p_stContext);
    else
        fn_v_Anl_ContextToSection(_p_stContext, _p_stNotify->a_szSectionName);
 
    /* Force character to be good (in case of a SCR_EA_Ntfy_AddSection) */
    if(p_szLastSep)
        *p_szLastSep = SCR_CC_c_Cfg_NameSeparator;
 
	/*
	 *	Update modification file.
	 */
    switch(_p_stNotify->eAction)
	{
    case SCR_EA_Ntfy_DeleteSection:
		SCR_M_v_SvL1_UpdateModify("(D)");
		break;
    case SCR_EA_Ntfy_RebuildSection:
		SCR_M_v_SvL1_UpdateModify("(R)");
		break;
    case SCR_EA_Ntfy_AddSection:
		SCR_M_v_SvL1_UpdateModify("(A)");
		break;
    case SCR_EA_Ntfy_ModifySection:
		SCR_M_v_SvL1_UpdateModify("(M)");
		break;
	}
	SCR_M_v_SvL1_UpdateModify(_p_stNotify->a_szSectionName);
	SCR_M_v_SvL1_UpdateModify("\n");
 
    switch(_p_stNotify->eAction)
    {
    /*
     *  We delete an existing section.
	 *	=> Delete all notifications to sub sections.
	 *	=> For a file, delete it.
	 *	=> Exit.
     */
	/*-----------------------------------------------------------------------------------*/
    case SCR_EA_Ntfy_DeleteSection:
	/*-----------------------------------------------------------------------------------*/
		/*
		 *	Delete all notifications to subsections.
		 */
		strcpy(a_szTemp, _p_stNotify->a_szSectionName);
		strcat(a_szTemp, SCR_CC_sz_Cfg_NameSeparator);
		SCR_fn_v_SvL1_DeleteRegisterNotify(a_szTemp, SCR_CDR_c_RdL0_Contains);
 
		/*
		 *	Call the callback.
		 */
		if(_p_stNotify->pfn_vCallback)
		{
			_p_stNotify->pfn_vCallback
			(
				&_p_stOpenFile->stFile,
				_p_stNotify->a_szSectionName,
				_p_stNotify->p_vData,
				_p_stNotify->eAction
			);
		}
		_p_stNotify->eAction = SCR_EA_Ntfy_Dummy;
 
		/*
		 *	For a file, delete it.
		 */
		if(strchr(_p_stNotify->a_szSectionName, SCR_CC_c_Cfg_NameSeparator) == NULL)
		{
			unlink(_p_stNotify->a_szSectionName);
			return 0;	/* We return 0 to stop notifications of that file */
		}
 
		/* Else delete for section too */
        SCR_fn_v_SvL1_DeleteSection(&_p_stOpenFile->stFile);
		break;
 
    /*
     *  We rebuild an existing section.
     */
	/*-----------------------------------------------------------------------------------*/
    case SCR_EA_Ntfy_RebuildSection:
	/*-----------------------------------------------------------------------------------*/
        SCR_fn_v_SvL1_DeleteSection(&_p_stOpenFile->stFile);
 
	/*
	 *	We add or rebuild an existing section.
	 */
	/*-----------------------------------------------------------------------------------*/
    case SCR_EA_Ntfy_AddSection:
	/*-----------------------------------------------------------------------------------*/
    case SCR_EA_Ntfy_ModifySection:
	/*-----------------------------------------------------------------------------------*/
 
		if(_p_stNotify->pfn_vCallback)
		{
			_p_stNotify->pfn_vCallback
			(
				&_p_stOpenFile->stFile,
				_p_stNotify->a_szSectionName,
				_p_stNotify->p_vData,
				_p_stNotify->eAction
			);
		}
        break;
    }
 
	/* This notification has already been done */
	_p_stNotify->eAction = SCR_EA_Ntfy_Dummy;
	/* Delete parsing infos to force update */
	SCR_M_DyAr_DeleteAllElements
	(
		SCR_tdst_Anl_SectionDes, 
		&_p_stOpenFile->stSectionsDes,
		{
			fn_v_Mem_SetMode(_p_stPointer_->stHeader.ucMemLevel);
			SCR_M_Cxt_FreeDynBuffers(&_p_stPointer_->stBuffers);
		}
	);
	fn_v_Hash_CloseTable(_p_stOpenFile->a_stHashSectionsDes);
	memset(&_p_stOpenFile->stParsingInfos, 0, sizeof(SCR_tdst_Pars_Infos));
	fn_v_Anl_ContextToFile(_p_stContext);
 
	return 1;
}
 
/*
 *-------------------------------------------------------------------------------------------------
 *  To update one notification.
 *  _p_stNotify		:   Notification to update.
 *	_eWantedAction	:	Really wanted action.
 *-------------------------------------------------------------------------------------------------
 */
void fn_v_SvL1_UpdateOneNotify
(
	SCR_tdst_Ntfy_Description	*_p_stNotify, 
	SCR_tde_Ntfy_Action			_eWantedAction
)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    char                        *p_szSection, *p_szTemp;
    SCR_tdst_File_Open          *p_stOpenFile;
    SCR_tdst_Cxt_Description    *p_stContext;
    SCR_tdx_Hash_Key            xHashKey;
    char                        a_szFileName[_MAX_PATH];
	char						cFileCreated;
/*ANNECY CB*/
    char                        a_szTempName1[_MAX_PATH];
    char                        a_szTempName[_MAX_PATH];
	SCR_FILE					xHandle;
	char						cHasRead = 0;
/*END ANNECY*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    SCR_M_Dbg_AssertStruct_P(SCR_tdst_Ntfy_Description, _p_stNotify);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 
    /*
     *  Inits for file.
     */
    p_szSection = strchr(_p_stNotify->a_szSectionName, SCR_CC_c_Cfg_NameSeparator);
    if(p_szSection)
        *p_szSection = '\0';
    strcpy(a_szFileName, _p_stNotify->a_szSectionName);
    if(p_szSection)
        *p_szSection = SCR_CC_c_Cfg_NameSeparator;
 
	/*
	 *	We verify that path is here, else we create it.
	 */
	p_szTemp = strrchr(a_szFileName, '\\');
	if(p_szTemp)
	{
		*p_szTemp = '\0';
		SCR_fn_v_RdL0_ValidatePath(a_szFileName, p_szTemp + 1);
		*p_szTemp = '\\';
	}
 
/*ANNECY CB*/
#if 0
    /*
     *  If file is in memory (cause it has been analysed), we delete it cause it will
     *  be corrupt.
     */
    xHashKey = SCR_fn_x_Hash_ComputeHashKeyForString(a_szFileName);
    p_stOpenFile = fnp_st_File_SearchOpen(a_szFileName, xHashKey);
    if(p_stOpenFile)
        fn_v_File_DeleteOpen(p_stOpenFile);
 
    /*
     *  Add a new free open file.
     */
    p_stOpenFile = fnp_st_File_AddOpen(a_szFileName, xHashKey);
#endif
/*END*/
 
    /*
     *  We determin if file exists. If not we created it.
     */
	cFileCreated = 0;
/*ANNECY CB*/
    if((xHandle = SCR_M_p_x_File_OpenRead(a_szFileName)) == (SCR_FILE) 0)
/*    if((p_stOpenFile->stFile.p_stHandle->xHandle = SCR_M_p_x_File_OpenRead(a_szFileName)) == (SCR_FILE) 0)*/
/*END ANNECY*/
    {
/*ANNECY CB*/
		if(*gsz_Version)
		{
			strcpy(a_szTempName, gsz_Version);
			if(strchr(_p_stNotify->a_szSectionName, '\\'))
				strcat(a_szTempName, strchr(_p_stNotify->a_szSectionName, '\\'));
			else
			{
				strcat(a_szTempName, "\\");
				strcat(a_szTempName, _p_stNotify->a_szSectionName);
			}
			
			p_szSection = strchr(a_szTempName, SCR_CC_c_Cfg_NameSeparator);
			if(p_szSection)
				*p_szSection = '\0';
			strcpy(a_szTempName1, a_szTempName);
			if(p_szSection)
				*p_szSection = SCR_CC_c_Cfg_NameSeparator;
			
			if((xHandle = SCR_M_p_x_File_OpenRead(a_szTempName1)) != (SCR_FILE) 0)
			{
				strcpy(_p_stNotify->a_szSectionName, a_szTempName);
				strcpy(a_szFileName, a_szTempName1);
				cHasRead = 1;
				goto zap;
			}
		}
		if(*gsz_Version1)
		{
			strcpy(a_szTempName, gsz_Version1);
			if(strchr(_p_stNotify->a_szSectionName, '\\'))
				strcat(a_szTempName, strchr(_p_stNotify->a_szSectionName, '\\'));
			else
			{
				strcat(a_szTempName, "\\");
				strcat(a_szTempName, _p_stNotify->a_szSectionName);
			}
			
			p_szSection = strchr(a_szTempName, SCR_CC_c_Cfg_NameSeparator);
			if(p_szSection)
				*p_szSection = '\0';
			strcpy(a_szTempName1, a_szTempName);
			if(p_szSection)
				*p_szSection = SCR_CC_c_Cfg_NameSeparator;
			
			if((xHandle = SCR_M_p_x_File_OpenRead(a_szTempName1)) != (SCR_FILE) 0)
			{
				strcpy(_p_stNotify->a_szSectionName, a_szTempName);
				strcpy(a_szFileName, a_szTempName1);
				cHasRead = 1;
				goto zap;
			}
		}
/*END ANNECY*/
		cFileCreated = 1;
/*ANNECY CB*/
		if((cHasRead == 0) && (*gsz_Version) && (gc_NoAsk == 0))
		{
			char	_szFileName[255];
			char	szText[1000];
			if(strrchr(a_szFileName, '\\'))
				strcpy(_szFileName, strrchr(a_szFileName, '\\') + 1);
			else
				strcpy(_szFileName, a_szFileName);
			sprintf(szText, "Do you want to create %s file in parallel %s tree ?", _szFileName, gsz_Version);
			if(MessageBox(NULL, szText, "Scripts", MB_YESNO) == IDYES)
			{
				strcpy(_p_stNotify->a_szSectionName, a_szTempName);
				strcpy(a_szFileName, a_szTempName1);
				/* We eventually create path */
				p_szSection = strchr(_p_stNotify->a_szSectionName, SCR_CC_c_Cfg_NameSeparator);
				if(p_szSection)	*p_szSection = '\0';
				strcpy(a_szFileName, _p_stNotify->a_szSectionName);
				if(p_szSection)	*p_szSection = SCR_CC_c_Cfg_NameSeparator;
				p_szTemp = strrchr(a_szFileName, '\\');
				if(p_szTemp)
				{
					*p_szTemp = '\0';
					SCR_fn_v_RdL0_ValidatePath(a_szFileName, p_szTemp + 1);
					*p_szTemp = '\\';
				}
			}
		}
 
        if((xHandle = SCR_M_p_x_File_OpenWrite(a_szFileName)) == (SCR_FILE) 0)
/*        if((p_stOpenFile->stFile.p_stHandle->xHandle = SCR_M_p_x_File_OpenWrite(a_szFileName)) == (SCR_FILE) 0)*/
/*END ANNECY*/
        {
            sprintf(g_st_Err_GlobalError.a_szBufferTmp1, "File is \"%s\".", a_szFileName);
            *g_st_Err_GlobalError.a_szBufferTmp2 = '\0';
            SCR_M_Err_RaiseError(SCR_EI_Err_OpenFile);
        }
		/* 
		 *	Close the file an open it to read.
		 */
/*ANNECY CB*/
#ifdef SCR_DM_OptCFiles
close(xHandle);
#else
fclose(xHandle);
#endif
/*    SCR_M_File_Close(&p_stOpenFile->stFile);*/
      if((xHandle = SCR_M_p_x_File_OpenRead(a_szFileName)) == (SCR_FILE) 0)
/*      if((p_stOpenFile->stFile.p_stHandle->xHandle = SCR_M_p_x_File_OpenRead(a_szFileName)) == (SCR_FILE) 0)*/
/*END ANNECY*/
        {
            sprintf(g_st_Err_GlobalError.a_szBufferTmp1, "File is \"%s\".", a_szFileName);
            *g_st_Err_GlobalError.a_szBufferTmp2 = '\0';
            SCR_M_Err_RaiseError(SCR_EI_Err_OpenFile);
        }
    }
        
/*ANNECY CB*/
zap:
    /*
     *  If file is in memory (cause it has been analysed), we delete it cause it will
     *  be corrupt.
     */
    xHashKey = SCR_fn_x_Hash_ComputeHashKeyForString(a_szFileName);
    p_stOpenFile = fnp_st_File_SearchOpen(a_szFileName, xHashKey);
    if(p_stOpenFile)
        fn_v_File_DeleteOpen(p_stOpenFile);
 
    /*
     *  Add a new free open file.
     */
    p_stOpenFile = fnp_st_File_AddOpen(a_szFileName, xHashKey);
	p_stOpenFile->stFile.p_stHandle->xHandle = xHandle;
/*END ANNECY*/
 
    /*
     *  We add one open context.
     *  We add one open file.
     *  We load file.
     */
    p_stContext = fnp_st_Cxt_Add();
    p_stContext->p_stOpenFile = p_stOpenFile;
    fn_v_Page_LoadFile(&p_stOpenFile->stFile);
    SCR_M_File_Close(&p_stOpenFile->stFile);
 
	/*
	 *	Update all notifications in a given order.
	 */
	if
	(
		fn_c_SvL1_UpdateWithAction
		(
			_p_stNotify, 
			p_stOpenFile, 
			p_stContext, 
			_p_stNotify->eAction, 
			_eWantedAction, 
			cFileCreated
		)
	)
	{
		/*
		 *  We save the file.
		 *  We delete the open file (that close it too).
		 *  We delete last context.
		 */
		if((p_stOpenFile->stFile.p_stHandle->xHandle = SCR_M_p_x_File_OpenWrite(a_szFileName)) == (SCR_FILE) 0)
		{
			sprintf(g_st_Err_GlobalError.a_szBufferTmp1, "File is \"%s\".", a_szFileName);
			*g_st_Err_GlobalError.a_szBufferTmp2 = '\0';
			SCR_M_Err_RaiseError(SCR_EI_Err_OpenFile);
		}
		fn_v_Page_SaveFile(&p_stOpenFile->stFile);
	}
	fn_v_File_DeleteOpen(p_stContext->p_stOpenFile);
	fn_v_Cxt_DeleteLast();
}
 
/*
 *-------------------------------------------------------------------------------------------------
 *  To sort all notifications.
 *-------------------------------------------------------------------------------------------------
 */
int fn_i_SvL1_SortNotifications(const void *_p_v1, const void *_p_v2)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	SCR_tdst_Ntfy_Description	*p_st1, *p_st2;
	int							iLen1, iLen2;
	char						*p_szTemp;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	if
	(
		(((SCR_tdst_DyAr_Element *) _p_v1)->eState != SCR_EDAS_DyAr_Occupy)
	&&	(((SCR_tdst_DyAr_Element *) _p_v2)->eState != SCR_EDAS_DyAr_Occupy)
	)
		return 0;
 
	if
	(
		(((SCR_tdst_DyAr_Element *) _p_v1)->eState == SCR_EDAS_DyAr_Occupy)
	&&	(((SCR_tdst_DyAr_Element *) _p_v2)->eState != SCR_EDAS_DyAr_Occupy)
	)
		return 1;
 
	if
	(
		(((SCR_tdst_DyAr_Element *) _p_v1)->eState != SCR_EDAS_DyAr_Occupy)
	&&	(((SCR_tdst_DyAr_Element *) _p_v2)->eState == SCR_EDAS_DyAr_Occupy)
	)
		return -1;
 
	p_st1 = (SCR_tdst_Ntfy_Description *) ((SCR_tdst_DyAr_Element *) _p_v1)->d_vElement;
	p_st2 = (SCR_tdst_Ntfy_Description *) ((SCR_tdst_DyAr_Element *) _p_v2)->d_vElement;
 
	/*
	 * Sorted section to subsections.
	 */
	iLen1 = 0;
	p_szTemp = strchr(p_st1->a_szSectionName, SCR_CC_c_Cfg_NameSeparator);
	while(p_szTemp)
	{
		iLen1++;
		p_szTemp = strchr(p_szTemp + 1, SCR_CC_c_Cfg_NameSeparator);
	}
 
	iLen2 = 0;
	p_szTemp = strchr(p_st2->a_szSectionName, SCR_CC_c_Cfg_NameSeparator);
	while(p_szTemp)
	{
		iLen2++;
		p_szTemp = strchr(p_szTemp + 1, SCR_CC_c_Cfg_NameSeparator);
	}
 
	return iLen1 == iLen2 ? 0 : iLen1 < iLen2 ? -1 : 1;
}
 
/*
 *-------------------------------------------------------------------------------------------------
 *  To delete current section.
 *  _p_stFile   :   File concerned.
 *-------------------------------------------------------------------------------------------------
 */
void SCR_fn_v_SvL1_UpdateAllNotify(void)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    unsigned int                uiPos;
    SCR_tdst_Ntfy_Description   *p_stNotify;
	SCR_tde_Ntfy_Action			eWantedAction, eCurrentAction;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 
    /* 
	 *---------------------------------------------------------------------------------------------
	 *	We sort notifications.
	 *---------------------------------------------------------------------------------------------
	 */
	qsort
	(
		SCR_g_st_Ntfy_Array.d_stDynArray, 
		SCR_g_st_Ntfy_Array.uiNumValues, 
		sizeof(SCR_tdst_DyAr_Element), 
		fn_i_SvL1_SortNotifications
	);
 
	/* 
	 *	We restore index in array cause of sort.
	 */
	uiPos = 0;
    SCR_M_DyAr_GetNextElement(SCR_tdst_Ntfy_Description, uiPos, p_stNotify, SCR_g_st_Ntfy_Array);
    while(p_stNotify)
    {
		p_stNotify->stHeader.uiIndexInArray = uiPos;
        uiPos++;
        SCR_M_DyAr_GetNextElement(SCR_tdst_Ntfy_Description, uiPos, p_stNotify, SCR_g_st_Ntfy_Array);
    }
 
	/* 
	 *---------------------------------------------------------------------------------------------
	 *	We update notifications.
	 *---------------------------------------------------------------------------------------------
	 */
	eCurrentAction = eWantedAction = SCR_EA_Ntfy_DeleteSection;
	while(eCurrentAction != SCR_EA_Ntfy_Dummy)
	{
		uiPos = 0;
		SCR_M_DyAr_GetNextElement(SCR_tdst_Ntfy_Description, uiPos, p_stNotify, SCR_g_st_Ntfy_Array);
		while(p_stNotify)
		{
			/* Update if not already done */
			if(p_stNotify->eAction == eCurrentAction)
				fn_v_SvL1_UpdateOneNotify(p_stNotify, eWantedAction);
			uiPos++;
			SCR_M_DyAr_GetNextElement(SCR_tdst_Ntfy_Description, uiPos, p_stNotify, SCR_g_st_Ntfy_Array);
		}
 
		/*
		 * Pass to next notification.
		 * Order is :
		 * - Delete
		 * - DeleteIfExists
		 * - Rebuild
		 * - AddOrRebuild with Rebuild
		 * - Modify
		 * - AddOrModify with Modify
		 * - AddOrRebuild with Add
		 * - AddOrModify with Add
		 * - Add
		 */
		switch(eCurrentAction)
		{
		case SCR_EA_Ntfy_DeleteSection:
			eCurrentAction = SCR_EA_Ntfy_DeleteIfExists;
			eWantedAction = SCR_EA_Ntfy_DeleteSection;
			break;
		case SCR_EA_Ntfy_DeleteIfExists:
			eCurrentAction = eWantedAction = SCR_EA_Ntfy_RebuildSection;
			break;
		case SCR_EA_Ntfy_RebuildSection:
			eCurrentAction = SCR_EA_Ntfy_AddOrRebuildSection;
			eWantedAction = SCR_EA_Ntfy_RebuildSection;
			break;
		case SCR_EA_Ntfy_AddOrRebuildSection:
			if(eWantedAction == SCR_EA_Ntfy_RebuildSection)
				eCurrentAction = eWantedAction = SCR_EA_Ntfy_ModifySection;
			else
			{
				eCurrentAction = SCR_EA_Ntfy_AddOrModifySection;
				eWantedAction = SCR_EA_Ntfy_AddSection;
			}
			break;
		case SCR_EA_Ntfy_ModifySection:
			eCurrentAction = SCR_EA_Ntfy_AddOrModifySection;
			eWantedAction = SCR_EA_Ntfy_ModifySection;
			break;
		case SCR_EA_Ntfy_AddOrModifySection:
			if(eWantedAction == SCR_EA_Ntfy_ModifySection)
			{
				eCurrentAction = SCR_EA_Ntfy_AddOrRebuildSection;
				eWantedAction = SCR_EA_Ntfy_AddSection;
			}
			else
				eCurrentAction = eWantedAction = SCR_EA_Ntfy_AddSection;
			break;
		case SCR_EA_Ntfy_AddSection:
			eCurrentAction = SCR_EA_Ntfy_Dummy;
			break;
		}
	}
 
    /*
     *  Delete all notifications.
     */
    fn_v_Ntfy_CloseModule();
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(;)
 
/*
 *-------------------------------------------------------------------------------------------------
 *  To set modification file list name.
 *  _p_szName	:   Name to set.
 *-------------------------------------------------------------------------------------------------
 */
void SCR_fn_v_SvL1_SetModificationFileName(char *_p_szName)
SCR_BEGIN
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	SCR_M_Dbg_Assert_D(_p_szName != NULL);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	strcpy(gs_a_szModifyFileName, _p_szName);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_CEND(;)
