Add dynamic symbol support to ND_Allocator_Exec_I(), ND_Desallocator_Exec_I(), ND_Manager_Exec_I() and ND_Manager_Exec_VI() functions, in order to add LibShMem support.

Break NDT_Allocator() API !!!
Win32 not compatible... 8^(
Code Cleanup.
This commit is contained in:
agibert 2005-01-11 20:57:04 +00:00
parent 1d9539466d
commit 80665f9931
3 changed files with 311 additions and 244 deletions

View File

@ -1,9 +1,9 @@
/*---------------------------------------------------------------------------------*/
/* $RCSfile: node.h,v $ */
/*---------------------------------------------------------------------------------*/
/* $Revision: 2.10 $ */
/* $Revision: 2.11 $ */
/* $Name: $ */
/* $Date: 2005/01/11 16:27:13 $ */
/* $Date: 2005/01/11 20:57:04 $ */
/* $Author: agibert $ */
/*---------------------------------------------------------------------------------*/
@ -226,7 +226,7 @@ typedef NDT_Status NDT_Manager( struct NDT_Root *, NDT_Index_Id, struct NDT_Nod
typedef char *NDT_Allocator_Name;
typedef NDT_Status NDT_Allocator(size_t, void **, void *);
typedef NDT_Status NDT_Allocator( void **, size_t, void *);
/* Pointeur de fonction sur le désallocateur */
@ -236,7 +236,7 @@ typedef NDT_Status NDT_Allocator(size_t, void **, void *);
typedef char *NDT_Desallocator_Name;
typedef NDT_Status NDT_Desallocator(void *, void *);
typedef NDT_Status NDT_Desallocator( void *, void *);
@ -271,7 +271,7 @@ typedef struct NDT_Root
char Desallocator_Name[NDD_DESALLOCATOR_NAME_SIZE_MAX]; /* Nom de la fonction de désallocation */
short Own_Value; /* Indique si la structure est propriétaire de ses valeurs */
void *User; /* Pointeur utilisable librement par l'utilisateur */
void *User_Ptr; /* Pointeur utilisable librement par l'utilisateur */
NDT_Index_Nb Index_Nb;
NDT_Index_Nb Index_Open_Count;
@ -467,8 +467,8 @@ NDD_DLL_API NDT_Status ND_Library_Close_C( void);
/*------------------------------------------------------------------------------*/
/* Définition de la sortie standard des messages d'erreur de la librairie */
/*------------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Library_StdErr_Set_I( FILE *Out);
NDD_DLL_API NDT_Status ND_Library_StdErr_Set_C( FILE *Out);
NDD_DLL_API NDT_Status ND_Library_StdErr_Set_I( FILE *);
NDD_DLL_API NDT_Status ND_Library_StdErr_Set_C( FILE *);
@ -492,8 +492,8 @@ NDD_DLL_API NDT_Status ND_DataStruct_Open_C( NDT_Root **, NDT_Index_Nb, NDT_In
/*------------------------------------------------------------------------------*/
/* (O) Root: pointeur sur la racine de la structure de données */
/*------------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_DataStruct_Close_I( NDT_Root *Root);
NDD_DLL_API NDT_Status ND_DataStruct_Close_C( NDT_Root *Root);
NDD_DLL_API NDT_Status ND_DataStruct_Close_I( NDT_Root *);
NDD_DLL_API NDT_Status ND_DataStruct_Close_C( NDT_Root *);
@ -502,8 +502,8 @@ NDD_DLL_API NDT_Status ND_DataStruct_Close_C( NDT_Root *Root);
/*------------------------------------------------------------------------------*/
/* (O) Root: pointeur sur la racine de la structure de données */
/*------------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_DataStruct_Flush_I( NDT_Root *Root);
NDD_DLL_API NDT_Status ND_DataStruct_Flush_C( NDT_Root *Root);
NDD_DLL_API NDT_Status ND_DataStruct_Flush_I( NDT_Root *);
NDD_DLL_API NDT_Status ND_DataStruct_Flush_C( NDT_Root *);
@ -517,8 +517,8 @@ NDD_DLL_API NDT_Status ND_DataStruct_Flush_C( NDT_Root *Root);
/* (O) Nb_Corrected : pointeur sur le nombre d'erreurs */
/* (I) Out : flux de sortie du rapport */
/*------------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_DataStruct_Check_I( NDT_Root *Root, int *Nb_Detected, int *Nb_Corrected, FILE *Out);
NDD_DLL_API NDT_Status ND_DataStruct_Check_C( NDT_Root *Root, int *Nb_Detected, int *Nb_Corrected, FILE *Out);
NDD_DLL_API NDT_Status ND_DataStruct_Check_I( NDT_Root *, int *, int *, FILE *);
NDD_DLL_API NDT_Status ND_DataStruct_Check_C( NDT_Root *, int *, int *, FILE *);
@ -529,8 +529,8 @@ NDD_DLL_API NDT_Status ND_DataStruct_Check_C( NDT_Root *Root, int *Nb_Detecte
/*------------------------------------------------------------------------------*/
/* (I) Root: pointeur sur la racine de la structure de données */
/*------------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_DataStruct_Reorg_I( NDT_Root *Root);
NDD_DLL_API NDT_Status ND_DataStruct_Reorg_C( NDT_Root *Root);
NDD_DLL_API NDT_Status ND_DataStruct_Reorg_I( NDT_Root *);
NDD_DLL_API NDT_Status ND_DataStruct_Reorg_C( NDT_Root *);
@ -553,10 +553,10 @@ NDD_DLL_API NDT_Status ND_DataStruct_Convert_C( NDT_Root *, NDT_Index_Type *)
/* (I) Command: Commande à exécuter sur chaque noeud traversé */
/* (I) Data: pointeur de données utilisateur */
/*------------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_DataStruct_Traverse_VI( NDT_Root *, NDT_Command Command, va_list);
NDD_DLL_API NDT_Status ND_DataStruct_Traverse_VC( NDT_Root *, NDT_Command Command, va_list);
NDD_DLL_API NDT_Status ND_DataStruct_Traverse_I( NDT_Root *, NDT_Command Command, ...);
NDD_DLL_API NDT_Status ND_DataStruct_Traverse_C( NDT_Root *, NDT_Command Command, ...);
NDD_DLL_API NDT_Status ND_DataStruct_Traverse_VI( NDT_Root *, NDT_Command, va_list);
NDD_DLL_API NDT_Status ND_DataStruct_Traverse_VC( NDT_Root *, NDT_Command, va_list);
NDD_DLL_API NDT_Status ND_DataStruct_Traverse_I( NDT_Root *, NDT_Command, ...);
NDD_DLL_API NDT_Status ND_DataStruct_Traverse_C( NDT_Root *, NDT_Command, ...);
@ -566,8 +566,8 @@ NDD_DLL_API NDT_Status ND_DataStruct_Traverse_C( NDT_Root *, NDT_Command Com
/* (I) Root: pointeur sur la racine de la structure de données */
/* (I) Out : flux de sortie */
/*------------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_DataStruct_Info_Print_I( FILE *, NDT_Root *Root, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset);
NDD_DLL_API NDT_Status ND_DataStruct_Info_Print_C( FILE *, NDT_Root *Root, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset);
NDD_DLL_API NDT_Status ND_DataStruct_Info_Print_I( FILE *, NDT_Root *, NDT_Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset);
NDD_DLL_API NDT_Status ND_DataStruct_Info_Print_C( FILE *, NDT_Root *, NDT_Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset);
@ -577,8 +577,8 @@ NDD_DLL_API NDT_Status ND_DataStruct_Info_Print_C( FILE *, NDT_Root *Root, ND
/* (I) Root: pointeur sur la racine de la structure de données */
/* (I) Value: pointeur sur la valeur à ajouter */
/*------------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_DataStruct_Value_Add_I( NDT_Root *Root, void *Value);
NDD_DLL_API NDT_Status ND_DataStruct_Value_Add_C( NDT_Root *Root, void *Value);
NDD_DLL_API NDT_Status ND_DataStruct_Value_Add_I( NDT_Root *, void *);
NDD_DLL_API NDT_Status ND_DataStruct_Value_Add_C( NDT_Root *, void *);
@ -589,8 +589,8 @@ NDD_DLL_API NDT_Status ND_DataStruct_Value_Add_C( NDT_Root *Root, void *Value
/* (I) Reference_Value : pointeur sur la valeur de référence */
/* (I) Removed_Value : adresse d'un pointeur sur la valeur supprimée */
/*------------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_DataStruct_Value_Remove_I( NDT_Root *Root, void *Value);
NDD_DLL_API NDT_Status ND_DataStruct_Value_Remove_C( NDT_Root *Root, void *Value);
NDD_DLL_API NDT_Status ND_DataStruct_Value_Remove_I( NDT_Root *, void *);
NDD_DLL_API NDT_Status ND_DataStruct_Value_Remove_C( NDT_Root *, void *);
@ -615,10 +615,10 @@ NDD_DLL_API NDT_Status ND_DataStruct_Value_Print_C( FILE *, NDT_Root *, NDT_
/* (I) Data : pointeur de données */
/*------------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_DataStruct_Value_Find_VI( void **Value_Ptr_Ptr, NDT_Root *Root_Ptr, void *Ref_Value_Ptr, va_list);
NDD_DLL_API NDT_Status ND_DataStruct_Value_Find_VC( void **Value_Ptr_Ptr, NDT_Root *Root_Ptr, void *Ref_Value_Ptr, va_list);
NDD_DLL_API NDT_Status ND_DataStruct_Value_Find_I( void **Value_Ptr_Ptr, NDT_Root *Root_Ptr, void *Ref_Value_Ptr, ...);
NDD_DLL_API NDT_Status ND_DataStruct_Value_Find_C( void **Value_Ptr_Ptr, NDT_Root *Root_Ptr, void *Ref_Value_Ptr, ...);
NDD_DLL_API NDT_Status ND_DataStruct_Value_Find_VI( void **, NDT_Root *, void *, va_list);
NDD_DLL_API NDT_Status ND_DataStruct_Value_Find_VC( void **, NDT_Root *, void *, va_list);
NDD_DLL_API NDT_Status ND_DataStruct_Value_Find_I( void **, NDT_Root *, void *, ...);
NDD_DLL_API NDT_Status ND_DataStruct_Value_Find_C( void **, NDT_Root *, void *, ...);
@ -667,8 +667,8 @@ NDD_DLL_API NDT_Status ND_Index_Flush_C( NDT_Root *, NDT_Index_Id);
/* (O) Nb_Corrected : pointeur sur le nombre d'erreurs */
/* (I) Out : flux de sortie du rapport */
/*------------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Check_I( NDT_Root *Root, NDT_Index_Id, int *, int *, FILE *);
NDD_DLL_API NDT_Status ND_Index_Check_C( NDT_Root *Root, NDT_Index_Id, int *, int *, FILE *);
NDD_DLL_API NDT_Status ND_Index_Check_I( NDT_Root *, NDT_Index_Id, int *, int *, FILE *);
NDD_DLL_API NDT_Status ND_Index_Check_C( NDT_Root *, NDT_Index_Id, int *, int *, FILE *);
@ -678,8 +678,8 @@ NDD_DLL_API NDT_Status ND_Index_Check_C( NDT_Root *Root, NDT_Index_Id, int *,
/* (I) Root: pointeur sur la racine de la structure de données */
/* (I) Target_Type: type de structure cible */
/*------------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Convert_I ( NDT_Root *, NDT_Index_Id Index_Id, NDT_Index_Type);
NDD_DLL_API NDT_Status ND_Index_Convert_C ( NDT_Root *, NDT_Index_Id Index_Id, NDT_Index_Type);
NDD_DLL_API NDT_Status ND_Index_Convert_I ( NDT_Root *, NDT_Index_Id, NDT_Index_Type);
NDD_DLL_API NDT_Status ND_Index_Convert_C ( NDT_Root *, NDT_Index_Id, NDT_Index_Type);
@ -729,8 +729,8 @@ NDD_DLL_API NDT_Status ND_Index_Info_Print_C( FILE *, NDT_Root *, NDT_Index_I
/* (I) Root: pointeur sur la racine de la structure de données */
/* (I) Value: pointeur sur la valeur à ajouter */
/*------------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Value_Add_I( NDT_Root *Root, NDT_Index_Id, void *Value);
NDD_DLL_API NDT_Status ND_Index_Value_Add_C( NDT_Root *Root, NDT_Index_Id, void *Value);
NDD_DLL_API NDT_Status ND_Index_Value_Add_I( NDT_Root *, NDT_Index_Id, void *);
NDD_DLL_API NDT_Status ND_Index_Value_Add_C( NDT_Root *, NDT_Index_Id, void *);
@ -741,8 +741,8 @@ NDD_DLL_API NDT_Status ND_Index_Value_Add_C( NDT_Root *Root, NDT_Index_Id, voi
/* (I) Reference_Value : pointeur sur la valeur de référence */
/* (I) Removed_Value : adresse d'un pointeur sur la valeur supprimée */
/*------------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Value_Remove_I( NDT_Root *Root, NDT_Index_Id, void *Value);
NDD_DLL_API NDT_Status ND_Index_Value_Remove_C( NDT_Root *Root, NDT_Index_Id, void *Value);
NDD_DLL_API NDT_Status ND_Index_Value_Remove_I( NDT_Root *, NDT_Index_Id, void *);
NDD_DLL_API NDT_Status ND_Index_Value_Remove_C( NDT_Root *, NDT_Index_Id, void *);
@ -764,8 +764,8 @@ NDD_DLL_API NDT_Status ND_Index_Value_Print_C( FILE *, NDT_Root *, NDT_Index
/* (I) Root: pointeur sur la racine de la structure de données */
/* (I) Node: pointeur sur le noeud à ajouter */
/*------------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Node_Add_I( NDT_Root * Root, NDT_Index_Id Index_Id, NDT_Node * Node );
NDD_DLL_API NDT_Status ND_Index_Node_Add_C( NDT_Root * Root, NDT_Index_Id Index_Id, NDT_Node * Node );
NDD_DLL_API NDT_Status ND_Index_Node_Add_I( NDT_Root *, NDT_Index_Id, NDT_Node *);
NDD_DLL_API NDT_Status ND_Index_Node_Add_C( NDT_Root *, NDT_Index_Id, NDT_Node *);
@ -774,8 +774,8 @@ NDD_DLL_API NDT_Status ND_Index_Node_Add_C( NDT_Root * Root, NDT_Index_Id Inde
/*------------------------------------------------------------------------------*/
/* (I) Node: pointeur sur le noeud à supprimer de la structure de données */
/*------------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Node_Remove_I( NDT_Node * Node);
NDD_DLL_API NDT_Status ND_Index_Node_Remove_C( NDT_Node * Node);
NDD_DLL_API NDT_Status ND_Index_Node_Remove_I( NDT_Node *);
NDD_DLL_API NDT_Status ND_Index_Node_Remove_C( NDT_Node *);
@ -892,8 +892,8 @@ NDD_DLL_API NDT_Status ND_Manager_Exec_C( NDT_Root *, NDT_Index_Id, NDT_Node
/* (I) Size : taille de la zone à allouer */
/* (I) Data : pointeur de données utiles à l'allocateur */
/*------------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Allocator_Exec_I( NDT_Allocator *, void **, size_t, void *);
NDD_DLL_API NDT_Status ND_Allocator_Exec_C( NDT_Allocator *, void **, size_t, void *);
NDD_DLL_API NDT_Status ND_Allocator_Exec_I( void **, size_t, NDT_Allocator_Name, NDT_Allocator *, void *);
NDD_DLL_API NDT_Status ND_Allocator_Exec_C( void **, size_t, NDT_Allocator_Name, NDT_Allocator *, void *);
@ -901,11 +901,12 @@ NDD_DLL_API NDT_Status ND_Allocator_Exec_C( NDT_Allocator *, void **, size_t,
/* Exécution d'une fonction de désallocation le dont nom est passé en paramètre */
/*------------------------------------------------------------------------------*/
/* (I) Function : nom de la fonction à exécuter */
/* (I) Function : nom de la fonction à exécuter */
/* (I) Ptr : adresse de la zone à désallouer */
/* (I) Data : pointeur de données utiles au désallocateur */
/*------------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Desallocator_Exec_I( NDT_Desallocator *, void *, void *);
NDD_DLL_API NDT_Status ND_Desallocator_Exec_C( NDT_Desallocator *, void *, void *);
NDD_DLL_API NDT_Status ND_Desallocator_Exec_I( void *, NDT_Desallocator_Name, NDT_Desallocator *, void *);
NDD_DLL_API NDT_Status ND_Desallocator_Exec_C( void *, NDT_Desallocator_Name, NDT_Desallocator *, void *);

View File

@ -1,9 +1,9 @@
/*---------------------------------------------------------------------------------*/
/* $RCSfile: libnode.c,v $ */
/*---------------------------------------------------------------------------------*/
/* $Revision: 2.13 $ */
/* $Revision: 2.14 $ */
/* $Name: $ */
/* $Date: 2005/01/11 16:17:44 $ */
/* $Date: 2005/01/11 20:57:04 $ */
/* $Author: agibert $ */
/*---------------------------------------------------------------------------------*/
@ -34,7 +34,7 @@
#include <libnode.h>
#ifdef _LIBVER_SUPPORT
VER_INFO_EXPORT( libnode, "$Revision: 2.13 $", "$Name: $", __FILE__, "$Author: agibert $")
VER_INFO_EXPORT( libnode, "$Revision: 2.14 $", "$Name: $", __FILE__, "$Author: agibert $")
#endif
@ -63,7 +63,7 @@ NDT_Status ND_Default_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT
Command_Name = "NDD_CMD_MANAGER_VERSION";
*Version_Name_Ptr = "$Revision: 2.13 $ $Name: $ $Date: 2005/01/11 16:17:44 $ $Author: agibert $";
*Version_Name_Ptr = "$Revision: 2.14 $ $Name: $ $Date: 2005/01/11 20:57:04 $ $Author: agibert $";
return( NDS_OK);
}
@ -369,7 +369,7 @@ NDT_Status ND_OpenStruct_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id,
Command_Name = "NDD_CMD_MANAGER_VERSION";
*Version_Name_Ptr = "$Revision: 2.13 $ $Name: $ $Date: 2005/01/11 16:17:44 $ $Author: agibert $";
*Version_Name_Ptr = "$Revision: 2.14 $ $Name: $ $Date: 2005/01/11 20:57:04 $ $Author: agibert $";
return( NDS_OK);
}
@ -604,6 +604,14 @@ NDT_Status ND_Library_Open_I( int Debug_Mode)
ND_Library_StdErr_Set_I( stderr);
}
if( ( NDG_Base.DL_Ptr = dlopen( NULL, ( RTLD_NOW | RTLD_GLOBAL))) == NULL)
{
sprintf( NDG_Base.Err_String, "Error ND_Library_Open: can't dlopen [%s]", dlerror());
ND_Error_Print();
return( NDS_KO);
}
return( NDS_OK);
}
@ -671,6 +679,13 @@ NDT_Status ND_Library_Close_I( void)
NDG_Base.Symbol_First_Ptr = (NDT_Symbol *)NULL;
if( dlclose( NDG_Base.DL_Ptr) != 0)
{
sprintf( NDG_Base.Err_String, "Error ND_Library_Open: can't dlclose [%s]", dlerror());
ND_Error_Print();
return( NDS_KO);
}
NDG_Base.Open_Status = NDD_FALSE;
@ -902,19 +917,18 @@ NDT_Status ND_Index_Open_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_I
NDT_Status ND_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Manager_Name Manager_Name, NDT_Manager *Manager_Ptr,
NDT_Allocator_Name Allocator_Name, NDT_Allocator *Allocator_Ptr, NDT_Desallocator_Name Desallocator_Name, NDT_Desallocator *Desallocator_Ptr, short Own_Value, void *Data)
{
NDT_Status status;
// const char *Real_Allocator, *Real_Desallocator; // Win32
NDT_Status status;
NDT_Manager_Name Real_Manager_Name;
NDT_Manager *Real_Manager_Ptr;
NDT_Manager *Real_Manager_Ptr;
NDT_Allocator_Name Real_Allocator_Name;
NDT_Allocator *Real_Allocator_Ptr;
NDT_Allocator *Real_Allocator_Ptr;
NDT_Desallocator_Name Real_Desallocator_Name;
NDT_Desallocator *Real_Desallocator_Ptr;
/* Valeurs par défaut des fonctions d'allocation et de désallocation */
if( Manager_Ptr)
if( ( Manager_Name != NULL) || ( Manager_Ptr != NULL))
{
Real_Manager_Name = Manager_Name;
Real_Manager_Ptr = Manager_Ptr;
@ -925,7 +939,7 @@ NDT_Status ND_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_N
Real_Manager_Ptr = ND_Default_Manager;
}
if( Allocator_Ptr)
if( ( Allocator_Name != NULL) || ( Allocator_Ptr != NULL))
{
Real_Allocator_Name = Allocator_Name;
Real_Allocator_Ptr = Allocator_Ptr;
@ -936,7 +950,7 @@ NDT_Status ND_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_N
Real_Allocator_Ptr = ND_Default_Allocator;
}
if( Desallocator_Ptr)
if( ( Desallocator_Name != NULL) || ( Desallocator_Ptr != NULL))
{
Real_Desallocator_Name = Desallocator_Name;
Real_Desallocator_Ptr = Desallocator_Ptr;
@ -2251,7 +2265,7 @@ NDT_Status ND_DataStruct_Info_Print_I( FILE *Out, NDT_Root *Root_Ptr, NDT_Recu
fprintf( Out, "%sRoot: (%s%p)\tIndex Nb: (%d)\tIndex Open Count: (%d)\tManager: (%s%p) [%s]\n%sAllocator: (%s%p) [%s]\tDesallocator: (%s%p) [%s]\tUser: (%s%p)\n%sManager Version: [%s]\n\n",
offset, NDD_PRINTF_PTR_PREFIX, Root_Ptr, Root_Ptr->Index_Nb, Root_Ptr->Index_Open_Count, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Manager_Ptr, Root_Ptr->Manager_Name,
offset, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Allocator_Ptr, Root_Ptr->Allocator_Name, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Desallocator_Ptr, Root_Ptr->Desallocator_Name, NDD_PRINTF_PTR_PREFIX, Root_Ptr->User,
offset, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Allocator_Ptr, Root_Ptr->Allocator_Name, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Desallocator_Ptr, Root_Ptr->Desallocator_Name, NDD_PRINTF_PTR_PREFIX, Root_Ptr->User_Ptr,
offset, version_name);
}
@ -2780,7 +2794,7 @@ NDT_Status ND_DataStruct_Value_Print_C( FILE *Out, NDT_Root *Root_Ptr, NDT_Re
sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Print_C: structure root is null");
ND_Error_Print();
return(NDS_ERRAPI);
return( NDS_ERRAPI);
}
if( !Out)
@ -2788,7 +2802,7 @@ NDT_Status ND_DataStruct_Value_Print_C( FILE *Out, NDT_Root *Root_Ptr, NDT_Re
sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Print_C: the stream descriptor is null");
ND_Error_Print();
return(NDS_ERRAPI);
return( NDS_ERRAPI);
}
status = ND_DataStruct_Value_Print_VI( Out, Root_Ptr, Recursive_Mode, Recursive_Depth, Recursive_Offset, user_args);
@ -2817,10 +2831,10 @@ NDT_Status ND_Index_Node_Add_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, ND
{
sprintf (NDG_Base.Err_String, "Error ND_Index_Node_Add_I: unknown structure type (%d)", Root_Ptr->Index_Tab[Index_Id].Type);
ND_Error_Print ();
return(NDS_ERRAPI);
return( NDS_ERRAPI);
}
return(NDS_KO);
return( NDS_KO);
}
@ -3796,7 +3810,20 @@ NDT_Status ND_Manager_Exec_VI( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT
NDT_Manager *manager_ptr;
manager_ptr = Root_Ptr->Manager_Ptr; // Win32
if( Root_Ptr->Manager_Ptr != NULL)
{
manager_ptr = Root_Ptr->Manager_Ptr;
}
else
{
if( ND_Symbol_Find( (void **)&manager_ptr, Root_Ptr->Manager_Name) != NDS_OK)
{
sprintf( NDG_Base.Err_String, "ND_Manager_Exec_VI: cant't find manger function");
ND_Error_Print();
return( NDS_KO);
}
}
status = manager_ptr( Root_Ptr, Index_Id, Node_Ptr, Command, Args);
@ -3865,7 +3892,20 @@ NDT_Status ND_Manager_Exec_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_
va_start( args, Command);
manager_ptr = Root_Ptr->Manager_Ptr; // Win32
if( Root_Ptr->Manager_Ptr != NULL)
{
manager_ptr = Root_Ptr->Manager_Ptr;
}
else
{
if( ND_Symbol_Find( (void **)&manager_ptr, Root_Ptr->Manager_Name) != NDS_OK)
{
sprintf( NDG_Base.Err_String, "ND_Manager_Exec_I: cant't find manger function");
ND_Error_Print();
return( NDS_KO);
}
}
status = manager_ptr( Root_Ptr, Index_Id, Node_Ptr, Command, args);
@ -3886,8 +3926,8 @@ NDT_Status ND_Manager_Exec_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_
NDT_Status ND_Manager_Exec_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, ...)
{
NDT_Status status;
va_list args;
NDT_Status status;
va_list args;
va_start( args, Command);
@ -3936,15 +3976,27 @@ NDT_Status ND_Manager_Exec_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_
/* (I) Data : données utilisateur utiles à l'allocateur */
/*------------------------------------------------------------------------------*/
NDT_Status ND_Allocator_Exec_I( NDT_Allocator *Function, void **Ptr_Ptr, size_t Size, void *Data_Ptr)
NDT_Status ND_Allocator_Exec_I( void **Ptr_Ptr, size_t Size, NDT_Allocator_Name Allocator_Name, NDT_Allocator *Allocator_Ptr, void *Data_Ptr)
{
NDT_Allocator *allocator_ptr;
*Ptr_Ptr = NULL;
allocator_ptr = Function;
if( Allocator_Ptr != NULL)
{
allocator_ptr = Allocator_Ptr;
}
else
{
if( ND_Symbol_Find( (void **)&allocator_ptr, Allocator_Name) != NDS_OK)
{
sprintf( NDG_Base.Err_String, "Error ND_Manager_Exec_I: cant't find allocator function");
ND_Error_Print();
return allocator_ptr( Size, Ptr_Ptr, Data_Ptr);
return( NDS_KO);
}
}
return allocator_ptr( Ptr_Ptr, Size, Data_Ptr);
}
@ -3960,11 +4012,8 @@ NDT_Status ND_Allocator_Exec_I( NDT_Allocator *Function, void **Ptr_Ptr, size
/* (I) Data : données utilisateur utiles à l'allocateur */
/*------------------------------------------------------------------------------*/
NDT_Status ND_Allocator_Exec_C ( NDT_Allocator *Function, void **Ptr_Ptr, size_t Size, void *Data_Ptr)
NDT_Status ND_Allocator_Exec_C( void **Ptr_Ptr, size_t Size, NDT_Allocator_Name Allocator_Name, NDT_Allocator *Allocator_Ptr, void *Data_Ptr)
{
NDT_Allocator *Allocator_Ptr;
if( NDG_Base.Open_Status != NDD_TRUE)
{
sprintf( NDG_Base.Err_String, "Error ND_Allocator_Exec_C: library is not open");
@ -3973,21 +4022,15 @@ NDT_Status ND_Allocator_Exec_C ( NDT_Allocator *Function, void **Ptr_Ptr, siz
return( NDS_ERRAPI);
}
*Ptr_Ptr = NULL;
if(!Function || !*Function)
if( ( Allocator_Name == NULL) && ( Allocator_Ptr == NULL))
{
sprintf( NDG_Base.Err_String, "Error ND_Allocator_Exec_C: undefined function name");
ND_Error_Print ();
ND_Error_Print();
return( NDS_ERRAPI);
}
Allocator_Ptr = Function;
if( !Allocator_Ptr) return( NDS_ERRAPI);
return( Allocator_Ptr (Size, Ptr_Ptr, Data_Ptr));
return( ND_Allocator_Exec_I( Ptr_Ptr, Size, Allocator_Name, Allocator_Ptr, Data_Ptr));
}
@ -4002,11 +4045,25 @@ NDT_Status ND_Allocator_Exec_C ( NDT_Allocator *Function, void **Ptr_Ptr, siz
/* (I) Data : données utilisateur utiles à l'allocateur */
/*------------------------------------------------------------------------------*/
NDT_Status ND_Desallocator_Exec_I( NDT_Desallocator *Function, void *Ptr, void *Data_Ptr)
NDT_Status ND_Desallocator_Exec_I( void *Ptr, NDT_Desallocator_Name Desallocator_Name, NDT_Desallocator *Desallocator_Ptr, void *Data_Ptr)
{
NDT_Desallocator *desallocator_ptr;
desallocator_ptr = Function;
if( Desallocator_Ptr != NULL)
{
desallocator_ptr = Desallocator_Ptr;
}
else
{
if( ND_Symbol_Find( (void **)&desallocator_ptr, Desallocator_Name) != NDS_OK)
{
sprintf( NDG_Base.Err_String, "Error ND_Manager_Exec_I: cant't find desallocator function");
ND_Error_Print();
return( NDS_KO);
}
}
return( desallocator_ptr( Ptr, Data_Ptr));
}
@ -4023,11 +4080,8 @@ NDT_Status ND_Desallocator_Exec_I( NDT_Desallocator *Function, void *Ptr, void
/* (I) Data : données utilisateur utiles à l'allocateur */
/*------------------------------------------------------------------------------*/
NDT_Status ND_Desallocator_Exec_C( NDT_Desallocator *Function, void *Ptr, void *Data_Ptr)
NDT_Status ND_Desallocator_Exec_C( void *Ptr, NDT_Desallocator_Name Desallocator_Name, NDT_Desallocator *Desallocator_Ptr, void *Data_Ptr)
{
NDT_Desallocator *desallocator_ptr;
if( NDG_Base.Open_Status != NDD_TRUE)
{
sprintf( NDG_Base.Err_String, "Error ND_Desallocator_Exec_C: library is not open");
@ -4036,19 +4090,15 @@ NDT_Status ND_Desallocator_Exec_C( NDT_Desallocator *Function, void *Ptr, voi
return( NDS_ERRAPI);
}
if (!Function || !*Function)
if( ( Desallocator_Name == NULL) && ( Desallocator_Ptr == NULL))
{
sprintf (NDG_Base.Err_String, "Error ND_Desallocator_Exec_C: undefined function name");
ND_Error_Print ();
sprintf( NDG_Base.Err_String, "Error ND_Desallocator_Exec_C: undefined function name");
ND_Error_Print();
return( NDS_ERRAPI);
}
desallocator_ptr = Function;
if( !desallocator_ptr) return( NDS_ERRAPI);
return( desallocator_ptr( Ptr, Data_Ptr));
return( ND_Desallocator_Exec_I( Ptr, Desallocator_Name, Desallocator_Ptr, Data_Ptr));
}
@ -4058,25 +4108,19 @@ NDT_Status ND_Desallocator_Exec_C( NDT_Desallocator *Function, void *Ptr, voi
/*------------------------------------------------------------------------------*/
/* FONCTIONS SECURISEES (ND_MODE = 0) */
/*------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------*/
/* FONCTIONS PRIVEES */
/* PRIVATE FUNCTIONS */
/*------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------*/
/* Recherche d'un symbole */
/* Symbol Lookup */
/*------------------------------------------------------------------------------*/
void *ND_Symbol_Find( const char *Symbol_Name)
NDT_Status ND_Symbol_Find( void **Ptr_Ptr, const char *Symbol_Name)
{
NDT_Symbol *Symbol_Ptr;
void *Ptr = NULL;
/* Recherche du symbole dans la table des symboles locale */
@ -4084,31 +4128,46 @@ void *ND_Symbol_Find( const char *Symbol_Name)
while( Symbol_Ptr)
{
if( !strcmp( Symbol_Ptr->Name, Symbol_Name)) return( Symbol_Ptr->Ptr);
else Symbol_Ptr = Symbol_Ptr->Next;
if( !strcmp( Symbol_Ptr->Name, Symbol_Name))
{
*Ptr_Ptr = Symbol_Ptr->Ptr;
return( NDS_OK);
}
else
{
Symbol_Ptr = Symbol_Ptr->Next;
}
}
/* Si le symbole n'a pas été trouvée dans la table des symboles locale, on l'y ajoute */
// Ptr = dlsym( RTLD_DEFAULT, (const char *)Symbol_Name);
if( !Ptr)
if( ( *Ptr_Ptr = dlsym( NDG_Base.DL_Ptr, (const char *)Symbol_Name)) == NULL)
{
sprintf( NDG_Base.Err_String, "Error ND_Symbol_Find: unable to find \"%s\"' in symbol table (%s)", Symbol_Name, NULL/*dlerror ()*/);
ND_Error_Print ();
return NULL;
sprintf( NDG_Base.Err_String, "Error ND_Symbol_Find: unable to find \"%s\"' in symbol table (%s)", Symbol_Name, dlerror());
ND_Error_Print();
return( NDS_KO);
}
Symbol_Ptr = (NDT_Symbol *)malloc( sizeof( NDT_Symbol));
if( Symbol_Ptr)
if( Symbol_Ptr == NULL)
{
sprintf( NDG_Base.Err_String, "Error ND_Symbol_Find: no more memory");
ND_Error_Print();
return( NDS_KO);
}
else
{
Symbol_Ptr->Name = strdup (Symbol_Name);
Symbol_Ptr->Ptr = Ptr;
Symbol_Ptr->Ptr = *Ptr_Ptr;
Symbol_Ptr->Next = NDG_Base.Symbol_First_Ptr;
NDG_Base.Symbol_First_Ptr = Symbol_Ptr;
}
return Ptr;
return( NDS_OK);
}
@ -4127,17 +4186,17 @@ NDT_Status ND_Node_Alloc( NDT_Root *Root_Ptr, NDT_Node **Node_Ptr_Ptr )
NDT_Status rc;
rc = ND_Allocator_Exec_I( Root_Ptr->Allocator_Ptr, (void **)Node_Ptr_Ptr, sizeof(NDT_Node), Root_Ptr->User);
if( ND_ERROR(rc)) return( rc);
rc = ND_Allocator_Exec_I( (void **)Node_Ptr_Ptr, sizeof(NDT_Node), Root_Ptr->Allocator_Name, Root_Ptr->Allocator_Ptr, Root_Ptr->User_Ptr);
if( ND_ERROR( rc)) return( rc);
(*Node_Ptr_Ptr)->Root = NULL;
(*Node_Ptr_Ptr)->Index = NDD_INDEX_UNKNOWN;
(*Node_Ptr_Ptr)->Root = NULL;
(*Node_Ptr_Ptr)->Index = NDD_INDEX_UNKNOWN;
(*Node_Ptr_Ptr)->Parent = NULL;
(*Node_Ptr_Ptr)->Left = NULL;
(*Node_Ptr_Ptr)->Right = NULL;
(*Node_Ptr_Ptr)->Value = NULL;
(*Node_Ptr_Ptr)->Left = NULL;
(*Node_Ptr_Ptr)->Right = NULL;
(*Node_Ptr_Ptr)->Value = NULL;
return(NDS_OK);
return( NDS_OK);
}
@ -4152,7 +4211,7 @@ NDT_Status ND_Node_Alloc( NDT_Root *Root_Ptr, NDT_Node **Node_Ptr_Ptr )
/*------------------------------------------------------------------------------*/
NDT_Status ND_Node_Free( NDT_Root *Root_Ptr, NDT_Node *Node_Ptr)
{
return ND_Desallocator_Exec_I( Root_Ptr->Desallocator_Ptr, Node_Ptr, Root_Ptr->User);
return( ND_Desallocator_Exec_I( Node_Ptr, Root_Ptr->Desallocator_Name, Root_Ptr->Desallocator_Ptr, Root_Ptr->User_Ptr));
}
@ -4172,18 +4231,18 @@ NDT_Status ND_Node_Free( NDT_Root *Root_Ptr, NDT_Node *Node_Ptr)
NDT_Status ND_Index_Clear( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id)
{
Root_Ptr->Index_Tab[Index_Id].Type = NDD_INDEX_STATUS_UNKNOWN;
Root_Ptr->Index_Tab[Index_Id].Type = NDD_INDEX_STATUS_UNKNOWN;
Root_Ptr->Index_Tab[Index_Id].Head = NULL;
Root_Ptr->Index_Tab[Index_Id].Tail = NULL;
Root_Ptr->Index_Tab[Index_Id].Save = NULL;
Root_Ptr->Index_Tab[Index_Id].Head = NULL;
Root_Ptr->Index_Tab[Index_Id].Tail = NULL;
Root_Ptr->Index_Tab[Index_Id].Save = NULL;
Root_Ptr->Index_Tab[Index_Id].Max_Dif = DEF_MAX_DIF;
Root_Ptr->Index_Tab[Index_Id].Max_Dif = DEF_MAX_DIF;
Root_Ptr->Index_Tab[Index_Id].Node_Number = 0;
Root_Ptr->Index_Tab[Index_Id].Max_Depth = 0;
Root_Ptr->Index_Tab[Index_Id].Min_Depth = NDD_HUGE_LONG;
Root_Ptr->Index_Tab[Index_Id].Nb_Equ = 0;
Root_Ptr->Index_Tab[Index_Id].Max_Depth = 0;
Root_Ptr->Index_Tab[Index_Id].Min_Depth = NDD_HUGE_LONG;
Root_Ptr->Index_Tab[Index_Id].Nb_Equ = 0;
return( NDS_OK);
}
@ -4208,25 +4267,25 @@ NDT_Status ND_Node_Root_Alloc( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_Nb,
NDT_Index_Id index_id;
status = ND_Allocator_Exec_I( Allocator_Ptr, (void **)Root_Ptr_Ptr, ( sizeof( NDT_Root) + sizeof(NDT_Index) * (Index_Nb - 1)), Data_Ptr);
status = ND_Allocator_Exec_I( (void **)Root_Ptr_Ptr, ( sizeof( NDT_Root) + sizeof(NDT_Index) * (Index_Nb - 1)), Allocator_Name, Allocator_Ptr, Data_Ptr);
if( ND_ERROR(status)) return( status);
if( strlen(Manager_Name) > NDD_MANAGER_NAME_LEN_MAX) return( NDS_ERRAPI);
strcpy( (*Root_Ptr_Ptr)->Manager_Name, Manager_Name);
(*Root_Ptr_Ptr)->Manager_Ptr = Manager_Ptr;
(*Root_Ptr_Ptr)->Manager_Ptr = Manager_Ptr;
if( strlen(Allocator_Name) > NDD_ALLOCATOR_NAME_LEN_MAX) return( NDS_ERRAPI);
strcpy( (*Root_Ptr_Ptr)->Allocator_Name, Allocator_Name);
(*Root_Ptr_Ptr)->Allocator_Ptr = Allocator_Ptr;
(*Root_Ptr_Ptr)->Allocator_Ptr = Allocator_Ptr;
if( strlen(Desallocator_Name) > NDD_DESALLOCATOR_NAME_LEN_MAX) return( NDS_ERRAPI);
strcpy( (*Root_Ptr_Ptr)->Desallocator_Name, Desallocator_Name);
(*Root_Ptr_Ptr)->Desallocator_Ptr = Desallocator_Ptr;
(*Root_Ptr_Ptr)->Own_Value = Own_Value;
(*Root_Ptr_Ptr)->User = Data_Ptr;
(*Root_Ptr_Ptr)->Own_Value = Own_Value;
(*Root_Ptr_Ptr)->User_Ptr = Data_Ptr;
(*Root_Ptr_Ptr)->Index_Nb = Index_Nb;
(*Root_Ptr_Ptr)->Index_Nb = Index_Nb;
(*Root_Ptr_Ptr)->Index_Open_Count = 0;
for( index_id = 0; index_id < Index_Nb; index_id++)
@ -4249,7 +4308,7 @@ NDT_Status ND_Node_Root_Alloc( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_Nb,
}
}
return(NDS_OK);
return( NDS_OK);
}
@ -4263,7 +4322,7 @@ NDT_Status ND_Node_Root_Alloc( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_Nb,
/*------------------------------------------------------------------------------*/
NDT_Status ND_Node_Root_Free( NDT_Root *Root_Ptr)
{
return ND_Desallocator_Exec_I( Root_Ptr->Desallocator_Ptr, Root_Ptr, Root_Ptr->User);
return( ND_Desallocator_Exec_I( Root_Ptr, Root_Ptr->Desallocator_Name, Root_Ptr->Desallocator_Ptr, Root_Ptr->User_Ptr));
}
@ -4387,11 +4446,11 @@ NDT_Status ND_List_Node_Add( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_N
if( ND_INDEX_SUBTYPE_FIFO_IS( Root_Ptr, Index_Id))
{
New_Node_Ptr->Root = Root_Ptr;
New_Node_Ptr->Index = Index_Id;
New_Node_Ptr->Root = Root_Ptr;
New_Node_Ptr->Index = Index_Id;
New_Node_Ptr->Parent = NULL;
New_Node_Ptr->Left = Root_Ptr->Index_Tab[Index_Id].Tail;
New_Node_Ptr->Right = NULL;
New_Node_Ptr->Left = Root_Ptr->Index_Tab[Index_Id].Tail;
New_Node_Ptr->Right = NULL;
if( !Root_Ptr->Index_Tab[Index_Id].Head) Root_Ptr->Index_Tab[Index_Id].Head = New_Node_Ptr;
else Root_Ptr->Index_Tab[Index_Id].Tail->Right = New_Node_Ptr;
@ -4407,11 +4466,11 @@ NDT_Status ND_List_Node_Add( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_N
if( ND_INDEX_SUBTYPE_LIFO_IS( Root_Ptr, Index_Id))
{
New_Node_Ptr->Root = Root_Ptr;
New_Node_Ptr->Index = Index_Id;
New_Node_Ptr->Root = Root_Ptr;
New_Node_Ptr->Index = Index_Id;
New_Node_Ptr->Parent = NULL;
New_Node_Ptr->Left = NULL;
New_Node_Ptr->Right = Root_Ptr->Index_Tab[Index_Id].Head;
New_Node_Ptr->Left = NULL;
New_Node_Ptr->Right = Root_Ptr->Index_Tab[Index_Id].Head;
if( !Root_Ptr->Index_Tab[Index_Id].Tail) Root_Ptr->Index_Tab[Index_Id].Tail = New_Node_Ptr;
else Root_Ptr->Index_Tab[Index_Id].Head->Left = New_Node_Ptr;
@ -4663,9 +4722,9 @@ NDT_Status ND_List_Node_Remove( NDT_Node *Node_Ptr)
Node_Ptr->Root->Index_Tab[Node_Ptr->Index].Node_Number--;
Node_Ptr->Root = NULL;
Node_Ptr->Root = NULL;
Node_Ptr->Index = NDD_INDEX_UNKNOWN;
Node_Ptr->Left = NULL;
Node_Ptr->Left = NULL;
Node_Ptr->Right = NULL;
return( NDS_OK);
@ -4702,20 +4761,22 @@ NDT_Status ND_List_Recursive_Make( NDT_Node *Node_Ptr, NDT_Root *Root_Ptr, ND
/*--------------------------------- main body --------------------------------*/
NDT_Status ND_List_Make( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id)
{
NDT_Node *node_ptr;
node_ptr = Root_Ptr->Index_Tab[Index_Id].Head;
Root_Ptr->Index_Tab[Index_Id].Head = NULL;
Root_Ptr->Index_Tab[Index_Id].Tail = NULL;
Root_Ptr->Index_Tab[Index_Id].Max_Dif = DEF_MAX_DIF;
Root_Ptr->Index_Tab[Index_Id].Head = NULL;
Root_Ptr->Index_Tab[Index_Id].Tail = NULL;
Root_Ptr->Index_Tab[Index_Id].Max_Dif = DEF_MAX_DIF;
Root_Ptr->Index_Tab[Index_Id].Node_Number = 0;
Root_Ptr->Index_Tab[Index_Id].Max_Depth = 0;
Root_Ptr->Index_Tab[Index_Id].Min_Depth = NDD_HUGE_LONG;
Root_Ptr->Index_Tab[Index_Id].Nb_Equ = 0;
Root_Ptr->Index_Tab[Index_Id].Type = NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_FIFO;
Root_Ptr->Index_Tab[Index_Id].Max_Depth = 0;
Root_Ptr->Index_Tab[Index_Id].Min_Depth = NDD_HUGE_LONG;
Root_Ptr->Index_Tab[Index_Id].Nb_Equ = 0;
Root_Ptr->Index_Tab[Index_Id].Type = NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_FIFO;
return( ND_List_Recursive_Make( node_ptr, Root_Ptr, Index_Id));
}
@ -4823,24 +4884,24 @@ NDT_Status ND_Tree_Make( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id )
if( ND_INDEX_SUBTYPE_SORTED_IS( Root_Ptr, Index_Id))
{
rc = ND_List_Sort( Root_Ptr, Index_Id);
if( ND_ERROR(rc)) return rc;
if( ND_ERROR(rc)) return( rc);
}
node_ptr = Root_Ptr->Index_Tab[Index_Id].Head;
node_number = Root_Ptr->Index_Tab[Index_Id].Node_Number;
Root_Ptr->Index_Tab[Index_Id].Head = NULL;
Root_Ptr->Index_Tab[Index_Id].Tail = NULL;
Root_Ptr->Index_Tab[Index_Id].Max_Dif = DEF_MAX_DIF;
Root_Ptr->Index_Tab[Index_Id].Head = NULL;
Root_Ptr->Index_Tab[Index_Id].Tail = NULL;
Root_Ptr->Index_Tab[Index_Id].Max_Dif = DEF_MAX_DIF;
Root_Ptr->Index_Tab[Index_Id].Node_Number = 0;
Root_Ptr->Index_Tab[Index_Id].Max_Depth = 0;
Root_Ptr->Index_Tab[Index_Id].Min_Depth = NDD_HUGE_LONG;
Root_Ptr->Index_Tab[Index_Id].Nb_Equ = 0;
Root_Ptr->Index_Tab[Index_Id].Type = NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED;
Root_Ptr->Index_Tab[Index_Id].Max_Depth = 0;
Root_Ptr->Index_Tab[Index_Id].Min_Depth = NDD_HUGE_LONG;
Root_Ptr->Index_Tab[Index_Id].Nb_Equ = 0;
Root_Ptr->Index_Tab[Index_Id].Type = NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED;
Root_Ptr->Index_Tab[Index_Id].Head = Root_Ptr->Index_Tab[Index_Id].Tail = ND_Tree_Recursive_Make( 1, node_number, node_ptr);
return NDS_OK;
return( NDS_OK);
}
@ -4857,16 +4918,12 @@ NDT_Status ND_Tree_Equalize( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id)
{
NDT_Status rc;
NDT_Index_Type type;
// char manager[30]; // Win32
NDT_Manager *manager; // Win32
long max_dif, nb_equ;
type = Root_Ptr->Index_Tab[Index_Id].Type;
// strcpy( Manager, Root_Ptr->Manager); // Win32
manager = Root_Ptr->Manager_Ptr; // Win32
type = Root_Ptr->Index_Tab[Index_Id].Type;
max_dif = Root_Ptr->Index_Tab[Index_Id].Max_Dif;
nb_equ = Root_Ptr->Index_Tab[Index_Id].Nb_Equ;
nb_equ = Root_Ptr->Index_Tab[Index_Id].Nb_Equ;
rc = ND_List_Make( Root_Ptr, Index_Id);
if( ND_ERROR(rc)) return(rc);
@ -4876,11 +4933,9 @@ NDT_Status ND_Tree_Equalize( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id)
rc = ND_Tree_Make( Root_Ptr, Index_Id);
if( ND_ERROR(rc)) return(rc);
Root_Ptr->Index_Tab[Index_Id].Type = type;
// strcpy( Root_Ptr->Manager, Manager); // Win32
Root_Ptr->Manager_Ptr = manager; // Win32
Root_Ptr->Index_Tab[Index_Id].Type = type;
Root_Ptr->Index_Tab[Index_Id].Max_Dif = max_dif;
Root_Ptr->Index_Tab[Index_Id].Nb_Equ = nb_equ + 1;
Root_Ptr->Index_Tab[Index_Id].Nb_Equ = nb_equ + 1;
return( NDS_OK);
}
@ -5015,7 +5070,7 @@ NDT_Status ND_Tree_List_Add( NDT_Root *Tree_Root_Ptr, NDT_Index_Id Tree_Index
while( node_ptr)
{
rc = ND_Tree_Node_Add( Tree_Root_Ptr, Tree_Index_Id, node_ptr);
if( ND_ERROR(rc)) return(rc);
if( ND_ERROR( rc)) return( rc);
node_ptr = node_ptr->Right;
}
@ -5068,7 +5123,7 @@ fprintf( Out, "]\n");
if( Node_Ptr->Left)
{
fprintf( Out, "%*s\\\n", (int)(Depth * BRANCH_LEN - 1), "");
fprintf( Out, "%*s\\\n", (int)( Depth * BRANCH_LEN - 1), "");
ND_Tree_Recursive_Print( Node_Ptr->Left, Depth + 1, Out);
}
}
@ -5086,19 +5141,21 @@ int ND_Node_Compare( void **Node1_Ptr_Ptr, void **Node2_Ptr_Ptr)
NDT_Status rc;
// rc = ND_Manager_Exec_I( Tmp_Root->Manager, NDD_CMD_COMP_VALUE_COMP, ((NDT_Node *)(*Node1))->Value, ((NDT_Node *)(*Node2))->Value);
rc = ND_Manager_Exec_I( ( ( NDT_Node *)( *Node1_Ptr_Ptr))->Root, ( ( NDT_Node *)(*Node1_Ptr_Ptr))->Index, *Node1_Ptr_Ptr, NDD_CMD_VALUE_COMP, ( (NDT_Node *) (*Node1_Ptr_Ptr))->Value, ( ( NDT_Node *)( *Node2_Ptr_Ptr))->Value, NULL);
switch( (int)rc)
{
case NDS_EQUAL: return 0;
case NDS_LOWER: return -1;
case NDS_GREATER: return 1;
case NDS_EQUAL: return( 0);
case NDS_LOWER: return( -1);
case NDS_GREATER: return( 1);
default:
{
sprintf( NDG_Base.Err_String, "Error ND_Node_Compare : incorrect return code from the manager: %d", rc);
ND_Error_Print();
return 0;
return( 0);
}
}
}
@ -5139,9 +5196,6 @@ NDT_Status ND_List_Sort( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id)
/* Tri du tableau de pointeurs de noeuds */
// Tmp_Root = Root;
// qsort( (void *)tab, (size_t)(Root_Ptr->Index_Tab[Index_Id].Node_Number), sizeof(NDT_Node *), ( int (__cdecl *)(const void *, const void *))&ND_Node_Compare);
qsort( (void *)tab, (size_t)( Root_Ptr->Index_Tab[Index_Id].Node_Number), sizeof( NDT_Node *), ( int (*)( const void *, const void *))&ND_Node_Compare);
/* On met à jour les liens entre les noeuds */
@ -5150,12 +5204,12 @@ NDT_Status ND_List_Sort( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id)
{
node_ptr = (NDT_Node *)tab[i];
node_ptr->Left = (i ? (NDT_Node *)(tab[i - 1]) : NULL);
node_ptr->Right = (i != Root_Ptr->Index_Tab[Index_Id].Node_Number - 1 ? (NDT_Node *)(tab[i + 1]) : NULL);
node_ptr->Left = (i ? (NDT_Node *)( tab[i - 1]) : NULL);
node_ptr->Right = (i != Root_Ptr->Index_Tab[Index_Id].Node_Number - 1 ? (NDT_Node *)( tab[i + 1]) : NULL);
}
Root_Ptr->Index_Tab[Index_Id].Head = (NDT_Node *)(tab[0]);
Root_Ptr->Index_Tab[Index_Id].Tail = (NDT_Node *)(tab[Root_Ptr->Index_Tab[Index_Id].Node_Number - 1]);
Root_Ptr->Index_Tab[Index_Id].Head = (NDT_Node *)( tab[0]);
Root_Ptr->Index_Tab[Index_Id].Tail = (NDT_Node *)( tab[Root_Ptr->Index_Tab[Index_Id].Node_Number - 1]);
/* Désallocation du tableau */
@ -5178,7 +5232,7 @@ NDT_Node *ND_Tree_Node_First_Recursive_Get( NDT_Node *Node_Ptr)
{
if( !Node_Ptr) return NULL;
if( !Node_Ptr->Left) return(Node_Ptr);
if( !Node_Ptr->Left) return( Node_Ptr);
return( ND_Tree_Node_First_Recursive_Get( Node_Ptr->Left));
}
@ -5197,7 +5251,7 @@ NDT_Node *ND_Tree_Node_Last_Recursive_Get( NDT_Node *Node_Ptr)
{
if( !Node_Ptr) return NULL;
if( !Node_Ptr->Right) return(Node_Ptr);
if( !Node_Ptr->Right) return( Node_Ptr);
return ND_Tree_Node_Last_Recursive_Get( Node_Ptr->Right);
}
@ -5207,15 +5261,15 @@ NDT_Node *ND_Tree_Node_Last_Recursive_Get( NDT_Node *Node_Ptr)
/*------------------------------------------------------------------------------*/
/* Redéfinition de la fonction malloc() avec retour de type NDT_Status */
/* Redéfinition de la fonction malloc() avec retour de type NDT_Status */
/*------------------------------------------------------------------------------*/
NDT_Status ND_Default_Allocator( size_t Size, void **Ptr_Ptr, void *Data_Ptr)
NDT_Status ND_Default_Allocator( void **Ptr_Ptr, size_t Size, void *Data_Ptr)
{
*Ptr_Ptr = malloc(Size);
*Ptr_Ptr = malloc( Size);
if( !*Ptr_Ptr) return(NDS_ERRMEM);
if( !*Ptr_Ptr) return( NDS_ERRMEM);
return( NDS_OK);
}
@ -5230,7 +5284,7 @@ NDT_Status ND_Default_Allocator( size_t Size, void **Ptr_Ptr, void *Data_Ptr
NDT_Status ND_Default_Desallocator( void *Ptr, void *Data_Ptr)
{
if( !Ptr) return(NDS_ERRAPI);
if( !Ptr) return( NDS_ERRAPI);
free( Ptr);

View File

@ -1,9 +1,9 @@
/*---------------------------------------------------------------------------------*/
/* $RCSfile: libnode.h,v $ */
/*---------------------------------------------------------------------------------*/
/* $Revision: 2.7 $ */
/* $Revision: 2.8 $ */
/* $Name: $ */
/* $Date: 2004/08/23 22:47:22 $ */
/* $Date: 2005/01/11 20:57:04 $ */
/* $Author: agibert $ */
/*---------------------------------------------------------------------------------*/
@ -32,11 +32,16 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
# include <errno.h>
# include <signal.h>
# include <setjmp.h>
#include <errno.h>
#include <signal.h>
#include <setjmp.h>
#include <dlfcn.h>
//#include <dlfcn.h>
/* Utilisation des API de la LIBNODE sans vérification des arguments */
#define ND_MODE 1
#include <node.h>
@ -88,6 +93,7 @@ typedef struct NDT_Base
jmp_buf SigLongJmp_Env;
#endif
NDT_Symbol *Symbol_First_Ptr;
void *DL_Ptr;
NDT_Index_Type OpenStruct_Index_Type[1];
NDT_Root *OpenStruct_Ptr;
} NDT_Base;
@ -101,6 +107,7 @@ NDT_Base NDG_Base =
0,
{0},
(NDT_Symbol *) NULL,
NULL,
{ NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_FIFO},
(NDT_Root *) NULL
};
@ -132,12 +139,12 @@ NDT_Status ND_OpenStruct_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_C
/*------------------------------------------------------------------------------*/
/* Redéfinition de la fonction malloc() avec retour de type NDT_Status */
/*------------------------------------------------------------------------------*/
NDT_Status ND_Default_Allocator( size_t Size, void **ptr, void *User);
NDT_Status ND_Default_Allocator( void **, size_t, void *);
/*------------------------------------------------------------------------------*/
/* Redéfinition de la fonction free() avec retour de type NDT_Status */
/*------------------------------------------------------------------------------*/
NDT_Status ND_Default_Desallocator( void *, void *);
NDT_Status ND_Default_Desallocator( void *, void *);
/*------------------------------------------------------------------------------*/
/* Création d'un noeud */
@ -153,7 +160,7 @@ NDT_Status ND_Node_Alloc( NDT_Root * Root, NDT_Node ** New_Node);
/* (I) Root : adresse de la racine dans laquelle on détruit un noeud */
/* (I) Node : pointeur sur le noeud à détruire */
/*------------------------------------------------------------------------------*/
NDT_Status ND_Node_Free( NDT_Root *, NDT_Node *);
NDT_Status ND_Node_Free( NDT_Root *, NDT_Node *);
/*------------------------------------------------------------------------------*/
/* Création d'une nouvelle structure de données */
@ -183,7 +190,7 @@ NDT_Status ND_Node_Root_Alloc( NDT_Root **, NDT_Index_Nb, NDT_Index_Type[], ch
/*------------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine à détruire */
/*------------------------------------------------------------------------------*/
NDT_Status ND_Node_Root_Free( NDT_Root *);
NDT_Status ND_Node_Root_Free( NDT_Root *);
/*------------------------------------------------------------------------------*/
/* Ajout d'un noeud à une liste chaînée */
@ -191,7 +198,7 @@ NDT_Status ND_Node_Root_Free( NDT_Root *);
/* (I) Root : pointeur sur la racine de la liste */
/* (I) New_Node : pointeur sur le noeud à ajouter */
/*------------------------------------------------------------------------------*/
NDT_Status ND_List_Node_Add( NDT_Root *, NDT_Index_Id, NDT_Node *);
NDT_Status ND_List_Node_Add( NDT_Root *, NDT_Index_Id, NDT_Node *);
/*------------------------------------------------------------------------------*/
/* Ajout d'une nouvelle valeur à une liste */
@ -199,7 +206,7 @@ NDT_Status ND_List_Node_Add( NDT_Root *, NDT_Index_Id, NDT_Node *);
/* (I) Root : pointeur sur la racine de la liste */
/* (I) Value : pointeur sur la valeur à ajouter */
/*------------------------------------------------------------------------------*/
NDT_Status ND_List_Value_Add( NDT_Root *, NDT_Index_Id, void *);
NDT_Status ND_List_Value_Add( NDT_Root *, NDT_Index_Id, void *);
/*------------------------------------------------------------------------------*/
/* Ajout d'un noeud à un arbre binaire */
@ -207,26 +214,26 @@ NDT_Status ND_List_Value_Add( NDT_Root *, NDT_Index_Id, void *);
/* (I) Root : pointeur sur la racine de l'arbre */
/* (I) Value : pointeur sur la valeur à ajouter */
/*------------------------------------------------------------------------------*/
NDT_Status ND_Tree_Value_Add( NDT_Root *, NDT_Index_Id, void *);
NDT_Status ND_Tree_Value_Add( NDT_Root *, NDT_Index_Id, void *);
/*------------------------------------------------------------------------------*/
/* Supprime le noeud d'une liste */
/*------------------------------------------------------------------------------*/
/* (I) Node : pointeur sur le noeud à supprimer */
/*------------------------------------------------------------------------------*/
NDT_Status ND_List_Node_Remove( NDT_Node *);
NDT_Status ND_List_Node_Remove( NDT_Node *);
/*------------------------------------------------------------------------------*/
/* Conversion d'une structure en liste chaînée */
/*------------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine du la structure à convertir */
/*------------------------------------------------------------------------------*/
NDT_Status ND_List_Make( NDT_Root *, NDT_Index_Id);
NDT_Status ND_List_Make( NDT_Root *, NDT_Index_Id);
/*------------------------------------------------------------------------------*/
/* Recherche une valeur dans une liste et retourne le noeud correspondant */
/*------------------------------------------------------------------------------*/
NDT_Node * ND_List_Node_Find( NDT_Root *, NDT_Index_Id, void *, va_list);
NDT_Node *ND_List_Node_Find( NDT_Root *, NDT_Index_Id, void *, va_list);
/*------------------------------------------------------------------------------*/
/* Recherche un noeud dans un arbre et retourne le pointeur sur le noeud */
@ -239,28 +246,28 @@ NDT_Node *ND_Tree_Node_Find( NDT_Root *, NDT_Index_Id, void *, va_list);
/* (I) Root : pointeur sur la racine du la structure à convertir */
/* (I) Type : type du futur arbre */
/*------------------------------------------------------------------------------*/
NDT_Status ND_Tree_Make( NDT_Root *, NDT_Index_Id);
NDT_Status ND_Tree_Make( NDT_Root *, NDT_Index_Id);
/*------------------------------------------------------------------------------*/
/* Equilibrage d'un arbre */
/*------------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de l'arbre */
/*------------------------------------------------------------------------------*/
NDT_Status ND_Tree_Equalize( NDT_Root *, NDT_Index_Id);
NDT_Status ND_Tree_Equalize( NDT_Root *, NDT_Index_Id);
/*------------------------------------------------------------------------------*/
/* Retourne la profondeur de la plus grande branche à partir d'un noeud */
/*------------------------------------------------------------------------------*/
/* (I) Node : pointeur sur le noeud */
/*------------------------------------------------------------------------------*/
long ND_Tree_MaxDepth_Get( NDT_Node *);
long ND_Tree_MaxDepth_Get( NDT_Node *);
/*------------------------------------------------------------------------------*/
/* Retourne la profondeur de la plus petite branche à partir d'un noeud */
/*------------------------------------------------------------------------------*/
/* (I) Node : pointeur sur le noeud */
/*------------------------------------------------------------------------------*/
long ND_Tree_MinDepth_Get( NDT_Node *);
long ND_Tree_MinDepth_Get( NDT_Node *);
/*------------------------------------------------------------------------------*/
/* Ajout d'un noeud à un arbre binaire */
@ -268,7 +275,7 @@ long ND_Tree_MinDepth_Get( NDT_Node *);
/* (I) Root : pointeur sur la racine de l'arbre */
/* (I) Node : pointeur sur le noeud à ajouter */
/*------------------------------------------------------------------------------*/
NDT_Status ND_Tree_Node_Add( NDT_Root *, NDT_Index_Id, NDT_Node *);
NDT_Status ND_Tree_Node_Add( NDT_Root *, NDT_Index_Id, NDT_Node *);
/*------------------------------------------------------------------------------*/
/* Ajoute tous les noeud d'une liste à un arbre */
@ -276,60 +283,65 @@ NDT_Status ND_Tree_Node_Add( NDT_Root *, NDT_Index_Id, NDT_Node *);
/* (I) Tree_Root : pointeur sur la racine de l'arbre */
/* (I) List_Root : pointeur sur la racine de la liste */
/*------------------------------------------------------------------------------*/
NDT_Status ND_Tree_List_Add( NDT_Root *, NDT_Index_Id, NDT_Root *, NDT_Index_Id);
NDT_Status ND_Tree_List_Add( NDT_Root *, NDT_Index_Id, NDT_Root *, NDT_Index_Id);
/*------------------------------------------------------------------------------*/
/* Fonction de comparaison de noeuds (pour le quick sort) */
/*------------------------------------------------------------------------------*/
int ND_Node_Compare( void **, void **);
int ND_Node_Compare( void **, void **);
/*------------------------------------------------------------------------------*/
/* Ordonne une liste chaînée selon l'algorithme du tri à bulle */
/*------------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la liste à trier */
/*------------------------------------------------------------------------------*/
NDT_Status ND_List_Sort( NDT_Root *, NDT_Index_Id);
NDT_Status ND_List_Sort( NDT_Root *, NDT_Index_Id);
/*------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------*/
/* Fonctions et procédures privées de la librairie (bas niveau) */
/* PRIVATE FUNCTIONS */
/*------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------*/
void ND_List_Check( NDT_Root *, NDT_Index_Id, int *, int *, FILE *);
void ND_List_Check( NDT_Root *, NDT_Index_Id, int *, int *, FILE *);
void ND_List_Link_Check( NDT_Root *, NDT_Index_Id, int *, int *, FILE *);
void ND_List_Link_Check( NDT_Root *, NDT_Index_Id, int *, int *, FILE *);
void ND_Value_Check( NDT_Root *, NDT_Index_Id, int *, int *, FILE *);
void ND_Value_Check( NDT_Root *, NDT_Index_Id, int *, int *, FILE *);
void ND_Tree_Check( NDT_Root *, NDT_Index_Id, int *, int *, FILE *);
void ND_Tree_Check( NDT_Root *, NDT_Index_Id, int *, int *, FILE *);
void ND_Tree_Link_Check( NDT_Root *, NDT_Index_Id, int *, int *, FILE *);
void ND_Tree_Link_Check( NDT_Root *, NDT_Index_Id, int *, int *, FILE *);
NDT_Status ND_List_Recursive_Make( NDT_Node *, NDT_Root *, NDT_Index_Id);
NDT_Status ND_List_Recursive_Make( NDT_Node *, NDT_Root *, NDT_Index_Id);
NDT_Node * ND_Tree_Recursive_Make( long, long, NDT_Node *);
NDT_Node *ND_Tree_Recursive_Make( long, long, NDT_Node *);
void ND_Tree_Node_Recursive_Add( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Node **, long , NDT_Node *);
void ND_Tree_Node_Recursive_Add( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Node **, long , NDT_Node *);
NDT_Node * ND_Tree_Node_First_Recursive_Get( NDT_Node *);
NDT_Node *ND_Tree_Node_First_Recursive_Get( NDT_Node *);
NDT_Node * ND_Tree_Node_Last_Recursive_Get( NDT_Node *);
NDT_Node *ND_Tree_Node_Last_Recursive_Get( NDT_Node *);
NDT_Node * ND_Tree_Node_Recursive_Find( NDT_Node *, void *, va_list);
NDT_Node *ND_Tree_Node_Recursive_Find( NDT_Node *, void *, va_list);
NDT_Node * ND_Tree_Parent_Next_Recursive_Get( NDT_Node * Node);
NDT_Node *ND_Tree_Parent_Next_Recursive_Get( NDT_Node *);
NDT_Node * ND_Tree_Parent_Previous_Recursive_Get( NDT_Node *);
NDT_Node *ND_Tree_Parent_Previous_Recursive_Get( NDT_Node *);
void ND_Tree_Recursive_Print( NDT_Node *, long, FILE *);
void ND_Tree_Recursive_Print( NDT_Node *, long, FILE *);
void ND_Tree_Link_Recursive_Check( NDT_Node *Node, int *, int *, FILE *);
void ND_Tree_Link_Recursive_Check( NDT_Node *, int *, int *, FILE *);
void * ND_Symbol_Find( const char *);
NDT_Status ND_Symbol_Find( void **, const char *);
void ND_Error_Print( void);
void ND_Error_Print( void);
void ND_Signal_Trap( int);
void ND_Signal_Trap( int);
NDT_Status ND_Address_Check(void *);
NDT_Status ND_Address_Check( void *);