2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* libdatastr.c */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* This file is part of LibDataStr. */
/* */
/* LibDataStr is free software: you can redistribute it and/or modify it */
/* under the terms of the GNU Lesser General Public License as published */
/* by the Free Software Foundation, either version 3 of the License, or */
/* (at your option) any later version. */
/* */
/* LibDataStr is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Lesser General Public License for more details. */
/* */
/* You should have received a copy of the GNU Lesser General Public */
/* License along with LibDataStr. If not, see */
/* <https://www.gnu.org/licenses/>. */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* Includes */
/*----------------------------------------------------------------------------*/
# define _LIBDATASTR_C_
2000-07-28 17:30:55 +02:00
/* Utilisation des API sans v<> rification des arguments */
# define ND_MODE 1
# define SM_MODE 1
# include <libdatastr.h>
2024-04-22 18:37:50 +02:00
2024-04-22 00:24:37 +02:00
//VER_INFO_EXPORT (libdatastr,"$Revision: 1.1 $", "$Name: $",__FILE__,"$Author: smas $")
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* FONCTIONS PUBLIQUES */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* FONCTIONS OPTIMISATION MAXIMALE (DS_MODE = 2) */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
2024-04-24 20:27:46 +02:00
/* Library instance initialisation */
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
2024-04-24 20:27:46 +02:00
/* (I) Instance: Library instance id */
/* (I) Context: Context name */
/* (I) Debug_Mode: Open library in debug mode */
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
2024-04-22 18:37:50 +02:00
DST_Status DS_Library_Open_I ( int Instance , const char * Context , DST_Flags Debug_Mode )
2000-07-28 17:30:55 +02:00
{
2024-04-22 18:37:50 +02:00
DST_Status rc ;
LGT_Status lg_status ;
SMT_Status sm_status ;
NDT_Status nd_status ;
int sm_debug_flag = SMD_DEBUG_NONE ;
NDT_Index_Type index_type = ( NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED ) ;
2000-07-28 17:30:55 +02:00
/* D<> finition du mode debug */
2024-04-22 18:37:50 +02:00
if ( Debug_Mode & DSD_DEBUG )
2000-07-28 17:30:55 +02:00
{
2024-04-22 18:37:50 +02:00
DS_stderr = stderr ;
sm_debug_flag = SMD_DEBUG ;
2000-07-28 17:30:55 +02:00
}
2024-04-22 18:37:50 +02:00
else if ( Debug_Mode & DSD_DEBUG_ALL )
2000-07-28 17:30:55 +02:00
{
2024-04-22 18:37:50 +02:00
DS_stderr = stderr ;
sm_debug_flag = SMD_DEBUG_ALL ;
2000-07-28 17:30:55 +02:00
}
2024-04-22 18:37:50 +02:00
if ( ( lg_status = LG_Library_Open ( LGD_LOG_WRITER_DEFAULT , false ) ) ! = LGS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-22 18:37:50 +02:00
fprintf ( stderr , " Can't open LibLog library: (%d) \n " , lg_status ) ;
2024-04-24 20:27:46 +02:00
return ( DSS_KO ) ;
2024-04-22 18:37:50 +02:00
}
2000-07-28 17:30:55 +02:00
2024-04-22 18:37:50 +02:00
/* Ouverture de la librairie LIBSHMEM */
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 ) ;
2024-04-24 20:27:46 +02:00
return ( DSS_KO ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-24 20:27:46 +02:00
2000-07-28 17:30:55 +02:00
/*
2024-04-22 18:37:50 +02:00
Lors de la premi <EFBFBD> re ouverture de la librairie LIBDATASTR ,
on cr <EFBFBD> e une structure locale permettant de r <EFBFBD> f <EFBFBD> rencer
les data structures ouvertes .
*/
2000-07-28 17:30:55 +02:00
2024-04-22 18:37:50 +02:00
if ( DS_Open_Counter = = 0 )
2000-07-28 17:30:55 +02:00
{
2024-04-22 18:37:50 +02:00
if ( ( nd_status = ND_DataStruct_Open ( & OpenedDS_List , 1 , & index_type , " DS_OpenedDS_List_Manager " , NULL , NULL , NULL , NULL , NULL , TRUE , NULL ) ) ! = NDS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-22 18:37:50 +02:00
LG_LOG_ERROR_1 ( " Unable to create the opened data structure list: (%d) " , nd_status ) ;
2000-07-28 17:30:55 +02:00
SM_Library_Close ( SMD_CLOSE ) ;
2024-04-22 18:37:50 +02:00
2024-04-24 20:27:46 +02:00
return ( DSS_KO ) ;
2000-07-28 17:30:55 +02:00
}
}
DS_Open_Counter + + ;
2024-04-22 18:37:50 +02:00
return ( DSS_OK ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Fermeture de l'instance de la librairie */
/*----------------------------------------------------------------------------*/
2024-04-22 18:37:50 +02:00
DST_Status DS_Library_Close_I ( void )
2000-07-28 17:30:55 +02:00
{
2024-04-22 18:37:50 +02:00
NDT_Status nd_status ;
SMT_Status sm_status ;
LGT_Status lg_status ;
2000-07-28 17:30:55 +02:00
2024-04-22 18:37:50 +02:00
2000-07-28 17:30:55 +02:00
/*
A la derni <EFBFBD> re fermeture de la librairie LIBDATASTR , on d <EFBFBD> truit
la structure locale qui r <EFBFBD> f <EFBFBD> rence les data structures ouvertes .
2024-04-22 18:37:50 +02:00
*/
2000-07-28 17:30:55 +02:00
2024-04-22 18:37:50 +02:00
if ( DS_Open_Counter = = 1 )
{
if ( ( nd_status = ND_DataStruct_Close ( OpenedDS_List ) ) ! = NDS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-22 18:37:50 +02:00
LG_LOG_ERROR_1 ( " Unable to close the opened data structure list: (%d) " , nd_status ) ;
return ( DSS_KO ) ;
2000-07-28 17:30:55 +02:00
}
}
2024-04-22 18:37:50 +02:00
2000-07-28 17:30:55 +02:00
/* Fermeture de la librairie LIBSHMEM */
2024-04-22 18:37:50 +02:00
if ( ( sm_status = SM_Library_Close ( SMD_CLOSE ) ) ! = SMS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-22 18:37:50 +02:00
LG_LOG_ERROR_1 ( " Unable to close the LibShMem library: (%d) " , sm_status ) ;
return ( DSS_KO ) ;
2000-07-28 17:30:55 +02:00
}
DS_Open_Counter - - ;
2024-04-22 18:37:50 +02:00
if ( ( lg_status = LG_Library_Close ( false ) ) ! = LGS_OK )
{
fprintf ( stderr , " Can't close LibLog library: (%d) \n " , lg_status ) ;
return ( DSS_KO ) ;
}
return ( DSS_OK ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* D<> finition de la sortie standard des messages d'erreur de la librairie */
/*----------------------------------------------------------------------------*/
/* (I) Out : flux de sortie des messages d'erreur */
/*----------------------------------------------------------------------------*/
2024-04-22 18:37:50 +02:00
DST_Status DS_Library_Stderr_Set_I ( FILE * Out )
2000-07-28 17:30:55 +02:00
{
DS_stderr = Out ;
2024-04-22 18:37:50 +02:00
return ( DSS_OK ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Cr<43> ation / ouverture d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (O) Root : adresse du pointeur sur la racine de la structure */
2024-04-23 17:10:37 +02:00
/* (I) DS_Name : nom de la structure */
2024-04-22 00:24:37 +02:00
/* (I) Type : type de la structure de donn<6E> es */
/* (I) Manager_FileName : nom du fichier qui d<> finit les fonctions manager */
/* (I) Segment_Size : taille ds segments du heap sous-jacent */
/* (I) Open_Mode : mode d'ouverture de la structure */
2024-04-23 17:10:37 +02:00
/* (I) Own_Value : indique si la structure poss<73> de ses valeurs */
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
2024-04-23 17:10:37 +02:00
//ND_DataStruct_Open( &OpenedDS_List, 1, &index_type, "DS_OpenedDS_List_Manager", NULL, NULL, NULL, NULL, NULL, TRUE, NULL)) != NDS_OK)
//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);
2024-04-24 20:27:46 +02:00
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 )
2000-07-28 17:30:55 +02:00
{
2024-04-23 17:10:37 +02:00
DST_Status status ;
SMT_Status sm_status ;
NDT_Status nd_status ;
2024-04-27 20:00:00 +02:00
2024-04-23 17:10:37 +02:00
SMT_Heap * heap_ptr ;
2024-04-24 20:27:46 +02:00
SMT_DSH * dsh_ptr ;
2024-04-27 20:00:00 +02:00
2024-04-23 17:10:37 +02:00
int locked , mode ;
2024-04-24 20:27:46 +02:00
DST_RootDesc * rootdesc_ptr , rootdesc_tmp ;
2024-04-27 20:00:00 +02:00
DST_DataStruct * opened_datastruct_ptr ;
2024-04-28 19:59:38 +02:00
char prefixed_name [ DSD_NAME_SIZE ] ;
2024-04-23 17:10:37 +02:00
union semun Sem_Ctl ;
2000-07-28 17:30:55 +02:00
2024-04-28 19:59:38 +02:00
DS_Name_Prefix ( prefixed_name , DS_Name ) ;
2024-04-23 17:10:37 +02:00
* Root_Ptr_Ptr = NULL ;
2000-07-28 17:30:55 +02:00
/* On d<> finit ce qu'on va faire en fonction du mode d'ouverture demand<6E> et de ce qui existe d<> j<EFBFBD> ou non */
2024-04-23 17:10:37 +02:00
2024-04-28 19:59:38 +02:00
if ( SM_Heap_Exist ( prefixed_name ) = = SMS_YES )
2000-07-28 17:30:55 +02:00
{
2024-04-23 17:10:37 +02:00
if ( DSD_MSK_OPEN ( Open_Mode ) ) mode = 2 ;
else if ( DSD_MSK_NEW ( Open_Mode ) ) mode = 1 ;
2000-07-28 17:30:55 +02:00
else
{
2024-04-23 17:10:37 +02:00
LG_LOG_ERROR_1 ( " The data structure: [%s] already exists and (Flags & DSD_OPEN & DSD_NEW) is false " , DS_Name ) ;
2000-07-28 17:30:55 +02:00
2024-04-23 17:10:37 +02:00
return ( DSS_ERRAPI ) ;
2000-07-28 17:30:55 +02:00
}
}
2024-04-23 17:10:37 +02:00
else if ( DSD_MSK_CREATE ( Open_Mode ) ) mode = 3 ;
2000-07-28 17:30:55 +02:00
else
{
2024-04-23 17:10:37 +02:00
LG_LOG_ERROR_1 ( " The data structure: [%s] does no exist and (Flags & DSD_CREATE) is false " , DS_Name ) ;
2000-07-28 17:30:55 +02:00
2024-04-23 17:10:37 +02:00
return ( DSS_ERRAPI ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-24 20:27:46 +02:00
2024-04-23 17:10:37 +02:00
LG_LOG_TRACE_1 ( LGD_LOG_LEVEL_DEFAULT , " Creation Mode:(%d) " , mode ) ;
switch ( mode )
2000-07-28 17:30:55 +02:00
{
case 1 :
2024-04-23 17:10:37 +02:00
{
2024-04-22 00:24:37 +02:00
/*--------------- Cr<43> ation d'une nouvelle data structure dans un heap existant -------------*/
2000-07-28 17:30:55 +02:00
/* Ouverture du heap en <20> criture */
2024-04-23 17:10:37 +02:00
2024-04-28 19:59:38 +02:00
if ( ( status = SM_Heap_Open ( prefixed_name , & heap_ptr , 0 , ( SMD_OPEN | SMD_WRITE ) , & locked ) ) ! = SMS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable to open the data structure heap: [%s] for writing, status: (%d) " , prefixed_name , sm_status ) ;
2000-07-28 17:30:55 +02:00
2024-04-23 17:10:37 +02:00
return ( SMS_KO ) ;
2000-07-28 17:30:55 +02:00
}
/* Cr<43> ation de la node structure */
2024-04-23 17:10:37 +02:00
2024-04-28 19:59:38 +02:00
strncpy ( rootdesc_tmp . Heap_Name , prefixed_name , DSD_NAME_LEN ) ;
rootdesc_tmp . Heap_Name [ DSD_NAME_LEN ] = ' \0 ' ;
2000-07-28 17:30:55 +02:00
2024-04-24 20:27:46 +02:00
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 )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable to create a new node structure in the existing heap: [%s], status: (%d) " , heap_ptr - > Name , nd_status ) ;
2000-07-28 17:30:55 +02:00
2024-04-28 19:59:38 +02:00
if ( locked = = TRUE )
{
if ( ( sm_status = SM_Heap_Unlock ( heap_ptr ) ) ! = SMS_OK )
{
LG_LOG_ERROR_2 ( " Unable to unlock the data structure heap: [%s], status: (%d) " , heap_ptr - > Name , sm_status ) ;
}
}
2024-04-23 17:10:37 +02:00
* Root_Ptr_Ptr = NULL ;
2000-07-28 17:30:55 +02:00
2024-04-23 17:10:37 +02:00
return ( SMS_KO ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-24 20:27:46 +02:00
2000-07-28 17:30:55 +02:00
/* Allocation de m<> moire pour la description de la nouvelle data structure */
2024-04-24 20:27:46 +02:00
if ( ( status = DS_DataStruct_Alloc ( ( void * * ) ( & rootdesc_ptr ) , sizeof ( DST_RootDesc ) , & rootdesc_tmp ) ) ! = DSS_OK )
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable to allocate memory for the data structure description for new heap: [%s], status: (%d) " , heap_ptr - > Name , status ) ;
/*
Strange : why end the heap here ?
2000-07-28 17:30:55 +02:00
2024-04-28 19:59:38 +02:00
if ( ( sm_status = SM_Heap_End ( prefixed_name ) ) ! = SMS_OK )
{
LG_LOG_ERROR_2 ( " Unable to remove the heap: [%s], status: (%d) " , prefixed_name , sm_status ) ;
}
*/
if ( locked = = TRUE )
{
if ( ( sm_status = SM_Heap_Unlock ( heap_ptr ) ) ! = SMS_OK )
{
LG_LOG_ERROR_2 ( " Unable to unlock the data structure heap: [%s], status: (%d) " , heap_ptr - > Name , sm_status ) ;
}
}
2024-04-24 20:27:46 +02:00
* Root_Ptr_Ptr = NULL ;
return ( status ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-28 19:59:38 +02:00
strncpy ( rootdesc_ptr - > Heap_Name , prefixed_name , DSD_NAME_LEN ) ;
rootdesc_ptr - > Heap_Name [ DSD_NAME_LEN ] = ' \0 ' ;
rootdesc_ptr - > Manager_Name = ( * Root_Ptr_Ptr ) - > Manager_Name ;
2024-04-24 20:27:46 +02:00
/* On indique que la structure n'est pas propri<72> taire de son heap */
2000-07-28 17:30:55 +02:00
2024-04-24 20:27:46 +02:00
rootdesc_ptr - > Heap_Owner = FALSE ;
2000-07-28 17:30:55 +02:00
2024-04-24 20:27:46 +02:00
2000-07-28 17:30:55 +02:00
/* On indique que la structure est valide */
2024-04-24 20:27:46 +02:00
rootdesc_ptr - > Valid = TRUE ;
2000-07-28 17:30:55 +02:00
/* On rattache la desription de la data structure <20> la racine */
2024-04-24 20:27:46 +02:00
( * Root_Ptr_Ptr ) - > User_Ptr = rootdesc_ptr ;
2000-07-28 17:30:55 +02:00
/* D<> verrouillage du heap */
2024-04-24 20:27:46 +02:00
if ( locked = = TRUE )
2000-07-28 17:30:55 +02:00
{
2024-04-24 20:27:46 +02:00
if ( ( sm_status = SM_Heap_Unlock ( heap_ptr ) ) ! = SMS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable to unlock the data structure heap: [%s], status: (%d) " , heap_ptr - > Name , sm_status ) ;
2024-04-24 20:27:46 +02:00
return ( DSS_KO ) ;
2000-07-28 17:30:55 +02:00
}
}
2024-04-24 20:27:46 +02:00
return ( DSS_OK ) ;
2024-04-23 17:10:37 +02:00
}
2000-07-28 17:30:55 +02:00
2024-04-24 20:27:46 +02:00
case 2 :
{
2024-04-22 00:24:37 +02:00
/*--------------- Ouverture d'une data structure existante ------------------*/
2000-07-28 17:30:55 +02:00
/* Si la structure a d<> j<EFBFBD> <20> t<EFBFBD> ouverte, on ne recommence pas */
2024-04-24 20:27:46 +02:00
if ( ( status = DS_DataStruct_IsOpen ( Root_Ptr_Ptr , DS_Name ) ) ! = DSS_OK )
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable test data structure: [%s] state, status: (%d) " , DS_Name , status ) ;
2024-04-24 20:27:46 +02:00
return ( status ) ;
}
else
{
if ( * Root_Ptr_Ptr ! = NULL )
{
return ( DSS_OK ) ;
}
}
2000-07-28 17:30:55 +02:00
/* Acc<63> s au heap sous-jacent en lecture */
2024-04-24 20:27:46 +02:00
2024-04-28 19:59:38 +02:00
if ( ( status = SM_Heap_Open ( prefixed_name , & heap_ptr , 0 , ( SMD_OPEN | SMD_READ ) , & locked ) ) ! = SMS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable to open the data structure heap: [%s] for reading, status: (%d) " , heap_ptr - > Name , status ) ;
if ( locked = = TRUE )
{
if ( ( sm_status = SM_Heap_Unlock ( heap_ptr ) ) ! = SMS_OK )
{
LG_LOG_ERROR_2 ( " Unable to unlock the data structure heap: [%s], status: (%d) " , heap_ptr - > Name , sm_status ) ;
}
}
2024-04-24 20:27:46 +02:00
* Root_Ptr_Ptr = NULL ;
return ( status ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-24 20:27:46 +02:00
dsh_ptr = heap_ptr - > MHH - > DSR - > Index_Tab [ NDD_INDEX_PRIMARY ] . Head - > Value ;
2000-07-28 17:30:55 +02:00
2024-04-24 20:27:46 +02:00
2000-07-28 17:30:55 +02:00
/* La racine de la structure se trouve dans le premier chunk du premier segment du heap */
2024-04-24 20:27:46 +02:00
* Root_Ptr_Ptr = ( NDT_Root * ) ( ( size_t ) ( dsh_ptr - > Start ) + sizeof ( NDT_Node ) + sizeof ( SMT_Chunk ) ) ;
2000-07-28 17:30:55 +02:00
/* Chargement des fonctions manager de la structure */
2024-04-24 20:27:46 +02:00
rootdesc_ptr = ( * Root_Ptr_Ptr ) - > User_Ptr ;
if ( ! rootdesc_ptr )
2000-07-28 17:30:55 +02:00
{
2024-04-24 20:27:46 +02:00
LG_LOG_ERROR_1 ( " Data structure [%s] has no description defined " , DS_Name ) ;
2000-07-28 17:30:55 +02:00
2024-04-28 19:59:38 +02:00
if ( locked = = TRUE )
{
if ( ( sm_status = SM_Heap_Unlock ( heap_ptr ) ) ! = SMS_OK )
{
LG_LOG_ERROR_2 ( " Unable to unlock the data structure heap: [%s], status: (%d) " , heap_ptr - > Name , sm_status ) ;
}
}
2024-04-24 20:27:46 +02:00
* Root_Ptr_Ptr = NULL ;
return ( DSS_ERRAPI ) ;
}
/*
if ( ! RootDesc - > Manager_Name | | ! dlopen ( ( const char * ) ( RootDesc - > Manager_FileName ) , RTLD_LAZY | RTLD_GLOBAL ) )
2000-07-28 17:30:55 +02:00
{
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 ( ) ;
if ( Locked = = TRUE ) SM_Heap_Unlock ( Heap ) ;
* Root = NULL ;
return DSS_ERRDLL ;
}
2024-04-23 17:10:37 +02:00
*/
2024-04-28 19:59:38 +02:00
2024-04-24 20:27:46 +02:00
break ;
}
2000-07-28 17:30:55 +02:00
case 3 :
2024-04-23 17:10:37 +02:00
{
2024-04-22 00:24:37 +02:00
/*--------------- Cr<43> ation d'une nouvelle structure de donn<6E> es dans un nouveau heap -----------------*/
2024-04-23 17:10:37 +02:00
2024-04-24 20:27:46 +02:00
if ( ! Manager_Name )
2000-07-28 17:30:55 +02:00
{
2024-04-24 20:27:46 +02:00
LG_LOG_ERROR_0 ( " The manager name is undefined " ) ;
2024-04-23 17:10:37 +02:00
return ( DSS_ERRAPI ) ;
2000-07-28 17:30:55 +02:00
}
/* Cr<43> ation d'un nouveau heap */
2024-04-23 17:10:37 +02:00
2024-04-28 19:59:38 +02:00
if ( ( sm_status = SM_Heap_Open ( prefixed_name , & heap_ptr , Segment_Size , ( SMD_CREATE | SMD_WRITE ) , & locked ) ) ! = SMS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable to create a heap for the data structure [%s], status: (%d) " , DS_Name , sm_status ) ;
2024-04-23 17:10:37 +02:00
return ( sm_status ) ;
2000-07-28 17:30:55 +02:00
}
/* Cr<43> ation de la structure de donn<6E> es dans le heap */
2024-04-23 17:10:37 +02:00
2024-04-28 19:59:38 +02:00
strncpy ( rootdesc_tmp . Heap_Name , prefixed_name , DSD_NAME_LEN ) ;
rootdesc_tmp . Heap_Name [ DSD_NAME_LEN ] = ' \0 ' ;
2000-07-28 17:30:55 +02:00
2024-04-24 20:27:46 +02:00
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 )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable to create a new node structure in new heap: [%s], status: (%d) " , heap_ptr - > Name , nd_status ) ;
if ( ( sm_status = SM_Heap_End ( prefixed_name ) ) ! = SMS_OK )
{
LG_LOG_ERROR_2 ( " Unable to remove the heap: [%s], status: (%d) " , prefixed_name , sm_status ) ;
}
2024-04-24 20:27:46 +02:00
2024-04-23 17:10:37 +02:00
* Root_Ptr_Ptr = NULL ;
return ( SMS_KO ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-24 20:27:46 +02:00
2000-07-28 17:30:55 +02:00
/* Allocation de m<> moire pour la description de la structure */
2024-04-24 20:27:46 +02:00
if ( ( status = DS_DataStruct_Alloc ( ( void * * ) ( & rootdesc_ptr ) , sizeof ( DST_RootDesc ) , & rootdesc_tmp ) ) ! = DSS_OK )
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable to allocate memory for the data structure description for new heap: [%s], status: (%d) " , heap_ptr - > Name , status ) ;
if ( ( sm_status = SM_Heap_End ( prefixed_name ) ) ! = SMS_OK )
{
LG_LOG_ERROR_2 ( " Unable to remove the heap: [%s], status: (%d) " , prefixed_name , sm_status ) ;
}
2000-07-28 17:30:55 +02:00
2024-04-24 20:27:46 +02:00
* Root_Ptr_Ptr = NULL ;
return ( status ) ;
}
2000-07-28 17:30:55 +02:00
2024-04-28 19:59:38 +02:00
strncpy ( rootdesc_ptr - > Heap_Name , prefixed_name , DSD_NAME_LEN ) ;
rootdesc_ptr - > Heap_Name [ DSD_NAME_LEN ] = ' \0 ' ;
rootdesc_ptr - > Manager_Name = ( * Root_Ptr_Ptr ) - > Manager_Name ;
2024-04-24 20:27:46 +02:00
2000-07-28 17:30:55 +02:00
/* On indique que la structure est propri<72> taire du heap */
2024-04-24 20:27:46 +02:00
rootdesc_ptr - > Heap_Owner = TRUE ;
2000-07-28 17:30:55 +02:00
/* On indique que la structure est valide */
2024-04-24 20:27:46 +02:00
rootdesc_ptr - > Valid = TRUE ;
2000-07-28 17:30:55 +02:00
/* On rattache la desription de la data structure <20> la racine */
2024-04-24 20:27:46 +02:00
( * Root_Ptr_Ptr ) - > User_Ptr = rootdesc_ptr ;
2000-07-28 17:30:55 +02:00
/* On cr<63> e un s<> maphore pour compter le nombre de processus qui ouvrent la structure */
2024-04-27 20:00:00 +02:00
if ( ( status = DS_Semaphore_Create ( * Root_Ptr_Ptr ) ) ! = DSS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable to create a semaphore for the data structure: [%s], status: (%d) " , DS_Name , status ) ;
2024-04-27 20:00:00 +02:00
2024-04-28 19:59:38 +02:00
if ( ( sm_status = SM_Heap_End ( prefixed_name ) ) ! = SMS_OK )
{
LG_LOG_ERROR_2 ( " Unable to remove the heap: [%s], status: (%d) " , prefixed_name , sm_status ) ;
}
2024-04-27 20:00:00 +02:00
* Root_Ptr_Ptr = NULL ;
return ( status ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-27 20:00:00 +02:00
2000-07-28 17:30:55 +02:00
break ;
2024-04-23 17:10:37 +02:00
}
2000-07-28 17:30:55 +02:00
default :
2024-04-23 17:10:37 +02:00
{
2000-07-28 17:30:55 +02:00
break ;
2024-04-23 17:10:37 +02:00
}
2000-07-28 17:30:55 +02:00
}
2024-04-27 20:00:00 +02:00
2000-07-28 17:30:55 +02:00
/* On incr<63> mente le s<> maphore qui compte le nombre de processus qui ouvrent la structure */
2024-04-27 20:00:00 +02:00
if ( ( status = DS_Semaphore_Operate ( rootdesc_ptr - > OpenSemId , DS_SemOp_Open , 1 ) ) ! = DSS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable to incremente the semaphore of data structure: [%s], status: (%d) " , DS_Name , status ) ;
2000-07-28 17:30:55 +02:00
2024-04-28 19:59:38 +02:00
if ( locked = = TRUE )
{
if ( ( sm_status = SM_Heap_Unlock ( heap_ptr ) ) ! = SMS_OK )
{
LG_LOG_ERROR_2 ( " Unable to unlock the data structure heap: [%s], status: (%d) " , heap_ptr - > Name , sm_status ) ;
}
}
2000-07-28 17:30:55 +02:00
2024-04-27 20:00:00 +02:00
if ( mode = = 3 )
2000-07-28 17:30:55 +02:00
{
2024-04-27 20:00:00 +02:00
semctl ( rootdesc_ptr - > OpenSemId , 0 , IPC_RMID , Sem_Ctl ) ;
2024-04-28 19:59:38 +02:00
if ( ( sm_status = SM_Heap_End ( prefixed_name ) ) ! = SMS_OK )
{
LG_LOG_ERROR_2 ( " Unable to remove the heap: [%s], status: (%d) " , prefixed_name , sm_status ) ;
}
2024-04-27 20:00:00 +02:00
}
else
{
DS_Semaphore_Operate ( rootdesc_ptr - > OpenSemId , DS_SemOp_Close , 1 ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-27 20:00:00 +02:00
* Root_Ptr_Ptr = NULL ;
2000-07-28 17:30:55 +02:00
2024-04-27 20:00:00 +02:00
return ( status ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-27 20:00:00 +02:00
2000-07-28 17:30:55 +02:00
/* On ajoute la data structure <20> la liste des structures ouvertes par le processus courant */
2024-04-27 20:00:00 +02:00
if ( ( nd_status = ND_Value_Alloc ( ( void * * ) & opened_datastruct_ptr , OpenedDS_List , DS_Name , Root_Ptr_Ptr ) ) ! = NDS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable to alloc a new opened data structure element: [%s], status: (%d) " , DS_Name , nd_status ) ;
2000-07-28 17:30:55 +02:00
2024-04-28 19:59:38 +02:00
if ( locked = = TRUE )
{
if ( ( sm_status = SM_Heap_Unlock ( heap_ptr ) ) ! = SMS_OK )
{
LG_LOG_ERROR_2 ( " Unable to unlock the data structure heap: [%s], status: (%d) " , heap_ptr - > Name , sm_status ) ;
}
}
2000-07-28 17:30:55 +02:00
2024-04-27 20:00:00 +02:00
if ( mode = = 3 )
2000-07-28 17:30:55 +02:00
{
2024-04-27 20:00:00 +02:00
semctl ( rootdesc_ptr - > OpenSemId , 0 , IPC_RMID , Sem_Ctl ) ;
2024-04-28 19:59:38 +02:00
if ( ( sm_status = SM_Heap_End ( prefixed_name ) ) ! = SMS_OK )
{
LG_LOG_ERROR_2 ( " Unable to remove the heap: [%s], status: (%d) " , prefixed_name , sm_status ) ;
}
2024-04-27 20:00:00 +02:00
}
else
{
DS_Semaphore_Operate ( rootdesc_ptr - > OpenSemId , DS_SemOp_Close , 1 ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-27 20:00:00 +02:00
* Root_Ptr_Ptr = NULL ;
2000-07-28 17:30:55 +02:00
2024-04-27 20:00:00 +02:00
return ( DSS_KO ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-27 20:00:00 +02:00
if ( ( nd_status = ND_DataStruct_Value_Add ( OpenedDS_List , ( void * ) opened_datastruct_ptr ) ) ! = NDS_OK )
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable to add an new data structure element: [%s] to the opened structure list, status: (%d) " , DS_Name , status ) ;
2024-04-27 20:00:00 +02:00
if ( ( nd_status = ND_Value_Free ( OpenedDS_List , ( void * ) opened_datastruct_ptr ) ) ! = NDS_OK )
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable to free a new opened data structure element: [%s], status: (%d) " , DS_Name , nd_status ) ;
2024-04-27 20:00:00 +02:00
}
2024-04-28 19:59:38 +02:00
if ( locked = = TRUE )
{
if ( ( sm_status = SM_Heap_Unlock ( heap_ptr ) ) ! = SMS_OK )
{
LG_LOG_ERROR_2 ( " Unable to unlock the data structure heap: [%s], status: (%d) " , heap_ptr - > Name , sm_status ) ;
}
}
2024-04-27 20:00:00 +02:00
if ( mode = = 3 )
{
semctl ( rootdesc_ptr - > OpenSemId , 0 , IPC_RMID , Sem_Ctl ) ;
2024-04-28 19:59:38 +02:00
if ( ( sm_status = SM_Heap_End ( prefixed_name ) ) ! = SMS_OK )
{
LG_LOG_ERROR_2 ( " Unable to remove the heap: [%s], status: (%d) " , prefixed_name , sm_status ) ;
}
2024-04-27 20:00:00 +02:00
}
else
{
DS_Semaphore_Operate ( rootdesc_ptr - > OpenSemId , DS_SemOp_Close , 1 ) ;
}
* Root_Ptr_Ptr = NULL ;
2000-07-28 17:30:55 +02:00
2024-04-27 20:00:00 +02:00
return ( DSS_KO ) ;
}
2000-07-28 17:30:55 +02:00
/* D<> verrouillage du heap */
2024-04-27 20:00:00 +02:00
if ( locked = = TRUE )
2000-07-28 17:30:55 +02:00
{
2024-04-27 20:00:00 +02:00
if ( sm_status = ( SM_Heap_Unlock ( heap_ptr ) ) ! = SMS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable to unlock the data structure heap: [%s], status: (%d) " , prefixed_name , sm_status ) ;
2000-07-28 17:30:55 +02:00
2024-04-27 20:00:00 +02:00
if ( ( nd_status = ND_DataStruct_Value_Remove ( OpenedDS_List , opened_datastruct_ptr ) ) ! = NDS_OK )
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable to remove a data structure element: [%s] to the opened structure list, status: (%d) " , DS_Name , status ) ;
2024-04-27 20:00:00 +02:00
}
if ( ( nd_status = ND_Value_Free ( OpenedDS_List , opened_datastruct_ptr ) ) ! = NDS_OK )
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable to free a new opened data structure element: [%s], status: (%d) " , DS_Name , nd_status ) ;
2024-04-27 20:00:00 +02:00
}
if ( mode = = 3 )
{
semctl ( rootdesc_ptr - > OpenSemId , 0 , IPC_RMID , Sem_Ctl ) ;
2024-04-28 19:59:38 +02:00
if ( ( sm_status = SM_Heap_End ( prefixed_name ) ) ! = SMS_OK )
{
LG_LOG_ERROR_2 ( " Unable to remove the heap: [%s], status: (%d) " , prefixed_name , sm_status ) ;
}
2024-04-27 20:00:00 +02:00
}
else
2000-07-28 17:30:55 +02:00
{
2024-04-27 20:00:00 +02:00
DS_Semaphore_Operate ( rootdesc_ptr - > OpenSemId , DS_SemOp_Close , 1 ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-27 20:00:00 +02:00
* Root_Ptr_Ptr = NULL ;
2000-07-28 17:30:55 +02:00
2024-04-27 20:00:00 +02:00
return ( DSS_KO ) ;
2000-07-28 17:30:55 +02:00
}
}
2024-04-27 20:00:00 +02:00
2024-04-23 17:10:37 +02:00
return ( DSS_OK ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-22 00:24:37 +02:00
2024-04-22 18:37:50 +02:00
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Verrouillage d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure */
/* (I) Lock_Mode : type de verrou <20> poser sur la structure */
/* (O) Locked : verrou effectif (TRUE ou FALSE) */
/*----------------------------------------------------------------------------*/
2024-04-29 12:08:11 +02:00
DST_Status DS_DataStruct_Lock_I ( NDT_Root * Root_Ptr , DST_Flags Lock_Mode , int * Locked )
2000-07-28 17:30:55 +02:00
{
2024-04-29 12:08:11 +02:00
char * Heap_Name = ( ( DST_RootDesc * ) ( Root_Ptr - > User_Ptr ) ) - > Heap_Name ;
2000-07-28 17:30:55 +02:00
2024-04-29 12:08:11 +02:00
SMT_Status sm_status ;
SMT_Heap * heap_ptr ;
2000-07-28 17:30:55 +02:00
/* R<> ouverture du heap sous-jacent (rafra<72> chissement des segments) + verrouillage */
2024-04-29 12:08:11 +02:00
if ( ( sm_status = SM_Heap_Open ( Heap_Name , & heap_ptr , 0 , ( SMD_OPEN | Lock_Mode ) , Locked ) ) ! = SMS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-29 12:08:11 +02:00
LG_LOG_ERROR_3 ( " Unable to reopen the data structure heap: [%s] for [%s], status: (%d) " ,
Heap_Name , ( DSD_MSK_READ ( Lock_Mode ) ? " reading " : " writing " ) , sm_status ) ;
2000-07-28 17:30:55 +02:00
2024-04-29 12:08:11 +02:00
return ( DSS_KO ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-29 12:08:11 +02:00
return ( DSS_OK ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-29 12:08:11 +02:00
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* D<> verrouillage d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure */
/*----------------------------------------------------------------------------*/
2024-04-29 12:08:11 +02:00
DST_Status DS_DataStruct_Unlock_I ( NDT_Root * Root_Ptr )
2000-07-28 17:30:55 +02:00
{
2024-04-29 12:08:11 +02:00
char * Heap_Name = ( ( DST_RootDesc * ) ( Root_Ptr - > User_Ptr ) ) - > Heap_Name ;
2000-07-28 17:30:55 +02:00
2024-04-29 12:08:11 +02:00
SMT_Status sm_status ;
SMT_Heap * heap_ptr ;
if ( ( sm_status = SM_Heap_IsOpen ( Heap_Name , & heap_ptr ) ) ! = SMS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-29 12:08:11 +02:00
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 ) ;
2000-07-28 17:30:55 +02:00
2024-04-29 12:08:11 +02:00
return ( DSS_KO ) ;
}
2000-07-28 17:30:55 +02:00
}
2024-04-29 12:08:11 +02:00
if ( ( sm_status = SM_Heap_Unlock ( heap_ptr ) ) ! = SMS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-29 12:08:11 +02:00
LG_LOG_ERROR_2 ( " Unable to unlock the data structure heap: [%s], status: (%d) " , Heap_Name , sm_status ) ;
2000-07-28 17:30:55 +02:00
2024-04-29 12:08:11 +02:00
return ( DSS_KO ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-29 12:08:11 +02:00
return ( DSS_OK ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-29 12:08:11 +02:00
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Fermeture d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
2000-07-28 17:30:55 +02:00
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es <20> fermer */
2024-04-22 00:24:37 +02:00
/* (I) Close_Mode : mode de fermeture de la structure (destruction ou non) */
/*----------------------------------------------------------------------------*/
2024-04-28 19:59:38 +02:00
DST_Status DS_DataStruct_Close_I ( NDT_Root * Root_Ptr , DST_Flags Close_Mode )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
DST_RootDesc * RootDesc_Ptr = ( DST_RootDesc * ) ( Root_Ptr - > User_Ptr ) ;
2000-07-28 17:30:55 +02:00
2024-04-28 19:59:38 +02:00
DST_Status status ;
NDT_Status nd_status ;
SMT_Status sm_status ;
SMT_Heap * heap_ptr ;
char heap_name [ DSD_NAME_SIZE ] , * ds_name ;
DST_DataStruct to_remove , * opened_datastruct_ptr ;
union semun sem_ctl ;
2000-07-28 17:30:55 +02:00
2024-04-28 19:59:38 +02:00
strcpy ( heap_name , RootDesc_Ptr - > Heap_Name ) ;
ds_name = strstr ( heap_name , DS_PREFIX ) ;
if ( ds_name ) ds_name + = strlen ( DS_PREFIX ) + 1 ;
else ds_name = heap_name ;
2000-07-28 17:30:55 +02:00
2024-04-28 19:59:38 +02:00
if ( Close_Mode = = DSD_DESTROY ) /* Destruction de la data structure */
{
2000-07-28 17:30:55 +02:00
/* La data structure est-elle propri<72> taire du heap sous-jacent ? */
2024-04-28 19:59:38 +02:00
if ( RootDesc_Ptr - > Heap_Owner = = TRUE )
2000-07-28 17:30:55 +02:00
{
/* On v<> rifie qu'aucun autre processus n'a ouvert la data structure */
2024-04-28 19:59:38 +02:00
if ( ( status = DS_Semaphore_Operate ( RootDesc_Ptr - > OpenSemId , DS_SemOp_Destroy , 2 ) ) ! = DSS_OK )
{
LG_LOG_ERROR_1 ( " Unable to destroy the data structure: [%s] because it is opened by another process " , ds_name ) ;
2000-07-28 17:30:55 +02:00
2024-04-28 19:59:38 +02:00
return ( status ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-28 19:59:38 +02:00
2000-07-28 17:30:55 +02:00
/* On supprime la structure proprement (toutes les valeurs sont supprim<69> es les unes apr<70> s les autres) */
2024-04-28 19:59:38 +02:00
2024-04-29 12:08:11 +02:00
if ( ( nd_status = ND_DataStruct_Close ( Root_Ptr ) ) ! = NDS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable to close the node structure of data structure: [%s], status: (%d) " , ds_name , nd_status ) ;
2000-07-28 17:30:55 +02:00
2024-04-28 19:59:38 +02:00
return ( DSS_KO ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-29 12:08:11 +02:00
2000-07-28 17:30:55 +02:00
/* Suppression du s<> maphore */
2024-04-28 19:59:38 +02:00
semctl ( RootDesc_Ptr - > OpenSemId , 0 , IPC_RMID , sem_ctl ) ;
2000-07-28 17:30:55 +02:00
/* On supprime maintenant le heap */
2024-04-28 19:59:38 +02:00
if ( ( sm_status = SM_Heap_End ( heap_name ) ) ! = SMS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable to remove the heap: [%s], status: (%d) " , heap_name , sm_status ) ;
2000-07-28 17:30:55 +02:00
2024-04-28 19:59:38 +02:00
return ( DSS_KO ) ;
2000-07-28 17:30:55 +02:00
}
}
else
{
/*
2024-04-29 12:08:11 +02:00
Dans le cas o <EFBFBD> la data structure n ' est pas propri <EFBFBD> taire du heap sous - jacent ,
on ne peut pas garantir qu ' aucun autre processus ne l ' a ouverte .
On la supprime donc sans contr <EFBFBD> le .
*/
2024-04-28 19:59:38 +02:00
if ( ( nd_status = ND_DataStruct_Close ( Root_Ptr ) ) ! = NDS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable to close the node structure of data structure: [%s], status: (%d) " , ds_name , nd_status ) ;
return ( DSS_KO ) ;
}
2000-07-28 17:30:55 +02:00
2024-04-28 19:59:38 +02:00
if ( ( status = DS_DataStruct_Free ( RootDesc_Ptr , ( void * ) RootDesc_Ptr ) ) ! = DSS_OK )
{
LG_LOG_ERROR_2 ( " Unable to free data structure: [%s], status: (%d) " , ds_name , status ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-29 12:08:11 +02:00
return ( status ) ;
2000-07-28 17:30:55 +02:00
}
}
else /* Fermeture simple de la data structure */
2024-04-28 19:59:38 +02:00
{
2000-07-28 17:30:55 +02:00
/* On d<> cr<63> mente le s<> maphore qui compte le nombre de processus ayant ouvert la data structure */
2024-04-28 19:59:38 +02:00
if ( ( status = DS_Semaphore_Operate ( RootDesc_Ptr - > OpenSemId , DS_SemOp_Close , 1 ) ) ! = DSS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_1 ( " Unable to decremente the semaphore of data structure: [%s] " , ds_name ) ;
2000-07-28 17:30:55 +02:00
2024-04-28 19:59:38 +02:00
return ( status ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-28 19:59:38 +02:00
2000-07-28 17:30:55 +02:00
/* Fermeture simple du heap */
2024-04-28 19:59:38 +02:00
if ( ( sm_status = SM_Heap_IsOpen ( heap_name , & heap_ptr ) ) ! = SMS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable to check if heap: [%s] is open, status: (%d) " , heap_name , sm_status ) ;
2000-07-28 17:30:55 +02:00
2024-04-28 19:59:38 +02:00
return ( DSS_KO ) ;
}
else
{
if ( heap_ptr ! = NULL )
{
if ( ( sm_status = SM_Heap_Close ( heap_ptr ) ) ! = SMS_OK )
{
LG_LOG_ERROR_2 ( " Unable to close heap: [%s], status: (%d) " , heap_name , sm_status ) ;
return ( DSS_KO ) ;
}
2000-07-28 17:30:55 +02:00
}
}
}
2024-04-28 19:59:38 +02:00
2000-07-28 17:30:55 +02:00
/* Suppression de la data structure de la liste des structures ouvertes */
2024-04-28 19:59:38 +02:00
to_remove . Name = ds_name ;
if ( ( nd_status = ND_DataStruct_Value_Find ( ( void * * ) & opened_datastruct_ptr , OpenedDS_List , & to_remove ) ) ! = NDS_OK )
{
LG_LOG_ERROR_2 ( " Unable to find data struct element: [%s] from opened structure list, status: (%d) " , ds_name , nd_status ) ;
return ( DSS_KO ) ;
}
else
{
if ( ( nd_status = ND_DataStruct_Value_Remove ( OpenedDS_List , opened_datastruct_ptr ) ) ! = NDS_OK )
{
LG_LOG_ERROR_2 ( " Unable to remove data struct element: [%s] from opened structure list, status: (%d) " , ds_name , nd_status ) ;
return ( DSS_KO ) ;
}
else
{
if ( ( nd_status = ND_Value_Free ( OpenedDS_List , opened_datastruct_ptr ) ) ! = NDS_OK )
{
LG_LOG_ERROR_2 ( " Unable to free data struct element: [%s] from opened structure list, status: (%d) " , ds_name , nd_status ) ;
return ( DSS_KO ) ;
}
}
}
return ( DSS_OK ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-24 20:27:46 +02:00
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
2024-04-24 20:27:46 +02:00
/* Print data structure information */
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
2024-04-24 20:27:46 +02:00
/* (I) Stream: Output stream */
/* (I) Root_Ptr: Data structure pointer */
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
2024-04-24 20:27:46 +02:00
DST_Status DS_DataStruct_Info_Print_I ( FILE * Out , NDT_Root * Root_Ptr )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
DST_RootDesc * RootDesc_Ptr = ( DST_RootDesc * ) ( Root_Ptr - > User_Ptr ) ;
2024-04-24 20:27:46 +02:00
DST_Status status ;
NDT_Status nd_status ;
2000-07-28 17:30:55 +02:00
2024-04-24 20:27:46 +02:00
LG_LOG_INFO_5 ( " DatatStruct Heap_Name: [%s] Manager_Name: [%s] OpenSemId: (%d) Heap_Owner: [%s] Valid: [%s] " ,
2024-04-28 19:59:38 +02:00
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 ) ) ;
2024-04-24 20:27:46 +02:00
2000-07-28 17:30:55 +02:00
/* On v<> rifie que la data structure est valide */
2024-04-24 20:27:46 +02:00
2024-04-28 19:59:38 +02:00
if ( RootDesc_Ptr - > Valid = = FALSE )
2000-07-28 17:30:55 +02:00
{
int Nb_Detected , Nb_Corrected ;
/* On v<> rifie la structure */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
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 ;
}
2024-04-24 20:27:46 +02:00
*/
2000-07-28 17:30:55 +02:00
}
2024-04-24 20:27:46 +02:00
2000-07-28 17:30:55 +02:00
/* Affichage des informations sur la structure */
2024-04-24 20:27:46 +02:00
if ( ( nd_status = ND_DataStruct_Info_Print ( Out , Root_Ptr , NDD_RECURSIVE_MODE_PARENT_CHILD , 99 , 0 ) ) ! = NDS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-24 20:27:46 +02:00
LG_LOG_ERROR_1 ( " Unable to print info about the data structure: (%d) " , nd_status ) ;
2000-07-28 17:30:55 +02:00
2024-04-24 20:27:46 +02:00
return ( DSS_KO ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-28 19:59:38 +02:00
/* Dump SM */
SM_Library_Dump ( stderr ) ;
2024-04-24 20:27:46 +02:00
return ( DSS_OK ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-24 20:27:46 +02:00
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* R<> organisation d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
2000-07-28 17:30:55 +02:00
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es <20> r<> organiser */
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
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 */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( RootDesc - > Valid = = FALSE )
{
int Nb_Detected , Nb_Corrected ;
/* On v<> rifie la structure */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
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 */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
RootDesc - > Valid = FALSE ;
/* R<> organisation de la node structure */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
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 <20> nouveau valide */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
RootDesc - > Valid = TRUE ;
return DSS_OK ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Parcours de tous les noeuds d'une structure de donn<6E> es et ex<65> cution d'une */
/* commande sur chacun d'eux */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es <20> parcourir*/
/* (I) Command : commande <20> ex<65> cuter sur chaque noeud travers<72> */
/* (I) Data : pointeur de donn<6E> es utilisateur */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_DataStruct_Traverse_I ( NDT_Root * Root , NDT_Command Command , void * Data )
{
DST_Status rc ;
DST_RootDesc * RootDesc = ( DST_RootDesc * ) ( Root - > User ) ;
/* On v<> rifie que la data structure est valide */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( RootDesc - > Valid = = FALSE )
{
int Nb_Detected , Nb_Corrected ;
/* On v<> rifie la structure */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
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_Traverse : unable to check the data structure " ) ;
DS_Error_Print ( ) ;
return rc ;
}
}
/* On rend <20> ventuellement la structure invalide le temps de sa travers<72> e */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
switch ( ( int ) Command )
{
case NDD_CMD_PRINT_VALUE :
break ;
default :
RootDesc - > Valid = FALSE ;
break ;
}
/* Travers<72> e de la node structure */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = ND_DataStruct_Traverse ( Root , Command , Data ) ;
if ( rc ! = NDS_OK )
{
sprintf ( DS_Error_Msg , " Error DS_DataStruct_Traverse : unable to traverse the node structure " ) ;
DS_Error_Print ( ) ;
if ( ! DS_ERROR ( rc ) ) RootDesc - > Valid = TRUE ;
return rc ;
}
/* On rend la structure valide */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
RootDesc - > Valid = TRUE ;
return DSS_OK ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Conversion d'une structure de donn<6E> es d'un type en un autre */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
/* (I) Target_Type : type de structure cible */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
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 */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( RootDesc - > Valid = = FALSE )
{
int Nb_Detected , Nb_Corrected ;
/* On v<> rifie la structure */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
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 */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
RootDesc - > Valid = FALSE ;
/* Conversion de la node structure */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
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 <20> nouveau valide */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
RootDesc - > Valid = TRUE ;
return DSS_OK ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Affichage d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es <20> afficher */
/* (I) Out : flux de sortie */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_DataStruct_Print_I ( NDT_Root * Root , FILE * Out )
{
return DS_DataStruct_Traverse_I ( Root , NDD_CMD_PRINT_VALUE , Out ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Fonction de v<> rification / r<> paration d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure */
/* (O) Nb_Detected : pointeur sur le nombre d'erreurs d<> tect<63> es */
/* (O) Nb_Corrected : pointeur sur le nombre d'erreurs corrig<69> es */
/* (I) Out : flux de sortie du rapport */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
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'<27> tat de verrouillage pr<70> c<EFBFBD> dent */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
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 <20> criture */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
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 <20> la data structure */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
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 */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
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 */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( * Nb_Corrected = = * Nb_Detected ) RootDesc - > Valid = TRUE ;
else RootDesc - > Valid = FALSE ;
/* Retour au mode de verrouillage pr<70> c<EFBFBD> dent */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
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<6F> dure de v<> rification */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
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 ;
}
2024-04-29 12:08:11 +02:00
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
2024-04-29 12:08:11 +02:00
/* Print all the data structure values */
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
2024-04-29 12:08:11 +02:00
/* (I) Stream: Output stream */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Recursive_Mode: Child or Parent */
/* (I) Recursive_Depth: Curent recursion depth */
/* (I) Recursive_Offset: Curent print out offset */
/* (I) ...: User args */
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
2024-04-29 12:08:11 +02:00
DST_Status DS_DataStruct_Value_Print_I ( FILE * Out_Ptr , NDT_Root * Root_Ptr , NDT_Recursive_Mode Recursive_Mode , NDT_Recursive_Depth Recursive_Depth , NDT_Recursive_Offset Recursive_Offset , . . . )
2000-07-28 17:30:55 +02:00
{
2024-04-29 12:08:11 +02:00
DST_RootDesc * RootDesc_Ptr = ( DST_RootDesc * ) ( Root_Ptr - > User_Ptr ) ;
DST_Status status ;
NDT_Status nd_status ;
va_list user_args ;
2000-07-28 17:30:55 +02:00
2024-04-29 12:08:11 +02:00
va_start ( user_args , Recursive_Offset ) ;
2000-07-28 17:30:55 +02:00
/* On v<> rifie que la data structure est valide */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( RootDesc - > Valid = = FALSE )
{
int Nb_Detected , Nb_Corrected ;
/* On v<> rifie la structure */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
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 ( ) ;
return rc ;
}
}
2024-04-29 12:08:11 +02:00
*/
2000-07-28 17:30:55 +02:00
/* Affichage de la node structure */
2024-04-29 12:08:11 +02:00
if ( ( nd_status = ND_DataStruct_Value_Print_VI ( Out_Ptr , Root_Ptr , Recursive_Mode , Recursive_Depth , Recursive_Offset , & user_args ) ) ! = NDS_OK )
{
LG_LOG_ERROR_1 ( " Unable to dump the node structure: (%d) " , nd_status ) ;
status = DSS_KO ;
}
else
{
status = DSS_OK ;
2000-07-28 17:30:55 +02:00
}
2024-04-29 12:08:11 +02:00
va_end ( user_args ) ;
2000-07-28 17:30:55 +02:00
2024-04-29 12:08:11 +02:00
return ( status ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-29 12:08:11 +02:00
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* R<> cup<75> ration du premier noeud d'une structure */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine dont on cherche le premier noeud */
/* (O) Node : pointeur sur le noeud <20> r<> cup<75> rer */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Node_First_Get_I ( NDT_Root * Root , NDT_Node * * Node )
{
DST_Status rc ;
DST_RootDesc * RootDesc = ( DST_RootDesc * ) ( Root - > User ) ;
/* On v<> rifie que la data structure est valide */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( RootDesc - > Valid = = FALSE )
{
int Nb_Detected , Nb_Corrected ;
/* On v<> rifie la structure */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
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_Node_First_Get : unable to check the data structure " ) ;
DS_Error_Print ( ) ;
return rc ;
}
}
/* R<> cup<75> ration du premier noeud */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = ND_Node_First_Get ( Root , Node ) ;
return rc ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* R<> cup<75> ration du dernier noeud d'une structure */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine dont on cherche le dernier noeud */
/* (O) Node : pointeur sur le noeud <20> r<> cup<75> rer */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Node_Last_Get_I ( NDT_Root * Root , NDT_Node * * Node )
{
DST_Status rc ;
DST_RootDesc * RootDesc = ( DST_RootDesc * ) ( Root - > User ) ;
/* On v<> rifie que la data structure est valide */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( RootDesc - > Valid = = FALSE )
{
int Nb_Detected , Nb_Corrected ;
/* On v<> rifie la structure */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
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_Node_Last_Get : unable to check the data structure " ) ;
DS_Error_Print ( ) ;
return rc ;
}
}
/* R<> cup<75> ration du dernier noeud */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = ND_Node_Last_Get ( Root , Node ) ;
return rc ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* R<> cup<75> ration du noeud suivant */
/*----------------------------------------------------------------------------*/
/* (I) Node : pointeur sur le noeud dont on cherche le suivant */
/* (O) Next_Node : pointeur sur le noeud suivant */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Node_Next_Get_I ( NDT_Node * Node , NDT_Node * * Next_Node )
{
DST_Status rc ;
DST_RootDesc * RootDesc = ( DST_RootDesc * ) ( Node - > Root - > User ) ;
/* On v<> rifie que la data structure est valide */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( RootDesc - > Valid = = FALSE )
{
int Nb_Detected , Nb_Corrected ;
/* On v<> rifie la structure */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
Nb_Detected = Nb_Corrected = 0 ;
rc = DS_DataStruct_Check_L ( Node - > Root , & Nb_Detected , & Nb_Corrected , DS_stderr ) ;
if ( rc ! = DSS_OK )
{
sprintf ( DS_Error_Msg , " Error DS_Node_Next_Get : unable to check the data structure " ) ;
DS_Error_Print ( ) ;
return rc ;
}
}
/* R<> cup<75> ration du noeud suivant */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = ND_Node_Next_Get ( Node , Next_Node ) ;
return rc ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* R<> cup<75> ration du noeud pr<70> c<EFBFBD> dant */
/*----------------------------------------------------------------------------*/
/* (I) Node : pointeur sur le noeud dont on cherche le pr<70> c<EFBFBD> dant */
/* (O) Prev_Node : pointeur sur le noeud pr<70> c<EFBFBD> dant */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Node_Previous_Get_I ( NDT_Node * Node , NDT_Node * * Prev_Node )
{
DST_Status rc ;
DST_RootDesc * RootDesc = ( DST_RootDesc * ) ( Node - > Root - > User ) ;
/* On v<> rifie que la data structure est valide */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( RootDesc - > Valid = = FALSE )
{
int Nb_Detected , Nb_Corrected ;
/* On v<> rifie la structure */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
Nb_Detected = Nb_Corrected = 0 ;
rc = DS_DataStruct_Check_L ( Node - > Root , & Nb_Detected , & Nb_Corrected , DS_stderr ) ;
if ( rc ! = DSS_OK )
{
sprintf ( DS_Error_Msg , " Error DS_Node_Previous_Get : unable to check the data structure " ) ;
DS_Error_Print ( ) ;
return rc ;
}
}
/* R<> cup<75> ration du noeud pr<70> c<EFBFBD> dent */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = ND_Node_Previous_Get ( Node , Prev_Node ) ;
return rc ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Ajout d'un noeud <20> une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
/* (I) Node : pointeur sur le noeud <20> ajouter */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Node_Add_I ( NDT_Root * Root , NDT_Node * Node )
{
DST_Status rc ;
DST_RootDesc * RootDesc = ( DST_RootDesc * ) ( Root - > User ) ;
/* On v<> rifie que la data structure est valide */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( RootDesc - > Valid = = FALSE )
{
int Nb_Detected , Nb_Corrected ;
/* On v<> rifie la structure */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
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_Node_Add : unable to check the data structure " ) ;
DS_Error_Print ( ) ;
return rc ;
}
}
/* On rend la structure invalide le temps de l'ajout */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
RootDesc - > Valid = FALSE ;
/* Ajout du noeud */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = ND_Node_Add ( Root , Node ) ;
if ( rc ! = NDS_OK )
{
sprintf ( DS_Error_Msg , " Error DS_Node_Add : unable to add a node to the data structure " ) ;
DS_Error_Print ( ) ;
if ( ! DS_ERROR ( rc ) ) RootDesc - > Valid = TRUE ;
return rc ;
}
/* On rend la structure <20> nouveau valide */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
RootDesc - > Valid = TRUE ;
return DSS_OK ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Suppression d'un noeud dans une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Node : pointeur sur le noeud <20> supprimer */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Node_Remove_I ( NDT_Node * Node )
{
DST_Status rc ;
NDT_Root * Root ;
DST_RootDesc * RootDesc = ( DST_RootDesc * ) ( Node - > Root - > User ) ;
Root = Node - > Root ;
/* On v<> rifie que la data structure est valide */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( RootDesc - > Valid = = FALSE )
{
int Nb_Detected , Nb_Corrected ;
/* On v<> rifie la structure */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
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_Node_Remove : unable to check the data structure " ) ;
DS_Error_Print ( ) ;
return rc ;
}
}
/* On rend la structure invalide le temps de la suppression du noeud */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
RootDesc - > Valid = FALSE ;
/* Suppression dans la node structure */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = ND_Node_Remove ( Node ) ;
if ( rc ! = NDS_OK )
{
sprintf ( DS_Error_Msg , " Error DS_Node_Remove : unable to remove a node from the structure " ) ;
DS_Error_Print ( ) ;
if ( ! DS_ERROR ( rc ) ) RootDesc - > Valid = TRUE ;
return rc ;
}
/* On rend la structure <20> nouveau valide */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
RootDesc - > Valid = TRUE ;
return DSS_OK ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Recherche un noeud dans un arbre et retourne le pointeur sur le noeud */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de l'abre */
/* (O) Node : adresse du pointeur sur le noeud <20> r<> cuperer */
/* (I) Value : pointeur sur la valeur <20> rechercher */
/* (I) Data : pointeur de donn<6E> es */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Node_Find_I ( NDT_Root * Root , NDT_Node * * Node , void * Value , void * Data )
{
DST_Status rc ;
DST_RootDesc * RootDesc = ( DST_RootDesc * ) ( Root - > User ) ;
* Node = NULL ;
/* On v<> rifie que la data structure est valide */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( RootDesc - > Valid = = FALSE )
{
int Nb_Detected , Nb_Corrected ;
/* On v<> rifie la structure */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
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_Node_Find : unable to check the data structure " ) ;
DS_Error_Print ( ) ;
return rc ;
}
}
/* Recherche dans la node structure */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = ND_Node_Find ( Root , Node , Value , Data ) ;
return rc ;
}
2024-04-29 12:08:11 +02:00
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Allocation d'une valeur d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (O) Value : adresse d'un pointeur sur la valeur <20> allouer */
2024-04-29 12:08:11 +02:00
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
2024-04-22 00:24:37 +02:00
/* (I) ... : arguments relatifs <20> l'allocation de la valeur */
/*----------------------------------------------------------------------------*/
2024-04-29 12:08:11 +02:00
DST_Status DS_Value_Alloc_I ( void * * Value_Ptr_Ptr , NDT_Root * Root_Ptr , . . . )
2000-07-28 17:30:55 +02:00
{
2024-04-29 12:08:11 +02:00
DST_Status status ;
NDT_Status nd_status ;
va_list user_args ;
2000-07-28 17:30:55 +02:00
2024-04-29 12:08:11 +02:00
2000-07-28 17:30:55 +02:00
/* R<> cup<75> ration des arguments pour l'allocation de la valeur */
2024-04-29 12:08:11 +02:00
va_start ( user_args , Root_Ptr ) ;
2000-07-28 17:30:55 +02:00
/* Appel du manager */
2024-04-29 12:08:11 +02:00
if ( ( nd_status = ND_Manager_Exec ( Root_Ptr , NDD_INDEX_UNKNOWN , NULL , NDD_CMD_VALUE_ALLOC , Value_Ptr_Ptr , & user_args ) ) ! = NDS_OK )
{
LG_LOG_ERROR_1 ( " Unnable to alloc a new value: (%d) " , nd_status ) ;
2000-07-28 17:30:55 +02:00
2024-04-29 12:08:11 +02:00
status = DSS_KO ;
}
else
{
status = DSS_OK ;
}
va_end ( user_args ) ;
return ( status ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-29 12:08:11 +02:00
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Ajout d'une valeur <20> une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
/* (I) Value : pointeur sur la valeur <20> ajouter <20> la structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
2024-04-29 12:08:11 +02:00
DST_Status DS_Value_Add_I ( NDT_Root * Root_Ptr , void * Value_Ptr )
2000-07-28 17:30:55 +02:00
{
2024-04-29 12:08:11 +02:00
DST_RootDesc * RootDesc_Ptr = ( DST_RootDesc * ) ( Root_Ptr - > User_Ptr ) ;
2000-07-28 17:30:55 +02:00
2024-04-29 12:08:11 +02:00
DST_Status status ;
NDT_Status nd_status ;
2000-07-28 17:30:55 +02:00
/* On v<> rifie que la data structure est valide */
2024-04-22 00:24:37 +02:00
/*
2024-04-29 12:08:11 +02:00
if ( RootDesc_Ptr - > Valid = = FALSE )
2000-07-28 17:30:55 +02:00
{
2024-04-29 12:08:11 +02:00
int Nb_Detected , Nb_Corrected ;
2000-07-28 17:30:55 +02:00
/* On v<> rifie la structure */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
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 ( ) ;
return rc ;
}
}
2024-04-29 12:08:11 +02:00
*/
2000-07-28 17:30:55 +02:00
/* On rend la structure invalide le temps de l'ajout */
2024-04-29 12:08:11 +02:00
RootDesc_Ptr - > Valid = FALSE ;
2000-07-28 17:30:55 +02:00
/* Ajout de la valeur */
2024-04-29 12:08:11 +02:00
if ( ( nd_status = ND_DataStruct_Value_Add ( Root_Ptr , Value_Ptr ) ) ! = NDS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-29 12:08:11 +02:00
LG_LOG_ERROR_1 ( " Unable to add a value to the data structure: (%d) " , nd_status ) ;
2000-07-28 17:30:55 +02:00
2024-04-29 12:08:11 +02:00
// if (!DS_ERROR(rc)) RootDesc->Valid = TRUE;
2000-07-28 17:30:55 +02:00
2024-04-29 12:08:11 +02:00
return ( DSS_KO ) ;
2000-07-28 17:30:55 +02:00
}
/* On rend la structure <20> nouveau valide */
2024-04-29 12:08:11 +02:00
RootDesc_Ptr - > Valid = TRUE ;
return ( DSS_OK ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Suppression du premier noeud correspondant <20> une valeur donn<6E> e */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
/* (I) Reference_Value : pointeur sur la valeur de r<> f<EFBFBD> rence */
/* (I) Removed_Value : adresse d'un pointeur sur la valeur supprim<69> e */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Value_Remove_I ( NDT_Root * Root , void * Reference_Value , void * * Removed_Value )
{
DST_Status rc ;
DST_RootDesc * RootDesc = ( DST_RootDesc * ) ( Root - > User ) ;
/* On v<> rifie que la data structure est valide */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( RootDesc - > Valid = = FALSE )
{
int Nb_Detected , Nb_Corrected ;
/* On v<> rifie la structure */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
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_Remove : unable to check the data structure " ) ;
DS_Error_Print ( ) ;
return rc ;
}
}
/* On rend la structure invalide le temps de la suppression de valeur */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
RootDesc - > Valid = FALSE ;
/* Suppression du noeud correspondant <20> la valeur de r<> f<EFBFBD> rence */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = ND_Value_Remove ( Root , Reference_Value , Removed_Value ) ;
if ( rc ! = NDS_OK )
{
sprintf ( DS_Error_Msg , " Error DS_Value_Remove : unable to remove a value from the data structure " ) ;
DS_Error_Print ( ) ;
if ( ! DS_ERROR ( rc ) ) RootDesc - > Valid = TRUE ;
return rc ;
}
/* On rend la structure <20> nouveau valide */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
RootDesc - > Valid = TRUE ;
return DSS_OK ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* D<> sallocation d'une valeur d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
/* (I) Value : pointeur sur la valeur <20> d<> sallouer */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Value_Free_I ( NDT_Root * Root , void * Value )
{
return ND_Value_Free ( Root , Value ) ;
}
2024-04-29 12:08:11 +02:00
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Allocation de m<> moire pour une structure de donn<6E> es : */
/*----------------------------------------------------------------------------*/
2024-04-29 12:08:11 +02:00
/* (O) Ptr : adresse du pointeur sur la zone de donn<6E> es allou<6F> e */
2024-04-22 00:24:37 +02:00
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
/* (I) Size : taille m<> moire <20> allouer */
/*----------------------------------------------------------------------------*/
2024-04-22 18:37:50 +02:00
2024-04-29 12:08:11 +02:00
DST_Status DS_Alloc_I ( void * * Ptr_Ptr , NDT_Root * Root_Ptr , size_t Size )
2000-07-28 17:30:55 +02:00
{
2024-04-29 12:08:11 +02:00
return ( DS_DataStruct_Alloc ( Ptr_Ptr , Size , Root_Ptr - > User_Ptr ) ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-22 18:37:50 +02:00
2024-04-29 12:08:11 +02:00
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* D<> sallocation d'une ressource pour une structure de donn<6E> es : */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
/* (I) Ptr : pointeur sur la zone <20> d<> sallouer */
/*----------------------------------------------------------------------------*/
2024-04-22 18:37:50 +02:00
DST_Status DS_Free_I ( NDT_Root * Root , void * Ptr )
2000-07-28 17:30:55 +02:00
{
2024-04-22 18:37:50 +02:00
// return DS_DataStruct_Free (Ptr, Root->User);
2000-07-28 17:30:55 +02:00
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* FONCTIONS OPTIMISATION MOYENNE (DS_MODE = 1) */
/*----------------------------------------------------------------------------*/
2000-07-28 17:30:55 +02:00
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Ouverture d'une instance de la librairie */
/*----------------------------------------------------------------------------*/
/* (I) Instance : num<75> ro de l'instance de la librairie */
/* (I) Context : nom du contexte */
/* (I) Debug_Mode : mode d'affichage des messages d'erreur */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Library_Open_L ( int Instance , const char * Context , DST_Flags Debug_Mode )
{
return DS_Library_Open_I ( Instance , Context , Debug_Mode ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Fermeture de l'instance de la librairie */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Library_Close_L ( void )
{
return DS_Library_Close_I ( ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* D<> finition de la sortie standard des messages d'erreur de la librairie */
/*----------------------------------------------------------------------------*/
/* (I) Out : flux de sortie des messages d'erreur */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Library_Stderr_Set_L ( FILE * Out )
{
return DS_Library_Stderr_Set_I ( Out ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Cr<43> ation / ouverture d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) DS_Name : nom de la structure */
/* (O) Root : adresse du pointeur sur la racine de la structure */
/* (I) Type : type de la structure de donn<6E> es */
/* (I) Manager_FileName : nom du fichier qui d<> finit les fonctions manager */
/* (I) Segment_Size : taille ds segments du heap sous-jacent */
/* (I) Open_Mode : mode d'ouverture de la structure */
/* (I) Own_Values : indique si la structure poss<73> de ses valeurs */
/*----------------------------------------------------------------------------*/
/*
DST_Status DS_DataStruct_Open_L ( const char * DS_Name , NDT_Root * * Root , \
2000-07-28 17:30:55 +02:00
NDT_DataStruct_Type Type , const char * Manager_FileName , \
size_t Segment_Size , DST_Flags Open_Mode , int Own_Values )
{
return DS_DataStruct_Open_I ( DS_Name , Root , Type , Manager_FileName , Segment_Size , Open_Mode , Own_Values ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Verrouillage d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure */
/* (I) Lock_Mode : type de verrou <20> poser sur la structure */
/* (O) Locked : verrou effectif (TRUE ou FALSE) */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_DataStruct_Lock_L ( NDT_Root * Root , DST_Flags Lock_Mode , int * Locked )
{
return DS_DataStruct_Lock_I ( Root , Lock_Mode , Locked ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* D<> verrouillage d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_DataStruct_Unlock_L ( NDT_Root * Root )
{
return DS_DataStruct_Unlock_I ( Root ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Fermeture d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
2000-07-28 17:30:55 +02:00
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es <20> fermer */
2024-04-22 00:24:37 +02:00
/* (I) Close_Mode : mode de fermeture de la structure (destruction ou non) */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_DataStruct_Close_L ( NDT_Root * Root , DST_Flags Close_Mode )
{
return DS_DataStruct_Close_I ( Root , Close_Mode ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Affiche les informations d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root: pointeur sur la racine de la structure de donn<6E> es */
/* (I) Out : flux de sortie de l'affichage */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_DataStruct_Info_Print_L ( NDT_Root * Root , FILE * Out )
{
DST_Status rc ;
int Locked ;
/* Verrouillage de la data structure en lecture */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = DS_DataStruct_Lock_I ( Root , SMD_READ , & Locked ) ;
if ( rc ! = DSS_OK )
{
sprintf ( DS_Error_Msg , " Error DS_DataStruct_Info_Print : unable to lock the data structure for reading " ) ;
DS_Error_Print ( ) ;
return rc ;
}
rc = DS_DataStruct_Info_Print_I ( Root , Out ) ;
/* D<> verrouillage de la data structure si besoin */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( Locked = = TRUE ) DS_DataStruct_Unlock_I ( Root ) ;
return rc ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* R<> organisation d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
2000-07-28 17:30:55 +02:00
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es <20> r<> organiser */
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_DataStruct_Reorg_L ( NDT_Root * Root )
{
DST_Status rc ;
int Locked ;
/* Verrouillage de la data structure en <20> criture */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
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 */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( Locked = = TRUE ) DS_DataStruct_Unlock_I ( Root ) ;
return rc ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Parcours de tous les noeuds d'une structure de donn<6E> es et ex<65> cution d'une */
/* commande sur chacun d'eux */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es <20> parcourir*/
/* (I) Command : commande <20> ex<65> cuter sur chaque noeud travers<72> */
/* (I) Data : pointeur de donn<6E> es utilisateur */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_DataStruct_Traverse_L ( NDT_Root * Root , NDT_Command Command , void * Data )
{
DST_Status rc ;
SMT_Flags Lock_Mode ;
int Locked ;
/* D<> finition du mode de verrouillage de la data structure selon le type de commande */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
switch ( ( int ) Command )
{
case NDD_CMD_PRINT_VALUE :
Lock_Mode = SMD_READ ;
break ;
case NDD_CMD_DELETE_VALUE :
default :
Lock_Mode = SMD_WRITE ;
break ;
}
/* Verrouillage de la data structure */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = DS_DataStruct_Lock_I ( Root , Lock_Mode , & Locked ) ;
if ( rc ! = DSS_OK )
{
sprintf ( DS_Error_Msg , " Error DS_DataStruct_Traverse : unable to lock the data structure for %s " ,
Lock_Mode = = SMD_WRITE ? " writing " : " reading " ) ;
DS_Error_Print ( ) ;
return rc ;
}
rc = DS_DataStruct_Traverse_I ( Root , Command , Data ) ;
/* D<> verrouillage de la data structure si besoin */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( Locked = = TRUE ) DS_DataStruct_Unlock_I ( Root ) ;
return rc ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Conversion d'une structure de donn<6E> es d'un type en un autre */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
/* (I) Target_Type : type de structure cible */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
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 <20> criture */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
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 */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( Locked = = TRUE ) DS_DataStruct_Unlock_I ( Root ) ;
return rc ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Affichage d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es <20> afficher */
/* (I) Out : flux de sortie */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_DataStruct_Print_L ( NDT_Root * Root , FILE * Out )
{
return DS_DataStruct_Traverse_L ( Root , NDD_CMD_PRINT_VALUE , Out ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Fonction de v<> rification / r<> paration d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure */
/* (O) Nb_Detected : pointeur sur le nombre d'erreurs d<> tect<63> es */
/* (O) Nb_Corrected : pointeur sur le nombre d'erreurs corrig<69> es */
/* (I) Out : flux de sortie du rapport */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
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 ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Affiche la structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure */
/* (I) Out : flux de sortie */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_DataStruct_Dump_L ( NDT_Root * Root , FILE * Out )
{
DST_Status rc ;
int Locked ;
/* Verrouillage de la data structure en lecture */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = DS_DataStruct_Lock_I ( Root , SMD_READ , & Locked ) ;
if ( rc ! = DSS_OK )
{
sprintf ( DS_Error_Msg , " Error DS_DataStruct_Dump : unable to lock the data structure for reading " ) ;
DS_Error_Print ( ) ;
return rc ;
}
rc = DS_DataStruct_Dump_I ( Root , Out ) ;
/* D<> verrouillage de la data structure si besoin */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( Locked = = TRUE ) DS_DataStruct_Unlock_I ( Root ) ;
return rc ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* R<> cup<75> ration du premier noeud d'une structure */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine dont on cherche le premier noeud */
/* (O) Node : pointeur sur le noeud <20> r<> cup<75> rer */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Node_First_Get_L ( NDT_Root * Root , NDT_Node * * Node )
{
DST_Status rc ;
int Locked ;
/* Verrouillage de la data structure en lecture */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = DS_DataStruct_Lock_I ( Root , SMD_READ , & Locked ) ;
if ( rc ! = DSS_OK )
{
sprintf ( DS_Error_Msg , " Error DS_Node_First_Get : unable to lock the data structure for reading " ) ;
DS_Error_Print ( ) ;
return rc ;
}
rc = DS_Node_First_Get_I ( Root , Node ) ;
/* D<> verrouillage de la data structure si besoin */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( Locked = = TRUE ) DS_DataStruct_Unlock_I ( Root ) ;
return rc ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* R<> cup<75> ration du dernier noeud d'une structure */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine dont on cherche le dernier noeud */
/* (O) Node : pointeur sur le noeud <20> r<> cup<75> rer */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Node_Last_Get_L ( NDT_Root * Root , NDT_Node * * Node )
{
DST_Status rc ;
int Locked ;
/* Verrouillage de la data structure en lecture */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = DS_DataStruct_Lock_I ( Root , SMD_READ , & Locked ) ;
if ( rc ! = DSS_OK )
{
sprintf ( DS_Error_Msg , " Error DS_Node_Last_Get : unable to lock the data structure for reading " ) ;
DS_Error_Print ( ) ;
return rc ;
}
rc = DS_Node_Last_Get_I ( Root , Node ) ;
/* D<> verrouillage de la data structure si besoin */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( Locked = = TRUE ) DS_DataStruct_Unlock_I ( Root ) ;
return rc ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* R<> cup<75> ration du noeud suivant */
/*----------------------------------------------------------------------------*/
/* (I) Node : pointeur sur le noeud dont on cherche le suivant */
/* (O) Next_Node : pointeur sur le noeud suivant */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Node_Next_Get_L ( NDT_Node * Node , NDT_Node * * Next_Node )
{
DST_Status rc ;
int Locked ;
/* Verrouillage de la data structure en lecture */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = DS_DataStruct_Lock_I ( Node - > Root , SMD_READ , & Locked ) ;
if ( rc ! = DSS_OK )
{
sprintf ( DS_Error_Msg , " Error DS_Node_Next_Get : unable to lock the data structure for reading " ) ;
DS_Error_Print ( ) ;
return rc ;
}
rc = DS_Node_Next_Get_I ( Node , Next_Node ) ;
/* D<> verrouillage de la data structure si besoin */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( Locked = = TRUE ) DS_DataStruct_Unlock_I ( Node - > Root ) ;
return rc ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* R<> cup<75> ration du noeud pr<70> c<EFBFBD> dant */
/*----------------------------------------------------------------------------*/
/* (I) Node : pointeur sur le noeud dont on cherche le pr<70> c<EFBFBD> dant */
/* (O) Prev_Node : pointeur sur le noeud pr<70> c<EFBFBD> dant */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Node_Previous_Get_L ( NDT_Node * Node , NDT_Node * * Prev_Node )
{
DST_Status rc ;
int Locked ;
/* Verrouillage de la data structure en lecture */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = DS_DataStruct_Lock_I ( Node - > Root , SMD_READ , & Locked ) ;
if ( rc ! = DSS_OK )
{
sprintf ( DS_Error_Msg , " Error DS_Node_Previous_Get : unable to lock the data structure for reading " ) ;
DS_Error_Print ( ) ;
return rc ;
}
rc = DS_Node_Previous_Get_I ( Node , Prev_Node ) ;
/* D<> verrouillage de la data structure si besoin */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( Locked = = TRUE ) DS_DataStruct_Unlock_I ( Node - > Root ) ;
return rc ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Ajout d'un noeud <20> une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
/* (I) Node : pointeur sur le noeud <20> ajouter */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Node_Add_L ( NDT_Root * Root , NDT_Node * Node )
{
DST_Status rc ;
int Locked ;
/* Verrouillage de la data structure en <20> criture */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = DS_DataStruct_Lock_I ( Root , SMD_WRITE , & Locked ) ;
if ( rc ! = DSS_OK )
{
sprintf ( DS_Error_Msg , " Error DS_Node_Add : unable to lock the data structure for writing " ) ;
DS_Error_Print ( ) ;
return rc ;
}
rc = DS_Node_Add_I ( Root , Node ) ;
/* D<> verrouillage de la data structure si besoin */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( Locked = = TRUE ) DS_DataStruct_Unlock_I ( Root ) ;
return rc ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Suppression d'un noeud dans une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Node : pointeur sur le noeud <20> supprimer */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Node_Remove_L ( NDT_Node * Node )
{
DST_Status rc ;
int Locked ;
NDT_Root * Root = Node - > Root ;
/* Verrouillage de la data structure en <20> criture */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = DS_DataStruct_Lock_I ( Root , SMD_WRITE , & Locked ) ;
if ( rc ! = DSS_OK )
{
sprintf ( DS_Error_Msg , " Error DS_Node_Remove : unable to lock the data structure for writing " ) ;
DS_Error_Print ( ) ;
return rc ;
}
rc = DS_Node_Remove_I ( Node ) ;
/* D<> verrouillage de la data structure si besoin */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( Locked = = TRUE ) DS_DataStruct_Unlock_I ( Root ) ;
return rc ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Recherche un noeud dans un arbre et retourne le pointeur sur le noeud */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de l'abre */
/* (O) Node : adresse du pointeur sur le noeud <20> r<> cuperer */
/* (I) Value : pointeur sur la valeur <20> rechercher */
/* (I) Data : pointeur de donn<6E> es */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Node_Find_L ( NDT_Root * Root , NDT_Node * * Node , void * Value , void * Data )
{
DST_Status rc ;
int Locked ;
/* Verrouillage de la data structure en lecture */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = DS_DataStruct_Lock_I ( Root , SMD_READ , & Locked ) ;
if ( rc ! = DSS_OK )
{
sprintf ( DS_Error_Msg , " Error DS_Node_Find : unable to lock the data structure for reading " ) ;
DS_Error_Print ( ) ;
return rc ;
}
rc = DS_Node_Find_I ( Root , Node , Value , Data ) ;
/* D<> verrouillage de la data structure si besoin */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( Locked = = TRUE ) DS_DataStruct_Unlock_I ( Root ) ;
return rc ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Allocation d'une valeur d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
/* (O) Value : adresse d'un pointeur sur la valeur <20> allouer */
/* (I) ... : arguments relatifs <20> l'allocation de la valeur */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Value_Alloc_L ( NDT_Root * Root , void * * Value , . . . )
{
DST_Status rc ;
va_list Args ;
/* R<> cup<75> ration des arguments pour l'allocation de la valeur */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
va_start ( Args , Value ) ;
/* Appel du manager */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = ND_Manager_Exec ( Root - > Manager , NDD_CMD_MAKE_VALUE , Root , Value , Args ) ;
va_end ( Args ) ;
return rc ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Ajout d'une valeur <20> une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
/* (I) Value : pointeur sur la valeur <20> ajouter <20> la structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Value_Add_L ( NDT_Root * Root , void * Value )
{
DST_Status rc ;
int Locked ;
/* Verrouillage de la data structure en <20> criture */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = DS_DataStruct_Lock_I ( Root , SMD_WRITE , & Locked ) ;
if ( rc ! = DSS_OK )
{
sprintf ( DS_Error_Msg , " Error DS_Value_Add : unable to lock the data structure for writing " ) ;
DS_Error_Print ( ) ;
return rc ;
}
/* Ajout de la valeur */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = DS_Value_Add_I ( Root , Value ) ;
/* D<> verrouillage de la data structure si besoin */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( Locked = = TRUE ) DS_DataStruct_Unlock_I ( Root ) ;
return rc ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Suppression du premier noeud correspondant <20> une valeur donn<6E> e */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
/* (I) Reference_Value : pointeur sur la valeur de r<> f<EFBFBD> rence */
/* (I) Removed_Value : adresse d'un pointeur sur la valeur supprim<69> e */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Value_Remove_L ( NDT_Root * Root , void * Reference_Value , void * * Removed_Value )
{
DST_Status rc ;
int Locked ;
/* Verrouillage de la data structure en <20> criture */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = DS_DataStruct_Lock_I ( Root , SMD_WRITE , & Locked ) ;
if ( rc ! = DSS_OK )
{
sprintf ( DS_Error_Msg , " Error DS_Value_Remove : unable to lock the data structure for writing " ) ;
DS_Error_Print ( ) ;
return rc ;
}
rc = DS_Value_Remove_I ( Root , Reference_Value , Removed_Value ) ;
/* D<> verrouillage de la data structure si besoin */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
if ( Locked = = TRUE ) DS_DataStruct_Unlock_I ( Root ) ;
return DSS_OK ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* D<> sallocation d'une valeur d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
/* (I) Value : pointeur sur la valeur <20> d<> sallouer */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Value_Free_L ( NDT_Root * Root , void * Value )
{
return ND_Value_Free ( Root , Value ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Allocation de m<> moire pour une structure de donn<6E> es : */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
/* (I) Size : taille m<> moire <20> allouer */
/* (O) Ptr : adresse du pointeur sur la zone de donn<6E> es allou<6F> e */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Alloc_L ( NDT_Root * Root , size_t Size , void * * Ptr )
{
return DS_DataStruct_Alloc ( Size , Ptr , Root - > User ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* D<> sallocation d'une ressource pour une structure de donn<6E> es : */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
/* (I) Ptr : pointeur sur la zone <20> d<> sallouer */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Free_L ( NDT_Root * Root , void * Ptr )
{
return DS_DataStruct_Free ( Ptr , Root - > User ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* FONCTIONS SECURISEES (DS_MODE = 0) */
/*----------------------------------------------------------------------------*/
2000-07-28 17:30:55 +02:00
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Ouverture d'une instance de la librairie */
/*----------------------------------------------------------------------------*/
/* (I) Instance : num<75> ro de l'instance de la librairie */
/* (I) Context : nom du contexte */
/* (I) Debug_Mode : mode d'affichage des messages d'erreur */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Library_Open_CL ( int Instance , const char * Context , DST_Flags Debug_Mode )
{
return DS_Library_Open_I ( Instance , Context , Debug_Mode ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Fermeture de l'instance de la librairie */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Library_Close_CL ( void )
{
return DS_Library_Close_I ( ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* D<> finition de la sortie standard des messages d'erreur de la librairie */
/*----------------------------------------------------------------------------*/
/* (I) Out : flux de sortie des messages d'erreur */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Library_Stderr_Set_CL ( FILE * Out )
{
return DS_Library_Stderr_Set_I ( Out ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Cr<43> ation / ouverture d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) DS_Name : nom de la structure */
/* (O) Root : adresse du pointeur sur la racine de la structure */
/* (I) Type : type de la structure de donn<6E> es */
/* (I) Manager_FileName : nom du fichier qui d<> finit les fonctions manager */
/* (I) Segment_Size : taille ds segments du heap sous-jacent */
/* (I) Open_Mode : mode d'ouverture de la structure */
/* (I) Own_Values : indique si la structure poss<73> de ses valeurs */
/*----------------------------------------------------------------------------*/
/*
DST_Status DS_DataStruct_Open_CL ( const char * DS_Name , NDT_Root * * Root , \
2000-07-28 17:30:55 +02:00
NDT_DataStruct_Type Type , const char * Manager_FileName , \
size_t Segment_Size , DST_Flags Open_Mode , int Own_Values )
{
if ( ! DS_Name )
{
sprintf ( DS_Error_Msg , " Error DS_DataStruct_Open : the data structure name is undefined " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
if ( ! Root )
{
sprintf ( DS_Error_Msg , " Error DS_DataStruct_Open : the root address is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
if ( Open_Mode & ( DSD_CREATE | DSD_NEW ) & & ! Manager_FileName )
{
sprintf ( DS_Error_Msg , " Error DS_DataStruct_Open : the manager file name must be defined in creation mode " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
return DS_DataStruct_Open_I ( DS_Name , Root , Type , Manager_FileName , Segment_Size , Open_Mode , Own_Values ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Verrouillage d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure */
/* (I) Lock_Mode : type de verrou <20> poser sur la structure */
/* (O) Locked : verrou effectif (TRUE ou FALSE) */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_DataStruct_Lock_CL ( NDT_Root * Root , DST_Flags Lock_Mode , int * Locked )
{
if ( ! Root )
{
sprintf ( DS_Error_Msg , " Error DS_DataStruct_Lock : the structure root is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
if ( ! Locked )
{
sprintf ( DS_Error_Msg , " Error DS_DataStruct_Lock : the lock indicator address is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
return DS_DataStruct_Lock_I ( Root , Lock_Mode , Locked ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* D<> verrouillage d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_DataStruct_Unlock_CL ( NDT_Root * Root )
{
if ( ! Root )
{
sprintf ( DS_Error_Msg , " Error DS_DataStruct_Unlock : the structure root is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
return DS_DataStruct_Unlock_I ( Root ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Fermeture d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
2000-07-28 17:30:55 +02:00
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es <20> fermer */
2024-04-22 00:24:37 +02:00
/* (I) Close_Mode : mode de fermeture de la structure (destruction ou non) */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_DataStruct_Close_CL ( NDT_Root * Root , DST_Flags Close_Mode )
{
if ( ! Root )
{
sprintf ( DS_Error_Msg , " Error DS_DataStruct_Close : the structure root is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
return DS_DataStruct_Close_I ( Root , Close_Mode ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Affiche les informations d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root: pointeur sur la racine de la structure de donn<6E> es */
/* (I) Out : flux de sortie de l'affichage */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_DataStruct_Info_Print_CL ( NDT_Root * Root , FILE * Out )
{
if ( ! Root )
{
sprintf ( DS_Error_Msg , " Error DS_DataStruct_Info_Print : the structure root is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
if ( ! Out )
{
sprintf ( DS_Error_Msg , " Error DS_DataStruct_Info_Print : the out stream is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
return DS_DataStruct_Info_Print_L ( Root , Out ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* R<> organisation d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
2000-07-28 17:30:55 +02:00
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es <20> r<> organiser */
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_DataStruct_Reorg_CL ( NDT_Root * Root )
{
if ( ! Root )
{
sprintf ( DS_Error_Msg , " Error DS_DataStruct_Reorg : the structure root is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
return DS_DataStruct_Reorg_L ( Root ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Parcours de tous les noeuds d'une structure de donn<6E> es et ex<65> cution d'une */
/* commande sur chacun d'eux */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es <20> parcourir*/
/* (I) Command : commande <20> ex<65> cuter sur chaque noeud travers<72> */
/* (I) Data : pointeur de donn<6E> es utilisateur */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_DataStruct_Traverse_CL ( NDT_Root * Root , NDT_Command Command , void * Data )
{
if ( ! Root )
{
sprintf ( DS_Error_Msg , " Error DS_DataStruct_Traverse : the structure root is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
return DS_DataStruct_Traverse_L ( Root , Command , Data ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Conversion d'une structure de donn<6E> es d'un type en un autre */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
/* (I) Target_Type : type de structure cible */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_DataStruct_Convert_CL ( NDT_Root * Root , NDT_DataStruct_Type Target_Type )
{
if ( ! Root )
{
sprintf ( DS_Error_Msg , " Error DS_DataStruct_Convert : the structure root is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
return DS_DataStruct_Convert_L ( Root , Target_Type ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Affichage d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es <20> afficher */
/* (I) Out : flux de sortie */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_DataStruct_Print_CL ( NDT_Root * Root , FILE * Out )
{
return DS_DataStruct_Traverse_CL ( Root , NDD_CMD_PRINT_VALUE , Out ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Fonction de v<> rification / r<> paration d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure */
/* (O) Nb_Detected : pointeur sur le nombre d'erreurs d<> tect<63> es */
/* (O) Nb_Corrected : pointeur sur le nombre d'erreurs corrig<69> es */
/* (I) Out : flux de sortie du rapport */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_DataStruct_Check_CL ( NDT_Root * Root , int * Nb_Detected , int * Nb_Corrected , FILE * Out )
{
if ( ! Root )
{
sprintf ( DS_Error_Msg , " Error : the structure root is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
if ( ! Nb_Detected | | ! Nb_Corrected )
{
sprintf ( DS_Error_Msg , " Error : one of the error number address is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
if ( ! Out )
{
sprintf ( DS_Error_Msg , " Error : the out stream is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
return DS_DataStruct_Check_I ( Root , Nb_Detected , Nb_Corrected , Out ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Affiche la structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure */
/* (I) Out : flux de sortie */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_DataStruct_Dump_CL ( NDT_Root * Root , FILE * Out )
{
if ( ! Root )
{
sprintf ( DS_Error_Msg , " Error DS_DataStruct_Dump : the structure root is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
if ( ! Out )
{
sprintf ( DS_Error_Msg , " Error DS_DataStruct_Dump : the out stream is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
return DS_DataStruct_Dump_L ( Root , Out ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* R<> cup<75> ration du premier noeud d'une structure */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine dont on cherche le premier noeud */
/* (O) First_Node : adresse d'un pointeur sur le premier noeud <20> r<> cup<75> rer */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Node_First_Get_CL ( NDT_Root * Root , NDT_Node * * First_Node )
{
if ( ! Root )
{
sprintf ( DS_Error_Msg , " Error DS_Node_First_Get : the structure root is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
if ( ! First_Node )
{
sprintf ( DS_Error_Msg , " Error DS_Node_First_Get : the first node address is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
return DS_Node_First_Get_L ( Root , First_Node ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* R<> cup<75> ration du dernier noeud d'une structure */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la data structure */
/* (O) Last_Node : adresse d'un pointeur sur le dernier noeud */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Node_Last_Get_CL ( NDT_Root * Root , NDT_Node * * Last_Node )
{
if ( ! Root )
{
sprintf ( DS_Error_Msg , " Error DS_Node_Last_Get : the structure root is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
if ( ! Last_Node )
{
sprintf ( DS_Error_Msg , " Error DS_Node_Last_Get : the last node address is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
return DS_Node_Last_Get_L ( Root , Last_Node ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* R<> cup<75> ration du noeud suivant */
/*----------------------------------------------------------------------------*/
/* (I) Node : pointeur sur le noeud dont on cherche le suivant */
/* (O) Next_Node : pointeur sur le noeud suivant */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Node_Next_Get_CL ( NDT_Node * Node , NDT_Node * * Next_Node )
{
if ( ! Node )
{
sprintf ( DS_Error_Msg , " Error DS_Node_Next_Get : the node is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
if ( ! Next_Node )
{
sprintf ( DS_Error_Msg , " Error DS_Node_Next_Get : the next node address is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
return DS_Node_Next_Get_L ( Node , Next_Node ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* R<> cup<75> ration du noeud pr<70> c<EFBFBD> dant */
/*----------------------------------------------------------------------------*/
/* (I) Node : pointeur sur le noeud dont on cherche le pr<70> c<EFBFBD> dant */
/* (O) Prev_Node : pointeur sur le noeud pr<70> c<EFBFBD> dant */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Node_Previous_Get_CL ( NDT_Node * Node , NDT_Node * * Prev_Node )
{
if ( ! Node )
{
sprintf ( DS_Error_Msg , " Error DS_Node_Previous_Get : the node is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
if ( ! Prev_Node )
{
sprintf ( DS_Error_Msg , " Error DS_Node_Previous_Get : the previous node address is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
return DS_Node_Previous_Get_L ( Node , Prev_Node ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Ajout d'un noeud <20> une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
/* (I) Node : pointeur sur le noeud <20> ajouter */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Node_Add_CL ( NDT_Root * Root , NDT_Node * Node )
{
if ( ! Root )
{
sprintf ( DS_Error_Msg , " Error DS_Node_Add : the structure root is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
if ( ! Node )
{
sprintf ( DS_Error_Msg , " Error DS_Node_Add : the node is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
return DS_Node_Add_L ( Root , Node ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Suppression d'un noeud dans une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Node : pointeur sur le noeud <20> supprimer */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Node_Remove_CL ( NDT_Node * Node )
{
if ( ! Node )
{
sprintf ( DS_Error_Msg , " Error DS_Node_Remove : the node is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
return DS_Node_Remove_L ( Node ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Recherche un noeud dans un arbre et retourne le pointeur sur le noeud */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de l'abre */
/* (O) Node : adresse du pointeur sur le noeud <20> r<> cuperer */
/* (I) Value : pointeur sur la valeur <20> rechercher */
/* (I) Data : pointeur de donn<6E> es */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Node_Find_CL ( NDT_Root * Root , NDT_Node * * Node , void * Value , void * Data )
{
if ( ! Root )
{
sprintf ( DS_Error_Msg , " Error DS_Node_Find : the structure root is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
if ( ! Node )
{
sprintf ( DS_Error_Msg , " Error DS_Node_Find : the node address is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
if ( ! Value )
{
sprintf ( DS_Error_Msg , " Error DS_Node_Find : the value is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
return DS_Node_Find_L ( Root , Node , Value , Data ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Allocation d'une valeur d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
/* (O) Value : adresse d'un pointeur sur la valeur <20> allouer */
/* (I) ... : arguments relatifs <20> l'allocation de la valeur */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Value_Alloc_CL ( NDT_Root * Root , void * * Value , . . . )
{
DST_Status rc ;
va_list Args ;
if ( ! Root )
{
sprintf ( DS_Error_Msg , " Error DS_Value_Alloc : the structure root is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
if ( ! Value )
{
sprintf ( DS_Error_Msg , " Error DS_Value_Alloc : the value address is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
/* R<> cup<75> ration des arguments pour l'allocation de la valeur */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
va_start ( Args , Value ) ;
/* Appel du manager */
2024-04-22 00:24:37 +02:00
/*
2000-07-28 17:30:55 +02:00
rc = ND_Manager_Exec ( Root - > Manager , NDD_CMD_MAKE_VALUE , Root , Value , Args ) ;
va_end ( Args ) ;
return rc ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Ajout d'une valeur <20> une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
/* (I) Value : pointeur sur la valeur <20> ajouter <20> la structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Value_Add_CL ( NDT_Root * Root , void * Value )
{
if ( ! Root )
{
sprintf ( DS_Error_Msg , " Error DS_Value_Add : the structure root is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
if ( ! Value )
{
sprintf ( DS_Error_Msg , " Error DS_Value_Add : the value is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
return DS_Value_Add_L ( Root , Value ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Suppression du premier noeud correspondant <20> une valeur donn<6E> e */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
/* (I) Reference_Value : pointeur sur la valeur de r<> f<EFBFBD> rence */
/* (I) Removed_Value : adresse d'un pointeur sur la valeur supprim<69> e */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Value_Remove_CL ( NDT_Root * Root , void * Reference_Value , void * * Removed_Value )
{
if ( ! Root )
{
sprintf ( DS_Error_Msg , " Error DS_Value_Remove : the structure root is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
if ( ! Reference_Value )
{
sprintf ( DS_Error_Msg , " Error DS_Value_Remove : the reference value is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
if ( ! Removed_Value )
{
sprintf ( DS_Error_Msg , " Error DS_Value_Remove : the removed value adress is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
return DS_Value_Remove_L ( Root , Reference_Value , Removed_Value ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* D<> sallocation d'une valeur d'une structure de donn<6E> es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
/* (I) Value : pointeur sur la valeur <20> d<> sallouer */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Value_Free_CL ( NDT_Root * Root , void * Value )
{
if ( ! Root )
{
sprintf ( DS_Error_Msg , " Error DS_Value_Free : the structure root is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
if ( ! Value )
{
sprintf ( DS_Error_Msg , " Error DS_Value_Free : the value is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
return DS_Value_Free_L ( Root , Value ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Allocation de m<> moire pour une structure de donn<6E> es : */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
/* (I) Size : taille m<> moire <20> allouer */
/* (O) Ptr : adresse du pointeur sur la zone de donn<6E> es allou<6F> e */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Alloc_CL ( NDT_Root * Root , size_t Size , void * * Ptr )
{
if ( ! Root )
{
sprintf ( DS_Error_Msg , " Error DS_Alloc : the structure root is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
if ( Size < = 0 )
{
sprintf ( DS_Error_Msg , " Error DS_Alloc : the allocation size must be > 0 " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
if ( ! Ptr )
{
sprintf ( DS_Error_Msg , " Error DS_Alloc : the data pointer address is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
return DS_Alloc_L ( Root , Size , Ptr ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* D<> sallocation d'une ressource pour une structure de donn<6E> es : */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de donn<6E> es */
/* (I) Ptr : pointeur sur la zone <20> d<> sallouer */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
DST_Status DS_Free_CL ( NDT_Root * Root , void * Ptr )
{
if ( ! Root )
{
sprintf ( DS_Error_Msg , " Error DS_Free : the structure root is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
if ( ! Ptr )
{
sprintf ( DS_Error_Msg , " Error DS_Free : the data pointer is null " ) ;
DS_Error_Print ( ) ;
return DSS_ERRAPI ;
}
return DS_Free_L ( Root , Ptr ) ;
}
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* FONCTIONS PRIVEES */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
2000-07-28 17:30:55 +02:00
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Teste si une data structure a d<> j<EFBFBD> <20> t<EFBFBD> ouverte par le processus courant : */
/*----------------------------------------------------------------------------*/
/* (I) DS_Name : nom de la data structure */
/* (O) Root : adresse du pointeur sur la racine de la structure */
/*----------------------------------------------------------------------------*/
2000-07-28 17:30:55 +02:00
2024-04-24 20:27:46 +02:00
DST_Status DS_DataStruct_IsOpen ( NDT_Root * * Root_Ptr_Ptr , char * DS_Name )
{
NDT_Status nd_status ;
DST_DataStruct to_find , * found_ptr ;
to_find . Name = DS_Name ;
2000-07-28 17:30:55 +02:00
2024-04-24 20:27:46 +02:00
if ( ( nd_status = ND_DataStruct_Value_Find ( ( void * * ) & found_ptr , OpenedDS_List , & to_find ) ) ! = NDS_OK )
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Can't lookup for opened data structure: [%s], status: (%d) " , DS_Name , nd_status ) ;
2000-07-28 17:30:55 +02:00
2024-04-24 20:27:46 +02:00
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 ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-23 17:10:37 +02:00
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Fonction d'allocation attach<63> e <20> une structure de donn<6E> es : */
/*----------------------------------------------------------------------------*/
2024-04-23 17:10:37 +02:00
2024-04-28 19:59:38 +02:00
DST_Status DS_DataStruct_Alloc ( void * * Ptr_Ptr , size_t Size , void * Data_Ptr )
2000-07-28 17:30:55 +02:00
{
2024-04-23 17:10:37 +02:00
DST_Status status ;
SMT_Status sm_status ;
SMT_Heap * heap_ptr ;
int locked ;
DST_RootDesc * RootDesc = ( DST_RootDesc * ) Data_Ptr ;
// char *heap_name = RootDesc->Heap_Name;
2000-07-28 17:30:55 +02:00
2024-04-23 17:10:37 +02:00
if ( ( sm_status = SM_Heap_IsOpen ( RootDesc - > Heap_Name , & heap_ptr ) ) ! = SMS_YES )
2000-07-28 17:30:55 +02:00
{
2024-04-23 17:10:37 +02:00
LG_LOG_ERROR_1 ( " The data structure heap: [%s] is not open " , RootDesc - > Heap_Name ) ;
2000-07-28 17:30:55 +02:00
2024-04-23 17:10:37 +02:00
return ( DSS_OK ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-23 17:10:37 +02:00
2000-07-28 17:30:55 +02:00
/* Verrouillage du heap en <20> criture */
2024-04-23 17:10:37 +02:00
if ( ( sm_status = SM_Heap_Lock ( heap_ptr , SMD_WRITE , & locked ) ) ! = SMS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable to lock the data structure heap: [%s] for writing, status: (%d) " , RootDesc - > Heap_Name , sm_status ) ;
2000-07-28 17:30:55 +02:00
2024-04-23 17:10:37 +02:00
return ( DSS_OK ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-23 17:10:37 +02:00
2000-07-28 17:30:55 +02:00
/* Allocation du chunk */
2024-04-23 17:10:37 +02:00
if ( ( sm_status = SM_Chunk_Alloc ( heap_ptr , Size , Ptr_Ptr ) ) ! = SMS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_3 ( " Unable to alloc size: (%d) in the heap: [%s] for writing, status: (%d) " , Size , RootDesc - > Heap_Name , sm_status ) ;
2024-04-23 17:10:37 +02:00
if ( locked = = TRUE ) SM_Heap_Unlock ( heap_ptr ) ;
return ( DSS_KO ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-23 17:10:37 +02:00
2000-07-28 17:30:55 +02:00
/* D<> verrouillage de la data structure si besoin */
2024-04-23 17:10:37 +02:00
2024-04-28 19:59:38 +02:00
if ( locked = = TRUE )
{
if ( ( sm_status = SM_Heap_Unlock ( heap_ptr ) ) ! = SMS_OK )
{
LG_LOG_ERROR_2 ( " Unable to unlock the data structure heap: [%s], status: (%d) " , heap_ptr - > Name , sm_status ) ;
}
}
2000-07-28 17:30:55 +02:00
2024-04-28 19:59:38 +02:00
return ( DSS_OK ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-28 19:59:38 +02:00
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Fonction de d<> sallocation attach<63> e <20> une structure de donn<6E> es : */
/*----------------------------------------------------------------------------*/
2024-04-28 19:59:38 +02:00
DST_Status DS_DataStruct_Free ( void * Ptr , void * Data_Ptr )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
DST_RootDesc * RootDesc_Ptr = ( DST_RootDesc * ) Data_Ptr ;
char * Heap_Name = RootDesc_Ptr - > Heap_Name ;
2000-07-28 17:30:55 +02:00
2024-04-28 19:59:38 +02:00
DST_Status status ;
SMT_Status sm_status ;
SMT_Heap * heap_ptr ;
int locked ;
if ( ( sm_status = SM_Heap_IsOpen ( Heap_Name , & heap_ptr ) ) ! = SMS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable to check if heap: [%s] is open, status: (%d) " , Heap_Name , sm_status ) ;
2000-07-28 17:30:55 +02:00
2024-04-28 19:59:38 +02:00
return ( DSS_KO ) ;
}
else
{
if ( heap_ptr = = NULL )
{
LG_LOG_ERROR_1 ( " DatatStructure heap: [%s] is not open " , Heap_Name ) ;
return ( DSS_KO ) ;
}
2000-07-28 17:30:55 +02:00
}
2024-04-28 19:59:38 +02:00
2000-07-28 17:30:55 +02:00
/* Verrouillage de la data structure en <20> criture */
2024-04-28 19:59:38 +02:00
if ( ( sm_status = SM_Heap_Lock ( heap_ptr , SMD_WRITE , & locked ) ) ! = SMS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unable to lock the data structure heap: [%s] for writing, status: (%d) " , heap_ptr - > Name , sm_status ) ;
2000-07-28 17:30:55 +02:00
2024-04-28 19:59:38 +02:00
return ( DSS_KO ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-28 19:59:38 +02:00
2000-07-28 17:30:55 +02:00
/* D<> sallocation du chunk */
2024-04-28 19:59:38 +02:00
if ( ( sm_status = SM_Chunk_Free ( heap_ptr , Ptr ) ) ! = SMS_OK )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_3 ( " Unable to free a chuck: [%p] from the datastructure heap: [%s], status: [%s] " , Ptr , heap_ptr - > Name , sm_status ) ;
status = DSS_KO ;
}
else
{
status = DSS_OK ;
2000-07-28 17:30:55 +02:00
}
2024-04-28 19:59:38 +02:00
2000-07-28 17:30:55 +02:00
/* D<> verrouillage de la data structure si besoin */
2024-04-28 19:59:38 +02:00
if ( locked = = TRUE )
{
if ( ( sm_status = SM_Heap_Unlock ( heap_ptr ) ) ! = SMS_OK )
{
LG_LOG_ERROR_2 ( " Unable to unlock the data structure heap: [%s], status: (%d) " , heap_ptr - > Name , sm_status ) ;
status = DSS_KO ;
}
}
return ( status ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-28 19:59:38 +02:00
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Routine d'affichage d'un message d'erreur */
/*----------------------------------------------------------------------------*/
/*
2000-07-28 17:30:55 +02:00
void DS_Error_Print ( void )
{
if ( DS_stderr ) fprintf ( DS_stderr , " %s \n " , DS_Error_Msg ) ;
}
2024-04-28 19:59:38 +02:00
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Pour pr<70> fixer les noms de heap avec l'identifiant de la librairie */
/*----------------------------------------------------------------------------*/
2024-04-23 17:10:37 +02:00
2024-04-28 19:59:38 +02:00
DST_Status DS_Name_Prefix ( char * Prefixed_Name_Ptr , const char * Unprefixed_Name_Ptr )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
snprintf ( Prefixed_Name_Ptr , DSD_NAME_SIZE , " %s/%s " , DS_PREFIX , Unprefixed_Name_Ptr ) ;
2000-07-28 17:30:55 +02:00
2024-04-28 19:59:38 +02:00
return ( DSS_OK ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-27 20:00:00 +02:00
2024-04-28 19:59:38 +02:00
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Cr<43> ation d'un s<> maphore pour g<> rer l'ouverture d'une data structure */
/*----------------------------------------------------------------------------*/
2024-04-27 20:00:00 +02:00
DST_Status DS_Semaphore_Create ( NDT_Root * Root_Ptr )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
DST_RootDesc * RootDesc_Ptr = ( DST_RootDesc * ) ( Root_Ptr - > User_Ptr ) ;
2024-04-27 20:00:00 +02:00
union semun sem_ctl ;
2000-07-28 17:30:55 +02:00
2024-04-27 20:00:00 +02:00
2000-07-28 17:30:55 +02:00
/* Cr<43> ation du s<> maphore */
2024-04-27 20:00:00 +02:00
2024-04-28 19:59:38 +02:00
RootDesc_Ptr - > OpenSemId = semget ( IPC_PRIVATE , 1 , ( 0777 | IPC_CREAT | IPC_EXCL ) ) ;
if ( RootDesc_Ptr - > OpenSemId = = - 1 )
2000-07-28 17:30:55 +02:00
{
2024-04-27 20:00:00 +02:00
switch ( errno )
2000-07-28 17:30:55 +02:00
{
case ENOMEM :
2024-04-27 20:00:00 +02:00
{
LG_LOG_ERROR_0 ( " Not enough memory to create a new semaphore " ) ;
2000-07-28 17:30:55 +02:00
break ;
2024-04-27 20:00:00 +02:00
}
2000-07-28 17:30:55 +02:00
case ENOSPC :
2024-04-27 20:00:00 +02:00
{
LG_LOG_ERROR_0 ( " The number of semaphores would exceeds the system-imposed limit " ) ;
2000-07-28 17:30:55 +02:00
break ;
2024-04-27 20:00:00 +02:00
}
2000-07-28 17:30:55 +02:00
default :
2024-04-27 20:00:00 +02:00
{
LG_LOG_ERROR_1 ( " Unknown error: (%d) while creating a semaphore " , errno ) ;
2000-07-28 17:30:55 +02:00
break ;
2024-04-27 20:00:00 +02:00
}
2000-07-28 17:30:55 +02:00
}
2024-04-27 20:00:00 +02:00
return ( DSS_ERRSEM ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-27 20:00:00 +02:00
2000-07-28 17:30:55 +02:00
/* Initialisation du s<> maphore <20> 0 */
2024-04-27 20:00:00 +02:00
sem_ctl . val = 0 ;
2024-04-28 19:59:38 +02:00
if ( semctl ( RootDesc_Ptr - > OpenSemId , 0 , SETVAL , sem_ctl ) )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_1 ( " Unable to initialize the value of the semaphore: (%x) " , RootDesc_Ptr - > OpenSemId ) ;
2000-07-28 17:30:55 +02:00
2024-04-28 19:59:38 +02:00
semctl ( RootDesc_Ptr - > OpenSemId , 0 , IPC_RMID , sem_ctl ) ;
2000-07-28 17:30:55 +02:00
2024-04-27 20:00:00 +02:00
return ( DSS_ERRSEM ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-27 20:00:00 +02:00
return ( DSS_OK ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-27 20:00:00 +02:00
2024-04-28 19:59:38 +02:00
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Op<4F> ration sur un s<> maphore */
/*----------------------------------------------------------------------------*/
2024-04-27 20:00:00 +02:00
2024-04-28 19:59:38 +02:00
DST_Status DS_Semaphore_Operate ( int SemId , struct sembuf * Operations , unsigned int Nb_Oper )
2000-07-28 17:30:55 +02:00
{
2024-04-28 19:59:38 +02:00
if ( semop ( SemId , Operations , Nb_Oper ) = = - 1 )
2000-07-28 17:30:55 +02:00
{
2024-04-27 20:00:00 +02:00
switch ( errno )
2000-07-28 17:30:55 +02:00
{
case EAGAIN :
2024-04-27 20:00:00 +02:00
{
LG_LOG_ERROR_0 ( " The operation would result in suspension of the calling process but the operations have been defined in no wait mode " ) ;
2000-07-28 17:30:55 +02:00
break ;
2024-04-27 20:00:00 +02:00
}
2000-07-28 17:30:55 +02:00
case EACCES :
2024-04-27 20:00:00 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_1 ( " Current process is not allowed to operate on semaphore: (%x) " , SemId ) ;
2024-04-27 20:00:00 +02:00
2000-07-28 17:30:55 +02:00
break ;
2024-04-27 20:00:00 +02:00
}
2000-07-28 17:30:55 +02:00
case EIDRM :
2024-04-27 20:00:00 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_1 ( " Semaphore: (%x) does not exist " , SemId ) ;
2024-04-27 20:00:00 +02:00
2000-07-28 17:30:55 +02:00
break ;
2024-04-27 20:00:00 +02:00
}
2000-07-28 17:30:55 +02:00
case EINTR :
2024-04-27 20:00:00 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_1 ( " A signal was received while operating on semaphore: (%x) " , SemId ) ;
2024-04-27 20:00:00 +02:00
return ( DSS_ERRSIG ) ;
}
2000-07-28 17:30:55 +02:00
case EINVAL :
2024-04-27 20:00:00 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_1 ( " The semaphore key: (%x) is incorrect or the number of operations which can be done in UNDO mode exceeds the system-imposed limit " , SemId ) ;
2024-04-27 20:00:00 +02:00
2000-07-28 17:30:55 +02:00
break ;
2024-04-27 20:00:00 +02:00
}
2000-07-28 17:30:55 +02:00
case ENOSPC :
2024-04-27 20:00:00 +02:00
{
LG_LOG_ERROR_0 ( " The maximum number of process which can operate on semaphore in UNDO mode has been reached " ) ;
2000-07-28 17:30:55 +02:00
break ;
2024-04-27 20:00:00 +02:00
}
2000-07-28 17:30:55 +02:00
case ERANGE :
2024-04-27 20:00:00 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_1 ( " The value of semaphore: (%x) has reached the system-imposed limit " , SemId ) ;
2024-04-27 20:00:00 +02:00
2000-07-28 17:30:55 +02:00
break ;
2024-04-27 20:00:00 +02:00
}
2000-07-28 17:30:55 +02:00
default :
2024-04-27 20:00:00 +02:00
{
2024-04-28 19:59:38 +02:00
LG_LOG_ERROR_2 ( " Unknown error: (%d) while operating on semaphore: (%x) " , errno , SemId ) ;
2024-04-27 20:00:00 +02:00
2000-07-28 17:30:55 +02:00
break ;
2024-04-27 20:00:00 +02:00
}
2000-07-28 17:30:55 +02:00
}
2024-04-27 20:00:00 +02:00
return ( DSS_ERRSEM ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-27 20:00:00 +02:00
return ( DSS_OK ) ;
2000-07-28 17:30:55 +02:00
}
2024-04-27 20:00:00 +02:00
2024-04-28 19:59:38 +02:00
2024-04-22 00:24:37 +02:00
/*----------------------------------------------------------------------------*/
/* Fonction manager de la liste des DS ouvertes */
/*----------------------------------------------------------------------------*/
2000-07-28 17:30:55 +02:00
2024-04-24 20:27:46 +02:00
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_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 ) ;
}
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 ) ;
}
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 ) ;
*/
2024-04-27 20:00:00 +02:00
ND_VA_ARG_GET ( Opened_DataStruct_Ptr_Ptr , * Args_Ptr , DST_DataStruct * * ) ;
ND_VA_LIST_OPEN ( user_args , * Args_Ptr ) ;
ND_VA_ARG_GET ( DS_Name , user_args , char * ) ;
ND_VA_ARG_GET ( Root_Ptr , user_args , NDT_Root * ) ;
ND_VA_LIST_CLOSE ( user_args ) ;
2024-04-24 20:27:46 +02:00
Command_Name = " NDD_CMD_VALUE_ALLOC " ;
2024-04-27 20:00:00 +02:00
LG_LOG_TRACE_1 ( LGD_LOG_LEVEL_DEFAULT , " Command: [%s] called " , Command_Name ) ;
2024-04-24 20:27:46 +02:00
2024-04-27 20:00:00 +02:00
if ( ( * Opened_DataStruct_Ptr_Ptr = ( DST_DataStruct * ) malloc ( sizeof ( DST_DataStruct ) ) ) = = NULL )
{
LG_LOG_ERROR_1 ( " Can't allocate value zise: (%d) " , sizeof ( DST_DataStruct ) ) ;
return ( DSS_KO ) ;
}
else
{
( * Opened_DataStruct_Ptr_Ptr ) - > Name = DS_Name ;
( * Opened_DataStruct_Ptr_Ptr ) - > Root_Ptr = Root_Ptr ;
return ( DSS_OK ) ;
}
2024-04-24 20:27:46 +02:00
}
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 ) ;
*/
2024-04-27 20:00:00 +02:00
ND_VA_ARG_GET ( Opened_DataStruct_Ptr , * Args_Ptr , DST_DataStruct * ) ;
2024-04-24 20:27:46 +02:00
Command_Name = " NDD_CMD_VALUE_FREE " ;
2024-04-27 20:00:00 +02:00
LG_LOG_TRACE_1 ( LGD_LOG_LEVEL_DEFAULT , " Command: [%s] called " , Command_Name ) ;
free ( Opened_DataStruct_Ptr ) ;
2024-04-24 20:27:46 +02:00
/*
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 ) ;
2000-07-28 17:30:55 +02:00
}