- Add DS_OpenedDS_List_Manager & DS_DataStruct_IsOpen implementation,

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

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);