libdatastr/include/datastr.h
Arnaud G. GIBERT d110799f8e - Add DS_STRUCT_LOCK() & DS_STRUCT_UNLOCK() macros,
- Implement DS_DataStruct_Traverse_I() & DS_DataStruct_Convert_L() API,
- code cleanup...
2024-05-11 22:43:25 +02:00

926 lines
52 KiB
C
Raw Permalink Blame History

/*----------------------------------------------------------------------------*/
/* datastr.h */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* This file is part of LibDataStr. */
/* */
/* LibDataStr is free software: you can redistribute it and/or modify it */
/* under the terms of the GNU Lesser General Public License as published */
/* by the Free Software Foundation, either version 3 of the License, or */
/* (at your option) any later version. */
/* */
/* LibDataStr is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Lesser General Public License for more details. */
/* */
/* You should have received a copy of the GNU Lesser General Public */
/* License along with LibDataStr. If not, see */
/* <https://www.gnu.org/licenses/>. */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* Includes */
/*----------------------------------------------------------------------------*/
#ifndef _LIBDATASTR
#define _LIBDATASTR
#ifdef __cplusplus
//extern "C" {
#endif
#include <stddef.h>
#include <shmem.h>
/* Code retour des fonctions constituant l'API */
typedef long DST_Status;
#define DSS_OK SMS_OK /* La fonction s'est correctement ex<65>cut<75>e et a produit un r<>sultat */
#define DSS_KO SMS_KO /* La fonction s'est correctement ex<65>cut<75>e mais n'a pas produit de r<>sultat */
#define DSS_YES SMS_OK /* R<>sultat bool<6F>en positif */
#define DSS_NO SMS_KO /* R<>sultat bool<6F>en n<>gatif */
#define DSS_ERRMEM SMS_ERRMEM /* Probl<62>me d'allocation m<>moire */
#define DSS_ERRAPI SMS_ERRAPI /* Utilisation incorrecte des API */
#define DSS_ERRSHM SMS_ERRSHM /* Probl<62>me relatif aux segments de m<>moire partag<61>e */
#define DSS_ERRSEM SMS_ERRSEM /* Probl<62>me relatif <20> l'utilisation des s<>maphores */
#define DSS_ERRSIG SMS_ERRSIG /* Op<4F>ration sur s<>maphore interrompue par un signal */
#define DSS_ERRDLL -6 /* Probl<62>me de chargement dynamique de librairie */
#define DS_ERROR(s) ((s) < 0) /* Tous les codes retour n<>gatifs correspondent <20> des erreurs */
/* Indicateurs */
typedef int DST_Flags;
#define DSD_UNDEF 0
/* Flags d'ouverture d'une data structure */
#define DSD_OPEN SMD_OPEN /* autorise l'ouverture d'une structure existante */
#define DSD_CREATE SMD_CREATE /* autorise la cr<63>ation de la structure */
#define DSD_NEW ~(DSD_OPEN|DSD_CREATE) /* cr<63>e une autre structure dans un heap existant */
/* Flags de debug sur l'ouverture de la librairie */
#define DSD_DEBUG_NONE 0 /* pour n'afficher aucun message g<>n<EFBFBD>r<EFBFBD> par les diverses librairies */
#define DSD_DEBUG 1 /* pour afficher les messages g<>n<EFBFBD>r<EFBFBD>s par la librairie */
#define DSD_DEBUG_ALL 2 /* pour afficher les messages g<>n<EFBFBD>r<EFBFBD>s par toutes les librairies sous-jacentes */
/*----------------------------------------------------------------------------*/
/* Utilisations possibles des flags d'ouverture */
/*----------------------------------------------------------------------------*/
/* */
/* DSD_OPEN */
/* -> ouvrir une structure existante */
/* -> ne pas la cr<63>er si elle n'existe pas */
/* */
/* DSD_OPEN | DSD_CREATE */
/* -> ouvrir une structure si elle existe */
/* -> la cr<63>er si elle n'existe pas */
/* */
/* DSD_CREATE */
/* -> cr<63>er une structure */
/* -> ne pas l'ouvrir si elle existe d<>j<EFBFBD> */
/* */
/* DSD_CREATE | DSD_NEW */
/* -> cr<63>er la structure si elle n'existe pas */
/* -> cr<63>er une autre structure dans le m<>me heap si elle existe d<>j<EFBFBD> */
/* */
/* DSD_NEW */
/* -> cr<63>er une autre structure dans le m<>me heap si elle existe d<>j<EFBFBD> */
/* -> ne pas la cr<63>er si elle n'existe pas */
/* */
/*----------------------------------------------------------------------------*/
/* Flags de verrouillage d'une data structure */
#define DSD_READ SMD_READ /* verrou partag<61> */
#define DSD_WRITE SMD_WRITE /* verrou exclusif */
/* Flags de fermeture d'une data structure */
#define DSD_CLOSE SMD_CLOSE /* pour fermer simplement la structure */
#define DSD_DESTROY SMD_DESTROY /* pour d<>truire la structure */
/* Masques pour r<>cup<75>rer des valeurs combin<69>es */
#define DSD_MSK_OPEN(a) ( DSD_OPEN & (a))
#define DSD_MSK_CREATE(a) ( DSD_CREATE & (a))
#define DSD_MSK_NEW(a) ( DSD_NEW & (a))
#define DSD_MSK_READ(a) ( DSD_READ & (a))
#define DSD_MSK_WRITE(a) ( DSD_WRITE & (a))
#define DSD_MSK_RW(a) ( ( DSD_READ | DSD_WRITE) & (a))
#define DSD_BOOL_VALUE_ASCII_GET( v) ( ( (v) == true) ? "TRUE" : "FALSE")
#define DSD_NAME_LEN ( short)SMD_NAME_LEN
#define DSD_NAME_SIZE ( DSD_NAME_LEN + 1)
#define DSD_DATASTRUCT_STATUS_UNKNOWN 0x0000
#define DSD_DATASTRUCT_STATUS_TEMPORARY 0x0001
#define DSD_DATASTRUCT_STATUS_VALID 0x0002
#define DSD_DATASTRUCT_STATUS_INVALID 0x0003
#define DSD_DATASTRUCT_STATUS_MSK ( DSD_DATASTRUCT_STATUS_UNKNOWN | DSD_DATASTRUCT_STATUS_TEMPORARY | DSD_DATASTRUCT_STATUS_VALID | DSD_DATASTRUCT_STATUS_INVALID)
#define DSD_DATASTRUCT_STATUS_RMSK ( DSD_DATASTRUCT_STATUS_MSK
#define DSD_DATASTRUCT_STATUS_VALUE_UNKNOWN_IS( V) ( ( V) == DSD_DATASTRUCT_STATUS_UNKNOWN)
#define DSD_DATASTRUCT_STATUS_VALUE_TEMPORARY( V) ( ( V) == DSD_DATASTRUCT_STATUS_TEMPORARY)
#define DSD_DATASTRUCT_STATUS_VALUE_VALID( V) ( ( V) == DSD_DATASTRUCT_STATUS_VALID)
#define DSD_DATASTRUCT_STATUS_VALUE_INVALID( V) ( ( V) == DSD_DATASTRUCT_STATUS_INVALID)
#define DSD_DATASTRUCT_STATUS_VALUE_ASCII_GET( V) ( DSD_DATASTRUCT_STATUS_VALUE_UNKNOWN_IS( V) ? "UNKNOWN" : ( DSD_DATASTRUCT_STATUS_VALUE_TEMPORARY( V) ? "TEMPORARY" : ( DSD_DATASTRUCT_STATUS_VALUE_VALID( V) ? "VALID" : ( DSD_DATASTRUCT_STATUS_VALUE_INVALID( V) ? "INVALID" : "???"))))
typedef struct DST_Root
{
char Name[ DSD_NAME_SIZE];
char Heap_Name[ DSD_NAME_SIZE];
int OpenSemId; /* Indique le nombre de processus ayant ouvert la struture */
short Heap_Owner; /* Indique si la structure est propri<72>taire du heap sous-jacent */
short Status; /* Indique si la structure est valide ou non */
NDT_Root ND_Root;
} DST_Root;
/*
On utilise le pointeur 'User' de la racine de la struture pour y
rattacher des donn<6E>es sur le heap sous-jacent.
*/
#define DSD_DS_ROOT_GET( ND_Root_Ptr) (( DST_Root *)( ( char *)( ND_Root_Ptr) - offsetof( DST_Root, ND_Root)))
#define DSD_ND_ROOT_GET( DS_Root_Ptr) (( NDT_Root *)( ( char *)( DS_Root_Ptr) + offsetof( DST_Root, ND_Root)))
typedef struct DST_RootDescZ
{
char Heap_Name[ DSD_NAME_SIZE];
char *Manager_Name;
int OpenSemId; /* Indique le nombre de processus ayant ouvert la struture */
short Heap_Owner; /* Indique si la structure est propri<72>taire du heap sous-jacent */
short Valid; /* Indique si la structure est valide ou non */
} DST_RootDescZ;
//char DS_Error_Msg [512];
/*------------------------------------------------------------------------------*/
/* */
/*------------------------------------------------------------------------------*/
#define DS_STRUCT_VALID_CHECK( Root_Ptr) \
if( !DSD_DATASTRUCT_STATUS_VALUE_VALID( (Root_Ptr)->Status)) \
{ \
DST_Status status; \
int nb_detected = 0, nb_corrected = 0; \
\
\
if( ( status = DS_DataStruct_Check_I( (Root_Ptr), &nb_detected, &nb_corrected, DS_stderr)) != DSS_OK) \
{ \
LG_LOG_ERROR_0( "Unable to check the data structure"); \
\
return( status); \
} \
}
/*------------------------------------------------------------------------------*/
/* */
/*------------------------------------------------------------------------------*/
#define DS_STRUCT_LOCK( Root_Ptr, Lock_Mode, Lock_Flag_Ptr) \
{ \
DST_Status status; \
\
\
if( ( status = DS_DataStruct_Lock_I( (Root_Ptr), (Lock_Mode), (Lock_Flag_Ptr))) != DSS_OK) \
{ \
LG_LOG_ERROR_0( "Unable to lock the data structure"); \
\
return( status); \
} \
}
/*------------------------------------------------------------------------------*/
/* */
/*------------------------------------------------------------------------------*/
#define DS_STRUCT_UNLOCK( Root_Ptr, Lock_Flag) \
{ \
DST_Status status; \
\
\
if( (Lock_Flag) && ( ( status = DS_DataStruct_Unlock_I( (Root_Ptr))) != DSS_OK)) \
{ \
LG_LOG_ERROR_0( "Unable to unlock the data structure"); \
\
return( status); \
} \
}
/* D<>finition des alias de l'API */
#ifndef DS_MODE
#define DS_MODE 0
#endif
#if DS_MODE == 2
/*
Utilisation des API sans v<>rification des arguments et sans verrouillage de
des data structures utilis<69>es.
Cette configuration correspond <20> une utilisation optimis<69>e mais non s<>curis<69>e
des API de la librairie.
Puisque les verrouillages ne sont pas faits syst<73>matiquement par les fonctions,
l'utilisateur veillera <20> verrouiller lui-m<>me les data structures qu'il utilise.
*/
# define DS_Library_Open DS_Library_Open_I
# define DS_Library_Close DS_Library_Close_I
# define DS_Library_Stderr_Set DS_Library_Stderr_Set_I
# define DS_DataStruct_Open DS_DataStruct_Open_I
# define DS_DataStruct_Close DS_DataStruct_Close_I
# define DS_DataStruct_Flush DS_DataStruct_Flush_I
# define DS_DataStruct_Check DS_DataStruct_Check_I
# define DS_DataStruct_Convert DS_DataStruct_Convert_I
# define DS_DataStruct_Reorg DS_DataStruct_Reorg_I
# define DS_DataStruct_Traverse DS_DataStruct_Traverse_I
# define DS_DataStruct_Info_Print DS_DataStruct_Info_Print_I
# define DS_DataStruct_Print DS_DataStruct_Print_I
# define DS_DataStruct_Lock DS_DataStruct_Lock_I
# define DS_DataStruct_Unlock DS_DataStruct_Unlock_I
# define DS_DataStruct_Value_Add DS_DataStruct_Value_Add_I
# define DS_DataStruct_Value_Remove DS_DataStruct_Value_Remove_I
# define DS_DataStruct_Value_Print DS_DataStruct_Value_Print_I
# define DS_DataStruct_Value_Find DS_DataStruct_Value_Find_I
# define DS_Index_Open DS_Index_Open_I
# define DS_Index_Close DS_Index_Close_I
# define DS_Index_Reorg DS_Index_Reorg_I
# define DS_Index_Check DS_Index_Check_I
# define DS_Index_Convert DS_Index_Convert_I
# define DS_Index_Info_Print DS_Index_Info_Print_I
# define DS_Node_Root_Get DS_Node_Root_Get_I
# define DS_Node_First_Get DS_Node_First_Get_I
# define DS_Node_Last_Get DS_Node_Last_Get_I
# define DS_Node_Next_Get DS_Node_Next_Get_I
# define DS_Node_Previous_Get DS_Node_Previous_Get_I
# define DS_Node_Add DS_Node_Add_I
# define DS_Node_Remove DS_Node_Remove_I
# define DS_Node_Find DS_Node_Find_I
# define DS_Value_Alloc DS_Value_Alloc_I
# define DS_Value_Free DS_Value_Free_I
# define DS_Alloc DS_Alloc_I
# define DS_Free DS_Free_I
#elif DS_MODE == 1
/*
Utilisation des API sans v<>rification des arguments mais avec
verrouillage syst<73>matique des data structures utilis<69>es.
*/
# define DS_Library_Open DS_Library_Open_L
# define DS_Library_Close DS_Library_Close_L
# define DS_Library_Stderr_Set DS_Library_Stderr_Set_L
# define DS_DataStruct_Open DS_DataStruct_Open_L
# define DS_DataStruct_Close DS_DataStruct_Close_L
# define DS_DataStruct_Flush DS_DataStruct_Flush_L
# define DS_DataStruct_Check DS_DataStruct_Check_L
# define DS_DataStruct_Convert DS_DataStruct_Convert_L
# define DS_DataStruct_Reorg DS_DataStruct_Reorg_L
# define DS_DataStruct_Traverse DS_DataStruct_Traverse_L
# define DS_DataStruct_Convert DS_DataStruct_Convert_L
# define DS_DataStruct_Info_Print DS_DataStruct_Info_Print_L
# define DS_DataStruct_Print DS_DataStruct_Print_L
# define DS_DataStruct_Check DS_DataStruct_Check_L
# define DS_DataStruct_Lock DS_DataStruct_Lock_L
# define DS_DataStruct_Unlock DS_DataStruct_Unlock_L
# define DS_DataStruct_Value_Add DS_DataStruct_Value_Add_L
# define DS_DataStruct_Value_Remove DS_DataStruct_Value_Remove_L
# define DS_DataStruct_Value_Print DS_DataStruct_Value_Print_L
# define DS_DataStruct_Value_Find DS_DataStruct_Value_Find_L
# define DS_Index_Open DS_Index_Open_L
# define DS_Index_Close DS_Index_Close_L
# define DS_Index_Reorg DS_Index_Reorg_L
# define DS_Index_Check DS_Index_Check_L
# define DS_Index_Convert DS_Index_Convert_L
# define DS_Index_Info_Print DS_Index_Info_Print_L
# define DS_Node_Root_Get DS_Node_Root_Get_L
# define DS_Node_First_Get DS_Node_First_Get_L
# define DS_Node_Last_Get DS_Node_Last_Get_L
# define DS_Node_Next_Get DS_Node_Next_Get_L
# define DS_Node_Previous_Get DS_Node_Previous_Get_L
# define DS_Node_Add DS_Node_Add_L
# define DS_Node_Remove DS_Node_Remove_L
# define DS_Node_Find DS_Node_Find_L
# define DS_Value_Alloc DS_Value_Alloc_L
# define DS_Value_Free DS_Value_Free_L
# define DS_Alloc DS_Alloc_L
# define DS_Free DS_Free_L
#else
/*
Utilisation des API avec v<>rification des arguments
et avec verrouillage des data structures utilis<69>es.
*/
# define DS_Library_Open DS_Library_Open_CL
# define DS_Library_Close DS_Library_Close_CL
# define DS_Library_Stderr_Set DS_Library_Stderr_Set_CL
# define DS_DataStruct_Convert DS_DataStruct_Convert_CL
# define DS_DataStruct_Open DS_DataStruct_Open_CL
# define DS_DataStruct_Close DS_DataStruct_Close_CL
# define DS_DataStruct_Flush DS_DataStruct_Flush_CL
# define DS_DataStruct_Check DS_DataStruct_Check_CL
# define DS_DataStruct_Reorg DS_DataStruct_Reorg_CL
# define DS_DataStruct_Traverse DS_DataStruct_Traverse_CL
# define DS_DataStruct_Info_Print DS_DataStruct_Info_Print_CL
# define DS_DataStruct_Print DS_DataStruct_Print_CL
# define DS_DataStruct_Lock DS_DataStruct_Lock_CL
# define DS_DataStruct_Unlock DS_DataStruct_Unlock_CL
# define DS_DataStruct_Value_Add DS_DataStruct_Value_Add_CL
# define DS_DataStruct_Value_Remove DS_DataStruct_Value_Remove_CL
# define DS_DataStruct_Value_Print DS_DataStruct_Value_Print_CL
# define DS_DataStruct_Value_Find DS_DataStruct_Value_Find_CL
# define DS_Index_Open DS_Index_Open_CL
# define DS_Index_Close DS_Index_Close_CL
# define DS_Index_Reorg DS_Index_Reorg_CL
# define DS_Index_Check DS_Index_Check_CL
# define DS_Index_Convert DS_Index_Convert_CL
# define DS_Index_Info_Print DS_Index_Info_Print_CL
# define DS_Node_Root_Get DS_Node_Root_Get_CL
# define DS_Node_First_Get DS_Node_First_Get_CL
# define DS_Node_Last_Get DS_Node_Last_Get_CL
# define DS_Node_Next_Get DS_Node_Next_Get_CL
# define DS_Node_Previous_Get DS_Node_Previous_Get_CL
# define DS_Node_Add DS_Node_Add_CL
# define DS_Node_Remove DS_Node_Remove_CL
# define DS_Node_Find DS_Node_Find_CL
# define DS_Value_Alloc DS_Value_Alloc_CL
# define DS_Value_Free DS_Value_Free_CL
# define DS_Alloc DS_Alloc_CL
# define DS_Free DS_Free_CL
#endif
/*----------------------------------------------------------------------------*/
/* DSD_API definition */
/*----------------------------------------------------------------------------*/
# ifdef _LIBDATASTR_C_
# define DSD_API
# else
# define DSD_API extern
# endif
/*----------------------------------------------------------------------------*/
/* Ouverture d'une instance de la librairie */
/*----------------------------------------------------------------------------*/
/* (I) Instance : num<75>ro de l'instance de la librairie */
/* (I) Context : nom du contexte */
/* (I) Debug_Mode : mode d'affichage des messages d'erreur */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_Library_Open_I( int Instance, const char *Context, DST_Flags Debug_Mode);
DSD_API DST_Status DS_Library_Open_L( int Instance, const char *Context, DST_Flags Debug_Mode);
DSD_API DST_Status DS_Library_Open_CL( int Instance, const char *Context, DST_Flags Debug_Mode);
/*----------------------------------------------------------------------------*/
/* Fermeture de l'instance de la librairie */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_Library_Close_I( void);
DSD_API DST_Status DS_Library_Close_L( void);
DSD_API DST_Status DS_Library_Close_CL( void);
/*----------------------------------------------------------------------------*/
/* D<>finition de la sortie standard des messages d'erreur de la librairie */
/*----------------------------------------------------------------------------*/
/* (I) Out : flux de sortie des messages d'erreur */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_Library_Stderr_Set_I( FILE *Out);
DSD_API DST_Status DS_Library_Stderr_Set_L( FILE *Out);
DSD_API DST_Status DS_Library_Stderr_Set_CL( FILE *Out);
/*----------------------------------------------------------------------------*/
/* Cr<43>ation / ouverture d'une structure de donn<6E>es */
/*----------------------------------------------------------------------------*/
/* (O) Root_Ptr_Ptr: Pointer adress of the new data structure */
/* (I) DS_Name: Data structure name */
/* (I) Index_Nb: Number of index */
/* (I) Index_Type_Ptr: Array of Index type (List, tree, ...) */
/* (I) Manager_Name: Manager function name */
/* (I) Segment_Size : taille ds segments du heap sous-jacent */
/* (I) Open_Mode : mode d'ouverture de la structure */
/* (I) Own_Value: Flag indicating if the structure is the node owner */
/* (I) Manager_FileName : nom du fichier qui d<>finit les fonctions manager */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_DataStruct_Open_I( DST_Root **Root, char *DS_Name, NDT_Index_Nb, NDT_Index_Type *, char *Manager_FileName, size_t Segment_Size, DST_Flags Open_Mode, short Own_Value);
/*
DSD_API DST_Status DS_DataStruct_Open_I( const char *DS_Name, NDT_Root **Root, NDT_DataStruct_Type Type, const char * Manager_FileName, size_t Segment_Size, DST_Flags Open_Mode, int Own_Value);
DSD_API DST_Status DS_DataStruct_Open_L( const char *DS_Name, NDT_Root **Root, NDT_DataStruct_Type Type, const char * Manager_FileName, size_t Segment_Size, DST_Flags Open_Mode, int Own_Value);
DSD_API DST_Status DS_DataStruct_Open_CL( const char *DS_Name, NDT_Root **Root, NDT_DataStruct_Type Type, const char * Manager_FileName, size_t Segment_Size, DST_Flags Open_Mode, int Own_Value);
/*----------------------------------------------------------------------------*/
/* Verrouillage d'une structure de donn<6E>es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure */
/* (I) Lock_Mode : type de verrou <20> poser sur la structure */
/* (O) Locked : verrou effectif (TRUE ou FALSE) */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_DataStruct_Lock_I( DST_Root *Root_Ptr, DST_Flags Lock_Mode, int *Locked);
DSD_API DST_Status DS_DataStruct_Lock_L( DST_Root *Root_Ptr, DST_Flags Lock_Mode, int *Locked);
DSD_API DST_Status DS_DataStruct_Lock_CL( DST_Root *Root_Ptr, DST_Flags Lock_Mode, int *Locked);
/*----------------------------------------------------------------------------*/
/* D<>verrouillage d'une structure de donn<6E>es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_DataStruct_Unlock_I( DST_Root *Root_Ptr);
DSD_API DST_Status DS_DataStruct_Unlock_L( DST_Root *Root_Ptr);
DSD_API DST_Status DS_DataStruct_Unlock_CL( DST_Root *Root_Ptr);
/*----------------------------------------------------------------------------*/
/* Fermeture d'une structure de donn<6E>es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E>es */
/* (I) Close_Mode : mode de fermeture de la structure (destruction ou non) */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_DataStruct_Close_I( DST_Root *Root_Ptr, DST_Flags Close_Mode);
DSD_API DST_Status DS_DataStruct_Close_L( DST_Root *Root_Ptr, DST_Flags Close_Mode);
DSD_API DST_Status DS_DataStruct_Close_CL( DST_Root *Root_Ptr, DST_Flags Close_Mode);
/*----------------------------------------------------------------------------*/
/* Destroy all data of a data structure */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/*----------------------------------------------------------------------------*/
DSD_API NDT_Status DS_DataStruct_Flush_I( DST_Root *Root_Ptr);
DSD_API NDT_Status DS_DataStruct_Flush_L( DST_Root *Root_Ptr);
DSD_API NDT_Status DS_DataStruct_Flush_CL( DST_Root *Root_Ptr);
/*----------------------------------------------------------------------------*/
/* Check & repare a datat structure: */
/* - Check & fix node links */
/* - Update data structure statistics */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (O) Error_Dectected_Nb_Ptr: Number of error detected pointer */
/* (O) Error_Corrected_Nb_Ptr: Number of error corected pointer */
/* (I) Out: Output stream */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_DataStruct_Check_I( DST_Root *Root_Ptr, int *Error_Detected_Nb_Ptr, int *Error_Corrected_Nb_Ptr, FILE *Out);
DSD_API DST_Status DS_DataStruct_Check_L( DST_Root *Root_Ptr, int *Error_Detected_Nb_Ptr, int *Error_Corrected_Nb_Ptr, FILE *Out);
DSD_API DST_Status DS_DataStruct_Check_CL( DST_Root *Root_Ptr, int *Error_Detected_Nb_Ptr, int *Error_Corrected_Nb_Ptr, FILE *Out);
/*----------------------------------------------------------------------------*/
/* Convert a data structure indexe types */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Type_Ptr: Array of index type (List, tree, ...) */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_DataStruct_Convert_I( DST_Root *Root_Ptr, NDT_Index_Type *Index_Type_Ptr);
DSD_API DST_Status DS_DataStruct_Convert_L( DST_Root *Root_Ptr, NDT_Index_Type *Index_Type_Ptr);
DSD_API DST_Status DS_DataStruct_Convert_CL( DST_Root *Root_Ptr, NDT_Index_Type *Index_Type_Ptr);
/*----------------------------------------------------------------------------*/
/* Reorganise a data structure indexes: */
/* - Sort a non-sorted list */
/* - Rebalance a non auto-balanced tree */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_DataStruct_Reorg_I( DST_Root *Root_Ptr);
DSD_API DST_Status DS_DataStruct_Reorg_L( DST_Root *Root_Ptr);
DSD_API DST_Status DS_DataStruct_Reorg_CL( DST_Root *Root_Ptr);
/*----------------------------------------------------------------------------*/
/* Print data structure information */
/*----------------------------------------------------------------------------*/
/* (I) Stream: Output stream */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Recursive_Mode: Child or Parent */
/* (I) Recursive_Depth: Curent recursion depth */
/* (I) Recursive_Offset: Curent print out offset */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_DataStruct_Info_Print_I( FILE *Out, DST_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset);
DSD_API DST_Status DS_DataStruct_Info_Print_L( FILE *Out, DST_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset);
DSD_API DST_Status DS_DataStruct_Info_Print_CL( FILE *Out, DST_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset);
/*----------------------------------------------------------------------------*/
/* Add a new value to a data structure */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Value_Ptr: Value pointer */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_DataStruct_Value_Add_I( DST_Root *Root_Ptr, void *Value_Ptr);
DSD_API DST_Status DS_DataStruct_Value_Add_L( DST_Root *Root_Ptr, void *Value_Ptr);
DSD_API DST_Status DS_DataStruct_Value_Add_CL( DST_Root *Root_Ptr, void *Value_Ptr);
/*----------------------------------------------------------------------------*/
/* Remove the first matching value from a data structure */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Ref_Value_Ptr: Reference value pointer to search */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_DataStruct_Value_Remove_I( DST_Root *Root_Ptr, void *Ref_Value_Ptr);
DSD_API DST_Status DS_DataStruct_Value_Remove_L( DST_Root *Root_Ptr, void *Ref_Value_Ptr);
DSD_API DST_Status DS_DataStruct_Value_Remove_CL( DST_Root *Root_Ptr, void *Ref_Value_Ptr);
/*----------------------------------------------------------------------------*/
/* Print all the data structure values */
/*----------------------------------------------------------------------------*/
/* (I) Stream: Output stream */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Recursive_Mode: Child or Parent */
/* (I) Recursive_Depth: Curent recursion depth */
/* (I) Recursive_Offset: Curent print out offset */
/* (I) ...: User args */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_DataStruct_Value_Print_I( FILE *Out_Ptr, DST_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset, ...);
DSD_API DST_Status DS_DataStruct_Value_Print_L( FILE *Out_Ptr, DST_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset, ...);
DSD_API DST_Status DS_DataStruct_Value_Print_CL( FILE *Out_Ptr, DST_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset, ...);
/*----------------------------------------------------------------------------*/
/* Find a value in a data structure */
/*----------------------------------------------------------------------------*/
/* (O) Value_Ptr_Ptr: Value pointer address found */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Ref_Value_Ptr: Reference value pointer to search */
/* (I) ...: User args */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_DataStruct_Value_Find_I( void **Value_Ptr_Ptr, DST_Root *Root_Ptr, void *Ref_Value_Ptr, ...);
DSD_API DST_Status DS_DataStruct_Value_Find_C( void **Value_Ptr_Ptr, DST_Root *Root_Ptr, void *Ref_Value_Ptr, ...);
DSD_API DST_Status SD_DataStruct_Value_Find_CL( void **Value_Ptr_Ptr, DST_Root *Root_Ptr, void *Ref_Value_Ptr, ...);
/*----------------------------------------------------------------------------*/
/* Traverse a data structure & execute a command on each node */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Command: Manager command */
/* (I) ...: User args */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_DataStruct_Traverse_I( DST_Root *Root_Ptr, NDT_Command Command, ...);
DSD_API DST_Status DS_DataStruct_Traverse_L( DST_Root *Root_Ptr, NDT_Command Command, ...);
DSD_API DST_Status DS_DataStruct_Traverse_CL( DST_Root *Root_Ptr, NDT_Command Command, ...);
/*----------------------------------------------------------------------------*/
/* Affichage de la valeur de tous les noeuds d'une structure de donn<6E>es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E>es */
/* (I) Out : flux de sortie */
/*----------------------------------------------------------------------------*/
/*
DSD_API DST_Status DS_DataStruct_Print_I( NDT_Root * Root, FILE * Out);
DSD_API DST_Status DS_DataStruct_Print_L( NDT_Root * Root, FILE * Out);
DSD_API DST_Status DS_DataStruct_Print_CL( NDT_Root * Root, FILE * Out);
/*----------------------------------------------------------------------------*/
/* Create a new index */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/* (I) Index_Type: Index type (List, tree, ...) */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_Index_Open_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type);
DSD_API DST_Status DS_Index_Open_L( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type);
DSD_API DST_Status DS_Index_Open_CL( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type);
/*----------------------------------------------------------------------------*/
/* Remove an Index */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_Index_Close_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id);
DSD_API DST_Status DS_Index_Close_L( DST_Root *Root_Ptr, NDT_Index_Id Index_Id);
DSD_API DST_Status DS_Index_Close_CL( DST_Root *Root_Ptr, NDT_Index_Id Index_Id);
/*----------------------------------------------------------------------------*/
/* Check & repare a data structure index: */
/* - Check & fix node links */
/* - Update data structure statistics */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/* (O) Error_Dectected_Nb_Ptr: Number of error detected pointer */
/* (O) Error_Corrected_Nb_Ptr: Number of error corected pointer */
/* (I) Out: Output stream */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_Index_Check_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, int *Error_Dectected_Nb_Ptr, int *Error_Corrected_Nb_Ptr, FILE *Out);
DSD_API DST_Status DS_Index_Check_L( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, int *Error_Dectected_Nb_Ptr, int *Error_Corrected_Nb_Ptr, FILE *Out);
DSD_API DST_Status DS_Index_Check_CL( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, int *Error_Dectected_Nb_Ptr, int *Error_Corrected_Nb_Ptr, FILE *Out);
/*----------------------------------------------------------------------------*/
/* Convert a data structure index to another type */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/* (I) Index_Type: Index type (List, tree, ...) */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_Index_Convert_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type);
DSD_API DST_Status DS_Index_Convert_L( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type);
DSD_API DST_Status DS_Index_Convert_CL( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type);
/*----------------------------------------------------------------------------*/
/* Reorganise a data structure index: */
/* - Sort a non-sorted list */
/* - Rebalance a non auto-balanced tree */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_Index_Reorg_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id);
DSD_API DST_Status DS_Index_Reorg_L( DST_Root *Root_Ptr, NDT_Index_Id Index_Id);
DSD_API DST_Status DS_Index_Reorg_CL( DST_Root *Root_Ptr, NDT_Index_Id Index_Id);
/*----------------------------------------------------------------------------*/
/* Print data structure index information */
/*----------------------------------------------------------------------------*/
/* (I) Stream: Output stream */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/* (I) Recursive_Mode: Child or Parent */
/* (I) Recursive_Depth: Curent recursion depth */
/* (I) Recursive_Offset: Curent print out offset */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_Index_Info_Print_I( FILE *Out, DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset);
DSD_API DST_Status DS_Index_Info_Print_L( FILE *Out, DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset);
DSD_API DST_Status DS_Index_Info_Print_CL( FILE *Out, DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset);
/*----------------------------------------------------------------------------*/
/* R<>cup<75>ration du premier noeud d'une structure */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine dont on cherche le premier noeud */
/* (O) Node : pointeur sur le noeud <20> r<>cup<75>rer */
/*----------------------------------------------------------------------------*/
/*
DSD_API DST_Status DS_Node_First_Get_I( NDT_Root * Root, NDT_Node ** Node);
DSD_API DST_Status DS_Node_First_Get_L( NDT_Root * Root, NDT_Node ** Node);
DSD_API DST_Status DS_Node_First_Get_CL( NDT_Root * Root, NDT_Node ** Node);
/*----------------------------------------------------------------------------*/
/* R<>cup<75>ration du dernier noeud d'une structure */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine dont on cherche le dernier noeud */
/* (O) Node : pointeur sur le noeud <20> r<>cup<75>rer */
/*----------------------------------------------------------------------------*/
/*
DSD_API DST_Status DS_Node_Last_Get_I( NDT_Root * Root, NDT_Node ** Node);
DSD_API DST_Status DS_Node_Last_Get_L( NDT_Root * Root, NDT_Node ** Node);
DSD_API DST_Status DS_Node_Last_Get_CL( NDT_Root * Root, NDT_Node ** Node);
/*----------------------------------------------------------------------------*/
/* R<>cup<75>ration du noeud suivant */
/*----------------------------------------------------------------------------*/
/* (I) Node : pointeur sur le noeud dont on cherche le suivant */
/* (O) Next_Node : pointeur sur le noeud suivant */
/*----------------------------------------------------------------------------*/
/*
DSD_API DST_Status DS_Node_Next_Get_I( NDT_Node * Node, NDT_Node ** Next_Node);
DSD_API DST_Status DS_Node_Next_Get_L( NDT_Node * Node, NDT_Node ** Next_Node);
DSD_API DST_Status DS_Node_Next_Get_CL( NDT_Node * Node, NDT_Node ** Next_Node);
/*----------------------------------------------------------------------------*/
/* R<>cup<75>ration du noeud pr<70>c<EFBFBD>dant */
/*----------------------------------------------------------------------------*/
/* (I) Node : pointeur sur le noeud dont on cherche le pr<70>c<EFBFBD>dant */
/* (O) Prev_Node : pointeur sur le noeud pr<70>c<EFBFBD>dant */
/*----------------------------------------------------------------------------*/
/*
DSD_API DST_Status DS_Node_Previous_Get_I( NDT_Node * Node, NDT_Node ** Prev_Node);
DSD_API DST_Status DS_Node_Previous_Get_L( NDT_Node * Node, NDT_Node ** Prev_Node);
DSD_API DST_Status DS_Node_Previous_Get_CL( NDT_Node * Node, NDT_Node ** Prev_Node);
/*----------------------------------------------------------------------------*/
/* Ajout d'un noeud <20> une structure de donn<6E>es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E>es */
/* (I) Node : pointeur sur le noeud <20> ajouter */
/*----------------------------------------------------------------------------*/
/*
DSD_API DST_Status DS_Node_Add_I( NDT_Root * Root, NDT_Node * Node);
DSD_API DST_Status DS_Node_Add_L( NDT_Root * Root, NDT_Node * Node);
DSD_API DST_Status DS_Node_Add_CL( NDT_Root * Root, NDT_Node * Node);
/*----------------------------------------------------------------------------*/
/* Suppression d'un noeud dans une structure de donn<6E>es */
/*----------------------------------------------------------------------------*/
/* (I) Node: pointeur sur le noeud <20> supprimer de la structure de donn<6E>es */
/*----------------------------------------------------------------------------*/
/*
DSD_API DST_Status DS_Node_Remove_I( NDT_Node * Node);
DSD_API DST_Status DS_Node_Remove_L( NDT_Node * Node);
DSD_API DST_Status DS_Node_Remove_CL( NDT_Node * Node);
/*----------------------------------------------------------------------------*/
/* Recherche un noeud dans un arbre et retourne le pointeur sur le noeud */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de l'abre */
/* (O) Node : adresse du pointeur sur le noeud <20> r<>cuperer */
/* (I) Value : pointeur sur la valeur <20> rechercher */
/* (I) Data : pointeur de donn<6E>es */
/*----------------------------------------------------------------------------*/
/*
DSD_API DST_Status DS_Node_Find_I( NDT_Root * Root, NDT_Node ** Node, void * Value, void * Data);
DSD_API DST_Status DS_Node_Find_L( NDT_Root * Root, NDT_Node ** Node, void * Value, void * Data);
DSD_API DST_Status DS_Node_Find_CL( NDT_Root * Root, NDT_Node ** Node, void * Value, void * Data);
/*----------------------------------------------------------------------------*/
/* Allocation d'une valeur d'une structure de donn<6E>es */
/*----------------------------------------------------------------------------*/
/* (O) Value : adresse d'un pointeur sur la valeur <20> allouer */
/* (I) Root : pointeur sur la racine de la structure de donn<6E>es */
/* (I) ... : arguments relatifs <20> l'allocation de la valeur */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_Value_Alloc_I( void **Value_Ptr_Ptr, DST_Root *Root_Ptr, ...);
DSD_API DST_Status DS_Value_Alloc_L( void **Value_Ptr_Ptr, DST_Root *Root_Ptr, ...);
DSD_API DST_Status DS_Value_Alloc_CL( void **Value_Ptr_Ptr, DST_Root *Root_Ptr, ...);
/*----------------------------------------------------------------------------*/
/* D<>sallocation d'une valeur d'une structure de donn<6E>es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E>es */
/* (I) Value : pointeur sur la valeur <20> d<>sallouer */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_Value_Free_I( DST_Root *Root_Ptr, void *Value_Ptr);
DSD_API DST_Status DS_Value_Free_L( DST_Root *Root_Ptr, void *Value_Ptr);
DSD_API DST_Status DS_Value_Free_CL( DST_Root *Root_Ptr, void *Value_Ptr);
/*----------------------------------------------------------------------------*/
/* Allocation de m<>moire pour une structure de donn<6E>es : */
/*----------------------------------------------------------------------------*/
/* (O) Ptr : adresse du pointeur sur la zone de donn<6E>es allou<6F>e */
/* (I) Root : pointeur sur la racine de la structure de donn<6E>es */
/* (I) Size : taille m<>moire <20> allouer */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_Alloc_I( void **Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size);
DSD_API DST_Status DS_Alloc_L( void **Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size);
DSD_API DST_Status DS_Alloc_CL( void **Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size);
/*----------------------------------------------------------------------------*/
/* D<>sallocation d'une ressource pour une structure de donn<6E>es : */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E>es */
/* (I) Ptr : pointeur sur la zone <20> d<>sallouer */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_Free_I( NDT_Root *Root_Ptr, void *Ptr);
DSD_API DST_Status DS_Free_L( NDT_Root *Root_Ptr, void *Ptr);
DSD_API DST_Status DS_Free_CL( NDT_Root *Root_Ptr, void *Ptr);
#ifdef __cplusplus
//}
#endif
#endif