2001-11-26 11:17:44 +01:00
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
|
/* $RCSfile: libnode.h,v $ */
|
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
2001-11-26 11:53:14 +01:00
|
|
|
|
/* $Revision: 2.0 $ */
|
2001-11-26 11:17:44 +01:00
|
|
|
|
/* $Name: $ */
|
2001-11-26 11:53:14 +01:00
|
|
|
|
/* $Date: 2001/11/26 10:54:13 $ */
|
2001-11-26 11:17:44 +01:00
|
|
|
|
/* $Author: agibert $ */
|
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-07-18 16:51:56 +02:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <signal.h>
|
2001-11-26 11:17:44 +01:00
|
|
|
|
//#include <dlfcn.h>
|
2000-07-18 16:51:56 +02:00
|
|
|
|
#include <node.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __linux
|
|
|
|
|
|
|
|
|
|
# define NDD_PRINTF_PTR_PREFIX ""
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
# define NDD_PRINTF_PTR_PREFIX "0x"
|
|
|
|
|
|
2000-07-18 16:51:56 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define NDD_HUGE_LONG (long)0xFFFFFFL
|
|
|
|
|
|
2000-07-18 16:51:56 +02:00
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
|
|
NDT_Root * Tmp_Root;
|
|
|
|
|
|
|
|
|
|
extern char * strdup (const char *);
|
|
|
|
|
extern int sigrelse (int sig);
|
|
|
|
|
|
|
|
|
|
int Sig_Trapped;
|
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Fonctions et proc<6F>dures priv<69>es de la librairie (moyen niveau) */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Manager par d<>faut */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* (I) va_list Arguments : Liste d'arguments contextuels */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
NDT_Status Default_Manager( NDT_Root *, NDT_Index_Id, NDT_Command, va_list);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Red<65>finition de la fonction malloc() avec retour de type NDT_Status */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
NDT_Status ND_Default_Allocator( size_t Size, void **ptr, void *User);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Red<65>finition de la fonction free() avec retour de type NDT_Status */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
NDT_Status ND_Default_Desallocator( void *, void *);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Cr<43>ation d'un noeud */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* (I) Root : adresse de la racine pour laquelle on cr<63>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);
|
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Destruction d'un noeud */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* (I) Root : adresse de la racine dans laquelle on d<>truit un noeud */
|
|
|
|
|
/* (I) Node : pointeur sur le noeud <20> d<>truire */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
NDT_Status ND_Node_Free (NDT_Root * Root, NDT_Node * Node);
|
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Cr<43>ation de la racine d'une structure de donn<6E>es quelconque */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* (O) New_Root : adresse du pointeur sur la nouvelle racine */
|
|
|
|
|
/* (I) Type : type de la structure de donn<6E>es */
|
|
|
|
|
/* (I) Allocater : pointeur vers la fonction d'allocation */
|
|
|
|
|
/* (I) Desallocater : pointeur vers la fonction de d<>sallocation */
|
|
|
|
|
/* (I) Data : pointeur de donn<6E>es utiles <20> l'allocateur */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
NDT_Status ND_Node_Root_Alloc( NDT_Root **, NDT_Index_Nb, NDT_Index_Type[], char *, NDT_Manager *, char *, NDT_Allocator *, char *, NDT_Desallocator *, short, void *);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Destruction d'une racine */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* (I) Root : pointeur sur la racine <20> d<>truire */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
NDT_Status ND_Node_Root_Free (NDT_Root * Root);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Ajout d'un noeud <20> une liste cha<68>n<EFBFBD>e */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* (I) Root : pointeur sur la racine de la liste */
|
|
|
|
|
/* (I) New_Node : pointeur sur le noeud <20> ajouter */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
NDT_Status ND_List_Node_Add (NDT_Root *, NDT_Index_Id, NDT_Node *);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Ajout d'une nouvelle valeur <20> une liste */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* (I) Root : pointeur sur la racine de la liste */
|
|
|
|
|
/* (I) Value : pointeur sur la valeur <20> ajouter */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
NDT_Status ND_List_Value_Add (NDT_Root *, NDT_Index_Id, void *);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Ajout d'un noeud <20> un arbre binaire */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* (I) Root : pointeur sur la racine de l'arbre */
|
|
|
|
|
/* (I) Value : pointeur sur la valeur <20> ajouter */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
NDT_Status ND_Tree_Value_Add (NDT_Root *, NDT_Index_Id, void *);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Supprime le noeud d'une liste */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* (I) Node : pointeur sur le noeud <20> supprimer */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
NDT_Status ND_List_Node_Remove (NDT_Node *);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Conversion d'une structure en liste cha<68>n<EFBFBD>e */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* (I) Root : pointeur sur la racine du la structure <20> convertir */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
NDT_Status ND_List_Make (NDT_Root *, NDT_Index_Id);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Recherche une valeur dans une liste et retourne le noeud correspondant */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
NDT_Node * ND_List_Node_Find (NDT_Root *, NDT_Index_Id, void *, va_list);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Recherche un noeud dans un arbre et retourne le pointeur sur le noeud */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
NDT_Node *ND_Tree_Node_Find( NDT_Root *, NDT_Index_Id, void *, va_list);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Conversion d'une structure en arbre binaire */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* (I) Root : pointeur sur la racine du la structure <20> convertir */
|
|
|
|
|
/* (I) Type : type du futur arbre */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
NDT_Status ND_Tree_Make (NDT_Root *, NDT_Index_Id);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Equilibrage d'un arbre */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* (I) Root : pointeur sur la racine de l'arbre */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
NDT_Status ND_Tree_Equalize (NDT_Root *, NDT_Index_Id);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Retourne la profondeur de la plus grande branche <20> partir d'un noeud */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* (I) Node : pointeur sur le noeud */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
long ND_Tree_MaxDepth_Get (NDT_Node *Node);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Retourne la profondeur de la plus petite branche <20> partir d'un noeud */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* (I) Node : pointeur sur le noeud */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
long ND_Tree_MinDepth_Get (NDT_Node *Node);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Ajout d'un noeud <20> un arbre binaire */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* (I) Root : pointeur sur la racine de l'arbre */
|
|
|
|
|
/* (I) Node : pointeur sur le noeud <20> ajouter */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
NDT_Status ND_Tree_Node_Add (NDT_Root *, NDT_Index_Id, NDT_Node *);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Ajoute tous les noeud d'une liste <20> un arbre */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* (I) Tree_Root : pointeur sur la racine de l'arbre */
|
|
|
|
|
/* (I) List_Root : pointeur sur la racine de la liste */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
NDT_Status ND_Tree_List_Add (NDT_Root *, NDT_Index_Id, NDT_Root *, NDT_Index_Id);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Fonction de comparaison de noeuds (pour le quick sort) */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
int ND_Node_Compare (void ** Node1, void ** Node2);
|
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Ordonne une liste cha<68>n<EFBFBD>e selon l'algorithme du tri <20> bulle */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* (I) Root : pointeur sur la racine de la liste <20> trier */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
NDT_Status ND_List_Sort (NDT_Root *, NDT_Index_Id);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/* Fonctions et proc<6F>dures priv<69>es de la librairie (bas niveau) */
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
/*------------------------------------------------------------------------------*/
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
void ND_List_Check (NDT_Root *, NDT_Index_Id, int *, int *, FILE *);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
void ND_List_Link_Check (NDT_Root *, NDT_Index_Id, int *, int *, FILE *);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
void ND_Value_Check (NDT_Root *, NDT_Index_Id, int *, int *, FILE *);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
void ND_Tree_Check (NDT_Root *, NDT_Index_Id, int *, int *, FILE *);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
void ND_Tree_Link_Check (NDT_Root *, NDT_Index_Id, int *, int *, FILE *);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
NDT_Status ND_List_Recursive_Make (NDT_Node *, NDT_Root *, NDT_Index_Id);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
NDT_Node * ND_Tree_Recursive_Make (long, long, NDT_Node *);
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
void ND_Tree_Node_Recursive_Add( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Node **, long , NDT_Node *);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
NDT_Node * ND_Tree_Node_First_Recursive_Get (NDT_Node * Node);
|
|
|
|
|
|
|
|
|
|
NDT_Node * ND_Tree_Node_Last_Recursive_Get (NDT_Node * Node);
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
NDT_Node * ND_Tree_Node_Recursive_Find (NDT_Node * Node, void * Value, va_list);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
NDT_Node * ND_Tree_Parent_Next_Recursive_Get (NDT_Node * Node);
|
|
|
|
|
|
|
|
|
|
NDT_Node * ND_Tree_Parent_Previous_Recursive_Get (NDT_Node * Node);
|
|
|
|
|
|
|
|
|
|
void ND_Tree_Recursive_Print (NDT_Node * Node, long Depth, FILE *);
|
|
|
|
|
|
|
|
|
|
void ND_Tree_Link_Recursive_Check (NDT_Node * Node, int *, int *, FILE *);
|
|
|
|
|
|
|
|
|
|
void * ND_Symbol_Find (const char *);
|
|
|
|
|
|
|
|
|
|
void ND_Error_Print (void);
|
|
|
|
|
|
|
|
|
|
void ND_Signal_Trap (int);
|
|
|
|
|
|
|
|
|
|
NDT_Status ND_Address_Check (void * Address);
|