libdatastr/lib/libdatastr.c

4234 lines
140 KiB
C
Raw Normal View History

/*----------------------------------------------------------------------------*/
/* 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>
//VER_INFO_EXPORT (libdatastr,"$Revision: 1.1 $", "$Name: $",__FILE__,"$Author: smas $")
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* FONCTIONS PUBLIQUES */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* FONCTIONS OPTIMISATION MAXIMALE (DS_MODE = 2) */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* Library instance initialisation */
/*----------------------------------------------------------------------------*/
/* (I) Instance: Library instance id */
/* (I) Context: Context name */
/* (I) Debug_Mode: Open library in debug mode */
/*----------------------------------------------------------------------------*/
DST_Status DS_Library_Open_I ( int Instance, const char *Context, DST_Flags Debug_Mode )
2000-07-28 17:30:55 +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 */
if( Debug_Mode & DSD_DEBUG)
2000-07-28 17:30:55 +02:00
{
DS_stderr = stderr;
sm_debug_flag = SMD_DEBUG;
2000-07-28 17:30:55 +02:00
}
else if( Debug_Mode & DSD_DEBUG_ALL)
2000-07-28 17:30:55 +02:00
{
DS_stderr = stderr;
sm_debug_flag = SMD_DEBUG_ALL;
2000-07-28 17:30:55 +02:00
}
if( ( lg_status = LG_Library_Open( LGD_LOG_WRITER_DEFAULT, false)) != LGS_OK)
2000-07-28 17:30:55 +02:00
{
fprintf( stderr, "Can't open LibLog library: (%d)\n", lg_status);
return( DSS_KO);
}
2000-07-28 17:30:55 +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);
return( DSS_KO);
2000-07-28 17:30:55 +02:00
}
2000-07-28 17:30:55 +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
if( DS_Open_Counter == 0)
2000-07-28 17:30:55 +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
{
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);
return( DSS_KO);
2000-07-28 17:30:55 +02:00
}
}
DS_Open_Counter++;
return( DSS_OK);
2000-07-28 17:30:55 +02:00
}
/*----------------------------------------------------------------------------*/
/* Fermeture de l'instance de la librairie */
/*----------------------------------------------------------------------------*/
DST_Status DS_Library_Close_I( void)
2000-07-28 17:30:55 +02:00
{
NDT_Status nd_status;
SMT_Status sm_status;
LGT_Status lg_status;
2000-07-28 17:30:55 +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.
*/
2000-07-28 17:30:55 +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
{
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
}
}
2000-07-28 17:30:55 +02:00
/* Fermeture de la librairie LIBSHMEM */
if( ( sm_status = SM_Library_Close( SMD_CLOSE)) != SMS_OK)
2000-07-28 17:30:55 +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--;
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
}
/*----------------------------------------------------------------------------*/
/* D<>finition de la sortie standard des messages d'erreur de la librairie */
/*----------------------------------------------------------------------------*/
/* (I) Out : flux de sortie des messages d'erreur */
/*----------------------------------------------------------------------------*/
DST_Status DS_Library_Stderr_Set_I( FILE *Out)
2000-07-28 17:30:55 +02:00
{
DS_stderr = Out;
return( DSS_OK);
2000-07-28 17:30:55 +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 */
/* (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 */
/*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Open_I( DST_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-23 17:10:37 +02:00
SMT_Heap *heap_ptr;
SMT_DSH *dsh_ptr;
2024-04-23 17:10:37 +02:00
int locked, mode;
DST_Root root_tmp;
NDT_Root *nd_root_ptr;
// DST_RootDesc *rootdesc_ptr, rootdesc_tmp;
DST_DataStruct *opened_datastruct_ptr;
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
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
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
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-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
{
/*--------------- 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
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
{
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
}
2024-04-23 17:10:37 +02:00
/* Create the Root structure */
strncpy( root_tmp.Heap_Name, prefixed_name, DSD_NAME_LEN);
root_tmp.Heap_Name[ DSD_NAME_LEN] = '\0';
root_tmp.Status = DSD_DATASTRUCT_STATUS_TEMPORARY;
/* Cr<43>ation de la node structure */
if( ( nd_status = ND_DataStruct_Open( &nd_root_ptr, Index_Nb, Index_Type_Tab, Manager_Name, NULL, "DS_Allocator", NULL, "DS_Deallocator", NULL, Own_Value, &root_tmp)) != NDS_OK)
2000-07-28 17:30:55 +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
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
}
/* Initialise root */
*Root_Ptr_Ptr = DSD_DS_ROOT_GET( nd_root_ptr);
strncpy( ( *Root_Ptr_Ptr)->Name, DS_Name, DSD_NAME_LEN);
( *Root_Ptr_Ptr)->Name[ DSD_NAME_LEN] = '\0';
strncpy( ( *Root_Ptr_Ptr)->Heap_Name, prefixed_name, DSD_NAME_LEN);
( *Root_Ptr_Ptr)->Heap_Name[ DSD_NAME_LEN] = '\0';
2000-07-28 17:30:55 +02:00
( *Root_Ptr_Ptr)->Heap_Owner = FALSE;
( *Root_Ptr_Ptr)->Status = DSD_DATASTRUCT_STATUS_VALID;
( *Root_Ptr_Ptr)->ND_Root.User_Ptr = NULL;
2000-07-28 17:30:55 +02:00
/* D<>verrouillage du heap */
if( locked == TRUE)
2000-07-28 17:30:55 +02:00
{
if( ( sm_status = SM_Heap_Unlock( heap_ptr)) != SMS_OK)
2000-07-28 17:30:55 +02:00
{
LG_LOG_ERROR_2( "Unable to unlock the data structure heap: [%s], status: (%d)", heap_ptr->Name, sm_status);
return( DSS_KO);
2000-07-28 17:30:55 +02:00
}
}
return( DSS_OK);
2024-04-23 17:10:37 +02:00
}
2000-07-28 17:30:55 +02:00
case 2:
{
/*--------------- 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 */
if( ( status = DS_DataStruct_IsOpen( Root_Ptr_Ptr, DS_Name)) != DSS_OK)
{
LG_LOG_ERROR_2( "Unable test data structure: [%s] state, status: (%d)", DS_Name, status);
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 */
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
{
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);
}
}
*Root_Ptr_Ptr = NULL;
return( status);
2000-07-28 17:30:55 +02:00
}
dsh_ptr = heap_ptr->MHH->DSR->Index_Tab[ NDD_INDEX_PRIMARY].Head->Value;
2000-07-28 17:30:55 +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 */
*Root_Ptr_Ptr = ( DST_Root *)( ( size_t)( dsh_ptr->Start) + sizeof( NDT_Node) + sizeof( SMT_Chunk));
break;
}
2000-07-28 17:30:55 +02:00
case 3:
2024-04-23 17:10: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
if( !Manager_Name)
2000-07-28 17:30:55 +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
}
2000-07-28 17:30:55 +02:00
/* Cr<43>ation d'un nouveau heap */
2024-04-23 17:10:37 +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
{
LG_LOG_ERROR_2( "Unable to create a heap for the data structure [%s], status: (%d)", DS_Name, sm_status);
return( DSS_KO);
2000-07-28 17:30:55 +02:00
}
/* Create the Root structure */
2024-04-23 17:10:37 +02:00
strncpy( root_tmp.Heap_Name, prefixed_name, DSD_NAME_LEN);
root_tmp.Heap_Name[ DSD_NAME_LEN] = '\0';
root_tmp.Status = DSD_DATASTRUCT_STATUS_TEMPORARY;
/* Cr<43>ation de la structure de donn<6E>es dans le heap */
if( ( nd_status = ND_DataStruct_Open( &nd_root_ptr, Index_Nb, Index_Type_Tab, Manager_Name, NULL, "DS_Allocator", NULL, "DS_Deallocator", NULL, Own_Value, &root_tmp)) != NDS_OK)
2000-07-28 17:30:55 +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-23 17:10:37 +02:00
*Root_Ptr_Ptr = NULL;
return( SMS_KO);
2000-07-28 17:30:55 +02:00
}
/* Initialise root */
*Root_Ptr_Ptr = DSD_DS_ROOT_GET( nd_root_ptr);
strncpy( ( *Root_Ptr_Ptr)->Name, DS_Name, DSD_NAME_LEN);
( *Root_Ptr_Ptr)->Name[ DSD_NAME_LEN] = '\0';
strncpy( ( *Root_Ptr_Ptr)->Heap_Name, prefixed_name, DSD_NAME_LEN);
( *Root_Ptr_Ptr)->Heap_Name[ DSD_NAME_LEN] = '\0';
( *Root_Ptr_Ptr)->Heap_Owner = FALSE;
( *Root_Ptr_Ptr)->Status = DSD_DATASTRUCT_STATUS_VALID;
( *Root_Ptr_Ptr)->ND_Root.User_Ptr = NULL;
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 */
if( ( status = DS_Semaphore_Create( *Root_Ptr_Ptr)) != DSS_OK)
2000-07-28 17:30:55 +02:00
{
LG_LOG_ERROR_2( "Unable to create a semaphore for the data structure: [%s], status: (%d)", DS_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);
}
*Root_Ptr_Ptr = NULL;
return( status);
2000-07-28 17:30:55 +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
}
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 */
if( ( status = DS_Semaphore_Operate( ( *Root_Ptr_Ptr)->OpenSemId, DS_SemOp_Open, 1)) != DSS_OK)
2000-07-28 17:30:55 +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
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
if( mode == 3)
2000-07-28 17:30:55 +02:00
{
semctl( ( *Root_Ptr_Ptr)->OpenSemId, 0, IPC_RMID, Sem_Ctl);
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);
}
}
else
{
DS_Semaphore_Operate( ( *Root_Ptr_Ptr)->OpenSemId, DS_SemOp_Close, 1);
2000-07-28 17:30:55 +02:00
}
*Root_Ptr_Ptr = NULL;
2000-07-28 17:30:55 +02:00
return( status);
2000-07-28 17:30:55 +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 */
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
{
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
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
if( mode == 3)
2000-07-28 17:30:55 +02:00
{
semctl( ( *Root_Ptr_Ptr)->OpenSemId, 0, IPC_RMID, Sem_Ctl);
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);
}
}
else
{
DS_Semaphore_Operate( ( *Root_Ptr_Ptr)->OpenSemId, DS_SemOp_Close, 1);
2000-07-28 17:30:55 +02:00
}
*Root_Ptr_Ptr = NULL;
2000-07-28 17:30:55 +02:00
return( DSS_KO);
2000-07-28 17:30:55 +02:00
}
if( ( nd_status = ND_DataStruct_Value_Add( OpenedDS_List, (void *)opened_datastruct_ptr)) != NDS_OK)
{
LG_LOG_ERROR_2( "Unable to add an new data structure element: [%s] to the opened structure list, status: (%d)", DS_Name, status);
if( ( nd_status = ND_Value_Free( OpenedDS_List, (void *)opened_datastruct_ptr)) != NDS_OK)
{
LG_LOG_ERROR_2( "Unable to free a new opened data structure element: [%s], status: (%d)", DS_Name, nd_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);
}
}
if( mode == 3)
{
semctl( ( *Root_Ptr_Ptr)->OpenSemId, 0, IPC_RMID, Sem_Ctl);
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);
}
}
else
{
DS_Semaphore_Operate( ( *Root_Ptr_Ptr)->OpenSemId, DS_SemOp_Close, 1);
}
*Root_Ptr_Ptr = NULL;
2000-07-28 17:30:55 +02:00
return( DSS_KO);
}
2000-07-28 17:30:55 +02:00
/* D<>verrouillage du heap */
if( locked == TRUE)
2000-07-28 17:30:55 +02:00
{
if( sm_status = ( SM_Heap_Unlock( heap_ptr)) != SMS_OK)
2000-07-28 17:30:55 +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
if( ( nd_status = ND_DataStruct_Value_Remove( OpenedDS_List, opened_datastruct_ptr)) != NDS_OK)
{
LG_LOG_ERROR_2( "Unable to remove a data structure element: [%s] to the opened structure list, status: (%d)", DS_Name, status);
}
if( ( nd_status = ND_Value_Free( OpenedDS_List, opened_datastruct_ptr)) != NDS_OK)
{
LG_LOG_ERROR_2( "Unable to free a new opened data structure element: [%s], status: (%d)", DS_Name, nd_status);
}
if( mode == 3)
{
semctl( ( *Root_Ptr_Ptr)->OpenSemId, 0, IPC_RMID, Sem_Ctl);
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);
}
}
else
2000-07-28 17:30:55 +02:00
{
DS_Semaphore_Operate( ( *Root_Ptr_Ptr)->OpenSemId, DS_SemOp_Close, 1);
2000-07-28 17:30:55 +02:00
}
*Root_Ptr_Ptr = NULL;
2000-07-28 17:30:55 +02:00
return( DSS_KO);
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
}
/*----------------------------------------------------------------------------*/
/* 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 */
/* (I) Close_Mode : mode de fermeture de la structure (destruction ou non) */
/*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Close_I( DST_Root *Root_Ptr, DST_Flags Close_Mode)
2000-07-28 17:30:55 +02:00
{
// DST_RootDesc *RootDesc_Ptr = (DST_RootDesc *)( Root_Ptr->User_Ptr);
2000-07-28 17:30:55 +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
strcpy( heap_name, Root_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
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 ? */
if( Root_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 */
if( ( status = DS_Semaphore_Operate( Root_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
return( status);
2000-07-28 17:30:55 +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) */
if( ( nd_status = ND_DataStruct_Close( &( Root_Ptr->ND_Root))) != NDS_OK)
2000-07-28 17:30:55 +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
return( DSS_KO);
2000-07-28 17:30:55 +02:00
}
2000-07-28 17:30:55 +02:00
/* Suppression du s<>maphore */
semctl( Root_Ptr->OpenSemId, 0, IPC_RMID, sem_ctl);
2000-07-28 17:30:55 +02:00
/* On supprime maintenant le heap */
if( ( sm_status = SM_Heap_End( heap_name)) != SMS_OK)
2000-07-28 17:30:55 +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
return( DSS_KO);
2000-07-28 17:30:55 +02:00
}
}
else
{
/*
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.
*/
if( ( nd_status = ND_DataStruct_Close( &( Root_Ptr->ND_Root))) != NDS_OK)
2000-07-28 17:30:55 +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
if( ( status = DS_Deallocator( Root_Ptr, &( Root_Ptr->ND_Root), NULL)) != 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
}
return( status);
2000-07-28 17:30:55 +02:00
}
}
else /* Fermeture simple de la data structure */
{
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 */
if( ( status = DS_Semaphore_Operate( Root_Ptr->OpenSemId, DS_SemOp_Close, 1)) != DSS_OK)
2000-07-28 17:30:55 +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
return( status);
2000-07-28 17:30:55 +02:00
}
2000-07-28 17:30:55 +02:00
/* Fermeture simple du heap */
if( ( sm_status = SM_Heap_IsOpen( heap_name, &heap_ptr)) != SMS_OK)
2000-07-28 17:30:55 +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
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
}
}
}
2000-07-28 17:30:55 +02:00
/* Suppression de la data structure de la liste des structures ouvertes */
strncpy( to_remove.Name, ds_name, DSD_NAME_LEN);
if( ( ( nd_status = ND_DataStruct_Value_Find( ( void **)&opened_datastruct_ptr, OpenedDS_List, &to_remove)) != NDS_OK) || ( opened_datastruct_ptr == NULL))
{
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
}
/*----------------------------------------------------------------------------*/
/* Destroy all data of a data structure */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/*----------------------------------------------------------------------------*/
NDT_Status DS_DataStruct_Flush_I( DST_Root *Root_Ptr)
{
NDT_Status nd_status;
if( ( nd_status = ND_DataStruct_Flush_I( &( Root_Ptr->ND_Root))) != NDS_OK)
{
LG_LOG_ERROR_1( "Unable to flush datastructure, status: (%d)", nd_status);
return( DSS_KO);
}
else
{
return( DSS_OK);
}
}
/*----------------------------------------------------------------------------*/
/* Check & repare a datat structure: */
/* - Check & fix node links */
/* - Update data structure statistics */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (O) Error_Dectected_Nb_Ptr: Number of error detected pointer */
/* (O) Error_Corrected_Nb_Ptr: Number of error corected pointer */
/* (I) Out: Output stream */
/*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Check_I( DST_Root *Root_Ptr, int *Error_Detected_Nb_Ptr, int *Error_Corrected_Nb_Ptr, FILE *Out)
2000-07-28 17:30:55 +02:00
{
// DST_RootDesc *RootDesc_Ptr = (DST_RootDesc *)( Root_Ptr->User_Ptr);
// char *Heap_Name = RootDesc_Ptr->Heap_Name;
DST_Status status, status2;
SMT_Status sm_status;
NDT_Status nd_status;
SMT_Heap *heap_ptr;
int locked;
DST_Flags previous_lock;
2000-07-28 17:30:55 +02:00
/* On sauvegarde l'<27>tat de verrouillage pr<70>c<EFBFBD>dent */
if( ( sm_status = SM_Heap_IsOpen( Root_Ptr->Heap_Name, &heap_ptr)) != SMS_OK)
{
LG_LOG_ERROR_2( "Unable to check if heap: [%s] is open, status: (%d)", Root_Ptr->Heap_Name, sm_status);
return( DSS_KO);
}
else
{
if( heap_ptr == NULL)
{
LG_LOG_ERROR_1( "Data structure heap: [%s] is not open", Root_Ptr->Heap_Name);
return( DSS_KO);
}
}
previous_lock = heap_ptr->Lock_Mode;
/* Verrouillage de la data structure en <20>criture */
if( ( status = DS_DataStruct_Lock_I( Root_Ptr, SMD_WRITE, &locked)) != DSS_OK)
2000-07-28 17:30:55 +02:00
{
LG_LOG_ERROR_2( "Unable to lock the data structure: [%s] for writing, status : (%s)", Root_Ptr->Heap_Name, status);
2000-07-28 17:30:55 +02:00
return( SMS_OK);
}
2000-07-28 17:30:55 +02:00
/* V<>rification du heap sous-jacent <20> la data structure */
if( ( sm_status = SM_Heap_Check( heap_ptr, Error_Detected_Nb_Ptr, Error_Corrected_Nb_Ptr, Out)) != SMS_OK)
{
LG_LOG_ERROR_2( "Unable to check the heap: [%s] for writing, status : (%s)", Root_Ptr->Heap_Name, sm_status);
status= DSS_KO;
}
else
{
/* V<>rification de la structure de noeuds */
LG_LOG_INFO_0( "Checking the node structure...");
if( ( nd_status = ND_DataStruct_Check( &(Root_Ptr->ND_Root), Error_Detected_Nb_Ptr, Error_Corrected_Nb_Ptr, Out)) != NDS_OK)
2000-07-28 17:30:55 +02:00
{
LG_LOG_ERROR_2( "Unable to check the data structure: [%s], status: (%d)", Root_Ptr->Heap_Name, nd_status);
2000-07-28 17:30:55 +02:00
status = DSS_KO;
}
else
{
/* On valide ou invalide la structure selon le r<>sultat */
if( *Error_Corrected_Nb_Ptr == *Error_Detected_Nb_Ptr)
{
Root_Ptr->Status = DSD_DATASTRUCT_STATUS_VALID;
}
else
{
Root_Ptr->Status = DSD_DATASTRUCT_STATUS_INVALID;
}
/* Affichage du r<>sultat de la proc<6F>dure de v<>rification */
if( *Error_Detected_Nb_Ptr)
{
if( *Error_Corrected_Nb_Ptr < *Error_Detected_Nb_Ptr)
{
LG_LOG_ERROR_2( "Error(s) detected: (%d) corected: (%d)", *Error_Detected_Nb_Ptr, *Error_Corrected_Nb_Ptr);
status = SMS_KO;
}
else
{
LG_LOG_WARNING_2( "Error(s) detected: (%d) corected: (%d)", *Error_Detected_Nb_Ptr, *Error_Corrected_Nb_Ptr);
status = SMS_OK;
}
}
else
{
LG_LOG_INFO_0( "No error detected in the data structure");
status = SMS_OK;
}
2000-07-28 17:30:55 +02:00
}
}
/* Retour au mode de verrouillage pr<70>c<EFBFBD>dent */
if( previous_lock == SMD_UNDEF)
{
if( ( status2 = DS_DataStruct_Unlock_I( Root_Ptr)) != DSS_OK)
{
LG_LOG_ERROR_2( "Unable to unlock the data structure: [%s], status: (%d)", Root_Ptr->Heap_Name, status2);
status = status2;
}
}
else
{
if( ( status2 = DS_DataStruct_Lock_I( Root_Ptr, previous_lock, &locked)) != SMS_OK)
{
LG_LOG_ERROR_2( "Unable to lock the data structure: [%s], status: (%d)", Root_Ptr->Heap_Name, status2);
status = status2;
}
}
return( status);
}
/*----------------------------------------------------------------------------*/
/* Convert a data structure indexe types */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Type_Ptr: Array of index type (List, tree, ...) */
/*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Convert_I( DST_Root *Root_Ptr, NDT_Index_Type *Index_Type_Ptr)
{
DST_Status status;
NDT_Status nd_status;
/* On v<>rifie que la data structure est valide */
DS_STRUCT_VALID_CHECK( Root_Ptr);
/* On rend la structure invalide le temps de sa conversion */
2000-07-28 17:30:55 +02:00
Root_Ptr->Status = DSD_DATASTRUCT_STATUS_INVALID;
2000-07-28 17:30:55 +02:00
/* Conversion de la node structure */
if( ( nd_status = ND_DataStruct_Convert( &( Root_Ptr->ND_Root), Index_Type_Ptr)) != NDS_OK)
{
LG_LOG_ERROR_1( "Unable to convert the node structure, status: (%d)", nd_status);
return( DSS_KO);
}
else
{
/* On rend la structure <20> nouveau valide */
Root_Ptr->Status = DSD_DATASTRUCT_STATUS_VALID;
return( DSS_OK);
}
2000-07-28 17:30:55 +02:00
}
/*----------------------------------------------------------------------------*/
/* Reorganise a data structure indexes: */
/* - Sort a non-sorted list */
/* - Rebalance a non auto-balanced tree */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Reorg_I( DST_Root *Root_Ptr)
2000-07-28 17:30:55 +02:00
{
// DST_RootDesc *RootDesc_Ptr = (DST_RootDesc *)( Root_Ptr->User_Ptr);
2000-07-28 17:30:55 +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 */
DS_STRUCT_VALID_CHECK( Root_Ptr);
2000-07-28 17:30:55 +02:00
/* On rend la structure invalide, le temps de sa r<>organisation */
Root_Ptr->Status = DSD_DATASTRUCT_STATUS_INVALID;
2000-07-28 17:30:55 +02:00
/* R<>organisation de la node structure */
if( ( nd_status = ND_DataStruct_Reorg( &( Root_Ptr->ND_Root))) != NDS_OK)
2000-07-28 17:30:55 +02:00
{
LG_LOG_ERROR_1( "Unable to reorg the node structure, status: (%d)", nd_status);
2000-07-28 17:30:55 +02:00
return( DSS_KO);
}
else
{
/* On rend la structure <20> nouveau valide */
2000-07-28 17:30:55 +02:00
Root_Ptr->Status = DSD_DATASTRUCT_STATUS_VALID;
2000-07-28 17:30:55 +02:00
return( DSS_OK);
2000-07-28 17:30:55 +02:00
}
}
2000-07-28 17:30:55 +02:00
/*----------------------------------------------------------------------------*/
/* Traverse a data structure & execute a command on each node */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Command: Manager command */
/* (I) ...: User args */
/*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Traverse_I( DST_Root *Root_Ptr, NDT_Command Command, ...)
{
DST_Status status;
NDT_Status nd_status;
va_list user_args;
/* On v<>rifie que la data structure est valide */
DS_STRUCT_VALID_CHECK( Root_Ptr);
/* R<>cup<75>ration des arguments pour l'allocation de la valeur */
va_start( user_args, Command);
/* On rend <20>ventuellement la structure invalide le temps de sa travers<72>e */
switch( Command)
{
case NDD_CMD_VALUE_PRINT:
break;
default:
Root_Ptr->Status = DSD_DATASTRUCT_STATUS_INVALID;
break;
}
/* Travers<72>e de la node structure */
if( ( nd_status = ND_DataStruct_Traverse_VI( &( Root_Ptr->ND_Root), Command, &user_args)) != NDS_OK)
{
LG_LOG_ERROR_1( "Unable to traverse the node structure, status: (%d)", nd_status);
status = DSS_KO;
}
else
{
status = DSS_OK;
}
/* On rend la structure valide */
Root_Ptr->Status = DSD_DATASTRUCT_STATUS_VALID;
va_end( user_args);
return( status);
}
/*----------------------------------------------------------------------------*/
/* Print data structure information */
/*----------------------------------------------------------------------------*/
/* (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 */
/*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Info_Print_I( FILE *Out, DST_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
{
DST_Status status;
NDT_Status nd_status;
LG_LOG_INFO_6( "DatatStruct: (%p) Name: [%s] Heap_Name: [%s] OpenSemId: (%d) Heap_Owner: [%s] Status: [%s]",
Root_Ptr, Root_Ptr->Name, Root_Ptr->Heap_Name, Root_Ptr->OpenSemId, DSD_BOOL_VALUE_ASCII_GET( Root_Ptr->Heap_Owner), DSD_DATASTRUCT_STATUS_VALUE_ASCII_GET( Root_Ptr->Status));
2000-07-28 17:30:55 +02:00
/* On v<>rifie que la data structure est valide */
DS_STRUCT_VALID_CHECK( Root_Ptr);
2000-07-28 17:30:55 +02:00
/* Affichage des informations sur la structure */
2000-07-28 17:30:55 +02:00
if( ( nd_status = ND_DataStruct_Info_Print( Out, &( Root_Ptr->ND_Root), Recursive_Mode, Recursive_Depth, Recursive_Offset)) != NDS_OK)
{
LG_LOG_ERROR_1( "Unable to print info about the data structure: (%d)", nd_status);
return( DSS_KO);
2000-07-28 17:30:55 +02:00
}
/* Opened DS Print */
if( ( nd_status = ND_DataStruct_Info_Print( Out, OpenedDS_List, Recursive_Mode, Recursive_Depth, Recursive_Offset)) != NDS_OK)
2000-07-28 17:30:55 +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
return( DSS_KO);
2000-07-28 17:30:55 +02:00
}
if( ( nd_status = ND_DataStruct_Value_Print( Out, OpenedDS_List, Recursive_Mode, Recursive_Depth, Recursive_Offset)) != NDS_OK)
2000-07-28 17:30:55 +02:00
{
LG_LOG_ERROR_1( "Unable to print values about the data structure: (%d)", nd_status);
2000-07-28 17:30:55 +02:00
return( DSS_KO);
2000-07-28 17:30:55 +02:00
}
/* Dump SM */
SM_Library_Dump( stderr);
2000-07-28 17:30:55 +02:00
return( DSS_OK);
2000-07-28 17:30:55 +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_I( DST_Root *Root_Ptr, DST_Flags Lock_Mode, int *Locked )
{
// char *Heap_Name = ( (DST_RootDesc *)( Root_Ptr->User_Ptr))->Heap_Name;
2000-07-28 17:30:55 +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 */
2000-07-28 17:30:55 +02:00
if( ( sm_status = SM_Heap_Open( Root_Ptr->Heap_Name, &heap_ptr, 0, ( SMD_OPEN | Lock_Mode), Locked)) != SMS_OK)
{
LG_LOG_ERROR_3( "Unable to reopen the data structure heap: [%s] for [%s], status: (%d)",
Root_Ptr->Heap_Name, (DSD_MSK_READ( Lock_Mode) ? "reading" : "writing"), sm_status);
2000-07-28 17:30:55 +02:00
return( DSS_KO);
}
return( DSS_OK);
}
2000-07-28 17:30:55 +02:00
/*----------------------------------------------------------------------------*/
/* D<>verrouillage d'une structure de donn<6E>es */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure */
/*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Unlock_I( DST_Root *Root_Ptr)
2000-07-28 17:30:55 +02:00
{
// char *Heap_Name = ( (DST_RootDesc *)( Root_Ptr->User_Ptr))->Heap_Name;
SMT_Status sm_status;
SMT_Heap *heap_ptr;
if( ( sm_status = SM_Heap_IsOpen( Root_Ptr->Heap_Name, &heap_ptr)) != SMS_OK)
{
LG_LOG_ERROR_2( "Unable to check if heap: [%s] is open, status: (%d)", Root_Ptr->Heap_Name, sm_status);
return( DSS_KO);
}
else
{
if( heap_ptr == NULL)
{
LG_LOG_ERROR_1( "Data structure heap: [%s] is not open", Root_Ptr->Heap_Name);
return( DSS_KO);
}
}
if( ( sm_status = SM_Heap_Unlock( heap_ptr)) != SMS_OK)
{
LG_LOG_ERROR_2( "Unable to unlock the data structure heap: [%s], status: (%d)", Root_Ptr->Heap_Name, sm_status);
return( DSS_KO);
}
return( DSS_OK);
2000-07-28 17:30:55 +02:00
}
/*----------------------------------------------------------------------------*/
/* Add a new value to a data structure */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Value_Ptr: Value pointer */
/*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Value_Add_I( DST_Root *Root_Ptr, void *Value_Ptr)
{
// DST_RootDesc *RootDesc_Ptr = (DST_RootDesc *)( Root_Ptr->User_Ptr);
NDT_Status nd_status;
/* On v<>rifie que la data structure est valide */
DS_STRUCT_VALID_CHECK( Root_Ptr);
/* On rend la structure invalide le temps de l'ajout */
Root_Ptr->Status = DSD_DATASTRUCT_STATUS_INVALID;
/* Ajout de la valeur */
if( ( nd_status = ND_DataStruct_Value_Add( &( Root_Ptr->ND_Root), Value_Ptr)) != NDS_OK)
{
LG_LOG_ERROR_1( "Unable to add a value to the data structure, status: (%d)", nd_status);
return( DSS_KO);
}
/* On rend la structure <20> nouveau valide */
Root_Ptr->Status = DSD_DATASTRUCT_STATUS_VALID;
return( DSS_OK);
}
/*----------------------------------------------------------------------------*/
/* Remove the first matching value from a data structure */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Ref_Value_Ptr: Reference value pointer to search */
/*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Value_Remove_I( DST_Root *Root_Ptr, void *Ref_Value_Ptr)
{
NDT_Status nd_status;
/* On v<>rifie que la data structure est valide */
DS_STRUCT_VALID_CHECK( Root_Ptr);
/* On rend la structure invalide le temps de l'ajout */
Root_Ptr->Status = DSD_DATASTRUCT_STATUS_INVALID;
/* Suppression du noeud correspondant <20> la valeur de r<>f<EFBFBD>rence */
if( ( nd_status = ND_DataStruct_Value_Remove( &( Root_Ptr->ND_Root), Ref_Value_Ptr)) != NDS_OK)
{
LG_LOG_ERROR_1( "Unable to remove a value to the data structure, status: (%d)", nd_status);
return( DSS_KO);
}
/* On rend la structure <20> nouveau valide */
Root_Ptr->Status = DSD_DATASTRUCT_STATUS_VALID;
return( DSS_OK);
}
/*----------------------------------------------------------------------------*/
/* Print all the data structure values */
/*----------------------------------------------------------------------------*/
/* (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 */
/*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Value_Print_I( FILE *Out_Ptr, DST_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
{
DST_Status status;
NDT_Status nd_status;
va_list user_args;
2000-07-28 17:30:55 +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 */
DS_STRUCT_VALID_CHECK( Root_Ptr);
2000-07-28 17:30:55 +02:00
2000-07-28 17:30:55 +02:00
/* Affichage de la node structure */
if( ( nd_status = ND_DataStruct_Value_Print_VI( Out_Ptr, &( Root_Ptr->ND_Root), Recursive_Mode, Recursive_Depth, Recursive_Offset, &user_args)) != NDS_OK)
{
LG_LOG_ERROR_1( "Unable to print the data structure values, status: (%d)", nd_status);
status = DSS_KO;
}
else
{
status = DSS_OK;
2000-07-28 17:30:55 +02:00
}
va_end( user_args);
2000-07-28 17:30:55 +02:00
return( status);
2000-07-28 17:30:55 +02:00
}
/*----------------------------------------------------------------------------*/
/* Find a value in a data structure */
/*----------------------------------------------------------------------------*/
/* (O) Value_Ptr_Ptr: Value pointer address found */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Ref_Value_Ptr: Reference value pointer to search */
/* (I) ...: User args */
/*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Value_Find_I( void **Value_Ptr_Ptr, DST_Root *Root_Ptr, void *Ref_Value_Ptr, ...)
{
DST_Status status;
NDT_Status nd_status;
va_list user_args;
va_start( user_args, Ref_Value_Ptr);
*Value_Ptr_Ptr = NULL;
/* On v<>rifie que la data structure est valide */
DS_STRUCT_VALID_CHECK( Root_Ptr);
/* Recherche dans la node structure */
if( ( nd_status = ND_DataStruct_Value_Find_VI( Value_Ptr_Ptr, &( Root_Ptr->ND_Root), Ref_Value_Ptr, &user_args)) != NDS_OK)
{
LG_LOG_ERROR_1( "Unable to search a value in the data structure, status: (%d)", nd_status);
status = DSS_KO;
}
else
{
status = DSS_OK;
}
va_end( user_args);
return( status);
}
/*----------------------------------------------------------------------------*/
/* Create a new index */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/* (I) Index_Type: Index type (List, tree, ...) */
/*----------------------------------------------------------------------------*/
DST_Status DS_Index_Open_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type)
{
NDT_Status nd_status;
if( ( nd_status = ND_Index_Open_I( &( Root_Ptr->ND_Root), Index_Id, Index_Type)) != NDS_OK)
{
LG_LOG_ERROR_2( "Unable to open index: (%d), status: (%d)", Index_Id, nd_status);
return( DSS_KO);
}
else
{
return( DSS_OK);
}
}
/*----------------------------------------------------------------------------*/
/* Remove an Index */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/*----------------------------------------------------------------------------*/
DST_Status DS_Index_Close_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id)
{
NDT_Status nd_status;
if( ( nd_status = ND_Index_Close_I( &( Root_Ptr->ND_Root), Index_Id)) != NDS_OK)
{
LG_LOG_ERROR_2( "Unable to close index: (%d), status: (%d)", Index_Id, nd_status);
return( DSS_KO);
}
else
{
return( DSS_OK);
}
}
/*----------------------------------------------------------------------------*/
/* Check & repare a data structure index: */
/* - Check & fix node links */
/* - Update data structure statistics */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/* (O) Error_Dectected_Nb_Ptr: Number of error detected pointer */
/* (O) Error_Corrected_Nb_Ptr: Number of error corected pointer */
/* (I) Out: Output stream */
/*----------------------------------------------------------------------------*/
DST_Status DS_Index_Check_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, int *Error_Dectected_Nb_Ptr, int *Error_Corrected_Nb_Ptr, FILE *Out)
{
NDT_Status nd_status;
if( ( nd_status = ND_Index_Check_I( &( Root_Ptr->ND_Root), Index_Id, Error_Dectected_Nb_Ptr, Error_Corrected_Nb_Ptr, Out)) != NDS_OK)
{
LG_LOG_ERROR_2( "Unable to convert index: (%d), status: (%d)", Index_Id, nd_status);
return( DSS_KO);
}
else
{
return( DSS_OK);
}
}
/*----------------------------------------------------------------------------*/
/* Convert a data structure index to another type */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/* (I) Index_Type: Index type (List, tree, ...) */
/*----------------------------------------------------------------------------*/
DST_Status DS_Index_Convert_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type)
{
NDT_Status nd_status;
if( ( nd_status = ND_Index_Convert_I( &( Root_Ptr->ND_Root), Index_Id, Index_Type)) != NDS_OK)
{
LG_LOG_ERROR_2( "Unable to convert index: (%d), status: (%d)", Index_Id, nd_status);
return( DSS_KO);
}
else
{
return( DSS_OK);
}
}
/*----------------------------------------------------------------------------*/
/* Reorganise a data structure index: */
/* - Sort a non-sorted list */
/* - Rebalance a non auto-balanced tree */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/*----------------------------------------------------------------------------*/
DST_Status DS_Index_Reorg_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id)
{
NDT_Status nd_status;
if( ( nd_status = ND_Index_Reorg_I( &( Root_Ptr->ND_Root), Index_Id)) != NDS_OK)
{
LG_LOG_ERROR_2( "Unable to reorg index: (%d), status: (%d)", Index_Id, nd_status);
return( DSS_KO);
}
else
{
return( DSS_OK);
}
}
/*----------------------------------------------------------------------------*/
/* Print data structure index information */
/*----------------------------------------------------------------------------*/
/* (I) Stream: Output stream */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/* (I) Recursive_Mode: Child or Parent */
/* (I) Recursive_Depth: Curent recursion depth */
/* (I) Recursive_Offset: Curent print out offset */
/*----------------------------------------------------------------------------*/
DST_Status DS_Index_Info_Print_I( FILE *Out, DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset)
{
NDT_Status nd_status;
if( ( nd_status = ND_Index_Info_Print( Out, &( Root_Ptr->ND_Root), Index_Id, Recursive_Mode, Recursive_Depth, Recursive_Offset)) != NDS_OK)
{
LG_LOG_ERROR_1( "Unable to print info about the data structure: (%d)", nd_status);
return( DSS_KO);
}
else
{
return( DSS_OK);
}
}
/*----------------------------------------------------------------------------*/
/* 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 */
/*
2000-07-28 17:30:55 +02:00
if (RootDesc->Valid == FALSE)
{
int Nb_Detected, Nb_Corrected;
/* On v<>rifie la structure */
/*
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 */
/*
2000-07-28 17:30:55 +02:00
rc = ND_Node_First_Get (Root, Node);
return rc;
}
/*----------------------------------------------------------------------------*/
/* 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 */
/*
2000-07-28 17:30:55 +02:00
if (RootDesc->Valid == FALSE)
{
int Nb_Detected, Nb_Corrected;
/* On v<>rifie la structure */
/*
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 */
/*
2000-07-28 17:30:55 +02:00
rc = ND_Node_Last_Get (Root, Node);
return rc;
}
/*----------------------------------------------------------------------------*/
/* 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 */
/*
2000-07-28 17:30:55 +02:00
if (RootDesc->Valid == FALSE)
{
int Nb_Detected, Nb_Corrected;
/* On v<>rifie la structure */
/*
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 */
/*
2000-07-28 17:30:55 +02:00
rc = ND_Node_Next_Get (Node, Next_Node);
return rc;
}
/*----------------------------------------------------------------------------*/
/* 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 */
/*
2000-07-28 17:30:55 +02:00
if (RootDesc->Valid == FALSE)
{
int Nb_Detected, Nb_Corrected;
/* On v<>rifie la structure */
/*
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 */
/*
2000-07-28 17:30:55 +02:00
rc = ND_Node_Previous_Get (Node, Prev_Node);
return rc;
}
/*----------------------------------------------------------------------------*/
/* 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 */
/*
2000-07-28 17:30:55 +02:00
if (RootDesc->Valid == FALSE)
{
int Nb_Detected, Nb_Corrected;
/* On v<>rifie la structure */
/*
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 */
/*
2000-07-28 17:30:55 +02:00
RootDesc->Valid = FALSE;
/* Ajout du noeud */
/*
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 */
/*
2000-07-28 17:30:55 +02:00
RootDesc->Valid = TRUE;
return DSS_OK;
}
/*----------------------------------------------------------------------------*/
/* 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 */
/*
2000-07-28 17:30:55 +02:00
if (RootDesc->Valid == FALSE)
{
int Nb_Detected, Nb_Corrected;
/* On v<>rifie la structure */
/*
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 */
/*
2000-07-28 17:30:55 +02:00
RootDesc->Valid = FALSE;
/* Suppression dans la node structure */
/*
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 */
/*
2000-07-28 17:30:55 +02:00
RootDesc->Valid = TRUE;
return DSS_OK;
}
/*----------------------------------------------------------------------------*/
/* 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 */
/*
2000-07-28 17:30:55 +02:00
if (RootDesc->Valid == FALSE)
{
int Nb_Detected, Nb_Corrected;
/* On v<>rifie la structure */
/*
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 */
/*
2000-07-28 17:30:55 +02:00
rc = ND_Node_Find (Root, Node, Value, Data);
return rc;
}
/*----------------------------------------------------------------------------*/
/* Allocation d'une valeur d'une structure de donn<6E>es */
/*----------------------------------------------------------------------------*/
/* (O) Value : adresse d'un pointeur sur la valeur <20> allouer */
/* (I) Root : pointeur sur la racine de la structure de donn<6E>es */
/* (I) ... : arguments relatifs <20> l'allocation de la valeur */
/*----------------------------------------------------------------------------*/
DST_Status DS_Value_Alloc_I( void **Value_Ptr_Ptr, DST_Root *Root_Ptr, ... )
2000-07-28 17:30:55 +02:00
{
DST_Status status;
NDT_Status nd_status;
va_list user_args;
2000-07-28 17:30:55 +02:00
2000-07-28 17:30:55 +02:00
/* R<>cup<75>ration des arguments pour l'allocation de la valeur */
va_start( user_args, Root_Ptr);
2000-07-28 17:30:55 +02:00
/* Appel du manager */
if( ( nd_status = ND_Manager_Exec( &( Root_Ptr->ND_Root), NDD_INDEX_UNKNOWN, NULL, NDD_CMD_VALUE_ALLOC, Value_Ptr_Ptr, &user_args)) != NDS_OK)
{
LG_LOG_ERROR_1( "Unable to alloc a new value, status: (%d)", nd_status);
2000-07-28 17:30:55 +02:00
status = DSS_KO;
}
else
{
status = DSS_OK;
}
va_end( user_args);
return( status);
2000-07-28 17:30:55 +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 */
/*----------------------------------------------------------------------------*/
DST_Status DS_Value_Free_I( DST_Root *Root_Ptr, void *Value_Ptr)
2000-07-28 17:30:55 +02:00
{
return ND_Value_Free( &( Root_Ptr->ND_Root), Value_Ptr);
2000-07-28 17:30:55 +02:00
}
/*----------------------------------------------------------------------------*/
/* Allocation de m<>moire pour une structure de donn<6E>es : */
/*----------------------------------------------------------------------------*/
/* (O) Ptr : adresse du pointeur sur la zone de donn<6E>es allou<6F>e */
/* (I) Root : pointeur sur la racine de la structure de donn<6E>es */
/* (I) Size : taille m<>moire <20> allouer */
/*----------------------------------------------------------------------------*/
DST_Status DS_Alloc_I( void **Ptr_Ptr, NDT_Root *ND_Root_Ptr, size_t Size)
2000-07-28 17:30:55 +02:00
{
return( DS_Allocator( Ptr_Ptr, ND_Root_Ptr, Size, NULL)); // TBC: Use defined allocator!
2000-07-28 17:30:55 +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 */
/*----------------------------------------------------------------------------*/
DST_Status DS_Free_I( NDT_Root *ND_Root_Ptr, void *Ptr)
2000-07-28 17:30:55 +02:00
{
return( DS_Deallocator( Ptr, ND_Root_Ptr, NULL)); // TBC: Use defined allocator!
2000-07-28 17:30:55 +02:00
}
/*----------------------------------------------------------------------------*/
/* FONCTIONS OPTIMISATION MOYENNE (DS_MODE = 1) */
/*----------------------------------------------------------------------------*/
2000-07-28 17:30:55 +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 */
/*----------------------------------------------------------------------------*/
DST_Status DS_Library_Open_L( int Instance, const char *Context, DST_Flags Debug_Mode)
2000-07-28 17:30:55 +02:00
{
return( DS_Library_Open_I( Instance, Context, Debug_Mode));
2000-07-28 17:30:55 +02:00
}
/*----------------------------------------------------------------------------*/
/* Fermeture de l'instance de la librairie */
/*----------------------------------------------------------------------------*/
DST_Status DS_Library_Close_L( void)
2000-07-28 17:30:55 +02:00
{
return DS_Library_Close_I();
2000-07-28 17:30:55 +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);
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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 */
/* (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);
}
/*----------------------------------------------------------------------------*/
/* Destroy all data of a data structure */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/*----------------------------------------------------------------------------*/
/*
NDT_Status DS_DataStruct_Flush_L( NDT_Root *Root_Ptr)
{
DS_DataStruct_Flush_L( NDT_Root *Root_Ptr)
}
/*----------------------------------------------------------------------------*/
/* Check & repare a datat structure: */
/* - Check & fix node links */
/* - Update data structure statistics */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (O) Error_Dectected_Nb_Ptr: Number of error detected pointer */
/* (O) Error_Corrected_Nb_Ptr: Number of error corected pointer */
/* (I) Out: Output stream */
/*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Check_L( DST_Root *Root_Ptr, int *Error_Detected_Nb_Ptr, int *Error_Corrected_Nb_Ptr, FILE *Out)
{
return( DS_DataStruct_Check_I( Root_Ptr, Error_Detected_Nb_Ptr, Error_Corrected_Nb_Ptr, Out));
}
/*----------------------------------------------------------------------------*/
/* Convert a data structure indexe types */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Type_Ptr: Array of index type (List, tree, ...) */
/*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Convert_L( DST_Root *Root_Ptr, NDT_Index_Type *Index_Type_Ptr)
2000-07-28 17:30:55 +02:00
{
DST_Status status;
int lock_flag;
2000-07-28 17:30:55 +02:00
/* Lock the data structure in write mode */
2000-07-28 17:30:55 +02:00
DS_STRUCT_LOCK( Root_Ptr, SMD_WRITE, &lock_flag);
2000-07-28 17:30:55 +02:00
status = DS_DataStruct_Convert_I( Root_Ptr, Index_Type_Ptr);
2000-07-28 17:30:55 +02:00
/* Unlock if needed Lock the data structure */
DS_STRUCT_UNLOCK( Root_Ptr, lock_flag);
return( status);
2000-07-28 17:30:55 +02:00
}
/*----------------------------------------------------------------------------*/
/* Reorganise a data structure indexes: */
/* - Sort a non-sorted list */
/* - Rebalance a non auto-balanced tree */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/*----------------------------------------------------------------------------*/
/*
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 */
/*
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 */
/*
2000-07-28 17:30:55 +02:00
if (Locked == TRUE) DS_DataStruct_Unlock_I (Root);
return rc;
}
/*----------------------------------------------------------------------------*/
/* 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 */
/*----------------------------------------------------------------------------*/
/*
DST_Status DS_DataStruct_Info_Print_L ( NDT_Root * Root, FILE * Out )
{
DST_Status rc;
int Locked;
/* Verrouillage de la data structure en lecture */
/*
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 */
/*
if (Locked == TRUE) DS_DataStruct_Unlock_I (Root);
return rc;
}
/*----------------------------------------------------------------------------*/
/* 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 */
/*
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 */
/*
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 */
/*
2000-07-28 17:30:55 +02:00
if (Locked == TRUE) DS_DataStruct_Unlock_I (Root);
return rc;
}
/*----------------------------------------------------------------------------*/
/* 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);
}
2000-07-28 17:30:55 +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 */
/*
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 */
/*
2000-07-28 17:30:55 +02:00
if (Locked == TRUE) DS_DataStruct_Unlock_I (Root);
return rc;
}
/*----------------------------------------------------------------------------*/
/* 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 */
/*
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 */
/*
2000-07-28 17:30:55 +02:00
if (Locked == TRUE) DS_DataStruct_Unlock_I (Root);
return rc;
}
/*----------------------------------------------------------------------------*/
/* 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 */
/*
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 */
/*
2000-07-28 17:30:55 +02:00
if (Locked == TRUE) DS_DataStruct_Unlock_I (Root);
return rc;
}
/*----------------------------------------------------------------------------*/
/* 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 */
/*
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 */
/*
2000-07-28 17:30:55 +02:00
if (Locked == TRUE) DS_DataStruct_Unlock_I (Node->Root);
return rc;
}
/*----------------------------------------------------------------------------*/
/* 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 */
/*
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 */
/*
2000-07-28 17:30:55 +02:00
if (Locked == TRUE) DS_DataStruct_Unlock_I (Node->Root);
return rc;
}
/*----------------------------------------------------------------------------*/
/* 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 */
/*
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 */
/*
2000-07-28 17:30:55 +02:00
if (Locked == TRUE) DS_DataStruct_Unlock_I (Root);
return rc;
}
/*----------------------------------------------------------------------------*/
/* 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 */
/*
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 */
/*
2000-07-28 17:30:55 +02:00
if (Locked == TRUE) DS_DataStruct_Unlock_I (Root);
return rc;
}
/*----------------------------------------------------------------------------*/
/* 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 */
/*
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 */
/*
2000-07-28 17:30:55 +02:00
if (Locked == TRUE) DS_DataStruct_Unlock_I (Root);
return rc;
}
/*----------------------------------------------------------------------------*/
/* 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 */
/*
2000-07-28 17:30:55 +02:00
va_start (Args, Value);
/* Appel du manager */
/*
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;
}
/*----------------------------------------------------------------------------*/
/* 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 */
/*
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 */
/*
2000-07-28 17:30:55 +02:00
rc = DS_Value_Add_I (Root, Value);
/* D<>verrouillage de la data structure si besoin */
/*
2000-07-28 17:30:55 +02:00
if (Locked == TRUE) DS_DataStruct_Unlock_I (Root);
return rc;
}
/*----------------------------------------------------------------------------*/
/* 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 */
/*
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 */
/*
2000-07-28 17:30:55 +02:00
if (Locked == TRUE) DS_DataStruct_Unlock_I (Root);
return DSS_OK;
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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_Allocator (Size, Ptr, Root->User);
2000-07-28 17:30:55 +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_Deallocator (Ptr, Root->User);
2000-07-28 17:30:55 +02:00
}
/*----------------------------------------------------------------------------*/
/* FONCTIONS SECURISEES (DS_MODE = 0) */
/*----------------------------------------------------------------------------*/
2000-07-28 17:30:55 +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 );
}
/*----------------------------------------------------------------------------*/
/* 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 ();
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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 */
/* (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);
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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 */
/*----------------------------------------------------------------------------*/
/*
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);
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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 */
/*
2000-07-28 17:30:55 +02:00
va_start (Args, Value);
/* Appel du manager */
/*
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;
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* FONCTIONS PRIVEES */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
2000-07-28 17:30:55 +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
DST_Status DS_DataStruct_IsOpen( DST_Root **Root_Ptr_Ptr, char *DS_Name)
{
NDT_Status nd_status;
DST_DataStruct to_find, *found_ptr;
strncpy( to_find.Name, DS_Name, DSD_NAME_LEN);
2000-07-28 17:30:55 +02:00
if( ( nd_status = ND_DataStruct_Value_Find( (void **)&found_ptr, OpenedDS_List, &to_find)) != NDS_OK)
{
LG_LOG_ERROR_2( "Can't lookup for opened data structure: [%s], status: (%d)", DS_Name, nd_status);
2000-07-28 17:30:55 +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
/*----------------------------------------------------------------------------*/
/* Fonction d'allocation attach<63>e <20> une structure de donn<6E>es : */
/*----------------------------------------------------------------------------*/
2024-04-23 17:10:37 +02:00
DST_Status DS_Allocator( void **Ptr_Ptr, NDT_Root *ND_Root_Ptr, size_t Size, void *User_Ptr)
{
// DST_RootDesc *RootDesc_Ptr = (DST_RootDesc *)Data_Ptr;
// char *Heap_Name = RootDesc_Ptr->Heap_Name;
DST_Root *Root_Ptr;
DST_Status status;
SMT_Status sm_status;
SMT_Heap *heap_ptr;
int locked;
size_t nd_root_offset;
if( ND_Root_Ptr == NULL)
{
if( User_Ptr == NULL)
{
LG_LOG_ERROR_0( "Unable to get data structure info");
return( DSS_ERRAPI);
}
else
{
/* Root node allocation case */
Root_Ptr = User_Ptr;
nd_root_offset = offsetof( DST_Root, ND_Root);
Size += nd_root_offset;
}
}
else
{
/* Default allocation case */
Root_Ptr = DSD_DS_ROOT_GET( ND_Root_Ptr);
nd_root_offset = 0;
}
if( ( sm_status = SM_Heap_IsOpen( Root_Ptr->Heap_Name, &heap_ptr)) != SMS_YES)
{
LG_LOG_ERROR_1( "The data structure heap: [%s] is not open", Root_Ptr->Heap_Name);
return( DSS_KO);
}
/* Verrouillage du heap en <20>criture */
if( ( sm_status = SM_Heap_Lock( heap_ptr, SMD_WRITE, &locked)) != SMS_OK)
{
LG_LOG_ERROR_2( "Unable to lock the data structure heap: [%s] for writing, status: (%d)", Root_Ptr->Heap_Name, sm_status);
return( DSS_OK);
}
/* Allocate the chunk */
if( ( sm_status = SM_Chunk_Alloc( heap_ptr, Size, Ptr_Ptr)) != SMS_OK)
{
LG_LOG_ERROR_3( "Unable to alloc size: (%d) in the heap: [%s] for writing, status: (%d)", Size, Root_Ptr->Heap_Name, sm_status);
status = DSS_KO;
}
else
{
status = DSS_OK;
LG_LOG_TRACE_3( LGD_LOG_LEVEL_DEFAULT, "New alloc: DS Root: (%p) ND Root: (%p) Offset: (%d)", *Ptr_Ptr, (*Ptr_Ptr + nd_root_offset), nd_root_offset);
*Ptr_Ptr += nd_root_offset;
}
/* D<>verrouillage de la data structure si besoin */
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);
}
/*
DST_Status DS_DataStruct_Alloc( void **Ptr_Ptr, size_t Size, void *Data_Ptr)
2000-07-28 17:30:55 +02:00
{
DST_RootDesc *RootDesc_Ptr = (DST_RootDesc *)Data_Ptr;
char *Heap_Name = RootDesc_Ptr->Heap_Name;
2024-04-23 17:10:37 +02:00
DST_Status status;
SMT_Status sm_status;
2024-04-23 17:10:37 +02:00
SMT_Heap *heap_ptr;
int locked;
2000-07-28 17:30:55 +02:00
2024-04-23 17:10:37 +02:00
if( ( sm_status = SM_Heap_IsOpen( Heap_Name, &heap_ptr)) != SMS_YES)
2000-07-28 17:30:55 +02:00
{
LG_LOG_ERROR_1( "The data structure heap: [%s] is not open", 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
{
LG_LOG_ERROR_2( "Unable to lock the data structure heap: [%s] for writing, status: (%d)", 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
{
LG_LOG_ERROR_3( "Unable to alloc size: (%d) in the heap: [%s] for writing, status: (%d)", Size, 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 */
/*
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
return( DSS_OK);
2000-07-28 17:30:55 +02:00
}
*/
2000-07-28 17:30:55 +02:00
/*----------------------------------------------------------------------------*/
/* Fonction de d<>sallocation attach<63>e <20> une structure de donn<6E>es : */
/*----------------------------------------------------------------------------*/
DST_Status DS_Deallocator( void *Ptr, NDT_Root *ND_Root_Ptr, void *User_Ptr)
2000-07-28 17:30:55 +02:00
{
// DST_RootDesc *RootDesc_Ptr = (DST_RootDesc *)Data_Ptr;
// char *Heap_Name = RootDesc_Ptr->Heap_Name;
DST_Root *Root_Ptr;
2000-07-28 17:30:55 +02:00
DST_Status status;
SMT_Status sm_status;
SMT_Heap *heap_ptr;
int locked;
if( ND_Root_Ptr == NULL)
{
/* Root node free case */
Root_Ptr = ( DST_Root *)Ptr;
}
else
{
/* Default free case */
Root_Ptr = DSD_DS_ROOT_GET( ND_Root_Ptr);
}
if( ( sm_status = SM_Heap_IsOpen( Root_Ptr->Heap_Name, &heap_ptr)) != SMS_OK)
2000-07-28 17:30:55 +02:00
{
LG_LOG_ERROR_2( "Unable to check if heap: [%s] is open, status: (%d)", Root_Ptr->Heap_Name, sm_status);
2000-07-28 17:30:55 +02:00
return( DSS_KO);
}
else
{
if( heap_ptr == NULL)
{
LG_LOG_ERROR_1( "DatatStructure heap: [%s] is not open", Root_Ptr->Heap_Name);
return( DSS_KO);
}
2000-07-28 17:30:55 +02:00
}
2000-07-28 17:30:55 +02:00
/* Verrouillage de la data structure en <20>criture */
if( ( sm_status = SM_Heap_Lock( heap_ptr, SMD_WRITE, &locked)) != SMS_OK)
2000-07-28 17:30:55 +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
return( DSS_KO);
2000-07-28 17:30:55 +02:00
}
2000-07-28 17:30:55 +02:00
/* D<>sallocation du chunk */
if( ( sm_status = SM_Chunk_Free( heap_ptr, Ptr)) != SMS_OK)
2000-07-28 17:30:55 +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
}
2000-07-28 17:30:55 +02:00
/* D<>verrouillage de la data structure si besoin */
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
}
/*----------------------------------------------------------------------------*/
/* 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);
}
/*----------------------------------------------------------------------------*/
/* Pour pr<70>fixer les noms de heap avec l'identifiant de la librairie */
/*----------------------------------------------------------------------------*/
2024-04-23 17:10:37 +02:00
DST_Status DS_Name_Prefix( char *Prefixed_Name_Ptr, const char *Unprefixed_Name_Ptr)
2000-07-28 17:30:55 +02:00
{
snprintf( Prefixed_Name_Ptr, DSD_NAME_SIZE, "%s/%s", DS_PREFIX, Unprefixed_Name_Ptr);
2000-07-28 17:30:55 +02:00
return( DSS_OK);
2000-07-28 17:30:55 +02:00
}
/*----------------------------------------------------------------------------*/
/* Cr<43>ation d'un s<>maphore pour g<>rer l'ouverture d'une data structure */
/*----------------------------------------------------------------------------*/
//DST_Status DS_Semaphore_Create ( NDT_Root *Root_Ptr)
DST_Status DS_Semaphore_Create ( DST_Root *Root_Ptr)
2000-07-28 17:30:55 +02:00
{
// DST_RootDesc *RootDesc_Ptr = (DST_RootDesc *)( Root_Ptr->User_Ptr);
union semun sem_ctl;
2000-07-28 17:30:55 +02:00
2000-07-28 17:30:55 +02:00
/* Cr<43>ation du s<>maphore */
/*
RootDesc_Ptr->OpenSemId = semget( IPC_PRIVATE, 1, ( 0777 | IPC_CREAT | IPC_EXCL));
if( RootDesc_Ptr->OpenSemId == -1)
*/
if( ( Root_Ptr->OpenSemId = semget( IPC_PRIVATE, 1, ( 0777 | IPC_CREAT | IPC_EXCL))) == -1)
2000-07-28 17:30:55 +02:00
{
switch( errno)
2000-07-28 17:30:55 +02:00
{
case ENOMEM:
{
LG_LOG_ERROR_0( "Not enough memory to create a new semaphore");
2000-07-28 17:30:55 +02:00
break;
}
2000-07-28 17:30:55 +02:00
case ENOSPC:
{
LG_LOG_ERROR_0( "The number of semaphores would exceeds the system-imposed limit");
2000-07-28 17:30:55 +02:00
break;
}
2000-07-28 17:30:55 +02:00
default:
{
LG_LOG_ERROR_1( "Unknown error: (%d) while creating a semaphore", errno);
2000-07-28 17:30:55 +02:00
break;
}
2000-07-28 17:30:55 +02:00
}
return( DSS_ERRSEM);
2000-07-28 17:30:55 +02:00
}
2000-07-28 17:30:55 +02:00
/* Initialisation du s<>maphore <20> 0 */
sem_ctl.val = 0;
// if( semctl( RootDesc_Ptr->OpenSemId, 0, SETVAL, sem_ctl))
if( semctl( Root_Ptr->OpenSemId, 0, SETVAL, sem_ctl))
2000-07-28 17:30:55 +02:00
{
LG_LOG_ERROR_1( "Unable to initialize the value of the semaphore: (%x)", Root_Ptr->OpenSemId);
2000-07-28 17:30:55 +02:00
semctl( Root_Ptr->OpenSemId, 0, IPC_RMID, sem_ctl);
2000-07-28 17:30:55 +02:00
return( DSS_ERRSEM);
2000-07-28 17:30:55 +02:00
}
return( DSS_OK);
2000-07-28 17:30:55 +02:00
}
/*----------------------------------------------------------------------------*/
/* Op<4F>ration sur un s<>maphore */
/*----------------------------------------------------------------------------*/
DST_Status DS_Semaphore_Operate( int SemId, struct sembuf *Operations, unsigned int Nb_Oper)
2000-07-28 17:30:55 +02:00
{
if( semop( SemId, Operations, Nb_Oper) == -1)
2000-07-28 17:30:55 +02:00
{
switch( errno)
2000-07-28 17:30:55 +02:00
{
case EAGAIN:
{
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;
}
2000-07-28 17:30:55 +02:00
case EACCES:
{
LG_LOG_ERROR_1( "Current process is not allowed to operate on semaphore: (%x)", SemId);
2000-07-28 17:30:55 +02:00
break;
}
2000-07-28 17:30:55 +02:00
case EIDRM:
{
LG_LOG_ERROR_1( "Semaphore: (%x) does not exist", SemId);
2000-07-28 17:30:55 +02:00
break;
}
2000-07-28 17:30:55 +02:00
case EINTR:
{
LG_LOG_ERROR_1( "A signal was received while operating on semaphore: (%x)", SemId);
return( DSS_ERRSIG);
}
2000-07-28 17:30:55 +02:00
case EINVAL:
{
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);
2000-07-28 17:30:55 +02:00
break;
}
2000-07-28 17:30:55 +02:00
case ENOSPC:
{
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;
}
2000-07-28 17:30:55 +02:00
case ERANGE:
{
LG_LOG_ERROR_1( "The value of semaphore: (%x) has reached the system-imposed limit", SemId);
2000-07-28 17:30:55 +02:00
break;
}
2000-07-28 17:30:55 +02:00
default:
{
LG_LOG_ERROR_2( "Unknown error: (%d) while operating on semaphore: (%x)", errno, SemId);
2000-07-28 17:30:55 +02:00
break;
}
2000-07-28 17:30:55 +02:00
}
return( DSS_ERRSEM);
2000-07-28 17:30:55 +02:00
}
return( DSS_OK);
2000-07-28 17:30:55 +02:00
}
/*----------------------------------------------------------------------------*/
/* Fonction manager de la liste des DS ouvertes */
/*----------------------------------------------------------------------------*/
2000-07-28 17:30:55 +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);
*/
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, DST_Root *);
ND_VA_LIST_CLOSE( user_args);
Command_Name = "NDD_CMD_VALUE_ALLOC";
LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Command: [%s] called", Command_Name);
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
{
strncpy( ( *Opened_DataStruct_Ptr_Ptr)->Name, DS_Name, DSD_NAME_LEN);
( *Opened_DataStruct_Ptr_Ptr)->Root_Ptr = Root_Ptr;
LG_LOG_TRACE_2( LGD_LOG_LEVEL_DEFAULT, "Allocate new DS: Name: [%s] Root_Ptr: (%p)", DS_Name, Root_Ptr);
return( DSS_OK);
}
}
case NDD_CMD_VALUE_FREE:
{
/*
ND_VA_ARG_GET( Value_Ptr, *Args_Ptr, void *);
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
ND_VA_ARG_GET( user_data, user_args, user_type);
ND_VA_ARG_GET( ..., user_args, ...);
ND_VA_LIST_CLOSE( user_args);
*/
ND_VA_ARG_GET( Opened_DataStruct_Ptr, *Args_Ptr, DST_DataStruct *);
Command_Name = "NDD_CMD_VALUE_FREE";
LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Command: [%s] called", Command_Name);
free( Opened_DataStruct_Ptr);
/*
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
}