- 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:
718
lib/libdatastr.c
718
lib/libdatastr.c
@@ -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 )
|
||||
|
||||
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 )
|
||||
|
||||
DST_Status DS_Library_Close_L( void)
|
||||
{
|
||||
return DS_Library_Close_I ();
|
||||
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 */
|
||||
|
||||
Reference in New Issue
Block a user