185 lines
6.5 KiB
C
185 lines
6.5 KiB
C
/*
|
|
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
* SCR_Ntfy.c
|
|
* To manage notify orders.
|
|
*
|
|
* Scripts, Beaudet Christophe, (c) Ubi Simulations 1997
|
|
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
*/
|
|
|
|
/*
|
|
*=================================================================================================
|
|
* Includes.
|
|
*=================================================================================================
|
|
*/
|
|
#include "SCR.h"
|
|
|
|
/*
|
|
*=================================================================================================
|
|
* Global variables.
|
|
*=================================================================================================
|
|
*/
|
|
|
|
/*
|
|
* Dynamic array of all notify.
|
|
*/
|
|
SCR_tdst_DyAr_Description SCR_g_st_Ntfy_Array;
|
|
|
|
/*
|
|
*=================================================================================================
|
|
* Functions.
|
|
*=================================================================================================
|
|
*/
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* Init.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void fn_v_Ntfy_InitModule(void)
|
|
{
|
|
fn_v_DyAr_InitArray(&SCR_g_st_Ntfy_Array);
|
|
}
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* Close.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void fn_v_Ntfy_CloseModule(void)
|
|
{
|
|
SCR_M_DyAr_DeleteAllElements(SCR_tdst_Ntfy_Description, &SCR_g_st_Ntfy_Array, ;);
|
|
}
|
|
|
|
/*===============================================================================================*/
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* 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 fn_v_Ntfy_Add
|
|
(
|
|
char *_p_szSectionName,
|
|
SCR_tdpfn_Ntfy_Callback _pfn_vCallback,
|
|
void *_p_vData,
|
|
SCR_tde_Ntfy_Action _eAction
|
|
)
|
|
{
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
unsigned int uiPos;
|
|
unsigned char ucMemo;
|
|
SCR_tdst_Ntfy_Description *p_stNotify;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_P(_p_szSectionName != NULL);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
/*
|
|
* Add element in array.
|
|
*/
|
|
ucMemo = g_uc_Mem_CurrentMemLevel;
|
|
g_uc_Mem_CurrentMemLevel = 0;
|
|
SCR_M_DyAr_AddElement(SCR_tdst_Ntfy_Description, uiPos, p_stNotify, SCR_g_st_Ntfy_Array);
|
|
g_uc_Mem_CurrentMemLevel = ucMemo;
|
|
|
|
/*
|
|
* Initialize structure
|
|
*/
|
|
strcpy(p_stNotify->a_szSectionName, _p_szSectionName);
|
|
p_stNotify->pfn_vCallback = _pfn_vCallback;
|
|
p_stNotify->p_vData = _p_vData;
|
|
p_stNotify->eAction = _eAction;
|
|
}
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To delete a notification.
|
|
* _p_stNotify : Notification to delete.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void fn_v_Ntfy_Delete(SCR_tdst_Ntfy_Description *_p_stNotify)
|
|
{
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_AssertStruct_P(SCR_tdst_Ntfy_Description, _p_stNotify);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
/*
|
|
* Delete structure.
|
|
*/
|
|
SCR_M_DyAr_DeleteElement
|
|
(
|
|
SCR_tdst_Ntfy_Description,
|
|
_p_stNotify->stHeader.uiIndexInArray,
|
|
&SCR_g_st_Ntfy_Array,
|
|
;
|
|
);
|
|
}
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To search a notification.
|
|
* _p_szSectionName : Section name to search.
|
|
* Returns address of structure if found, else NULL.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
SCR_tdst_Ntfy_Description *fnp_st_Ntfy_Search(char *_p_szSectionName)
|
|
{
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
unsigned int uiPos;
|
|
SCR_tdst_Ntfy_Description *p_stPointer = NULL;
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
SCR_M_Dbg_Assert_P(_p_szSectionName != NULL);
|
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
|
|
|
/*
|
|
* Search notification and return pointer.
|
|
*/
|
|
SCR_M_DyAr_SearchElement
|
|
(
|
|
SCR_tdst_Ntfy_Description,
|
|
uiPos,
|
|
p_stPointer,
|
|
SCR_g_st_Ntfy_Array,
|
|
(!strcmpi(p_stPointer->a_szSectionName, _p_szSectionName))
|
|
);
|
|
return p_stPointer;
|
|
}
|
|
|
|
/*
|
|
**************************************************************************************************
|
|
**************************************************************************************************
|
|
**************************************************************************************************
|
|
**************************************************************************************************
|
|
*/
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
* To reduce memory size.
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void fn_v_Ntfy_ReduceMemory(void)
|
|
{
|
|
/* Pack array of open files */
|
|
SCR_M_DyAr_PackArray(SCR_tdst_Ntfy_Description, SCR_g_st_Ntfy_Array, ;);
|
|
}
|
|
|
|
/*
|
|
*-------------------------------------------------------------------------------------------------
|
|
*-------------------------------------------------------------------------------------------------
|
|
*/
|
|
void fn_v_Ntfy_DeleteWithMemLevel(unsigned char _ucMin, unsigned char _ucMax)
|
|
{
|
|
SCR_M_DyAr_DeleteElementWithMemLevel
|
|
(
|
|
SCR_tdst_Ntfy_Description,
|
|
SCR_g_st_Ntfy_Array,
|
|
;,
|
|
_ucMin,
|
|
_ucMax
|
|
);
|
|
}
|