Add OpenStruct tracing support in ND_Library_Open(), ND_Library_Close(), ND_DataStruct_Open() and ND_DataStruct_Close(),
Create NDG_Base global structure variable and move all the sparced global variables into it, ND_Library_Open() call is now mandatory, Add library open test in *_C() functions, Code cleaning, Fix code indentation.
This commit is contained in:
parent
2274de2cf2
commit
8541d83655
@ -1,9 +1,9 @@
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* $RCSfile: node.h,v $ */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* $Revision: 2.6 $ */
|
||||
/* $Revision: 2.7 $ */
|
||||
/* $Name: $ */
|
||||
/* $Date: 2003/07/16 00:20:53 $ */
|
||||
/* $Date: 2004/08/01 23:18:37 $ */
|
||||
/* $Author: agibert $ */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
/* GNU Lesser General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU Lesser General Public License */
|
||||
/* along with Foobar; if not, write to the Free Software */
|
||||
/* along with LibNode; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
||||
@ -251,9 +251,9 @@ typedef struct NDT_Index
|
||||
long Max_Depth; /* Profondeur maximale de l'arbre */
|
||||
long Max_Dif; /* Différence maximale autorisée entre la branche la plus courte et la plus longue */
|
||||
long Nb_Equ; /* Nombre de réquilibrages réalisés sur l'arbre */
|
||||
struct NDT_Node * Head; /* Noeud de tête */
|
||||
struct NDT_Node * Tail; /* Noeud de queue */
|
||||
struct NDT_Node * Save; /* Pointeur de sauvegarde (utile pour la fonction de restauration) */
|
||||
struct NDT_Node *Head; /* Noeud de tête */
|
||||
struct NDT_Node *Tail; /* Noeud de queue */
|
||||
struct NDT_Node *Save; /* Pointeur de sauvegarde (utile pour la fonction de restauration) */
|
||||
|
||||
} NDT_Index;
|
||||
|
||||
@ -309,10 +309,6 @@ typedef struct NDT_Node
|
||||
|
||||
|
||||
|
||||
char ND_Error_Msg [512];
|
||||
|
||||
|
||||
|
||||
typedef int NDT_Recursive_Mode;
|
||||
typedef int NDT_Recursive_Depth;
|
||||
typedef int NDT_Recursive_Offset;
|
||||
@ -339,7 +335,7 @@ typedef int NDT_Recursive_Offset;
|
||||
|
||||
#define ND_Library_Open ND_Library_Open_I
|
||||
#define ND_Library_Close ND_Library_Close_I
|
||||
#define ND_Library_Stderr_Set ND_Library_Stderr_Set_I
|
||||
#define ND_Library_StdErr_Set ND_Library_Stderr_Set_I
|
||||
|
||||
#define ND_DataStruct_Open ND_DataStruct_Open_I
|
||||
#define ND_DataStruct_Close ND_DataStruct_Close_I
|
||||
@ -389,7 +385,7 @@ typedef int NDT_Recursive_Offset;
|
||||
|
||||
#define ND_Library_Open ND_Library_Open_C
|
||||
#define ND_Library_Close ND_Library_Close_C
|
||||
#define ND_Library_Stderr_Set ND_Library_Stderr_Set_C
|
||||
#define ND_Library_StdErr_Set ND_Library_Stderr_Set_C
|
||||
|
||||
#define ND_DataStruct_Open ND_DataStruct_Open_C
|
||||
#define ND_DataStruct_Close ND_DataStruct_Close_C
|
||||
@ -472,8 +468,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 *Out);
|
||||
NDD_DLL_API NDT_Status ND_Library_StdErr_Set_C( FILE *Out);
|
||||
|
||||
|
||||
|
||||
|
1231
lib/libnode.c
1231
lib/libnode.c
File diff suppressed because it is too large
Load Diff
137
lib/libnode.h
137
lib/libnode.h
@ -1,9 +1,9 @@
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* $RCSfile: libnode.h,v $ */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* $Revision: 2.4 $ */
|
||||
/* $Revision: 2.5 $ */
|
||||
/* $Name: $ */
|
||||
/* $Date: 2002/07/29 14:53:51 $ */
|
||||
/* $Date: 2004/08/01 23:18:38 $ */
|
||||
/* $Author: agibert $ */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
/* GNU Lesser General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU Lesser General Public License */
|
||||
/* along with Foobar; if not, write to the Free Software */
|
||||
/* along with LibNode; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
||||
@ -43,13 +43,9 @@
|
||||
|
||||
|
||||
#ifdef __linux
|
||||
|
||||
# define NDD_PRINTF_PTR_PREFIX ""
|
||||
|
||||
#else
|
||||
|
||||
# define NDD_PRINTF_PTR_PREFIX "0x"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -58,24 +54,52 @@
|
||||
|
||||
#define NDD_HUGE_LONG (long)0xFFFFFFL
|
||||
|
||||
/* Sortie standard des messages d'erreur */
|
||||
|
||||
FILE * ND_stderr;
|
||||
|
||||
/* Table des symboles locale */
|
||||
|
||||
struct Symbol {
|
||||
void * Ptr;
|
||||
char * Name;
|
||||
struct Symbol * Next;
|
||||
} * Symbol_Table = NULL;
|
||||
struct NDT_Symbol;
|
||||
|
||||
typedef struct NDT_Symbol
|
||||
{
|
||||
void *Ptr;
|
||||
char *Name;
|
||||
struct NDT_Symbol *Next;
|
||||
} NDT_Symbol;
|
||||
|
||||
|
||||
|
||||
/* LibNode Global Base Structure */
|
||||
|
||||
typedef struct NDT_Base
|
||||
{
|
||||
int Open_Status;
|
||||
int Debug_Mode;
|
||||
char Err_String[512];
|
||||
FILE *Err_Stream;
|
||||
int Sig_Trapped;
|
||||
NDT_Symbol *Symbol_First_Ptr;
|
||||
NDT_Index_Type OpenStruct_Index_Type[1];
|
||||
NDT_Root *OpenStruct_Ptr;
|
||||
} NDT_Base;
|
||||
|
||||
NDT_Base NDG_Base =
|
||||
{
|
||||
NDD_FALSE,
|
||||
NDD_TRUE,
|
||||
"",
|
||||
(FILE *)-1,
|
||||
0,
|
||||
(NDT_Symbol *)NULL,
|
||||
{ NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_FIFO},
|
||||
(NDT_Root *)NULL
|
||||
};
|
||||
|
||||
|
||||
NDT_Root * Tmp_Root;
|
||||
|
||||
//extern char * strdup (const char *);
|
||||
//extern int sigrelse (int sig);
|
||||
|
||||
int Sig_Trapped;
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
@ -88,7 +112,14 @@ int Sig_Trapped;
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* (I) va_list Arguments : Liste d'arguments contextuels */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
NDT_Status Default_Manager( NDT_Root *, NDT_Index_Id, NDT_Command, va_list);
|
||||
NDT_Status ND_Default_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list);
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* OpenStruct Manager */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* (I) va_list Arguments : Liste d'arguments contextuels */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
NDT_Status ND_OpenStruct_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list);
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Redéfinition de la fonction malloc() avec retour de type NDT_Status */
|
||||
@ -106,7 +137,7 @@ NDT_Status ND_Default_Desallocator( void *, void *);
|
||||
/* (I) Root : adresse de la racine pour laquelle on crée un noeud */
|
||||
/* (O) New_Node : adresse du pointeur sur le nouveau noeud */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
NDT_Status ND_Node_Alloc (NDT_Root * Root, NDT_Node ** New_Node);
|
||||
NDT_Status ND_Node_Alloc( NDT_Root * Root, NDT_Node ** New_Node);
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Destruction d'un noeud */
|
||||
@ -114,7 +145,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 * Root, NDT_Node * Node);
|
||||
NDT_Status ND_Node_Free( NDT_Root *, NDT_Node *);
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Création d'une nouvelle structure de données */
|
||||
@ -144,7 +175,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 * Root);
|
||||
NDT_Status ND_Node_Root_Free( NDT_Root *);
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Ajout d'un noeud à une liste chaînée */
|
||||
@ -152,7 +183,7 @@ NDT_Status ND_Node_Root_Free (NDT_Root * 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 */
|
||||
@ -160,7 +191,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 */
|
||||
@ -168,26 +199,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 */
|
||||
@ -200,28 +231,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 *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 *Node);
|
||||
long ND_Tree_MinDepth_Get( NDT_Node *);
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Ajout d'un noeud à un arbre binaire */
|
||||
@ -229,7 +260,7 @@ long ND_Tree_MinDepth_Get (NDT_Node *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 */
|
||||
@ -237,19 +268,19 @@ 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 ** Node1, void ** Node2);
|
||||
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);
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
@ -257,40 +288,40 @@ NDT_Status ND_List_Sort (NDT_Root *, NDT_Index_Id);
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
|
||||
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 *);
|
||||
|
||||
NDT_Node * ND_Tree_Node_First_Recursive_Get (NDT_Node * Node);
|
||||
NDT_Node * ND_Tree_Node_First_Recursive_Get( NDT_Node *);
|
||||
|
||||
NDT_Node * ND_Tree_Node_Last_Recursive_Get (NDT_Node * Node);
|
||||
NDT_Node * ND_Tree_Node_Last_Recursive_Get( NDT_Node *);
|
||||
|
||||
NDT_Node * ND_Tree_Node_Recursive_Find (NDT_Node * Node, void * Value, 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 * Node);
|
||||
|
||||
NDT_Node * ND_Tree_Parent_Previous_Recursive_Get (NDT_Node * Node);
|
||||
NDT_Node * ND_Tree_Parent_Previous_Recursive_Get( NDT_Node *);
|
||||
|
||||
void ND_Tree_Recursive_Print (NDT_Node * Node, long Depth, 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 *Node, int *, int *, FILE *);
|
||||
|
||||
void * ND_Symbol_Find (const char *);
|
||||
void * ND_Symbol_Find( 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 * Address);
|
||||
NDT_Status ND_Address_Check(void *);
|
||||
|
Loading…
Reference in New Issue
Block a user