- Implement and use init handler.

This commit is contained in:
Arnaud G. GIBERT 2024-06-13 20:15:20 +02:00
parent fa777a9b89
commit cc97394120
3 changed files with 22 additions and 25 deletions

View File

@ -832,15 +832,15 @@ typedef struct NDT_Node
/* Handler protypes */
/*----------------------------------------------------------------------------*/
typedef NDT_Status NDT_Handler_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Cmd, va_list *);
typedef NDT_Status NDT_Handler_Init( NDT_Root **root_tmp_ptr_ptr, NDT_DataStruct_Name Name, NDT_Open_Flag Open_Mode, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Handler *Handler_Tab, short Own_Value, void *User_Ptr);
typedef NDT_Status NDT_Handler_Alloc( void **Memory_Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size, void *User_Ptr);
typedef NDT_Status NDT_Handler_Free( void *Memory_Ptr, NDT_Root *Root_Ptr, void *User_Ptr);
typedef NDT_Status NDT_Handler_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Cmd, va_list *);
typedef NDT_Status NDT_Handler_Init( NDT_Root **root_tmp_ptr_ptr, NDT_DataStruct_Name Name, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Handler *Handler_Tab, short Own_Value, void *User_Ptr);
typedef NDT_Status NDT_Handler_Alloc( void **Memory_Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size, void *User_Ptr);
typedef NDT_Status NDT_Handler_Free( void *Memory_Ptr, NDT_Root *Root_Ptr, void *User_Ptr);
typedef NDT_Status NDT_Handler_Open( NDT_Root **Root_Ptr_Ptr, NDT_Root *Root_Tmp_Ptr, NDT_Open_Flag Open_Mode);
typedef NDT_Status NDT_Handler_Close( NDT_Root *Root_Ptr, NDT_Close_Flag Close_Mode, void *User_Ptr);
typedef NDT_Status NDT_Handler_Close( NDT_Root *Root_Ptr, NDT_Close_Flag Close_Mode, void *User_Ptr);
typedef NDT_Status NDT_Handler_Info( NDT_Root *Root_Ptr, NDT_Recursive_Offset Recursive_Offset);
typedef NDT_Status NDT_Handler_Lock( NDT_Root *Root_Ptr, NDT_Lock_Flag Lock_Mode, bool *Locked_Ptr, void *User_Ptr);
typedef NDT_Status NDT_Handler_Unlock( NDT_Root *Root_Ptr, void *User_Ptr);
typedef NDT_Status NDT_Handler_Lock( NDT_Root *Root_Ptr, NDT_Lock_Flag Lock_Mode, bool *Locked_Ptr, void *User_Ptr);
typedef NDT_Status NDT_Handler_Unlock( NDT_Root *Root_Ptr, void *User_Ptr);
@ -1529,8 +1529,8 @@ NDD_DLL_API NDT_Status ND_Free_C( void *, NDT_Root *, void *);
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Init_Exec_I( NDT_Root **root_tmp_ptr_ptr, NDT_DataStruct_Name Name, NDT_Open_Flag Open_Mode, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Handler *Handler_Tab, short Own_Value, void *User_Ptr, NDT_Handler_Name Handler_Init_Name, NDT_Handler_Init *Handler_Init_Ptr);
NDT_Status ND_Handler_Init_Exec_C( NDT_Root **root_tmp_ptr_ptr, NDT_DataStruct_Name Name, NDT_Open_Flag Open_Mode, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Handler *Handler_Tab, short Own_Value, void *User_Ptr, NDT_Handler_Name Handler_Init_Name, NDT_Handler_Init *Handler_Init_Ptr);
NDT_Status ND_Handler_Init_Exec_I( NDT_Root **root_tmp_ptr_ptr, NDT_DataStruct_Name Name, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Handler *Handler_Tab, short Own_Value, void *User_Ptr, NDT_Handler_Name Handler_Init_Name, NDT_Handler_Init *Handler_Init_Ptr);
NDT_Status ND_Handler_Init_Exec_C( NDT_Root **root_tmp_ptr_ptr, NDT_DataStruct_Name Name, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Handler *Handler_Tab, short Own_Value, void *User_Ptr, NDT_Handler_Name Handler_Init_Name, NDT_Handler_Init *Handler_Init_Ptr);

View File

@ -1015,12 +1015,6 @@ NDT_Status ND_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, NDT_DataStruct_Name
}
/* Call init function */
// if( ( status = ND_Handler_Init_Exec_I( &root_tmp_ptr, Name, Open_Mode, Index_Nb, Type_Ptr, handler_target_tab, Own_Value, User_Ptr, handler_target_tab[ NDD_HANDLER_ID_INIT].Name, ( NDT_Handler_Init *)handler_target_tab[ NDD_HANDLER_ID_INIT].Ptr)) != NDS_OK)
// {
// return( status);
// }
//
// if( ND_DATASTRUCT_STATUS_TEMPORARY_IS( root_tmp_ptr))
// {
@ -1046,12 +1040,15 @@ NDT_Status ND_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, NDT_DataStruct_Name
/* Call Open function */
/* Call init handler */
if( ( status = ND_Root_Tmp_Alloc( &root_tmp_ptr, 0L, Name, Index_Nb, Type_Ptr, handler_target_tab, Own_Value, User_Ptr)) == NDS_OK)
if( ( status = ND_Handler_Init_Exec_I( &root_tmp_ptr, Name, Index_Nb, Type_Ptr, handler_target_tab, Own_Value, User_Ptr, handler_target_tab[ NDD_HANDLER_ID_INIT].Name, ( NDT_Handler_Init *)handler_target_tab[ NDD_HANDLER_ID_INIT].Ptr)) == NDS_OK)
{
*Root_Ptr_Ptr = root_tmp_ptr;
/* Call open handler */
status = ND_Handler_Open_Exec_I( Root_Ptr_Ptr, root_tmp_ptr, Open_Mode, root_tmp_ptr->Handler_Tab[ NDD_HANDLER_ID_OPEN].Name, ( NDT_Handler_Open *)root_tmp_ptr->Handler_Tab[ NDD_HANDLER_ID_OPEN].Ptr);
free( root_tmp_ptr);
@ -3716,14 +3713,14 @@ NDT_Status ND_Manager_Exec_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Init_Exec_I( NDT_Root **Root_Tmp_Ptr_Ptr, NDT_DataStruct_Name Name, NDT_Open_Flag Open_Mode, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Handler *Handler_Tab, short Own_Value, void *User_Ptr, NDT_Handler_Name Handler_Init_Name, NDT_Handler_Init *Handler_Init_Ptr)
NDT_Status ND_Handler_Init_Exec_I( NDT_Root **Root_Tmp_Ptr_Ptr, NDT_DataStruct_Name Name, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Handler *Handler_Tab, short Own_Value, void *User_Ptr, NDT_Handler_Name Handler_Init_Name, NDT_Handler_Init *Handler_Init_Ptr)
{
NDT_Handler_Init *handler_init_ptr;
ND_HANDLER_SYMBOL_FIND( handler_init_ptr, Handler_Init_Name, Handler_Init_Ptr);
return( handler_init_ptr( Root_Tmp_Ptr_Ptr, Name, Open_Mode, Index_Nb, Type_Ptr, Handler_Tab, Own_Value, User_Ptr));
return( handler_init_ptr( Root_Tmp_Ptr_Ptr, Name, Index_Nb, Type_Ptr, Handler_Tab, Own_Value, User_Ptr));
}
@ -3739,13 +3736,13 @@ NDT_Status ND_Handler_Init_Exec_I( NDT_Root **Root_Tmp_Ptr_Ptr, NDT_DataStruct
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Init_Exec_C( NDT_Root **Root_Tmp_Ptr_Ptr, NDT_DataStruct_Name Name, NDT_Open_Flag Open_Mode, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Handler *Handler_Tab, short Own_Value, void *User_Ptr, NDT_Handler_Name Handler_Init_Name, NDT_Handler_Init *Handler_Init_Ptr)
NDT_Status ND_Handler_Init_Exec_C( NDT_Root **Root_Tmp_Ptr_Ptr, NDT_DataStruct_Name Name, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Handler *Handler_Tab, short Own_Value, void *User_Ptr, NDT_Handler_Name Handler_Init_Name, NDT_Handler_Init *Handler_Init_Ptr)
{
ND_LIBNODE_OPEN_CHECK();
ND_HANDLER_NOT_NULL_CHECK( Handler_Init_Name, Handler_Init_Ptr);
return( ND_Handler_Init_Exec_I( Root_Tmp_Ptr_Ptr, Name, Open_Mode, Index_Nb, Type_Ptr, Handler_Tab, Own_Value, User_Ptr, Handler_Init_Name, Handler_Init_Ptr));
return( ND_Handler_Init_Exec_I( Root_Tmp_Ptr_Ptr, Name, Index_Nb, Type_Ptr, Handler_Tab, Own_Value, User_Ptr, Handler_Init_Name, Handler_Init_Ptr));
}
@ -4223,9 +4220,9 @@ NDT_Status ND_Deallocator_Exec_C( void *Ptr, NDT_Root *Root_Ptr, NDT_Deallocat
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Init_Default( NDT_Root **Root_Tmp_Ptr_Ptr, NDT_DataStruct_Name Name, NDT_Open_Flag Open_Mode, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Handler *Handler_Tab, short Own_Value, void *User_Ptr)
NDT_Status ND_Handler_Init_Default( NDT_Root **Root_Tmp_Ptr_Ptr, NDT_DataStruct_Name Name, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Handler *Handler_Tab, short Own_Value, void *User_Ptr)
{
// return( ND_Root_Tmp_Alloc( Root_Tmp_Ptr_Ptr, 0L, Name, Open_Mode, Index_Nb, Type_Ptr, Handler_Tab, Own_Value, User_Ptr));
return( ND_Root_Tmp_Alloc( Root_Tmp_Ptr_Ptr, 0L, Name, Index_Nb, Type_Ptr, Handler_Tab, Own_Value, User_Ptr));
}

View File

@ -325,7 +325,7 @@ NDT_Status ND_List_Sort( NDT_Root *, NDT_Index_Id);
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Init_Default( NDT_Root **root_tmp_ptr_ptr, NDT_DataStruct_Name Name, NDT_Open_Flag Open_Mode, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Handler *Handler_Tab, short Own_Value, void *User_Ptr);
NDT_Status ND_Handler_Init_Default( NDT_Root **root_tmp_ptr_ptr, NDT_DataStruct_Name Name, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Handler *Handler_Tab, short Own_Value, void *User_Ptr);