- Implement DS_DataStruct_Check_I(), DS_DataStruct_Reorg_I(), DS_DataStruct_Convert_I(),

- Add a new marco: DS_STRUCT_VALID_CHECK().
This commit is contained in:
Arnaud G. GIBERT 2024-05-02 01:06:11 +02:00
parent 6c74ecb997
commit 6dccb387f7
3 changed files with 476 additions and 399 deletions

View File

@ -155,6 +155,28 @@ typedef struct DST_RootDesc
/*------------------------------------------------------------------------------*/
/* */
/*------------------------------------------------------------------------------*/
#define DS_STRUCT_VALID_CHECK( Root_Ptr, RootDesc_Ptr) \
if( (RootDesc_Ptr)->Valid == FALSE) \
{ \
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); \
} \
} \
/* Définition des alias de l'API */
@ -182,12 +204,13 @@ typedef struct DST_RootDesc
# define DS_DataStruct_Close DS_DataStruct_Close_I
# define DS_DataStruct_Flush DS_DataStruct_Flush_I
# define DS_DataStruct_Reorg DS_DataStruct_Reorg_I
# define DS_DataStruct_Traverse DS_DataStruct_Traverse_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_Value_Print DS_DataStruct_Value_Print_I
# define DS_DataStruct_Print DS_DataStruct_Print_I
# define DS_DataStruct_Check DS_DataStruct_Check_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
@ -226,6 +249,8 @@ typedef struct DST_RootDesc
# 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
@ -268,16 +293,16 @@ typedef struct DST_RootDesc
# 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_Convert DS_DataStruct_Convert_CL
# define DS_DataStruct_Info_Print DS_DataStruct_Info_Print_CL
# define DS_DataStruct_Value_Print DS_DataStruct_Value_Print_CL
# define DS_DataStruct_Print DS_DataStruct_Print_CL
# define DS_DataStruct_Check DS_DataStruct_Check_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
@ -430,6 +455,50 @@ DSD_API NDT_Status DS_DataStruct_Flush_CL( NDT_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( NDT_Root *Root_Ptr, int *Error_Detected_Nb_Ptr, int *Error_Corrected_Nb_Ptr, FILE *Out);
DSD_API DST_Status DS_DataStruct_Check_L( NDT_Root *Root_Ptr, int *Error_Detected_Nb_Ptr, int *Error_Corrected_Nb_Ptr, FILE *Out);
DSD_API DST_Status DS_DataStruct_Check_CL( NDT_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( NDT_Root *Root_Ptr, NDT_Index_Type *Index_Type_Ptr);
DSD_API DST_Status DS_DataStruct_Convert_L( NDT_Root *Root_Ptr, NDT_Index_Type *Index_Type_Ptr);
DSD_API DST_Status DS_DataStruct_Convert_CL( NDT_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( NDT_Root *Root_Ptr);
DSD_API DST_Status DS_DataStruct_Reorg_L( NDT_Root *Root_Ptr);
DSD_API DST_Status DS_DataStruct_Reorg_CL( NDT_Root *Root_Ptr);
/*----------------------------------------------------------------------------*/
/* Print data structure information */
/*----------------------------------------------------------------------------*/
@ -459,20 +528,6 @@ DSD_API DST_Status DS_DataStruct_Value_Add_CL( NDT_Root *Root_Ptr, void *Valu
/*----------------------------------------------------------------------------*/
/* Réorganisation d'une structure de données : */
/* - ordonnancement d'une liste non ordonnée */
/* - réquilibrage d'un arbre non auto-équilibré */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de données */
/*----------------------------------------------------------------------------*/
/*
DSD_API DST_Status DS_DataStruct_Reorg_I( NDT_Root * Root);
DSD_API DST_Status DS_DataStruct_Reorg_L( NDT_Root * Root);
DSD_API DST_Status DS_DataStruct_Reorg_CL( NDT_Root * Root);
/*----------------------------------------------------------------------------*/
/* Parcours de tous les noeuds d'une structure de données et exécution d'une */
/* commande sur chacun d'eux */
@ -488,19 +543,6 @@ DSD_API DST_Status DS_DataStruct_Traverse_CL( NDT_Root * Root, NDT_Command Comm
/*----------------------------------------------------------------------------*/
/* Conversion d'une structure de données d'un type en un autre */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de données */
/* (I) Target_Type : type de structure cible */
/*----------------------------------------------------------------------------*/
/*
DSD_API DST_Status DS_DataStruct_Convert_I( NDT_Root * Root, NDT_DataStruct_Type Target_Type);
DSD_API DST_Status DS_DataStruct_Convert_L( NDT_Root * Root, NDT_DataStruct_Type Target_Type);
DSD_API DST_Status DS_DataStruct_Convert_CL( NDT_Root * Root, NDT_DataStruct_Type Target_Type);
/*----------------------------------------------------------------------------*/
/* Affichage de la valeur de tous les noeuds d'une structure de données */
/*----------------------------------------------------------------------------*/
@ -514,21 +556,6 @@ DSD_API DST_Status DS_DataStruct_Print_CL( NDT_Root * Root, FILE * Out);
/*----------------------------------------------------------------------------*/
/* Fonction de vérification / réparation d'une structure de données */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure */
/* (O) Nb_Detected : pointeur sur le nombre d'erreurs détectées */
/* (O) Nb_Corrected : pointeur sur le nombre d'erreurs corrigées */
/* (I) Out : flux de sortie du rapport */
/*----------------------------------------------------------------------------*/
/*
DSD_API DST_Status DS_DataStruct_Check_I( NDT_Root * Root, int * Nb_Detected, int * Nb_Corrected, FILE * Out);
DSD_API DST_Status DS_DataStruct_Check_L( NDT_Root * Root, int * Nb_Detected, int * Nb_Corrected, FILE * Out);
DSD_API DST_Status DS_DataStruct_Check_CL( NDT_Root * Root, int * Nb_Detected, int * Nb_Corrected, FILE * Out);
/*----------------------------------------------------------------------------*/
/* Print all the data structure values */
/*----------------------------------------------------------------------------*/

View File

@ -943,6 +943,242 @@ NDT_Status DS_DataStruct_Flush_I( NDT_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 */
/*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Check_I( NDT_Root *Root_Ptr, int *Error_Detected_Nb_Ptr, int *Error_Corrected_Nb_Ptr, FILE *Out)
{
DST_RootDesc *RootDesc_Ptr = (DST_RootDesc *)( Root_Ptr->User_Ptr);
char *Heap_Name = RootDesc_Ptr->Heap_Name;
DST_Status status, status2;
SMT_Status sm_status;
NDT_Status nd_status;
SMT_Heap *heap_ptr;
int locked;
DST_Flags previous_lock;
/* On sauvegarde l'état de verrouillage précédent */
if( ( sm_status = SM_Heap_IsOpen( Heap_Name, &heap_ptr)) != SMS_OK)
{
LG_LOG_ERROR_2( "Unable to check if heap: [%s] is open, status: (%d)", Heap_Name, sm_status);
return( DSS_KO);
}
else
{
if( heap_ptr == NULL)
{
LG_LOG_ERROR_1( "Data structure heap: [%s] is not open", Heap_Name);
return( DSS_KO);
}
}
previous_lock = heap_ptr->Lock_Mode;
/* Verrouillage de la data structure en écriture */
if( ( status = DS_DataStruct_Lock_I( Root_Ptr, SMD_WRITE, &locked)) != DSS_OK)
{
LG_LOG_ERROR_2( "Unable to lock the data structure: [%s] for writing, status : (%s)", Heap_Name, status);
return( SMS_OK);
}
/* Vérification du heap sous-jacent à la data structure */
if( ( sm_status = SM_Heap_Check( heap_ptr, Error_Detected_Nb_Ptr, Error_Corrected_Nb_Ptr, Out)) != SMS_OK)
{
LG_LOG_ERROR_2( "Unable to check the heap: [%s] for writing, status : (%s)", Heap_Name, sm_status);
status= DSS_KO;
}
else
{
/* Vérification de la structure de noeuds */
LG_LOG_INFO_0( "Checking the node structure...");
if( ( nd_status = ND_DataStruct_Check( Root_Ptr, Error_Detected_Nb_Ptr, Error_Corrected_Nb_Ptr, Out)) != NDS_OK)
{
LG_LOG_ERROR_2( "Unable to check the data structure: [%s], status: (%d)", Heap_Name, nd_status);
status = DSS_KO;
}
else
{
/* On valide ou invalide la structure selon le résultat */
if( *Error_Corrected_Nb_Ptr == *Error_Detected_Nb_Ptr)
{
RootDesc_Ptr->Valid = TRUE;
}
else
{
RootDesc_Ptr->Valid = FALSE;
}
/* Affichage du résultat de la procédure de vérification */
if( *Error_Detected_Nb_Ptr)
{
if( *Error_Corrected_Nb_Ptr < *Error_Detected_Nb_Ptr)
{
LG_LOG_ERROR_2( "Error(s) detected: (%d) corected: (%d)", *Error_Detected_Nb_Ptr, *Error_Corrected_Nb_Ptr);
status = SMS_KO;
}
else
{
LG_LOG_WARNING_2( "Error(s) detected: (%d) corected: (%d)", *Error_Detected_Nb_Ptr, *Error_Corrected_Nb_Ptr);
status = SMS_OK;
}
}
else
{
LG_LOG_INFO_0( "No error detected in the data structure");
status = SMS_OK;
}
}
}
/* Retour au mode de verrouillage précédent */
if( previous_lock == SMD_UNDEF)
{
if( ( status2 = DS_DataStruct_Unlock_I( Root_Ptr)) != DSS_OK)
{
LG_LOG_ERROR_2( "Unable to unlock the data structure: [%s], status: (%d)", Heap_Name, status2);
status = status2;
}
}
else
{
if( ( status2 = DS_DataStruct_Lock_I( Root_Ptr, previous_lock, &locked)) != SMS_OK)
{
LG_LOG_ERROR_2( "Unable to lock the data structure: [%s], status: (%d)", Heap_Name, status2);
status = status2;
}
}
return( status);
}
/*----------------------------------------------------------------------------*/
/* Convert a data structure indexe types */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Type_Ptr: Array of index type (List, tree, ...) */
/*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Convert_I( NDT_Root *Root_Ptr, NDT_Index_Type *Index_Type_Ptr)
{
DST_RootDesc *RootDesc_Ptr = (DST_RootDesc *)( Root_Ptr->User_Ptr);
DST_Status status;
NDT_Status nd_status;
/* On vérifie que la data structure est valide */
DS_STRUCT_VALID_CHECK( Root_Ptr, RootDesc_Ptr);
/* On rend la structure invalide le temps de sa conversion */
RootDesc_Ptr->Valid = FALSE;
/* Conversion de la node structure */
if( ( nd_status = ND_DataStruct_Convert( Root_Ptr, Index_Type_Ptr)) != NDS_OK)
{
LG_LOG_ERROR_1( "Unable to convert the node structure, status: (%d)", nd_status);
return( DSS_KO);
}
else
{
/* On rend la structure à nouveau valide */
RootDesc_Ptr->Valid = TRUE;
return( DSS_OK);
}
}
/*----------------------------------------------------------------------------*/
/* Reorganise a data structure indexes: */
/* - Sort a non-sorted list */
/* - Rebalance a non auto-balanced tree */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Reorg_I( NDT_Root *Root_Ptr)
{
DST_RootDesc *RootDesc_Ptr = (DST_RootDesc *)( Root_Ptr->User_Ptr);
DST_Status status;
NDT_Status nd_status;
/* On vérifie que la data structure est valide */
DS_STRUCT_VALID_CHECK( Root_Ptr, RootDesc_Ptr);
/* On rend la structure invalide, le temps de sa réorganisation */
RootDesc_Ptr->Valid = FALSE;
/* Réorganisation de la node structure */
if( ( nd_status = ND_DataStruct_Reorg( Root_Ptr)) != NDS_OK)
{
LG_LOG_ERROR_1( "Unable to reorg the node structure, status: (%d)", nd_status);
return( DSS_KO);
}
else
{
/* On rend la structure à nouveau valide */
RootDesc_Ptr->Valid = TRUE;
return( DSS_OK);
}
}
/*----------------------------------------------------------------------------*/
/* Print data structure information */
/*----------------------------------------------------------------------------*/
@ -967,24 +1203,7 @@ DST_Status DS_DataStruct_Info_Print_I( FILE *Out, NDT_Root *Root_Ptr, NDT_Recu
/* On vérifie que la data structure est valide */
if( RootDesc_Ptr->Valid == FALSE)
{
int Nb_Detected, Nb_Corrected;
/* On vérifie la structure */
/*
Nb_Detected = Nb_Corrected = 0;
rc = DS_DataStruct_Check_L (Root, &Nb_Detected, &Nb_Corrected, DS_stderr);
if (rc != DSS_OK)
{
sprintf (DS_Error_Msg, "Error DS_DataStruct_Info_Print : unable to check the data structure");
DS_Error_Print ();
return rc;
}
*/
}
DS_STRUCT_VALID_CHECK( Root_Ptr, RootDesc_Ptr);
/* Affichage des informations sur la structure */
@ -1024,63 +1243,6 @@ DST_Status DS_DataStruct_Info_Print_I( FILE *Out, NDT_Root *Root_Ptr, NDT_Recu
/*----------------------------------------------------------------------------*/
/* Réorganisation d'une structure de données */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de données à réorganiser */
/*----------------------------------------------------------------------------*/
/*
DST_Status DS_DataStruct_Reorg_I ( NDT_Root * Root )
{
DST_Status rc;
DST_RootDesc * RootDesc = (DST_RootDesc *)(Root->User);
/* On vérifie que la data structure est valide */
/*
if (RootDesc->Valid == FALSE)
{
int Nb_Detected, Nb_Corrected;
/* On vérifie la structure */
/*
Nb_Detected = Nb_Corrected = 0;
rc = DS_DataStruct_Check_L (Root, &Nb_Detected, &Nb_Corrected, DS_stderr);
if (rc != DSS_OK)
{
sprintf (DS_Error_Msg, "Error DS_DataStruct_Reorg : unable to check the data structure");
DS_Error_Print ();
return rc;
}
}
/* On rend la structure invalide, le temps de sa réorganisation */
/*
RootDesc->Valid = FALSE;
/* Réorganisation de la node structure */
/*
rc = ND_DataStruct_Reorg (Root);
if (rc != NDS_OK)
{
sprintf (DS_Error_Msg, "Error DS_DataStruct_Reorg : unable to reorganize the node structure ");
DS_Error_Print ();
RootDesc->Valid = TRUE;
if (!DS_ERROR(rc)) RootDesc->Valid = TRUE;
return rc;
}
/* On rend la structure à nouveau valide */
/*
RootDesc->Valid = TRUE;
return DSS_OK;
}
/*----------------------------------------------------------------------------*/
/* Parcours de tous les noeuds d'une structure de données et exécution d'une */
/* commande sur chacun d'eux */
@ -1099,19 +1261,17 @@ DST_Status DS_DataStruct_Traverse_I ( NDT_Root * Root, NDT_Command Command, void
/*
if (RootDesc->Valid == FALSE)
{
int Nb_Detected, Nb_Corrected;
int nb_detected, nb_corrected;
/* On vérifie la structure */
/*
Nb_Detected = Nb_Corrected = 0;
nb_detected = nb_corrected = 0;
rc = DS_DataStruct_Check_L (Root, &Nb_Detected, &Nb_Corrected, DS_stderr);
if (rc != DSS_OK)
if( ( status = DS_DataStruct_Check_L( Root_Ptr, &nb_detected, &nb_corrected, DS_stderr)) != DSS_OK)
{
sprintf (DS_Error_Msg, "Error DS_DataStruct_Traverse : unable to check the data structure");
DS_Error_Print ();
LG_LOG_ERROR_0( "Unable to check the data structure");
return rc;
return( status);
}
}
@ -1147,62 +1307,6 @@ DST_Status DS_DataStruct_Traverse_I ( NDT_Root * Root, NDT_Command Command, void
return DSS_OK;
}
/*----------------------------------------------------------------------------*/
/* Conversion d'une structure de données d'un type en un autre */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de données */
/* (I) Target_Type : type de structure cible */
/*----------------------------------------------------------------------------*/
/*
DST_Status DS_DataStruct_Convert_I ( NDT_Root * Root, NDT_DataStruct_Type Target_Type )
{
DST_Status rc;
DST_RootDesc * RootDesc = (DST_RootDesc *)(Root->User);
/* On vérifie que la data structure est valide */
/*
if (RootDesc->Valid == FALSE)
{
int Nb_Detected, Nb_Corrected;
/* On vérifie la structure */
/*
Nb_Detected = Nb_Corrected = 0;
rc = DS_DataStruct_Check_L (Root, &Nb_Detected, &Nb_Corrected, DS_stderr);
if (rc != DSS_OK)
{
sprintf (DS_Error_Msg, "Error DS_DataStruct_Convert : unable to check the data structure");
DS_Error_Print ();
return rc;
}
}
/* On rend la structure invalide le temps de sa conversion */
/*
RootDesc->Valid = FALSE;
/* Conversion de la node structure */
/*
rc = ND_DataStruct_Convert (Root, Target_Type);
if (rc != NDS_OK)
{
sprintf (DS_Error_Msg, "Error DS_DataStruct_Convert : unable to convert the node structure");
DS_Error_Print ();
if (!DS_ERROR(rc)) RootDesc->Valid = TRUE;
return rc;
}
/* On rend la structure à nouveau valide */
/*
RootDesc->Valid = TRUE;
return DSS_OK;
}
/*----------------------------------------------------------------------------*/
/* Affichage d'une structure de données */
/*----------------------------------------------------------------------------*/
@ -1215,96 +1319,6 @@ DST_Status DS_DataStruct_Print_I ( NDT_Root * Root, FILE * Out )
return DS_DataStruct_Traverse_I (Root, NDD_CMD_PRINT_VALUE, Out);
}
/*----------------------------------------------------------------------------*/
/* Fonction de vérification / réparation d'une structure de données */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure */
/* (O) Nb_Detected : pointeur sur le nombre d'erreurs détectées */
/* (O) Nb_Corrected : pointeur sur le nombre d'erreurs corrigées */
/* (I) Out : flux de sortie du rapport */
/*----------------------------------------------------------------------------*/
/*
DST_Status DS_DataStruct_Check_I ( NDT_Root * Root, int * Nb_Detected, int * Nb_Corrected, FILE * Out )
{
DST_Status rc;
SMT_Heap * Heap;
int Locked;
char * Heap_Name;
DST_Flags Previous_Lock;
DST_RootDesc * RootDesc = (DST_RootDesc *)(Root->User);
Heap_Name = RootDesc->Heap_Name;
/* On sauvegarde l'état de verrouillage précédent */
/*
rc = SM_Heap_IsOpen (Heap_Name, &Heap);
if (rc != SMS_YES)
{
sprintf (DS_Error_Msg, "Error DS_DataStruct_Check : the data structure heap \"%s\" is not open", Heap_Name);
DS_Error_Print ();
return rc;
}
Previous_Lock = Heap->Lock_Mode;
/* Verrouillage de la data structure en écriture */
/*
rc = DS_DataStruct_Lock_I (Root, SMD_WRITE, &Locked);
if (rc != DSS_OK)
{
sprintf (DS_Error_Msg, "Error ND_DataStruct_Check : unable to lock the data structure for writing");
DS_Error_Print ();
return rc;
}
/* Vérification du heap sous-jacent à la data structure */
/*
rc = SM_Heap_Check (Heap, Nb_Detected, Nb_Corrected, Out);
if (rc != SMS_OK)
{
if (Previous_Lock == SMD_UNDEF) DS_DataStruct_Unlock_I (Root);
else DS_DataStruct_Lock_I (Root, Previous_Lock, &Locked);
return rc;
}
else
{
/* Vérification de la structure de noeuds */
/*
fprintf (Out, "Checking the node structure ...\n");
rc = ND_DataStruct_Check (Root, Nb_Detected, Nb_Corrected, Out);
}
/* On valide ou invalide la structure selon le résultat */
/*
if (*Nb_Corrected == *Nb_Detected) RootDesc->Valid = TRUE;
else RootDesc->Valid = FALSE;
/* Retour au mode de verrouillage précédent */
/*
if (Previous_Lock == SMD_UNDEF) DS_DataStruct_Unlock_I (Root);
else DS_DataStruct_Lock_I (Root, Previous_Lock, &Locked);
/* Affichage du résultat de la procédure de vérification */
/*
if (*Nb_Detected)
{
fprintf (Out, "%d/%d error(s) corrected in the data structure\n", *Nb_Corrected, *Nb_Detected);
if (*Nb_Corrected < *Nb_Detected) return DSS_KO;
}
else fprintf (Out, "No error detected in the data structure\n");
return rc;
}
/*----------------------------------------------------------------------------*/
/* Add a new value to a data structure */
/*----------------------------------------------------------------------------*/
@ -1321,28 +1335,15 @@ DST_Status DS_DataStruct_Value_Add_I( NDT_Root *Root_Ptr, void *Value_Ptr)
/* On vérifie que la data structure est valide */
/*
if( RootDesc_Ptr->Valid == FALSE)
{
int Nb_Detected, Nb_Corrected;
/* On vérifie la structure */
/*
Nb_Detected = Nb_Corrected = 0;
rc = DS_DataStruct_Check_L (Root, &Nb_Detected, &Nb_Corrected, DS_stderr);
if (rc != DSS_OK)
{
sprintf (DS_Error_Msg, "Error DS_Value_Add : unable to check the data structure");
DS_Error_Print ();
DS_STRUCT_VALID_CHECK( Root_Ptr, RootDesc_Ptr);
return rc;
}
}
*/
/* On rend la structure invalide le temps de l'ajout */
RootDesc_Ptr->Valid = FALSE;
/* Ajout de la valeur */
if( ( nd_status = ND_DataStruct_Value_Add( Root_Ptr, Value_Ptr)) != NDS_OK)
@ -1354,6 +1355,7 @@ DST_Status DS_DataStruct_Value_Add_I( NDT_Root *Root_Ptr, void *Value_Ptr)
return( DSS_KO);
}
/* On rend la structure à nouveau valide */
RootDesc_Ptr->Valid = TRUE;
@ -1448,24 +1450,9 @@ DST_Status DS_DataStruct_Value_Print_I( FILE *Out_Ptr, NDT_Root *Root_Ptr, ND
va_start( user_args, Recursive_Offset);
/* On vérifie que la data structure est valide */
/*
if (RootDesc->Valid == FALSE)
{
int Nb_Detected, Nb_Corrected;
/* On vérifie la structure */
/*
Nb_Detected = Nb_Corrected = 0;
rc = DS_DataStruct_Check_L (Root, &Nb_Detected, &Nb_Corrected, DS_stderr);
if (rc != DSS_OK)
{
sprintf (DS_Error_Msg, "Error DS_DataStruct_Dump : unable to check the data structure");
DS_Error_Print ();
DS_STRUCT_VALID_CHECK( Root_Ptr, RootDesc_Ptr);
return rc;
}
}
*/
/* Affichage de la node structure */
@ -1983,21 +1970,29 @@ DST_Status DS_Free_I( NDT_Root *Root_Ptr, void *Ptr)
/* (I) Context : nom du contexte */
/* (I) Debug_Mode : mode d'affichage des messages d'erreur */
/*----------------------------------------------------------------------------*/
/*
DST_Status DS_Library_Open_L( int Instance, const char *Context, DST_Flags Debug_Mode)
{
return DS_Library_Open_I (Instance, Context, Debug_Mode);
return( DS_Library_Open_I( Instance, Context, Debug_Mode));
}
/*----------------------------------------------------------------------------*/
/* Fermeture de l'instance de la librairie */
/*----------------------------------------------------------------------------*/
/*
DST_Status DS_Library_Close_L( void)
{
return DS_Library_Close_I();
}
/*----------------------------------------------------------------------------*/
/* Définition de la sortie standard des messages d'erreur de la librairie */
/*----------------------------------------------------------------------------*/
@ -2064,6 +2059,118 @@ DST_Status DS_DataStruct_Close_L ( NDT_Root * Root, DST_Flags Close_Mode )
return DS_DataStruct_Close_I (Root, Close_Mode);
}
/*----------------------------------------------------------------------------*/
/* Destroy all data of a data structure */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/*----------------------------------------------------------------------------*/
/*
NDT_Status DS_DataStruct_Flush_L( NDT_Root *Root_Ptr)
{
DS_DataStruct_Flush_L( NDT_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 */
/*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Check_L( NDT_Root *Root_Ptr, int *Error_Detected_Nb_Ptr, int *Error_Corrected_Nb_Ptr, FILE *Out)
{
return( DS_DataStruct_Check_L( Root_Ptr, Error_Detected_Nb_Ptr, Error_Corrected_Nb_Ptr, Out));
}
/*----------------------------------------------------------------------------*/
/* Convert a data structure indexe types */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Type_Ptr: Array of index type (List, tree, ...) */
/*----------------------------------------------------------------------------*/
/*
DST_Status DS_DataStruct_Convert_L ( NDT_Root * Root, NDT_DataStruct_Type Target_Type )
{
DST_Status rc;
int Locked;
/* Verrouillage de la data structure en écriture */
/*
rc = DS_DataStruct_Lock_I (Root, SMD_WRITE, &Locked);
if (rc != DSS_OK)
{
sprintf (DS_Error_Msg, "Error DS_DataStruct_Convert : unable to lock the data structure for writing");
DS_Error_Print ();
return rc;
}
rc = DS_DataStruct_Convert_I (Root, Target_Type);
/* Déverrouillage de la data structure si besoin */
/*
if (Locked == TRUE) DS_DataStruct_Unlock_I (Root);
return rc;
}
/*----------------------------------------------------------------------------*/
/* Reorganise a data structure indexes: */
/* - Sort a non-sorted list */
/* - Rebalance a non auto-balanced tree */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/*----------------------------------------------------------------------------*/
/*
DST_Status DS_DataStruct_Reorg_L ( NDT_Root * Root )
{
DST_Status rc;
int Locked;
/* Verrouillage de la data structure en écriture */
/*
rc = DS_DataStruct_Lock_I (Root, SMD_WRITE, &Locked);
if (rc != DSS_OK)
{
sprintf (DS_Error_Msg, "Error DS_DataStruct_Reorg : unable to lock the data structure for writing");
DS_Error_Print ();
return rc;
}
rc = DS_DataStruct_Reorg_I (Root);
/* Déverrouillage de la data structure si besoin */
/*
if (Locked == TRUE) DS_DataStruct_Unlock_I (Root);
return rc;
}
/*----------------------------------------------------------------------------*/
/* Affiche les informations d'une structure de données */
/*----------------------------------------------------------------------------*/
@ -2096,37 +2203,6 @@ DST_Status DS_DataStruct_Info_Print_L ( NDT_Root * Root, FILE * Out )
return rc;
}
/*----------------------------------------------------------------------------*/
/* Réorganisation d'une structure de données */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de données à réorganiser */
/*----------------------------------------------------------------------------*/
/*
DST_Status DS_DataStruct_Reorg_L ( NDT_Root * Root )
{
DST_Status rc;
int Locked;
/* Verrouillage de la data structure en écriture */
/*
rc = DS_DataStruct_Lock_I (Root, SMD_WRITE, &Locked);
if (rc != DSS_OK)
{
sprintf (DS_Error_Msg, "Error DS_DataStruct_Reorg : unable to lock the data structure for writing");
DS_Error_Print ();
return rc;
}
rc = DS_DataStruct_Reorg_I (Root);
/* Déverrouillage de la data structure si besoin */
/*
if (Locked == TRUE) DS_DataStruct_Unlock_I (Root);
return rc;
}
/*----------------------------------------------------------------------------*/
/* Parcours de tous les noeuds d'une structure de données et exécution d'une */
/* commande sur chacun d'eux */
@ -2178,38 +2254,6 @@ DST_Status DS_DataStruct_Traverse_L ( NDT_Root * Root, NDT_Command Command, void
return rc;
}
/*----------------------------------------------------------------------------*/
/* Conversion d'une structure de données d'un type en un autre */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de données */
/* (I) Target_Type : type de structure cible */
/*----------------------------------------------------------------------------*/
/*
DST_Status DS_DataStruct_Convert_L ( NDT_Root * Root, NDT_DataStruct_Type Target_Type )
{
DST_Status rc;
int Locked;
/* Verrouillage de la data structure en écriture */
/*
rc = DS_DataStruct_Lock_I (Root, SMD_WRITE, &Locked);
if (rc != DSS_OK)
{
sprintf (DS_Error_Msg, "Error DS_DataStruct_Convert : unable to lock the data structure for writing");
DS_Error_Print ();
return rc;
}
rc = DS_DataStruct_Convert_I (Root, Target_Type);
/* Déverrouillage de la data structure si besoin */
/*
if (Locked == TRUE) DS_DataStruct_Unlock_I (Root);
return rc;
}
/*----------------------------------------------------------------------------*/
/* Affichage d'une structure de données */
/*----------------------------------------------------------------------------*/
@ -2222,19 +2266,9 @@ DST_Status DS_DataStruct_Print_L ( NDT_Root * Root, FILE * Out )
return DS_DataStruct_Traverse_L (Root, NDD_CMD_PRINT_VALUE, Out);
}
/*----------------------------------------------------------------------------*/
/* Fonction de vérification / réparation d'une structure de données */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure */
/* (O) Nb_Detected : pointeur sur le nombre d'erreurs détectées */
/* (O) Nb_Corrected : pointeur sur le nombre d'erreurs corrigées */
/* (I) Out : flux de sortie du rapport */
/*----------------------------------------------------------------------------*/
/*
DST_Status DS_DataStruct_Check_L ( NDT_Root * Root, int * Nb_Detected, int * Nb_Corrected, FILE * Out )
{
return DS_DataStruct_Check_I (Root, Nb_Detected, Nb_Corrected, Out);
}
/*----------------------------------------------------------------------------*/
/* Affiche la structure de données */

View File

@ -284,7 +284,7 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
NDT_Command_Name Command_Name;
LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Manager command: (%d) called", Command);
// LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Manager command: (%d) called", Command);
switch( Command)
{
@ -295,6 +295,8 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
Command_Name = "NDD_CMD_MANAGER_VERSION";
LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Command: [%s] called", Command_Name);
*Version_Name_Ptr = "Module Manager - DSBench";
return( NDS_OK);
@ -316,6 +318,8 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
Command_Name = "NDD_CMD_INDEX_GET";
LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Command: [%s] called", Command_Name);
switch(Cmd)
{
/*
@ -427,6 +431,8 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
Command_Name = "NDD_CMD_VALUE_COMP";
LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Command: [%s] called", Command_Name);
switch( Index_Id)
{
@ -476,6 +482,8 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
Command_Name = "NDD_CMD_VALUE_ADD";
LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Command: [%s] called", Command_Name);
/*
return( NDS_OK);
*/
@ -496,6 +504,8 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
Command_Name = "NDD_CMD_VALUE_REMOVE";
LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Command: [%s] called", Command_Name);
return( NDS_OK);
}
@ -538,6 +548,8 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
Command_Name = "NDD_CMD_VALUE_PRINT";
LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Command: [%s] called", Command_Name);
LG_LOG_INFO_2( "Id Module: (%d) Nom Module: [%s]", Module_Ptr->Id, Module_Ptr->Nom);
return( NDS_OK);
@ -581,6 +593,8 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
Command_Name = "NDD_CMD_INFO_PRINT";
LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Command: [%s] called", Command_Name);
/*
switch( (int)(Root_Ptr->Type & NDD_DS_MSK))
{
@ -642,6 +656,8 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
Command_Name = "NDD_CMD_USER_TRAVERSE";
LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Command: [%s] called", Command_Name);
/*
return( NDS_OK);
*/
@ -1008,15 +1024,15 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
Command_Exec_End_Print( File_Output, Choice, t_exec, 1);
break;
}
/*
case DS_CHECK:
{
Command_Exec_Begin_Print( File_Output, Choice);
Nb_Corrected = Nb_Detected = 0;
nb_corrected = nb_detected = 0;
t_start( t_exec);
ND_DataStruct_Check( *DS_Ptr_Ptr, &Nb_Detected, &Nb_Corrected, File_Output);
DS_DataStruct_Check( *DS_Ptr_Ptr, &nb_detected, &nb_corrected, File_Output);
t_stop( t_exec);
Command_Exec_End_Print( File_Output, Choice, t_exec, 1);
@ -1028,13 +1044,13 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
Command_Exec_Begin_Print( File_Output, Choice);
t_start( t_exec);
ND_DataStruct_Reorg( *DS_Ptr_Ptr);
DS_DataStruct_Reorg( *DS_Ptr_Ptr);
t_stop( t_exec);
Command_Exec_End_Print( File_Output, Choice, t_exec, 1);
break;
}
*/
case DS_INFO_PRINT:
{
Command_Exec_Begin_Print( File_Output, Choice);
@ -1255,10 +1271,10 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
break;
}
/*
case INDEX_TREE_OPEN:
{
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
Command_Index_Range_Get( File_Output, &low, &high, Arg1, Arg2, File_Input, Choice, "Index");
if( low != -1)
{
@ -1271,7 +1287,7 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
for( i = low; i <= high; i++)
{
ND_Index_Open( *DS_Ptr_Ptr, (NDT_Index_Id)i, idx_type_balanced_tree);
ND_Index_Open( *DS_Ptr_Ptr, (NDT_Index_Id)i, DBD_IDX_TYPE_BALANCED_TREE);
}
t_stop( t_exec);
@ -1284,7 +1300,7 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
case INDEX_CLOSE:
{
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
Command_Index_Range_Get( File_Output, &low, &high, Arg1, Arg2, File_Input, Choice, "Index");
if( low != -1)
{
@ -1307,7 +1323,7 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
break;
}
/*
case INDEX_LIST_SUBTYPE_SET:
{
int subtype;