- Add DS_OpenedDS_List_Manager & DS_DataStruct_IsOpen implementation,

- Continue DS_DataStruct_Open_I implementation.
This commit is contained in:
Arnaud G. GIBERT 2024-04-24 20:27:46 +02:00
parent 2967341251
commit 0c06f14b49
4 changed files with 589 additions and 235 deletions

View File

@ -35,6 +35,11 @@
#include <shmem.h>
/* Code retour des fonctions constituant l'API */
typedef long DST_Status;
@ -117,28 +122,40 @@ typedef int DST_Flags;
/* Masques pour récupérer des valeurs combiné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_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 SDD_NAME_LEN ( short)SMD_NAME_SIZE
#define SDD_NAME_SIZE ( SDD_NAME_LEN + 1)
/*
On utilise le pointeur 'User' de la racine de la struture pour y
rattacher des données sur le heap sous-jacent.
*/
typedef struct {
char * Heap_Name;
char * Manager_FileName;
int OpenSemID; /* Indique le nombre de processus ayant ouvert la struture */
int Heap_Owner; /* Indique si la structure est propriétaire du heap sous-jacent */
int Valid; /* Indique si la structure est valide ou non */
typedef struct DST_RootDesc
{
char *Heap_Name;
char *Manager_Name;
int OpenSemId; /* Indique le nombre de processus ayant ouvert la struture */
short Heap_Owner; /* Indique si la structure est propriétaire du heap sous-jacent */
short Valid; /* Indique si la structure est valide ou non */
} DST_RootDesc;
//char DS_Error_Msg [512];
/* Définition des alias de l'API */
#ifndef DS_MODE
@ -375,15 +392,15 @@ DSD_API DST_Status DS_DataStruct_Close_CL( NDT_Root * Root, DST_Flags Close_Mod
/*----------------------------------------------------------------------------*/
/* Affiche les informations d'une structure de données */
/* Print data structure information */
/*----------------------------------------------------------------------------*/
/* (I) Root: pointeur sur la racine de la structure de données */
/* (I) Out : flux de sortie de l'affichage */
/* (I) Stream: Output stream */
/* (I) Root_Ptr: Data structure pointer */
/*----------------------------------------------------------------------------*/
/*
DSD_API DST_Status DS_DataStruct_Info_Print_I( NDT_Root * Root, FILE * Out);
DSD_API DST_Status DS_DataStruct_Info_Print_L( NDT_Root * Root, FILE * Out);
DSD_API DST_Status DS_DataStruct_Info_Print_CL( NDT_Root * Root, FILE * Out);
DSD_API DST_Status DS_DataStruct_Info_Print_I( FILE *Out, NDT_Root *Root_Ptr);
DSD_API DST_Status DS_DataStruct_Info_Print_L( FILE *Out, NDT_Root *Root_Ptr);
DSD_API DST_Status DS_DataStruct_Info_Print_CL( FILE *Out, NDT_Root *Root_Ptr);

View File

@ -53,11 +53,11 @@
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* Ouverture d'une instance de la librairie */
/* Library instance initialisation */
/*----------------------------------------------------------------------------*/
/* (I) Instance : numéro de l'instance de la librairie */
/* (I) Context : nom du contexte */
/* (I) Debug_Mode : mode d'affichage des messages d'erreur */
/* (I) Instance: Library instance id */
/* (I) Context: Context name */
/* (I) Debug_Mode: Open library in debug mode */
/*----------------------------------------------------------------------------*/
DST_Status DS_Library_Open_I ( int Instance, const char *Context, DST_Flags Debug_Mode )
@ -87,7 +87,7 @@ DST_Status DS_Library_Open_I ( int Instance, const char *Context, DST_Flags D
if( ( lg_status = LG_Library_Open( LGD_LOG_WRITER_DEFAULT, false)) != LGS_OK)
{
fprintf( stderr, "Can't open LibLog library: (%d)\n", lg_status);
return( -1);
return( DSS_KO);
}
@ -96,9 +96,10 @@ DST_Status DS_Library_Open_I ( int Instance, const char *Context, DST_Flags D
if( ( sm_status = SM_Library_Open( Instance, Context, SMD_OPEN | sm_debug_flag)) != SMS_OK)
{
LG_LOG_ERROR_1( "Unable to open the LibShMem library: (%d)", sm_status);
return( DSS_OK);
return( DSS_KO);
}
/*
Lors de la première ouverture de la librairie LIBDATASTR,
on crée une structure locale permettant de référencer
@ -112,11 +113,7 @@ DST_Status DS_Library_Open_I ( int Instance, const char *Context, DST_Flags D
LG_LOG_ERROR_1( "Unable to create the opened data structure list: (%d)", nd_status);
SM_Library_Close (SMD_CLOSE);
return( SMS_KO);
}
else
{
// strcpy( OpenedDS_List->Manager, "DS_OpenedDS_List_Manager");
return( DSS_KO);
}
}
@ -204,15 +201,15 @@ DST_Status DS_Library_Stderr_Set_I( FILE *Out)
//DST_Status DS_DataStruct_Open_I( NDT_Root **Root, const char *DS_Name, NDT_DataStruct_Type Type, const char *Manager_FileName, size_t Segment_Size, DST_Flags Open_Mode, int Own_Values);
DST_Status DS_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, char *DS_Name, NDT_Index_Nb Index_Nb, NDT_Index_Type *Index_Type_Tab, char *Manager_FileName, size_t Segment_Size, DST_Flags Open_Mode, short Own_Value)
DST_Status DS_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, char *DS_Name, NDT_Index_Nb Index_Nb, NDT_Index_Type *Index_Type_Tab, char *Manager_Name, size_t Segment_Size, DST_Flags Open_Mode, short Own_Value)
{
DST_Status status;
SMT_Status sm_status;
NDT_Status nd_status;
SMT_Heap *heap_ptr;
SMT_DSH *dsh;
SMT_DSH *dsh_ptr;
int locked, mode;
DST_RootDesc *RootDesc, Tmp_RootDesc;
DST_RootDesc *rootdesc_ptr, rootdesc_tmp;
DST_DataStruct *Opened_DataStruct;
char *Prefixed_Name = DS_Name_Prefix( DS_Name);
union semun Sem_Ctl;
@ -241,6 +238,7 @@ DST_Status DS_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, char *DS_Name, NDT
return( DSS_ERRAPI);
}
LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Creation Mode:(%d)", mode);
switch( mode)
@ -251,7 +249,7 @@ DST_Status DS_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, char *DS_Name, NDT
/* Ouverture du heap en écriture */
if( ( status = SM_Heap_Open( Prefixed_Name, &heap_ptr, 0, SMD_OPEN | SMD_WRITE, &locked)) != SMS_OK)
if( ( status = SM_Heap_Open( Prefixed_Name, &heap_ptr, 0, ( SMD_OPEN | SMD_WRITE), &locked)) != SMS_OK)
{
LG_LOG_ERROR_2( "Unable to open the data structure heap: [%s] for writing, error: (%d)", Prefixed_Name, sm_status);
@ -260,9 +258,9 @@ DST_Status DS_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, char *DS_Name, NDT
/* Création de la node structure */
Tmp_RootDesc.Heap_Name = Prefixed_Name;
rootdesc_tmp.Heap_Name = Prefixed_Name;
if( ( nd_status = ND_DataStruct_Open( Root_Ptr_Ptr, Index_Nb, Index_Type_Tab, Manager_FileName, NULL, "DS_DataStruct_Alloc", NULL, "DS_DataStruct_Free", NULL, Own_Value, &Tmp_RootDesc)) != NDS_OK)
if( ( nd_status = ND_DataStruct_Open( Root_Ptr_Ptr, Index_Nb, Index_Type_Tab, Manager_Name, NULL, "DS_DataStruct_Alloc", NULL, "DS_DataStruct_Free", NULL, Own_Value, &rootdesc_tmp)) != NDS_OK)
{
LG_LOG_ERROR_2( "Unable to create a new node structure in the existing heap: [%s], error: (%d)", heap_ptr->Name, nd_status);
@ -272,99 +270,110 @@ DST_Status DS_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, char *DS_Name, NDT
return( SMS_KO);
}
/* Allocation de mémoire pour la description de la nouvelle data structure */
/*
rc = DS_DataStruct_Alloc (sizeof (DST_RootDesc) + strlen (Prefixed_Name) + strlen (Manager_FileName) + 2, (void **)(&RootDesc), &Tmp_RootDesc);
if (rc != DSS_OK)
if( ( status = DS_DataStruct_Alloc( (void **)( &rootdesc_ptr), sizeof( DST_RootDesc), &rootdesc_tmp)) != DSS_OK)
{
sprintf (DS_Error_Msg, "Error DS_DataStruct_Open : unable to allocate memory for the new data structure description");
DS_Error_Print ();
LG_LOG_ERROR_2( "Unable to allocate memory for the data structure description for new heap: [%s], error: (%d)", heap_ptr->Name, status);
DS_DataStruct_Free (*Root, &Tmp_RootDesc);
if (locked == TRUE) SM_Heap_Unlock (Heap);
*Root = NULL;
return rc;
SM_Heap_End( Prefixed_Name);
if( locked == TRUE) SM_Heap_Unlock( heap_ptr);
*Root_Ptr_Ptr = NULL;
return( status);
}
RootDesc->Heap_Name = (char *)((size_t)RootDesc + sizeof (DST_RootDesc) );
strcpy (RootDesc->Heap_Name, Prefixed_Name);
RootDesc->Manager_FileName = (char *)((size_t)RootDesc + sizeof (DST_RootDesc) + strlen (Prefixed_Name) + 1);
strcpy (RootDesc->Manager_FileName, Manager_FileName);
rootdesc_ptr->Heap_Name = heap_ptr->Name;
rootdesc_ptr->Manager_Name = ( *Root_Ptr_Ptr)->Manager_Name;
/* On indique que la structure n'est pas propriétaire de son heap */
/*
RootDesc->Heap_Owner = FALSE;
/*
/* On indique que la structure est valide */
/*
RootDesc->Valid = TRUE;
/*
/* On rattache la desription de la data structure à la racine */
/*
(*Root)->User = RootDesc;
/* Pour une telle data structure, on ne crée pas de sémaphore d'ouverture */
rootdesc_ptr->Heap_Owner = FALSE;
/* On indique que la structure est valide */
rootdesc_ptr->Valid = TRUE;
/* On rattache la desription de la data structure à la racine */
( *Root_Ptr_Ptr)->User_Ptr = rootdesc_ptr;
/* Déverrouillage du heap */
/*
if (Locked == TRUE)
if( locked == TRUE)
{
rc = SM_Heap_Unlock (Heap);
if (rc != SMS_OK)
if( ( sm_status = SM_Heap_Unlock( heap_ptr)) != SMS_OK)
{
sprintf (DS_Error_Msg, "Error DS_DataStruct_Open : unable to unlock the data structure heap \"%s\"", Prefixed_Name);
DS_Error_Print ();
return rc;
LG_LOG_ERROR_2( "Unable to unlock the data structure heap: [%s], error: (%d)", heap_ptr->Name, status);
return( DSS_KO);
}
}
return DSS_OK;
*/
break;
return( DSS_OK);
}
/*
case 2:
case 2:
{
/*--------------- Ouverture d'une data structure existante ------------------*/
/* Si la structure a déjà été ouverte, on ne recommence pas */
/*
rc = DS_DataStruct_IsOpen (DS_Name, Root);
if (rc == DSS_YES) return DSS_OK;
else if (DS_ERROR(rc)) return rc;
if( ( status = DS_DataStruct_IsOpen( Root_Ptr_Ptr, DS_Name)) != DSS_OK)
{
LG_LOG_ERROR_2( "Unable test data structure: [%s] state, error: (%d)", DS_Name, status);
return( status);
}
else
{
if( *Root_Ptr_Ptr != NULL)
{
return( DSS_OK);
}
}
/* Accès au heap sous-jacent en lecture */
/*
rc = SM_Heap_Open (Prefixed_Name, &Heap, 0, SMD_OPEN | SMD_READ, &Locked);
if (rc != SMS_OK)
if( ( status = SM_Heap_Open( Prefixed_Name, &heap_ptr, 0, ( SMD_OPEN | SMD_READ), &locked)) != SMS_OK)
{
sprintf (DS_Error_Msg, "Error DS_DataStruct_Open : unable to open the data structure heap \"%s\" for reading", Prefixed_Name);
DS_Error_Print ();
return rc;
LG_LOG_ERROR_2( "Unable to open the data structure heap: [%s] for reading, error: (%d)", heap_ptr->Name, status);
if( locked == TRUE) SM_Heap_Unlock( heap_ptr);
*Root_Ptr_Ptr = NULL;
return( status);
}
DSH = Heap->MHH->DSR->Head->Value;
dsh_ptr = heap_ptr->MHH->DSR->Index_Tab[ NDD_INDEX_PRIMARY].Head->Value;
/* La racine de la structure se trouve dans le premier chunk du premier segment du heap */
/*
*Root = ( NDT_Root *)((size_t)(DSH->Start) + sizeof (NDT_Node) + sizeof (SMT_Chunk));
*Root_Ptr_Ptr = (NDT_Root *)( ( size_t)( dsh_ptr->Start) + sizeof( NDT_Node) + sizeof( SMT_Chunk));
/* Chargement des fonctions manager de la structure */
/*
RootDesc = (*Root)->User;
if (!RootDesc)
rootdesc_ptr = (*Root_Ptr_Ptr)->User_Ptr;
if( !rootdesc_ptr)
{
sprintf (DS_Error_Msg, "Error DS_DataStruct_Open : data structure \"%s\" has no description defined", DS_Name);
DS_Error_Print ();
if (Locked == TRUE) SM_Heap_Unlock (Heap);
*Root = NULL;
return DSS_ERRAPI;
}
LG_LOG_ERROR_1( "Data structure [%s] has no description defined", DS_Name);
if (!RootDesc->Manager_FileName || !dlopen (( const char *)(RootDesc->Manager_FileName), RTLD_LAZY | RTLD_GLOBAL))
if( locked == TRUE) SM_Heap_Unlock( heap_ptr);
*Root_Ptr_Ptr = NULL;
return( DSS_ERRAPI);
}
/*
if( !RootDesc->Manager_Name || !dlopen (( const char *)(RootDesc->Manager_FileName), RTLD_LAZY | RTLD_GLOBAL))
{
sprintf (DS_Error_Msg, "Error DS_DataStruct_Open : unable to load the manager file %s of data structure \"%s\" (%s)", RootDesc->Manager_FileName == NULL ? "undefined" : (char *)(RootDesc->Manager_FileName), DS_Name, dlerror ());
DS_Error_Print ();
@ -372,16 +381,17 @@ DST_Status DS_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, char *DS_Name, NDT
*Root = NULL;
return DSS_ERRDLL;
}
break;
*/
break;
}
case 3:
{
/*--------------- Création d'une nouvelle structure de données dans un nouveau heap -----------------*/
if( !Manager_FileName)
if( !Manager_Name)
{
LG_LOG_ERROR_0( "The manager file name (.so) is undefined");
LG_LOG_ERROR_0( "The manager name is undefined");
return( DSS_ERRAPI);
}
@ -395,47 +405,50 @@ DST_Status DS_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, char *DS_Name, NDT
/* Création de la structure de données dans le heap */
Tmp_RootDesc.Heap_Name = Prefixed_Name;
rootdesc_tmp.Heap_Name = Prefixed_Name;
if( ( nd_status = ND_DataStruct_Open( Root_Ptr_Ptr, Index_Nb, Index_Type_Tab, Manager_FileName, NULL, "DS_DataStruct_Alloc", NULL, "DS_DataStruct_Free", NULL, Own_Value, &Tmp_RootDesc)) != NDS_OK)
if( ( nd_status = ND_DataStruct_Open( Root_Ptr_Ptr, Index_Nb, Index_Type_Tab, Manager_Name, NULL, "DS_DataStruct_Alloc", NULL, "DS_DataStruct_Free", NULL, Own_Value, &rootdesc_tmp)) != NDS_OK)
{
LG_LOG_ERROR_2( "Unable to create a new node structure in new heap: [%s], error: (%d)", heap_ptr->Name, nd_status);
SM_Heap_End( Prefixed_Name);
*Root_Ptr_Ptr = NULL;
return( SMS_KO);
}
/* Allocation de mémoire pour la description de la structure */
/*
rc = DS_DataStruct_Alloc (sizeof (DST_RootDesc) + strlen (Prefixed_Name) + strlen (Manager_FileName) + 2, (void **)(&RootDesc), &Tmp_RootDesc);
if (rc != DSS_OK)
if( ( status = DS_DataStruct_Alloc( (void **)( &rootdesc_ptr), sizeof( DST_RootDesc), &rootdesc_tmp)) != DSS_OK)
{
sprintf (DS_Error_Msg, "Error DS_DataStruct_Open : unable to allocate memory for the data structure description");
DS_Error_Print ();
SM_Heap_End (Prefixed_Name);
*Root = NULL;
return rc;
LG_LOG_ERROR_2( "Unable to allocate memory for the data structure description for new heap: [%s], error: (%d)", heap_ptr->Name, status);
SM_Heap_End( Prefixed_Name);
*Root_Ptr_Ptr = NULL;
return( status);
}
RootDesc->Heap_Name = (char *)((size_t)RootDesc + sizeof (DST_RootDesc) );
strcpy (RootDesc->Heap_Name, Prefixed_Name);
RootDesc->Manager_FileName = (char *)((size_t)RootDesc + sizeof (DST_RootDesc) + strlen (Prefixed_Name) + 1);
strcpy (RootDesc->Manager_FileName, Manager_FileName);
rootdesc_ptr->Heap_Name = heap_ptr->Name;
rootdesc_ptr->Manager_Name = ( *Root_Ptr_Ptr)->Manager_Name;
/* On indique que la structure est propriétaire du heap */
/*
RootDesc->Heap_Owner = TRUE;
rootdesc_ptr->Heap_Owner = TRUE;
/* On indique que la structure est valide */
/*
RootDesc->Valid = TRUE;
rootdesc_ptr->Valid = TRUE;
/* On rattache la desription de la data structure à la racine */
/*
(*Root)->User = RootDesc;
( *Root_Ptr_Ptr)->User_Ptr = rootdesc_ptr;
/* On crée un sémaphore pour compter le nombre de processus qui ouvrent la structure */
/*
rc = DS_Semaphore_Create (*Root);
@ -725,21 +738,29 @@ DST_Status DS_DataStruct_Close_I ( NDT_Root * Root, DST_Flags Close_Mode )
return DSS_OK;
}
/*----------------------------------------------------------------------------*/
/* Affiche les informations d'une structure de données */
/*----------------------------------------------------------------------------*/
/* (I) Root: pointeur sur la racine de la structure de données */
/* (I) Out : flux de sortie de l'affichage */
/*----------------------------------------------------------------------------*/
/*
DST_Status DS_DataStruct_Info_Print_I ( NDT_Root * Root, FILE * Out )
{
DST_Status rc;
DST_RootDesc * RootDesc = (DST_RootDesc *)(Root->User);
/*----------------------------------------------------------------------------*/
/* Print data structure information */
/*----------------------------------------------------------------------------*/
/* (I) Stream: Output stream */
/* (I) Root_Ptr: Data structure pointer */
/*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Info_Print_I( FILE *Out, NDT_Root *Root_Ptr)
{
DST_Status status;
NDT_Status nd_status;
DST_RootDesc *rootdesc_ptr = (DST_RootDesc *)(Root_Ptr->User_Ptr);
LG_LOG_INFO_5( "DatatStruct Heap_Name: [%s] Manager_Name: [%s] OpenSemId: (%d) Heap_Owner: [%s] Valid: [%s]",
rootdesc_ptr->Heap_Name, rootdesc_ptr->Manager_Name, rootdesc_ptr->OpenSemId, DSD_BOOL_VALUE_ASCII_GET( rootdesc_ptr->Heap_Owner), DSD_BOOL_VALUE_ASCII_GET( rootdesc_ptr->Valid));
/* On vérifie que la data structure est valide */
/*
if (RootDesc->Valid == FALSE)
if( rootdesc_ptr->Valid == FALSE)
{
int Nb_Detected, Nb_Corrected;
@ -755,22 +776,24 @@ DST_Status DS_DataStruct_Info_Print_I ( NDT_Root * Root, FILE * Out )
return rc;
}
*/
}
/* Affichage des informations sur la structure */
/*
rc = ND_DataStruct_Info_Print (Root, Out);
if (rc != NDS_OK)
{
sprintf (DS_Error_Msg, "Error DS_DataStruct_Info_Print : unable to print info about the data structure");
DS_Error_Print ();
return rc;
if( ( nd_status = ND_DataStruct_Info_Print( Out, Root_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 99, 0)) != NDS_OK)
{
LG_LOG_ERROR_1( "Unable to print info about the data structure: (%d)", nd_status);
return( DSS_KO);
}
return DSS_OK;
return( DSS_OK);
}
/*----------------------------------------------------------------------------*/
/* Réorganisation d'une structure de données */
/*----------------------------------------------------------------------------*/
@ -2949,24 +2972,38 @@ DST_Status DS_Free_CL ( NDT_Root * Root, void * Ptr )
/* (I) DS_Name : nom de la data structure */
/* (O) Root : adresse du pointeur sur la racine de la structure */
/*----------------------------------------------------------------------------*/
/*
DST_Status DS_DataStruct_IsOpen ( const char * DS_Name, NDT_Root ** Root )
DST_Status DS_DataStruct_IsOpen( NDT_Root **Root_Ptr_Ptr, char *DS_Name)
{
DST_Status rc;
DST_DataStruct To_Find;
NDT_Node * Node;
NDT_Status nd_status;
DST_DataStruct to_find, *found_ptr;
to_find.Name = DS_Name;
To_Find.Name = DS_Name;
if( ( nd_status = ND_DataStruct_Value_Find( (void **)&found_ptr, OpenedDS_List, &to_find)) != NDS_OK)
{
LG_LOG_ERROR_2( "Can't lookup for opened data structure: [%s], error: (%d)", DS_Name, nd_status);
rc = ND_Node_Find (OpenedDS_List, &Node, &To_Find, NULL);
if (DS_ERROR(rc)) return rc;
if (rc != NDS_OK) return DSS_NO;
*Root = ((DST_DataStruct *)(Node->Value))->Root;
return DSS_YES;
return( DSS_KO);
}
else
{
if( found_ptr == NULL)
{
LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Data structure: [%s] not found", DS_Name);
*Root_Ptr_Ptr = NULL;
}
else
{
LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Data structure: [%s] found", DS_Name);
*Root_Ptr_Ptr = found_ptr->Root_Ptr;
}
}
return( DSS_OK);
}
@ -3195,35 +3232,320 @@ DST_Status DS_Semaphore_Operate (int SemID, struct sembuf * Operations, unsigned
/*----------------------------------------------------------------------------*/
/* Fonction manager de la liste des DS ouvertes */
/*----------------------------------------------------------------------------*/
/*
NDT_Status DS_OpenedDS_List_Manager ( va_list Args )
NDT_Status DS_OpenedDS_List_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list *Args_Ptr)
{
NDT_Command Command = (NDT_Command) va_arg (Args, NDT_Command);
NDT_Command_Name Command_Name;
LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Manager command: (%d) called", Command);
switch( Command)
{
case NDD_CMD_MANAGER_VERSION:
{
ND_VA_ARG_GET( Version_Name_Ptr, *Args_Ptr, NDT_Version_Name *);
Command_Name = "NDD_CMD_MANAGER_VERSION";
*Version_Name_Ptr = "OpenedDS_List_Manager 2.0";
return( NDS_OK);
}
if (Command == NDD_CMD_COMP_VALUE)
{
DST_DataStruct * DataStruct1 = (DST_DataStruct *) va_arg (Args, void *);
DST_DataStruct * DataStruct2 = (DST_DataStruct *) va_arg (Args, void *);
long comp;
case NDD_CMD_INDEX_GET:
{
/*
ND_VA_ARG_GET( Reply_Index_Id_Ptr, *Args_Ptr, NDT_Index_Id *);
ND_VA_ARG_GET( Reply_Command_Ptr, *Args_Ptr, NDT_Command *);
ND_VA_ARG_GET( Cmd, *Args_Ptr, NDT_Command);
ND_VA_ARG_GET( Value_Ptr, *Args_Ptr, void *);
*/
ND_VA_ARG_GET( Reply_Index_Id_Ptr, *Args_Ptr, NDT_Index_Id *);
ND_VA_ARG_GET( Reply_Command_Ptr, *Args_Ptr, NDT_Command *);
ND_VA_ARG_GET( Cmd, *Args_Ptr, NDT_Command);
ND_VA_ARG_GET( Value_Ptr, *Args_Ptr, void *);
Command_Name = "NDD_CMD_INDEX_GET";
switch(Cmd)
{
/*
case NDT_CMD_SOME_USER_CMD:
{
*Reply_Index_Id_Ptr = 0;
*Reply_Command_Ptr = NDD_CMD_SOME_OTHER_CMD;
break;
}
...
*/
default:
{
*Reply_Index_Id_Ptr = Index_Id;
*Reply_Command_Ptr = Cmd;
break;
}
}
return( NDS_OK);
}
va_end (Args);
case NDD_CMD_VALUE_ALLOC:
{
/*
ND_VA_ARG_GET( Value_Ptr_Ptr, *Args_Ptr, void **);
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
ND_VA_ARG_GET( user_data, user_args, user_type);
ND_VA_ARG_GET( ..., user_args, ...);
ND_VA_LIST_CLOSE( user_args);
*/
comp = strcmp (DataStruct1->Name, DataStruct2->Name);
Command_Name = "NDD_CMD_VALUE_ALLOC";
if (comp < 0) return NDS_LOWER;
if (comp > 0) return NDS_GREATER;
return NDS_EQUAL;
}
LG_LOG_TRACE_0( LGD_LOG_LEVEL_DEFAULT, "CMD_VALUE_ALLOC called...");
if (Command == NDD_CMD_DELETE_VALUE)
{
NDT_Root * Root = va_arg (Args, NDT_Root *);
DST_DataStruct * DataStruct = (DST_DataStruct *) va_arg (Args, void *);
return( DSS_OK);
}
case NDD_CMD_VALUE_FREE:
{
/*
ND_VA_ARG_GET( Value_Ptr, *Args_Ptr, void *);
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
ND_VA_ARG_GET( user_data, user_args, user_type);
ND_VA_ARG_GET( ..., user_args, ...);
ND_VA_LIST_CLOSE( user_args);
*/
ND_VA_ARG_GET( Value_Ptr, *Args_Ptr, void *);
free (DataStruct->Name);
free (DataStruct);
}
Command_Name = "NDD_CMD_VALUE_FREE";
return NDS_OK;
/*
DS_Free( Root_Ptr, Value_Ptr);
*/
return( NDS_OK);
}
case NDD_CMD_VALUE_COMP:
{
/*
ND_VA_ARG_GET( Value1_Ptr, *Args_Ptr, void *);
ND_VA_ARG_GET( Value2_Ptr, *Args_Ptr, void *);
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
ND_VA_ARG_GET( user_data, user_args, user_type);
ND_VA_ARG_GET( ..., user_args, ...);
ND_VA_LIST_CLOSE( user_args);
*/
ND_VA_ARG_GET( DataStruct1_Ptr, *Args_Ptr, DST_DataStruct *);
ND_VA_ARG_GET( DataStruct2_Ptr, *Args_Ptr, DST_DataStruct *);
int comp;
Command_Name = "NDD_CMD_VALUE_COMP";
switch( Index_Id)
{
case 0:
{
comp = strcmp( DataStruct1_Ptr->Name, DataStruct2_Ptr->Name);
if( comp < 0)
{
return( NDS_LOWER);
}
else
{
if( comp > 0)
{
return( NDS_GREATER);
}
else
{
return( NDS_EQUAL);
}
}
}
default:
{
LG_LOG_ERROR_1( "Unknown comp index: (%d)", Index_Id);
return( NDS_KO);
}
}
return( NDS_OK);
}
case NDD_CMD_VALUE_ADD:
{
/*
ND_VA_ARG_GET( Value_Ptr, *Args_Ptr, void *);
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
ND_VA_ARG_GET( user_data, user_args, user_type);
ND_VA_ARG_GET( ..., user_args, ...);
ND_VA_LIST_CLOSE( user_args);
*/
Command_Name = "NDD_CMD_VALUE_ADD";
return( NDS_OK);
}
case NDD_CMD_VALUE_REMOVE:
{
/*
ND_VA_ARG_GET( Value_Ptr, *Args_Ptr, void *);
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
ND_VA_ARG_GET( user_data, user_args, user_type);
ND_VA_ARG_GET( ..., user_args, ...);
ND_VA_LIST_CLOSE( user_args);
*/
Command_Name = "NDD_CMD_VALUE_REMOVE";
return( NDS_OK);
}
case NDD_CMD_VALUE_PRINT:
{
/*
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
ND_VA_LIST_OPEN( lib_args, *Args_Ptr);
ND_VA_ARG_GET( Out, lib_args, FILE *);
ND_VA_ARG_GET( Recursive_Mode, lib_args, NDT_Recursive_Mode);
ND_VA_ARG_GET( Recursive_Depth, lib_args, NDT_Recursive_Depth);
ND_VA_ARG_GET( Recursive_Offset, lib_args, NDT_Recursive_Offset);
ND_VA_LIST_OPEN( user_args, lib_args);
ND_VA_ARG_GET( user_data, user_args, user_type);
ND_VA_ARG_GET( ..., user_args, ...);
ND_VA_LIST_CLOSE( user_args);
ND_VA_LIST_CLOSE( lib_args);
void *Value_Ptr = Node_Ptr->Value;
*/
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
ND_VA_LIST_OPEN( lib_args, *Args_Ptr);
ND_VA_ARG_GET( Out, lib_args, FILE *);
ND_VA_ARG_GET( Recursive_Mode, lib_args, NDT_Recursive_Mode);
ND_VA_ARG_GET( Recursive_Depth, lib_args, NDT_Recursive_Depth);
ND_VA_ARG_GET( Recursive_Offset, lib_args, NDT_Recursive_Offset);
ND_VA_LIST_CLOSE( lib_args);
DST_DataStruct *DataStruct_Ptr = (DST_DataStruct *)Node_Ptr->Value;
Command_Name = "NDD_CMD_VALUE_PRINT";
LG_LOG_INFO_2( "Name: [%s] Root: (%p)", DataStruct_Ptr->Name, DataStruct_Ptr->Root_Ptr);
return( NDS_OK);
}
case NDD_CMD_INFO_PRINT:
{
/*
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
ND_VA_LIST_OPEN( lib_args, *Args_Ptr);
ND_VA_ARG_GET( Out, lib_args, FILE *);
ND_VA_ARG_GET( Recursive_Mode, lib_args, NDT_Recursive_Mode);
ND_VA_ARG_GET( Recursive_Depth, lib_args, NDT_Recursive_Depth);
ND_VA_ARG_GET( Recursive_Offset, lib_args, NDT_Recursive_Offset);
ND_VA_LIST_OPEN( user_args, lib_args);
ND_VA_ARG_GET( user_data, user_args, user_type);
ND_VA_ARG_GET( ..., user_args, ...);
ND_VA_LIST_CLOSE( user_args);
ND_VA_LIST_CLOSE( lib_args);
*/
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
ND_VA_LIST_OPEN( lib_args, *Args_Ptr);
ND_VA_ARG_GET( Out, lib_args, FILE *);
ND_VA_ARG_GET( Recursive_Mode, lib_args, NDT_Recursive_Mode);
ND_VA_ARG_GET( Recursive_Depth, lib_args, NDT_Recursive_Depth);
ND_VA_ARG_GET( Recursive_Offset, lib_args, NDT_Recursive_Offset);
ND_VA_LIST_CLOSE( lib_args);
Command_Name = "NDD_CMD_INFO_PRINT";
return( NDS_OK);
}
case NDD_CMD_USER_TRAVERSE:
{
/*
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
ND_VA_ARG_GET( user_data, user_args, user_type);
ND_VA_ARG_GET( ..., user_args, ...);
ND_VA_LIST_CLOSE( user_args);
void *Value_Ptr = Node_Ptr->Value;
*/
Command_Name = "NDD_CMD_USER_TRAVERSE";
/*
return( NDS_OK);
*/
}
default:
{
LG_LOG_ERROR_1( "Manager called with an undefined command: (%d)", Command);
return( NDS_ERRAPI);
}
}
LG_LOG_ERROR_2( "Manager internal error with command: (%d) name: [%s]", Command, Command_Name);
return( NDS_OK);
}
*/

View File

@ -86,15 +86,20 @@ typedef union semun {
unsigned short int * array;
} semun;
/* Liste des data structure ouvertes par le processus courant */
NDT_Root * OpenedDS_List;
NDT_Root *OpenedDS_List;
typedef struct {
NDT_Root * Root;
char * Name;
typedef struct DST_DataStruct
{
NDT_Root *Root_Ptr;
char *Name;
} DST_DataStruct;
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* Fonctions privées de la librairie */
@ -143,9 +148,14 @@ static char *DS_Name_Prefix (const char *Name);
/*----------------------------------------------------------------------------*/
/* Teste si une data structure a déjà été ouverte par le processus courant */
/*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_IsOpen (const char * DS_Name, NDT_Root ** Root);
DST_Status DS_DataStruct_IsOpen( NDT_Root **Root_Ptr_Ptr, char *DS_Name);
/*----------------------------------------------------------------------------*/
/* Fonction manager de la liste des DS ouvertes */
/*----------------------------------------------------------------------------*/
NDT_Status DS_OpenedDS_List_Manager (va_list Args);
NDT_Status DS_OpenedDS_List_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list *Args_Ptr);

View File

@ -63,7 +63,7 @@ extern char * strdup ( const char *);
#define SHOW 13
#define CHECK 14
#define MANAGER_FILE_NAME "dsbench.so"
char DataStruct_Name [100];
char menu [1000];
@ -83,7 +83,7 @@ NDT_Status Module_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command,
void Menu_Init ( NDT_Root *);
int Menu_Print ( NDT_Root *);
/* Mesure des temps d'exécution */
/* Mesure des temps d'exécution */
typedef struct {
double sec;
@ -96,7 +96,7 @@ typedef struct {
T_Cpt t_exec;
/* Définition des valeurs attachées aux noeuds de la structure */
/* Définition des valeurs attachées aux noeuds de la structure */
typedef struct {
int Id;
@ -116,6 +116,8 @@ 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);
switch( Command)
{
case NDD_CMD_MANAGER_VERSION:
@ -125,7 +127,7 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
Command_Name = "NDD_CMD_MANAGER_VERSION";
*Version_Name_Ptr = "$Revision: 2.13 $ $Name: libnode-2_2_0-1 $ $Date: 2010/06/06 21:26:31 $ $Author: agibert $";
*Version_Name_Ptr = "Module Manager - DSBench";
return( NDS_OK);
}
@ -266,24 +268,25 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
{
if( Value1_Ptr->Id < Value2_Ptr->Id)
{
return(NDS_LOWER);
return( NDS_LOWER);
}
else
{
if( Value1_Ptr->Id > Value2_Ptr->Id)
{
return(NDS_GREATER);
return( NDS_GREATER);
}
else
{
return(NDS_EQUAL);
return( NDS_EQUAL);
}
}
}
default:
{
printf( "Unknown COMP idx (%d) !\n", Index_Id);
LG_LOG_ERROR_1( "Unknown comp index: (%d)", Index_Id);
return( NDS_KO);
}
}
@ -364,7 +367,7 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
ND_VA_LIST_CLOSE( lib_args);
T_Module *Module_Ptr = (T_Module *)Node_Ptr->Value;
T_Module *Module_Ptr = (T_Module *)Node_Ptr->Value;
Command_Name = "NDD_CMD_VALUE_PRINT";
@ -418,7 +421,7 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
{
switch ((int)(Root_Ptr->Type & NDD_MN_MSK))
{
case NDD_MN_ORDERED: Root_Type = strdup ("liste triée"); break;
case NDD_MN_ORDERED: Root_Type = strdup ("liste triée"); break;
case NDD_MN_FILO: Root_Type = strdup ("liste FILO"); break;
case NDD_MN_FIFO: Root_Type = strdup ("liste FIFO"); break;
default: Root_Type = strdup ("inconnu"); break;
@ -430,8 +433,8 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
{
switch( (int)(Root_Ptr->Type & NDD_MN_MSK))
{
case NDD_MN_AUTO_EQU: Root_Type = strdup ("arbre auto-équilibré"); break;
default: Root_Type = strdup ("arbre non auto-équilibré"); break;
case NDD_MN_AUTO_EQU: Root_Type = strdup ("arbre auto-équilibré"); break;
default: Root_Type = strdup ("arbre non auto-équilibré"); break;
}
break;
}
@ -445,7 +448,7 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
Root_Type, RootDesc->Heap_Name, RootDesc->Manager_FileName, Root_Ptr->Node_Number);
if( ( Root->Type & NDD_DS_MSK) == NDD_DS_TREE)
fprintf( Out, "\t- Profondeur maxi = %ld\n\t- Profondeur mini = %ld\n\t- Différence maximale autorisée = %ld\n\t- Nombre d'équilibrages = %ld\n", \
fprintf( Out, "\t- Profondeur maxi = %ld\n\t- Profondeur mini = %ld\n\t- Différence maximale autorisée = %ld\n\t- Nombre d'équilibrages = %ld\n", \
Root_Ptr->Max_Depth, Root_Ptr->Min_Depth, Root_Ptr->Max_Dif, Root_Ptr->Nb_Equ);
if( Root_Type) free( Root_Type);
@ -478,7 +481,7 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
}
default:
{
{
LG_LOG_ERROR_1( "Manager called with an undefined command: (%d)", Command);
return( NDS_ERRAPI);
}
@ -501,7 +504,7 @@ void Menu_Init( NDT_Root *Root )
sprintf (menu, "Menu :\n");
sprintf (buf, " - %d) %-30s\n", QUIT, "Quitter");
strcat (menu, buf);
sprintf (buf, " - %d) %-30s", CREATE_STRUCT, "Création de structure");
sprintf (buf, " - %d) %-30s", CREATE_STRUCT, "Création de structure");
strcat (menu, buf);
sprintf (buf, " - %d) %-30s\n", OPEN_STRUCT, "Ouverture de structure");
strcat (menu, buf);
@ -509,13 +512,13 @@ void Menu_Init( NDT_Root *Root )
{
sprintf (buf, " - %d) %-30s", CLOSE_STRUCT, "Fermer la structure");
strcat (menu, buf);
sprintf (buf, " - %d) %-30s\n", DELETE_STRUCT, "Détruire la structure");
sprintf (buf, " - %d) %-30s\n", DELETE_STRUCT, "Détruire la structure");
strcat (menu, buf);
sprintf (buf, " - %d) %-30s", ADD_VALUE, "Ajout de valeurs");
strcat (menu, buf);
sprintf (buf, " - %d) %-30s\n", REMOVE_VALUE, "Suppression de valeurs");
strcat (menu, buf);
sprintf (buf, " - %d) %-30s\n", FIND_VALUE, "Recherche de valeurs aléatoires");
sprintf (buf, " - %d) %-30s\n", FIND_VALUE, "Recherche de valeurs aléatoires");
strcat (menu, buf);
if( ND_INDEX_TYPE_LIST_IS( Root, NDD_INDEX_PRIMARY))
@ -527,17 +530,17 @@ void Menu_Init( NDT_Root *Root )
}
else
{
sprintf (buf, " - %d) %-30s", CONVERT_TO_LIST, "Conversion en liste triée");
sprintf (buf, " - %d) %-30s", CONVERT_TO_LIST, "Conversion en liste triée");
strcat (menu, buf);
}
sprintf (buf, " - %d) %-30s\n", REORG, "Réorganisation");
sprintf (buf, " - %d) %-30s\n", REORG, "Réorganisation");
strcat (menu, buf);
sprintf (buf, " - %d) %-30s", INFO, "Informations sur la structure");
strcat (menu, buf);
sprintf (buf, " - %d) %-30s\n", SHOW, "Affichage de la structure");
strcat (menu, buf);
sprintf (buf, " - %d) %-30s\n", CHECK, "Vérification de la structure");
sprintf (buf, " - %d) %-30s\n", CHECK, "Vérification de la structure");
strcat (menu, buf);
}
}
@ -604,8 +607,9 @@ int main( int argc, char **argv)
}
else
{
if( DS_Library_Open (0, NULL, DSD_DEBUG_ALL) != NDS_OK)
if( DS_Library_Open( 0, NULL, DSD_DEBUG_ALL) != DSS_OK)
{
LG_LOG_ERROR_0( "Can't open DataStr library");
rc = -1;
}
else
@ -618,7 +622,7 @@ int main( int argc, char **argv)
{
case CREATE_STRUCT:
{
fprintf( stdout, "\nNom de la structure à créer ? ");
fprintf( stdout, "\nNom de la structure à créer ? ");
fgets( DataStruct_Name, 100, stdin);
if( strlen( DataStruct_Name) < 2)
{
@ -627,7 +631,7 @@ int main( int argc, char **argv)
else
{
DataStruct_Name[ strlen( DataStruct_Name) - 1] = 0;
if( ( status = DS_DataStruct_Open( &Root_Ptr, DataStruct_Name, 1, &index_type, MANAGER_FILE_NAME, 0, DSD_CREATE, TRUE)) != DSS_OK)
if( ( status = DS_DataStruct_Open( &Root_Ptr, DataStruct_Name, 1, &index_type, "Module_Manager", 0, DSD_CREATE, TRUE)) != DSS_OK)
{
LG_LOG_ERROR_1( "Can't create data structure: (%d)", status);
}
@ -647,7 +651,7 @@ int main( int argc, char **argv)
if (DS_DataStruct_Close (Root, DSD_DESTROY) == DSS_KO) printf ("\nNOK\n");
else
{
printf ("\nStructure détruite : OK\n");
printf ("\nStructure détruite : OK\n");
Root = NULL;
}
@ -656,7 +660,7 @@ int main( int argc, char **argv)
case OPEN_STRUCT:
{
fprintf (stdout, "\nNom de la structure à ouvrir ? ");
fprintf (stdout, "\nNom de la structure à ouvrir ? ");
gets (DataStruct_Name);
if (DS_DataStruct_Open (DataStruct_Name, &Root, 0, NULL, 0, DSD_OPEN, TRUE) == NDS_KO)
@ -672,7 +676,7 @@ int main( int argc, char **argv)
if (DS_DataStruct_Close (Root, DSD_CLOSE) == DSS_KO) printf ("\nNOK\n");
else
{
printf ("\nStructure fermée : OK\n");
printf ("\nStructure fermée : OK\n");
Root = NULL;
}
@ -693,13 +697,13 @@ int main( int argc, char **argv)
m = atoi (tmp);
if (m < n)
{
printf ("\nEntrées non valides\n");
printf ("\nEntrées non valides\n");
break;
}
}
else
{
printf ("\nEntrées non valides\n");
printf ("\nEntrées non valides\n");
break;
}
@ -718,14 +722,14 @@ int main( int argc, char **argv)
DS_DataStruct_Unlock (Root);
fprintf (stdout, "\n%d valeur(s) recherchée(s) en %.4f sec (%.2f select/sec)\n", \
fprintf (stdout, "\n%d valeur(s) recherchée(s) en %.4f sec (%.2f select/sec)\n", \
m - n + 1, t_exec.sec, (m - n + 1) / t_exec.sec);
break;
}
case ADD_VALUE:
{
fprintf (stdout, "\nPlage des valeurs à ajouter (?->?) : ");
fprintf (stdout, "\nPlage des valeurs à ajouter (?->?) : ");
gets (buf);
tmp = strstr (buf, "->");
if (tmp != NULL)
@ -737,19 +741,19 @@ int main( int argc, char **argv)
m = atoi (tmp);
if (m < n)
{
printf ("\nEntrées non valides\n");
printf ("\nEntrées non valides\n");
break;
}
}
else
{
printf ("\nEntrées non valides\n");
printf ("\nEntrées non valides\n");
break;
}
DS_DataStruct_Lock (Root, DSD_WRITE, &Locked);
fprintf (stdout, "\nOrdre d'ajout (croissant=0 décroissant=1) ? ");
fprintf (stdout, "\nOrdre d'ajout (croissant=0 décroissant=1) ? ");
gets (buf);
choice = atoi (buf);
if (choice == 0)
@ -779,7 +783,7 @@ int main( int argc, char **argv)
DS_DataStruct_Unlock (Root);
fprintf (stdout, "\n%d valeur(s) ajoutée(s) en %.4f sec (%.2f ajouts/sec)\n", m - n + 1, \
fprintf (stdout, "\n%d valeur(s) ajoutée(s) en %.4f sec (%.2f ajouts/sec)\n", m - n + 1, \
t_exec.sec, (m - n + 1) / t_exec.sec);
break;
}
@ -787,7 +791,7 @@ int main( int argc, char **argv)
case REMOVE_VALUE:
{
Nb_Removed = 0;
fprintf (stdout, "\nPlage des valeurs à supprimer (?->?) : ");
fprintf (stdout, "\nPlage des valeurs à supprimer (?->?) : ");
gets (buf);
tmp = strstr (buf, "->");
if (tmp != NULL)
@ -799,19 +803,19 @@ int main( int argc, char **argv)
m = atoi (tmp);
if (m < n)
{
printf ("\nEntrées non valides\n");
printf ("\nEntrées non valides\n");
break;
}
}
else
{
printf ("\nEntrées non valides\n");
printf ("\nEntrées non valides\n");
break;
}
DS_DataStruct_Lock (Root, DSD_WRITE, &Locked);
fprintf (stdout, "\nOrdre de suppression (croissant=0 décroissant=1) ? ");
fprintf (stdout, "\nOrdre de suppression (croissant=0 décroissant=1) ? ");
gets (buf);
choice = atoi (buf);
if (choice == 0)
@ -851,14 +855,14 @@ int main( int argc, char **argv)
DS_DataStruct_Unlock (Root);
fprintf (stdout, "\n%d valeur(s) supprimée(s) en %.4f sec (%.2f suppressions/sec)\n",\
fprintf (stdout, "\n%d valeur(s) supprimée(s) en %.4f sec (%.2f suppressions/sec)\n",\
Nb_Removed, t_exec.sec, (m - n + 1) / t_exec.sec);
break;
}
case CHG_LIST_TYPE:
{
fprintf (stdout, "\nType de liste (FIFO=0 ; FILO=1 ; triée=2) ? ");
fprintf (stdout, "\nType de liste (FIFO=0 ; FILO=1 ; triée=2) ? ");
gets (buf);
choice = atoi (buf);
DS_DataStruct_Lock (Root, DSD_WRITE, &Locked);
@ -888,7 +892,7 @@ int main( int argc, char **argv)
DS_DataStruct_Reorg (Root);
DS_DataStruct_Unlock (Root);
t_stop (t_exec);
fprintf (stdout, "\nRéorganisation de la structure en %.4f sec\n", t_exec.sec);
fprintf (stdout, "\nRéorganisation de la structure en %.4f sec\n", t_exec.sec);
break;
}
@ -914,14 +918,15 @@ int main( int argc, char **argv)
break;
}
*/
case INFO:
{
DS_DataStruct_Lock (Root, DSD_READ, &Locked);
DS_DataStruct_Info_Print (Root, stdout);
DS_DataStruct_Unlock (Root);
// DS_DataStruct_Lock (Root, DSD_READ, &Locked);
DS_DataStruct_Info_Print( stdout, Root_Ptr);
// DS_DataStruct_Unlock (Root);
break;
}
/*
case SHOW:
{
DS_DataStruct_Lock (Root, DSD_READ, &Locked);
@ -939,7 +944,7 @@ int main( int argc, char **argv)
*/
default:
{
fprintf (stdout, "\nChoix %d non défini\n", choice);
fprintf (stdout, "\nChoix %d non défini\n", choice);
}
}
choice = Menu_Print( Root_Ptr);