- First try for the second libnode V3 implementation:

- ND_Handler_Open_Default() implemented.
This commit is contained in:
Arnaud G. GIBERT 2024-06-12 23:26:26 +02:00
parent 6339c66000
commit fa777a9b89
3 changed files with 79 additions and 59 deletions

View File

@ -832,14 +832,14 @@ 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_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_Open( NDT_Root *Root_Ptr, NDT_Open_Flag Open_Mode, 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_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_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);
@ -1472,7 +1472,7 @@ NDD_DLL_API NDT_Status ND_Value_Free_C( NDT_Root *, void *);
/* (O) Root_Tmp_Ptr_Ptr: Data structure pointer address */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Root_Tmp_Alloc( NDT_Root **Root_Tmp_Ptr_Ptr, size_t Root_Extra_Size, 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_Root_Tmp_Alloc( NDT_Root **Root_Tmp_Ptr_Ptr, size_t Root_Extra_Size, NDT_DataStruct_Name Name, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Handler *Handler_Tab, short Own_Value, void *User_Ptr);
@ -1575,8 +1575,8 @@ NDT_Status ND_Handler_Free_Exec_C( void *Memory_Ptr, NDT_Root *Root_Ptr, NDT_
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Open_Exec_I( NDT_Root *Root_Ptr, NDT_Open_Flag Open_Mode, NDT_Handler_Name Handler_Open_Name, NDT_Handler_Open *Handler_Open_Ptr, void *User_Ptr);
NDT_Status ND_Handler_Open_Exec_C( NDT_Root *Root_Ptr, NDT_Open_Flag Open_Mode, NDT_Handler_Name Handler_Open_Name, NDT_Handler_Open *Handler_Open_Ptr, void *User_Ptr);
NDT_Status ND_Handler_Open_Exec_I( NDT_Root **Root_Ptr_Ptr, NDT_Root *Root_Tmp_Ptr, NDT_Open_Flag Open_Mode, NDT_Handler_Name Handler_Open_Name, NDT_Handler_Open *Handler_Open_Ptr);
NDT_Status ND_Handler_Open_Exec_C( NDT_Root **Root_Ptr_Ptr, NDT_Root *Root_Tmp_Ptr, NDT_Open_Flag Open_Mode, NDT_Handler_Name Handler_Open_Name, NDT_Handler_Open *Handler_Open_Ptr);

View File

@ -980,8 +980,6 @@ NDT_Status ND_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, NDT_DataStruct_Name
NDT_Root *root_tmp_ptr;
*Root_Ptr_Ptr = NULL;
if( Handler_Tab == NULL)
{
Handler_Tab = NDG_Handler_Tab_Default;
@ -1019,54 +1017,47 @@ 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( ( 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))
// {
// /* Root Alloc */
//
// if( ( status = ND_Allocator_Exec_I( (void **)Root_Ptr_Ptr, root_tmp_ptr, root_tmp_ptr->Root_Size, root_tmp_ptr->Handler_Tab[ NDD_HANDLER_ID_ALLOC].Name, (NDT_Allocator *)root_tmp_ptr->Handler_Tab[ NDD_HANDLER_ID_ALLOC].Ptr, User_Ptr)) != NDS_OK)
// {
// return( status);
// }
//
//
// /* Root Tmp copy and free */
//
// memcpy( *Root_Ptr_Ptr, root_tmp_ptr, root_tmp_ptr->Root_Size);
// ( *Root_Ptr_Ptr)->Status = NDD_DATASTRUCT_STATUS_VALID;
//
// free( root_tmp_ptr);
// }
// else
// {
// *Root_Ptr_Ptr = root_tmp_ptr;
// }
if( ND_DATASTRUCT_STATUS_TEMPORARY_IS( root_tmp_ptr))
{
/* Root Alloc */
if( ( status = ND_Allocator_Exec_I( (void **)Root_Ptr_Ptr, root_tmp_ptr, root_tmp_ptr->Root_Size, root_tmp_ptr->Handler_Tab[ NDD_HANDLER_ID_ALLOC].Name, (NDT_Allocator *)root_tmp_ptr->Handler_Tab[ NDD_HANDLER_ID_ALLOC].Ptr, User_Ptr)) != NDS_OK)
{
return( status);
}
/* Root Tmp copy and free */
memcpy( *Root_Ptr_Ptr, root_tmp_ptr, root_tmp_ptr->Root_Size);
( *Root_Ptr_Ptr)->Status = NDD_DATASTRUCT_STATUS_VALID;
free( root_tmp_ptr);
}
else
{
*Root_Ptr_Ptr = root_tmp_ptr;
}
/* To be removed... */
ND_STR_CPY( ( *Root_Ptr_Ptr)->Manager_Name, ( *Root_Ptr_Ptr)->Handler_Tab[ NDD_HANDLER_ID_MANAGER].Name, NDD_HANDLER_NAME_SIZE);
( *Root_Ptr_Ptr)->Manager_Ptr = (NDT_Manager *)( *Root_Ptr_Ptr)->Handler_Tab[ NDD_HANDLER_ID_MANAGER].Ptr;
ND_STR_CPY( ( *Root_Ptr_Ptr)->Allocator_Name, ( *Root_Ptr_Ptr)->Handler_Tab[ NDD_HANDLER_ID_ALLOC].Name, NDD_HANDLER_NAME_SIZE);
( *Root_Ptr_Ptr)->Allocator_Ptr = (NDT_Allocator *)( *Root_Ptr_Ptr)->Handler_Tab[ NDD_HANDLER_ID_ALLOC].Ptr;
ND_STR_CPY( ( *Root_Ptr_Ptr)->Deallocator_Name, ( *Root_Ptr_Ptr)->Handler_Tab[ NDD_HANDLER_ID_FREE].Name, NDD_HANDLER_NAME_SIZE);
( *Root_Ptr_Ptr)->Deallocator_Ptr = (NDT_Deallocator *)( *Root_Ptr_Ptr)->Handler_Tab[ NDD_HANDLER_ID_FREE].Ptr;
/* Call Open function */
if( ( status = ND_Handler_Open_Exec_I( *Root_Ptr_Ptr, Open_Mode, ( *Root_Ptr_Ptr)->Handler_Tab[ NDD_HANDLER_ID_OPEN].Name, ( NDT_Handler_Open *)( *Root_Ptr_Ptr)->Handler_Tab[ NDD_HANDLER_ID_OPEN].Ptr, User_Ptr)) != NDS_OK)
if( ( status = ND_Root_Tmp_Alloc( &root_tmp_ptr, 0L, Name, Index_Nb, Type_Ptr, handler_target_tab, Own_Value, User_Ptr)) == NDS_OK)
{
return( status);
*Root_Ptr_Ptr = root_tmp_ptr;
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);
}
return( NDS_OK);
return( status);
}
@ -3500,7 +3491,7 @@ NDT_Status ND_Value_Free_C( NDT_Root *Root_Ptr, void *Value_Ptr)
/* (O) Root_Tmp_Ptr_Ptr: Data structure pointer address */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Root_Tmp_Alloc( NDT_Root **Root_Tmp_Ptr_Ptr, size_t Root_Extra_Size, 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_Root_Tmp_Alloc( NDT_Root **Root_Tmp_Ptr_Ptr, size_t Root_Extra_Size, 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_Status status;
size_t root_size;
@ -3867,14 +3858,14 @@ NDT_Status ND_Handler_Free_Exec_C( void *Memory_Ptr, NDT_Root *Root_Ptr, NDT_
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Open_Exec_I( NDT_Root *Root_Ptr, NDT_Open_Flag Open_Mode, NDT_Handler_Name Handler_Open_Name, NDT_Handler_Open *Handler_Open_Ptr, void *User_Ptr)
NDT_Status ND_Handler_Open_Exec_I( NDT_Root **Root_Ptr_Ptr, NDT_Root *Root_Tmp_Ptr, NDT_Open_Flag Open_Mode, NDT_Handler_Name Handler_Open_Name, NDT_Handler_Open *Handler_Open_Ptr)
{
NDT_Handler_Open *handler_open_ptr;
ND_HANDLER_SYMBOL_FIND( handler_open_ptr, Handler_Open_Name, Handler_Open_Ptr);
return( handler_open_ptr( Root_Ptr, Open_Mode, User_Ptr));
return( handler_open_ptr( Root_Ptr_Ptr, Root_Tmp_Ptr, Open_Mode));
}
@ -3891,13 +3882,13 @@ NDT_Status ND_Handler_Open_Exec_I( NDT_Root *Root_Ptr, NDT_Open_Flag Open_Mod
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Open_Exec_C( NDT_Root *Root_Ptr, NDT_Open_Flag Open_Mode, NDT_Handler_Name Handler_Open_Name, NDT_Handler_Open *Handler_Open_Ptr, void *User_Ptr)
NDT_Status ND_Handler_Open_Exec_C( NDT_Root **Root_Ptr_Ptr, NDT_Root *Root_Tmp_Ptr, NDT_Open_Flag Open_Mode, NDT_Handler_Name Handler_Open_Name, NDT_Handler_Open *Handler_Open_Ptr)
{
ND_LIBNODE_OPEN_CHECK();
ND_HANDLER_NOT_NULL_CHECK( Handler_Open_Name, Handler_Open_Ptr);
return( ND_Handler_Open_Exec_I( Root_Ptr, Open_Mode, Handler_Open_Name, Handler_Open_Ptr, User_Ptr));
return( ND_Handler_Open_Exec_I( Root_Ptr_Ptr, Root_Tmp_Ptr, Open_Mode, Handler_Open_Name, Handler_Open_Ptr));
}
@ -4234,7 +4225,7 @@ NDT_Status ND_Deallocator_Exec_C( void *Ptr, NDT_Root *Root_Ptr, NDT_Deallocat
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)
{
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, Open_Mode, Index_Nb, Type_Ptr, Handler_Tab, Own_Value, User_Ptr));
}
@ -4297,8 +4288,37 @@ NDT_Status ND_Handler_Free_Default( void *Memory_Ptr, NDT_Root *Root_Ptr, voi
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Open_Default( NDT_Root *Root_Ptr, NDT_Open_Flag Open_Mode, void *User_Ptr)
NDT_Status ND_Handler_Open_Default( NDT_Root **Root_Ptr_Ptr, NDT_Root *Root_Tmp_Ptr, NDT_Open_Flag Open_Mode)
{
NDT_Status status;
/* Root Alloc */
if( ( status = ND_Allocator_Exec_I( (void **)Root_Ptr_Ptr, Root_Tmp_Ptr, Root_Tmp_Ptr->Root_Size, Root_Tmp_Ptr->Handler_Tab[ NDD_HANDLER_ID_ALLOC].Name, (NDT_Allocator *)Root_Tmp_Ptr->Handler_Tab[ NDD_HANDLER_ID_ALLOC].Ptr, NULL)) != NDS_OK)
{
return( status);
}
/* Root Tmp copy and free */
memcpy( *Root_Ptr_Ptr, Root_Tmp_Ptr, Root_Tmp_Ptr->Root_Size);
( *Root_Ptr_Ptr)->Status = NDD_DATASTRUCT_STATUS_VALID;
/* To be removed... */
ND_STR_CPY( ( *Root_Ptr_Ptr)->Manager_Name, ( *Root_Ptr_Ptr)->Handler_Tab[ NDD_HANDLER_ID_MANAGER].Name, NDD_HANDLER_NAME_SIZE);
( *Root_Ptr_Ptr)->Manager_Ptr = (NDT_Manager *)( *Root_Ptr_Ptr)->Handler_Tab[ NDD_HANDLER_ID_MANAGER].Ptr;
ND_STR_CPY( ( *Root_Ptr_Ptr)->Allocator_Name, ( *Root_Ptr_Ptr)->Handler_Tab[ NDD_HANDLER_ID_ALLOC].Name, NDD_HANDLER_NAME_SIZE);
( *Root_Ptr_Ptr)->Allocator_Ptr = (NDT_Allocator *)( *Root_Ptr_Ptr)->Handler_Tab[ NDD_HANDLER_ID_ALLOC].Ptr;
ND_STR_CPY( ( *Root_Ptr_Ptr)->Deallocator_Name, ( *Root_Ptr_Ptr)->Handler_Tab[ NDD_HANDLER_ID_FREE].Name, NDD_HANDLER_NAME_SIZE);
( *Root_Ptr_Ptr)->Deallocator_Ptr = (NDT_Deallocator *)( *Root_Ptr_Ptr)->Handler_Tab[ NDD_HANDLER_ID_FREE].Ptr;
return( NDS_OK);
}

View File

@ -366,7 +366,7 @@ NDT_Status ND_Handler_Free_Default( void *Memory_Ptr, NDT_Root *Root_Ptr, voi
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Open_Default( NDT_Root *Root_Ptr, NDT_Open_Flag Open_Mode, void *User_Ptr);
NDT_Status ND_Handler_Open_Default( NDT_Root **Root_Ptr_Ptr, NDT_Root *Root_Tmp_Ptr, NDT_Open_Flag Open_Mode);