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 $ */ /* $RCSfile: node.h,v $ */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* $Revision: 2.10 $ */ /* $Revision: 2.11 $ */
/* $Name: $ */ /* $Name: $ */
/* $Date: 2005/01/11 16:27:13 $ */ /* $Date: 2005/01/11 20:57:04 $ */
/* $Author: agibert $ */ /* $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 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 */ /* Pointeur de fonction sur le désallocateur */
@ -271,7 +271,7 @@ typedef struct NDT_Root
char Desallocator_Name[NDD_DESALLOCATOR_NAME_SIZE_MAX]; /* Nom de la fonction de désallocation */ 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 */ 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_Nb;
NDT_Index_Nb Index_Open_Count; 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 */ /* 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_I( FILE *);
NDD_DLL_API NDT_Status ND_Library_StdErr_Set_C( FILE *Out); 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 */ /* (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_I( NDT_Root *);
NDD_DLL_API NDT_Status ND_DataStruct_Close_C( NDT_Root *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 */ /* (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_I( NDT_Root *);
NDD_DLL_API NDT_Status ND_DataStruct_Flush_C( NDT_Root *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 */ /* (O) Nb_Corrected : pointeur sur le nombre d'erreurs */
/* (I) Out : flux de sortie du rapport */ /* (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_I( NDT_Root *, int *, int *, FILE *);
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_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 */ /* (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_I( NDT_Root *);
NDD_DLL_API NDT_Status ND_DataStruct_Reorg_C( NDT_Root *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) Command: Commande à exécuter sur chaque noeud traversé */
/* (I) Data: pointeur de données utilisateur */ /* (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_VI( NDT_Root *, NDT_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_VC( NDT_Root *, NDT_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_I( NDT_Root *, NDT_Command, ...);
NDD_DLL_API NDT_Status ND_DataStruct_Traverse_C( NDT_Root *, NDT_Command 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) Root: pointeur sur la racine de la structure de données */
/* (I) Out : flux de sortie */ /* (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_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 *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 *, 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) Root: pointeur sur la racine de la structure de données */
/* (I) Value: pointeur sur la valeur à ajouter */ /* (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_I( NDT_Root *, void *);
NDD_DLL_API NDT_Status ND_DataStruct_Value_Add_C( NDT_Root *Root, void *Value); 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) Reference_Value : pointeur sur la valeur de référence */
/* (I) Removed_Value : adresse d'un pointeur sur la valeur supprimée */ /* (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_I( NDT_Root *, void *);
NDD_DLL_API NDT_Status ND_DataStruct_Value_Remove_C( NDT_Root *Root, void *Value); 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 */ /* (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_VI( void **, NDT_Root *, void *, 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_VC( void **, NDT_Root *, void *, 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_I( void **, NDT_Root *, void *, ...);
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_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 */ /* (O) Nb_Corrected : pointeur sur le nombre d'erreurs */
/* (I) Out : flux de sortie du rapport */ /* (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_I( NDT_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_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) Root: pointeur sur la racine de la structure de données */
/* (I) Target_Type: type de structure cible */ /* (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_I ( NDT_Root *, NDT_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_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) Root: pointeur sur la racine de la structure de données */
/* (I) Value: pointeur sur la valeur à ajouter */ /* (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_I( NDT_Root *, NDT_Index_Id, void *);
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_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) Reference_Value : pointeur sur la valeur de référence */
/* (I) Removed_Value : adresse d'un pointeur sur la valeur supprimée */ /* (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_I( NDT_Root *, NDT_Index_Id, void *);
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_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) Root: pointeur sur la racine de la structure de données */
/* (I) Node: pointeur sur le noeud à ajouter */ /* (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_I( NDT_Root *, NDT_Index_Id, NDT_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_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 */ /* (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_I( NDT_Node *);
NDD_DLL_API NDT_Status ND_Index_Node_Remove_C( NDT_Node * 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) Size : taille de la zone à allouer */
/* (I) Data : pointeur de données utiles à l'allocateur */ /* (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_I( void **, size_t, NDT_Allocator_Name, NDT_Allocator *, void *);
NDD_DLL_API NDT_Status ND_Allocator_Exec_C( NDT_Allocator *, void **, size_t, 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 */ /* 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) Function : nom de la fonction à exécuter */
/* (I) Ptr : adresse de la zone à désallouer */ /* (I) Ptr : adresse de la zone à désallouer */
/* (I) Data : pointeur de données utiles au désallocateur */ /* (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_I( void *, NDT_Desallocator_Name, NDT_Desallocator *, void *);
NDD_DLL_API NDT_Status ND_Desallocator_Exec_C( NDT_Desallocator *, void *, 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 $ */ /* $RCSfile: libnode.c,v $ */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* $Revision: 2.13 $ */ /* $Revision: 2.14 $ */
/* $Name: $ */ /* $Name: $ */
/* $Date: 2005/01/11 16:17:44 $ */ /* $Date: 2005/01/11 20:57:04 $ */
/* $Author: agibert $ */ /* $Author: agibert $ */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
@ -34,7 +34,7 @@
#include <libnode.h> #include <libnode.h>
#ifdef _LIBVER_SUPPORT #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 #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"; 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); 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"; 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); return( NDS_OK);
} }
@ -604,6 +604,14 @@ NDT_Status ND_Library_Open_I( int Debug_Mode)
ND_Library_StdErr_Set_I( stderr); 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); return( NDS_OK);
} }
@ -671,6 +679,13 @@ NDT_Status ND_Library_Close_I( void)
NDG_Base.Symbol_First_Ptr = (NDT_Symbol *)NULL; 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; NDG_Base.Open_Status = NDD_FALSE;
@ -903,7 +918,6 @@ NDT_Status ND_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_N
NDT_Allocator_Name Allocator_Name, NDT_Allocator *Allocator_Ptr, NDT_Desallocator_Name Desallocator_Name, NDT_Desallocator *Desallocator_Ptr, short Own_Value, void *Data) 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; NDT_Status status;
// const char *Real_Allocator, *Real_Desallocator; // Win32
NDT_Manager_Name Real_Manager_Name; NDT_Manager_Name Real_Manager_Name;
NDT_Manager *Real_Manager_Ptr; NDT_Manager *Real_Manager_Ptr;
NDT_Allocator_Name Real_Allocator_Name; NDT_Allocator_Name Real_Allocator_Name;
@ -914,7 +928,7 @@ NDT_Status ND_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_N
/* Valeurs par défaut des fonctions d'allocation et de désallocation */ /* 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_Name = Manager_Name;
Real_Manager_Ptr = Manager_Ptr; 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; Real_Manager_Ptr = ND_Default_Manager;
} }
if( Allocator_Ptr) if( ( Allocator_Name != NULL) || ( Allocator_Ptr != NULL))
{ {
Real_Allocator_Name = Allocator_Name; Real_Allocator_Name = Allocator_Name;
Real_Allocator_Ptr = Allocator_Ptr; 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; Real_Allocator_Ptr = ND_Default_Allocator;
} }
if( Desallocator_Ptr) if( ( Desallocator_Name != NULL) || ( Desallocator_Ptr != NULL))
{ {
Real_Desallocator_Name = Desallocator_Name; Real_Desallocator_Name = Desallocator_Name;
Real_Desallocator_Ptr = Desallocator_Ptr; 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", 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, 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); offset, version_name);
} }
@ -3796,7 +3810,20 @@ NDT_Status ND_Manager_Exec_VI( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT
NDT_Manager *manager_ptr; 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); 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); 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); status = manager_ptr( Root_Ptr, Index_Id, Node_Ptr, Command, args);
@ -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 */ /* (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; 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 */ /* (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) if( NDG_Base.Open_Status != NDD_TRUE)
{ {
sprintf( NDG_Base.Err_String, "Error ND_Allocator_Exec_C: library is not open"); sprintf( NDG_Base.Err_String, "Error ND_Allocator_Exec_C: library is not open");
@ -3973,9 +4022,7 @@ NDT_Status ND_Allocator_Exec_C ( NDT_Allocator *Function, void **Ptr_Ptr, siz
return( NDS_ERRAPI); return( NDS_ERRAPI);
} }
*Ptr_Ptr = NULL; if( ( Allocator_Name == NULL) && ( Allocator_Ptr == NULL))
if(!Function || !*Function)
{ {
sprintf( NDG_Base.Err_String, "Error ND_Allocator_Exec_C: undefined function name"); sprintf( NDG_Base.Err_String, "Error ND_Allocator_Exec_C: undefined function name");
ND_Error_Print(); ND_Error_Print();
@ -3983,11 +4030,7 @@ NDT_Status ND_Allocator_Exec_C ( NDT_Allocator *Function, void **Ptr_Ptr, siz
return( NDS_ERRAPI); return( NDS_ERRAPI);
} }
Allocator_Ptr = Function; return( ND_Allocator_Exec_I( Ptr_Ptr, Size, Allocator_Name, Allocator_Ptr, Data_Ptr));
if( !Allocator_Ptr) return( NDS_ERRAPI);
return( Allocator_Ptr (Size, Ptr_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 */ /* (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; 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)); 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 */ /* (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) if( NDG_Base.Open_Status != NDD_TRUE)
{ {
sprintf( NDG_Base.Err_String, "Error ND_Desallocator_Exec_C: library is not open"); sprintf( NDG_Base.Err_String, "Error ND_Desallocator_Exec_C: library is not open");
@ -4036,7 +4090,7 @@ NDT_Status ND_Desallocator_Exec_C( NDT_Desallocator *Function, void *Ptr, voi
return( NDS_ERRAPI); 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"); sprintf( NDG_Base.Err_String, "Error ND_Desallocator_Exec_C: undefined function name");
ND_Error_Print(); ND_Error_Print();
@ -4044,11 +4098,7 @@ NDT_Status ND_Desallocator_Exec_C( NDT_Desallocator *Function, void *Ptr, voi
return( NDS_ERRAPI); return( NDS_ERRAPI);
} }
desallocator_ptr = Function; return( ND_Desallocator_Exec_I( Ptr, Desallocator_Name, Desallocator_Ptr, Data_Ptr));
if( !desallocator_ptr) return( NDS_ERRAPI);
return( desallocator_ptr( Ptr, Data_Ptr));
} }
@ -4058,25 +4108,19 @@ NDT_Status ND_Desallocator_Exec_C( NDT_Desallocator *Function, void *Ptr, voi
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
/* FONCTIONS SECURISEES (ND_MODE = 0) */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
/* PRIVATE FUNCTIONS */
/*------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------*/
/* FONCTIONS PRIVEES */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
/* 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; NDT_Symbol *Symbol_Ptr;
void *Ptr = NULL;
/* Recherche du symbole dans la table des symboles locale */ /* Recherche du symbole dans la table des symboles locale */
@ -4084,31 +4128,46 @@ void *ND_Symbol_Find( const char *Symbol_Name)
while( Symbol_Ptr) while( Symbol_Ptr)
{ {
if( !strcmp( Symbol_Ptr->Name, Symbol_Name)) return( Symbol_Ptr->Ptr); if( !strcmp( Symbol_Ptr->Name, Symbol_Name))
else Symbol_Ptr = Symbol_Ptr->Next; {
*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 */ /* 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_Ptr = dlsym( NDG_Base.DL_Ptr, (const char *)Symbol_Name)) == NULL)
if( !Ptr)
{ {
sprintf( NDG_Base.Err_String, "Error ND_Symbol_Find: unable to find \"%s\"' in symbol table (%s)", Symbol_Name, NULL/*dlerror ()*/); sprintf( NDG_Base.Err_String, "Error ND_Symbol_Find: unable to find \"%s\"' in symbol table (%s)", Symbol_Name, dlerror());
ND_Error_Print(); ND_Error_Print();
return NULL;
return( NDS_KO);
} }
Symbol_Ptr = (NDT_Symbol *)malloc( sizeof( NDT_Symbol)); 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->Name = strdup (Symbol_Name);
Symbol_Ptr->Ptr = Ptr; Symbol_Ptr->Ptr = *Ptr_Ptr;
Symbol_Ptr->Next = NDG_Base.Symbol_First_Ptr; Symbol_Ptr->Next = NDG_Base.Symbol_First_Ptr;
NDG_Base.Symbol_First_Ptr = Symbol_Ptr; NDG_Base.Symbol_First_Ptr = Symbol_Ptr;
} }
return Ptr; return( NDS_OK);
} }
@ -4127,7 +4186,7 @@ NDT_Status ND_Node_Alloc( NDT_Root *Root_Ptr, NDT_Node **Node_Ptr_Ptr )
NDT_Status rc; NDT_Status rc;
rc = ND_Allocator_Exec_I( Root_Ptr->Allocator_Ptr, (void **)Node_Ptr_Ptr, sizeof(NDT_Node), Root_Ptr->User); 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); if( ND_ERROR( rc)) return( rc);
(*Node_Ptr_Ptr)->Root = NULL; (*Node_Ptr_Ptr)->Root = NULL;
@ -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) 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));
} }
@ -4208,7 +4267,7 @@ NDT_Status ND_Node_Root_Alloc( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_Nb,
NDT_Index_Id index_id; 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( ND_ERROR(status)) return( status);
if( strlen(Manager_Name) > NDD_MANAGER_NAME_LEN_MAX) return( NDS_ERRAPI); if( strlen(Manager_Name) > NDD_MANAGER_NAME_LEN_MAX) return( NDS_ERRAPI);
@ -4224,7 +4283,7 @@ NDT_Status ND_Node_Root_Alloc( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_Nb,
(*Root_Ptr_Ptr)->Desallocator_Ptr = Desallocator_Ptr; (*Root_Ptr_Ptr)->Desallocator_Ptr = Desallocator_Ptr;
(*Root_Ptr_Ptr)->Own_Value = Own_Value; (*Root_Ptr_Ptr)->Own_Value = Own_Value;
(*Root_Ptr_Ptr)->User = Data_Ptr; (*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; (*Root_Ptr_Ptr)->Index_Open_Count = 0;
@ -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) 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));
} }
@ -4702,10 +4761,12 @@ NDT_Status ND_List_Recursive_Make( NDT_Node *Node_Ptr, NDT_Root *Root_Ptr, ND
/*--------------------------------- main body --------------------------------*/ /*--------------------------------- main body --------------------------------*/
NDT_Status ND_List_Make( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) NDT_Status ND_List_Make( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id)
{ {
NDT_Node *node_ptr; NDT_Node *node_ptr;
node_ptr = Root_Ptr->Index_Tab[Index_Id].Head; node_ptr = Root_Ptr->Index_Tab[Index_Id].Head;
Root_Ptr->Index_Tab[Index_Id].Head = NULL; Root_Ptr->Index_Tab[Index_Id].Head = NULL;
@ -4823,7 +4884,7 @@ NDT_Status ND_Tree_Make( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id )
if( ND_INDEX_SUBTYPE_SORTED_IS( Root_Ptr, Index_Id)) if( ND_INDEX_SUBTYPE_SORTED_IS( Root_Ptr, Index_Id))
{ {
rc = ND_List_Sort( 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_ptr = Root_Ptr->Index_Tab[Index_Id].Head;
@ -4840,7 +4901,7 @@ NDT_Status ND_Tree_Make( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id )
Root_Ptr->Index_Tab[Index_Id].Head = Root_Ptr->Index_Tab[Index_Id].Tail = ND_Tree_Recursive_Make( 1, node_number, node_ptr); 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,14 +4918,10 @@ NDT_Status ND_Tree_Equalize( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id)
{ {
NDT_Status rc; NDT_Status rc;
NDT_Index_Type type; NDT_Index_Type type;
// char manager[30]; // Win32
NDT_Manager *manager; // Win32
long max_dif, nb_equ; long max_dif, nb_equ;
type = Root_Ptr->Index_Tab[Index_Id].Type; type = Root_Ptr->Index_Tab[Index_Id].Type;
// strcpy( Manager, Root_Ptr->Manager); // Win32
manager = Root_Ptr->Manager_Ptr; // Win32
max_dif = Root_Ptr->Index_Tab[Index_Id].Max_Dif; 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;
@ -4877,8 +4934,6 @@ NDT_Status ND_Tree_Equalize( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id)
if( ND_ERROR(rc)) return(rc); if( ND_ERROR(rc)) return(rc);
Root_Ptr->Index_Tab[Index_Id].Type = type; 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].Max_Dif = max_dif; 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;
@ -5086,19 +5141,21 @@ int ND_Node_Compare( void **Node1_Ptr_Ptr, void **Node2_Ptr_Ptr)
NDT_Status rc; 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); 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) switch( (int)rc)
{ {
case NDS_EQUAL: return 0; case NDS_EQUAL: return( 0);
case NDS_LOWER: return -1; case NDS_LOWER: return( -1);
case NDS_GREATER: return 1; case NDS_GREATER: return( 1);
default: default:
{
sprintf( NDG_Base.Err_String, "Error ND_Node_Compare : incorrect return code from the manager: %d", rc); sprintf( NDG_Base.Err_String, "Error ND_Node_Compare : incorrect return code from the manager: %d", rc);
ND_Error_Print(); 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 */ /* 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); 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 */ /* On met à jour les liens entre les noeuds */
@ -5210,7 +5264,7 @@ 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);

View File

@ -1,9 +1,9 @@
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* $RCSfile: libnode.h,v $ */ /* $RCSfile: libnode.h,v $ */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* $Revision: 2.7 $ */ /* $Revision: 2.8 $ */
/* $Name: $ */ /* $Name: $ */
/* $Date: 2004/08/23 22:47:22 $ */ /* $Date: 2005/01/11 20:57:04 $ */
/* $Author: agibert $ */ /* $Author: agibert $ */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
@ -35,8 +35,13 @@
#include <errno.h> #include <errno.h>
#include <signal.h> #include <signal.h>
#include <setjmp.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> #include <node.h>
@ -88,6 +93,7 @@ typedef struct NDT_Base
jmp_buf SigLongJmp_Env; jmp_buf SigLongJmp_Env;
#endif #endif
NDT_Symbol *Symbol_First_Ptr; NDT_Symbol *Symbol_First_Ptr;
void *DL_Ptr;
NDT_Index_Type OpenStruct_Index_Type[1]; NDT_Index_Type OpenStruct_Index_Type[1];
NDT_Root *OpenStruct_Ptr; NDT_Root *OpenStruct_Ptr;
} NDT_Base; } NDT_Base;
@ -101,6 +107,7 @@ NDT_Base NDG_Base =
0, 0,
{0}, {0},
(NDT_Symbol *) NULL, (NDT_Symbol *) NULL,
NULL,
{ NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_FIFO}, { NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_FIFO},
(NDT_Root *) NULL (NDT_Root *) NULL
}; };
@ -132,7 +139,7 @@ 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 */ /* 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 */ /* Redéfinition de la fonction free() avec retour de type NDT_Status */
@ -290,9 +297,14 @@ int ND_Node_Compare( void **, void **);
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
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 */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
@ -318,15 +330,15 @@ 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);