From 67e20bbd878e5d8ca6aa06b6943a8a6e296233e9 Mon Sep 17 00:00:00 2001 From: "Arnaud G. GIBERT" Date: Sat, 20 Apr 2024 21:06:21 +0200 Subject: [PATCH] - Continue LibLog migration. --- lib/libnode.c | 1011 ++++++++----------------------------------------- lib/libnode.h | 8 + 2 files changed, 175 insertions(+), 844 deletions(-) diff --git a/lib/libnode.c b/lib/libnode.c index e9e6d0e..2969a61 100644 --- a/lib/libnode.c +++ b/lib/libnode.c @@ -416,6 +416,7 @@ NDT_Status ND_OpenStruct_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, 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); @@ -488,6 +489,7 @@ NDT_Status ND_OpenStruct_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, ND_VA_LIST_CLOSE( user_args); */ + ND_VA_ARG_GET( Value1_Ptr, *Args_Ptr, void *); ND_VA_ARG_GET( Value2_Ptr, *Args_Ptr, void *); @@ -612,6 +614,7 @@ NDT_Status ND_OpenStruct_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, 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); @@ -687,8 +690,7 @@ NDT_Status ND_Library_Open_I( int Debug_Mode) #if !defined(_WIN32) if( ( NDG_Base.DL_Ptr = dlopen( NULL, ( RTLD_NOW | RTLD_GLOBAL))) == NULL) { - sprintf( NDG_Base.Err_String, "Error ND_Library_Open_I: can't dlopen [%s]", dlerror()); - ND_Error_Print(); + LG_LOG_ERROR_1( "Can't dlopen: [%s]", dlerror()); return( NDS_KO); } @@ -714,8 +716,7 @@ NDT_Status ND_Library_Open_C( int Debug_Mode) if( NDG_Base.Open_Status != NDD_FALSE) { - sprintf( NDG_Base.Err_String, "Error ND_Library_Open_C: library is not closed"); - ND_Error_Print(); + LG_LOG_ERROR_0( "Library is not closed"); return( NDS_KO); } @@ -725,8 +726,7 @@ NDT_Status ND_Library_Open_C( int Debug_Mode) { if( ( status = ND_DataStruct_Open_I( &(NDG_Base.OpenStruct_Ptr), 1, NDG_Base.OpenStruct_Index_Type, "ND_OpenStruct_Manager", ND_OpenStruct_Manager, NULL, NULL, NULL, NULL, 0, NULL)) != NDS_OK) { - sprintf( NDG_Base.Err_String, "Error ND_Library_Open_C: can't open OpenStruct"); - ND_Error_Print(); + LG_LOG_ERROR_0( "Can't open OpenStruct"); return( NDS_KO); } @@ -767,8 +767,7 @@ NDT_Status ND_Library_Close_I( void) #if !defined(_WIN32) if( dlclose( NDG_Base.DL_Ptr) != 0) { - sprintf( NDG_Base.Err_String, "Error ND_Library_Close_I: can't dlclose [%s]", dlerror()); - ND_Error_Print(); + LG_LOG_ERROR_1( "Can't dlclose: [%s]", dlerror()); return( NDS_KO); } @@ -798,25 +797,17 @@ NDT_Status ND_Library_Close_C( void) NDT_Status status; - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Library_Close_C: library is not opened"); - ND_Error_Print(); - - return( NDS_KO); - } + ND_LIBNODE_OPEN_CHECK(); if( ( NDG_Base.Debug_Mode == NDD_TRUE) && ( NDG_Base.Err_Stream != NULL)) { if( NDG_Base.OpenStruct_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number > 0) { - sprintf( NDG_Base.Err_String, "Error ND_Library_Close_C: Unclosed DataStruct:"); - ND_Error_Print(); + LG_LOG_ERROR_0( "Unclosed DataStruct:"); if( ( status = ND_DataStruct_Info_Print_I( NDG_Base.Err_Stream, NDG_Base.OpenStruct_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0)) != NDS_OK) { - sprintf( NDG_Base.Err_String, "Error ND_Library_Close_C: can't print OpenStruct info"); - ND_Error_Print(); + LG_LOG_ERROR_0( "Can't print OpenStruct info"); return( NDS_KO); } @@ -824,8 +815,7 @@ NDT_Status ND_Library_Close_C( void) if( ( status = ND_DataStruct_Close_I( NDG_Base.OpenStruct_Ptr)) != NDS_OK) { - sprintf( NDG_Base.Err_String, "Error ND_Library_Close_C: can't close OpenStruct"); - ND_Error_Print(); + LG_LOG_ERROR_0( "Can't close OpenStruct"); return( NDS_KO); } @@ -863,13 +853,7 @@ NDT_Status ND_Library_StdErr_Set_I( FILE *Out) NDT_Status ND_Library_StdErr_Set_C( FILE *Out) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Library_StdErr_Set_C: library is not opened"); - ND_Error_Print(); - - return( NDS_KO); - } + ND_LIBNODE_OPEN_CHECK(); return( ND_Library_StdErr_Set_I( Out)); } @@ -894,8 +878,7 @@ NDT_Status ND_Index_Open_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_In if( ( status = ND_Index_Clear( Root_Ptr, Index_Id)) != NDS_OK) { - sprintf( NDG_Base.Err_String, "Error ND_Index_Open_I: Index cleaning error"); - ND_Error_Print(); + LG_LOG_ERROR_0( "Index cleaning error"); return( NDS_KO); } @@ -908,8 +891,7 @@ NDT_Status ND_Index_Open_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_In { if( ( status = ND_Index_Node_First_Get_I( &node_ptr, Root_Ptr, NDD_INDEX_PRIMARY)) != NDS_OK) { - sprintf( NDG_Base.Err_String, "Error ND_Index_Open_I: can't get first primary index node"); - ND_Error_Print(); + LG_LOG_ERROR_0( "Can't get first primary index node"); return( NDS_KO); } @@ -918,16 +900,14 @@ NDT_Status ND_Index_Open_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_In { if( ( status = ND_Index_Value_Add_I( Root_Ptr, Index_Id, node_ptr->Value)) != NDS_OK) { - sprintf( NDG_Base.Err_String, "Error ND_Index_Open_I: can't add value"); - ND_Error_Print(); + LG_LOG_ERROR_0( "Can't add value"); return( NDS_KO); } if( ( status = ND_Index_Node_Next_Get_I( &node_ptr, node_ptr)) != NDS_OK) { - sprintf( NDG_Base.Err_String, "Error ND_Index_Open_I: can't get next node"); - ND_Error_Print(); + LG_LOG_ERROR_0( "Can't get next node"); return( NDS_KO); } @@ -951,34 +931,19 @@ NDT_Status ND_Index_Open_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_In NDT_Status ND_Index_Open_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Type) { - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Open_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Open_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + if( !ND_INDEX_STATUS_CLOSED_IS( Root_Ptr, Index_Id)) { - sprintf( NDG_Base.Err_String, "Error ND_Index_Open_C: index is not closed"); - ND_Error_Print(); + LG_LOG_ERROR_0( "Index is not closed"); return( NDS_ERRAPI); } if( ( Root_Ptr->Index_Open_Count == 0) && ( Index_Id != NDD_INDEX_PRIMARY)) { - sprintf( NDG_Base.Err_String, "Error ND_Index_Open_I: fist opened index should be the primary"); - ND_Error_Print(); + LG_LOG_ERROR_0( "Fist opened index should be the primary"); return( NDS_ERRAPI); } @@ -1023,8 +988,7 @@ NDT_Status ND_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_N #if defined(_WIN32) if( ( Manager_Name != NULL) && ( Manager_Ptr == NULL)) { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Open_I: no symbol lookup support, Manager_Ptr shouldn't be NULL"); - ND_Error_Print(); + LG_LOG_ERROR_0( "No symbol lookup support, Manager_Ptr shouldn't be NULL"); return( NDS_ERRAPI); } @@ -1044,8 +1008,7 @@ NDT_Status ND_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_N #if defined(_WIN32) if( ( Allocator_Name != NULL) && ( Allocator_Ptr == NULL)) { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Open_I: no symbol lookup support, Allocator_Ptr shouldn't be NULL"); - ND_Error_Print(); + LG_LOG_ERROR_0( "No symbol lookup support, Allocator_Ptr shouldn't be NULL"); return( NDS_ERRAPI); } @@ -1065,8 +1028,7 @@ NDT_Status ND_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_N #if defined(_WIN32) if( ( Deallocator_Name != NULL) && ( Deallocator_Ptr == NULL)) { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Open_I: no symbol lookup support, Deallocator_Ptr shouldn't be NULL"); - ND_Error_Print(); + LG_LOG_ERROR_0( "No symbol lookup support, Deallocator_Ptr shouldn't be NULL"); return( NDS_ERRAPI); } @@ -1116,13 +1078,7 @@ NDT_Status ND_DataStruct_Open_C( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_ NDT_Status status; - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Open_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); if( ( status = ND_DataStruct_Open_I( Root_Ptr_Ptr, Index_Nb, Type_Ptr, Manager_Name, Manager_Ptr, Allocator_Name, Allocator_Ptr, Deallocator_Name, Deallocator_Ptr, Own_Value, Data_Ptr)) != NDS_OK) { @@ -1133,8 +1089,7 @@ NDT_Status ND_DataStruct_Open_C( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_ { if( ( status = ND_DataStruct_Value_Add_I( NDG_Base.OpenStruct_Ptr, (void **)*Root_Ptr_Ptr)) != NDS_OK) { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Open_C: can't add value in OpenStruct"); - ND_Error_Print(); + LG_LOG_ERROR_0( "Can't add value in OpenStruct"); return( NDS_KO); } @@ -1161,8 +1116,8 @@ NDT_Status ND_Index_Close_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) if( ( Root_Ptr->Index_Open_Count != 1) && ( Index_Id == NDD_INDEX_PRIMARY)) { - sprintf( NDG_Base.Err_String, "Error ND_Index_Close_I: the primary should be the last closed"); - ND_Error_Print(); + LG_LOG_ERROR_0( "The primary should be the last closed"); + return(NDS_ERRAPI); } @@ -1189,26 +1144,12 @@ NDT_Status ND_Index_Close_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) NDT_Status ND_Index_Close_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Close_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Close_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + if( !ND_INDEX_STATUS_OPENED_IS( Root_Ptr, Index_Id)) { - sprintf( NDG_Base.Err_String, "Error ND_Index_Close_C: index is not opened"); - ND_Error_Print(); + LG_LOG_ERROR_0( "Index is not opened"); return( NDS_ERRAPI); } @@ -1252,22 +1193,9 @@ NDT_Status ND_DataStruct_Close_C( NDT_Root *Root_Ptr) NDT_Status status; - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Close_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if (!Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Close_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + if( ( status = ND_DataStruct_Close_I( Root_Ptr)) != NDS_OK) { return( status); @@ -1277,8 +1205,7 @@ NDT_Status ND_DataStruct_Close_C( NDT_Root *Root_Ptr) { if( ( status = ND_DataStruct_Value_Remove_I( NDG_Base.OpenStruct_Ptr, (void *)Root_Ptr)) != NDS_OK) { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Close_I: can't remove value from OpenStruct"); - ND_Error_Print(); + LG_LOG_ERROR_0( "Can't remove value from OpenStruct"); return( NDS_KO); } @@ -1347,22 +1274,9 @@ NDT_Status ND_Index_Flush_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) NDT_Status ND_Index_Flush_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Flush_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Flush_C: structure root is null"); - ND_Error_Print(); - - return(NDS_ERRAPI); - } - + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + return( ND_Index_Flush_I( Root_Ptr, Index_Id)); } @@ -1403,22 +1317,9 @@ NDT_Status ND_DataStruct_Flush_I( NDT_Root *Root_Ptr) NDT_Status ND_DataStruct_Flush_C( NDT_Root *Root_Ptr) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Flush_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if (!Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Flush_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + return ND_DataStruct_Flush_I( Root_Ptr); } @@ -1456,8 +1357,7 @@ NDT_Status ND_Index_Check_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, int } else { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Check_I: unknown structure type (%d) in structure (%p:%d)\n", Root_Ptr->Index_Tab[Index_Id].Type, Root_Ptr, Index_Id); - ND_Error_Print(); + LG_LOG_ERROR_3( "Unknown structure type: (%d) in structure: (%p:%d)\n", Root_Ptr->Index_Tab[Index_Id].Type, Root_Ptr, Index_Id); (*Detected_Nb_Ptr)++; return( NDS_OK); @@ -1496,31 +1396,9 @@ NDT_Status ND_Index_Check_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, int NDT_Status ND_Index_Check_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, int *Nb_Detected_Ptr, int *Nb_Corrected_Ptr, FILE *Out) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Check_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Check_C: structure root is null"); - ND_Error_Print(); - - (*Nb_Detected_Ptr)++; - - return(NDS_ERRAPI); - } - - if( !Out) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Check_C: the stream descriptor is null"); - ND_Error_Print(); - - return(NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + ND_NOT_NULL_CHECK( Out, "Stream descriptor"); return( ND_Index_Check_I( Root_Ptr, Index_Id, Nb_Detected_Ptr, Nb_Corrected_Ptr, Out)); } @@ -1576,29 +1454,9 @@ NDT_Status ND_DataStruct_Check_I( NDT_Root *Root_Ptr, int *Error_Detected_Nb_ NDT_Status ND_DataStruct_Check_C( NDT_Root *Root_Ptr, int *Nb_Detected_Ptr, int *Nb_Corrected_Ptr, FILE *Out) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Check_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Check_C: structure root is null"); - ND_Error_Print(); - (*Nb_Detected_Ptr)++; - - return( NDS_ERRAPI); - } - - if( !Out) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Check_C: the stream descriptor is null"); - ND_Error_Print(); - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + ND_NOT_NULL_CHECK( Out, "Stream descriptor"); return( ND_DataStruct_Check_I( Root_Ptr, Nb_Detected_Ptr, Nb_Corrected_Ptr, Out)); } @@ -1699,9 +1557,9 @@ NDT_Status ND_Index_Convert_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT default: { - sprintf( NDG_Base.Err_String, "Error ND_Index_Convert_I: unknown structure type (%d)", Root_Ptr->Index_Tab[Index_Id].Type); - ND_Error_Print (); - return NDS_ERRAPI; + LG_LOG_ERROR_1( "Unknown structure type: (%d)", Root_Ptr->Index_Tab[Index_Id].Type); + + return( NDS_ERRAPI); } } } @@ -1723,21 +1581,8 @@ NDT_Status ND_Index_Convert_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT NDT_Status ND_Index_Convert_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Target_Type) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Convert_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Convert_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); return( ND_Index_Convert_I( Root_Ptr, Index_Id, Target_Type)); } @@ -1753,7 +1598,7 @@ NDT_Status ND_Index_Convert_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT /* (I) Index_Type_Ptr: Array of index type (List, tree, ...) */ /*------------------------------------------------------------------------------*/ -NDT_Status ND_DataStruct_Convert_I( NDT_Root *Root_Ptr, NDT_Index_Type *Target_Type_Ptr) +NDT_Status ND_DataStruct_Convert_I( NDT_Root *Root_Ptr, NDT_Index_Type *Index_Type_Ptr) { NDT_Status rc; NDT_Index_Nb idx; @@ -1761,8 +1606,8 @@ NDT_Status ND_DataStruct_Convert_I( NDT_Root *Root_Ptr, NDT_Index_Type *Targe for( idx = 0; idx < Root_Ptr->Index_Nb; idx++) { - rc = ND_Index_Convert_I( Root_Ptr, idx, Target_Type_Ptr[idx]); - if( ND_ERROR(rc)) return rc; + rc = ND_Index_Convert_I( Root_Ptr, idx, Index_Type_Ptr[idx]); + if( ND_ERROR( rc)) return rc; } return( NDS_OK); @@ -1779,33 +1624,13 @@ NDT_Status ND_DataStruct_Convert_I( NDT_Root *Root_Ptr, NDT_Index_Type *Targe /* (I) Index_Type_Ptr: Array of index type (List, tree, ...) */ /*------------------------------------------------------------------------------*/ -NDT_Status ND_DataStruct_Convert_C( NDT_Root *Root_Ptr, NDT_Index_Type *Target_Type_Ptr) +NDT_Status ND_DataStruct_Convert_C( NDT_Root *Root_Ptr, NDT_Index_Type *Index_Type_Ptr) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Convert_C: library is not open"); - ND_Error_Print(); + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + ND_NOT_NULL_CHECK( Index_Type_Ptr, "Index type"); - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Convert_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Target_Type_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Convert_C: target type ptr is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - return( ND_DataStruct_Convert_I( Root_Ptr, Target_Type_Ptr)); + return( ND_DataStruct_Convert_I( Root_Ptr, Index_Type_Ptr)); } @@ -1849,8 +1674,7 @@ NDT_Status ND_Index_Reorg_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) } else { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Reorg_C: unknown structure type (%d) in structure (%p:%d)\n", Root_Ptr->Index_Tab[Index_Id].Type, Root_Ptr, Index_Id); - ND_Error_Print(); + LG_LOG_ERROR_3( "Unknown structure type: (%d) in structure: (%p:%d)\n", Root_Ptr->Index_Tab[Index_Id].Type, Root_Ptr, Index_Id); return( NDS_ERRAPI); } @@ -1875,21 +1699,8 @@ NDT_Status ND_Index_Reorg_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) NDT_Status ND_Index_Reorg_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Reorg_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Reorg_C: structure root is null"); - ND_Error_Print (); - - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); return( ND_Index_Reorg_I( Root_Ptr, Index_Id)); } @@ -1935,21 +1746,8 @@ NDT_Status ND_DataStruct_Reorg_I( NDT_Root *Root_Ptr) NDT_Status ND_DataStruct_Reorg_C( NDT_Root *Root_Ptr) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Reorg_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Reorg_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); return( ND_DataStruct_Reorg_I( Root_Ptr)); } @@ -2028,21 +1826,8 @@ NDT_Status ND_Index_Traverse_VI( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, ND NDT_Status ND_Index_Traverse_VC( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Command Command, va_list *Args_Ptr) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Traverse_VC: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Traverse_VC: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); return( ND_Index_Traverse_VI( Root_Ptr, Index_Id, Command, Args_Ptr)); } @@ -2132,24 +1917,11 @@ NDT_Status ND_Index_Traverse_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, ND va_list args; + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + va_start( args, Command); - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Traverse_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Traverse_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - status = ND_Index_Traverse_VI( Root_Ptr, Index_Id, Command, &args); va_end( args); @@ -2196,20 +1968,8 @@ NDT_Status ND_DataStruct_Traverse_VI( NDT_Root *Root_Ptr, NDT_Command Command, NDT_Status ND_DataStruct_Traverse_VC( NDT_Root *Root_Ptr, NDT_Command Command, va_list *Args_Ptr) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Traverse_VC: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Traverse_VC: structure root is null"); - ND_Error_Print(); - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); return( ND_DataStruct_Traverse_VI( Root_Ptr, Command, Args_Ptr)); } @@ -2264,24 +2024,11 @@ NDT_Status ND_DataStruct_Traverse_C( NDT_Root *Root_Ptr, NDT_Command Command, va_list args; + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + va_start( args, Command); - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Taverse_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Traverse_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - status = ND_DataStruct_Traverse_VI( Root_Ptr, Command, &args); va_end( args); @@ -2361,29 +2108,9 @@ NDT_Status ND_Index_Info_Print_I( FILE *Out, NDT_Root *Root_Ptr, NDT_Index_Id NDT_Status ND_Index_Info_Print_C( FILE *Out, NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Info_Print_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Info_Print_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Out) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Info_Print_C: the stream descriptor is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + ND_NOT_NULL_CHECK( Out, "Stream descriptor"); return( ND_Index_Info_Print_I( Out, Root_Ptr, Index_Id, Recursive_Mode, Recursive_Depth, Recursive_Offset)); } @@ -2464,28 +2191,9 @@ NDT_Status ND_DataStruct_Info_Print_I( FILE *Out, NDT_Root *Root_Ptr, NDT_Recu NDT_Status ND_DataStruct_Info_Print_C( FILE *Out, NDT_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Info_Print_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf (NDG_Base.Err_String, "Error ND_DataStruct_Info_Print_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Out) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Info_Print_C: the stream descriptor is null"); - ND_Error_Print(); - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + ND_NOT_NULL_CHECK( Out, "Stream descriptor"); return( ND_DataStruct_Info_Print_I( Out, Root_Ptr, Recursive_Mode, Recursive_Depth, Recursive_Offset)); } @@ -2519,8 +2227,8 @@ NDT_Status ND_Index_Value_Add_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, v } else { - sprintf( NDG_Base.Err_String, "Error ND_Index_Value_Add_I: unknown structure type (%d)", Root_Ptr->Index_Tab[Index_Id].Type); - ND_Error_Print(); + LG_LOG_ERROR_1( "Unknown structure type: (%d)", Root_Ptr->Index_Tab[Index_Id].Type); + return( NDS_ERRAPI); } @@ -2541,29 +2249,9 @@ NDT_Status ND_Index_Value_Add_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, v NDT_Status ND_Index_Value_Add_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, void *Value_Ptr) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Value_Add_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Value_Add_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Value_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Value_Add_C: the value to add is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + ND_NOT_NULL_CHECK( Value_Ptr, "Value"); return( ND_Index_Value_Add_I( Root_Ptr, Index_Id, Value_Ptr)); } @@ -2610,31 +2298,11 @@ NDT_Status ND_DataStruct_Value_Add_I( NDT_Root *Root_Ptr, void *Value_Ptr) NDT_Status ND_DataStruct_Value_Add_C( NDT_Root *Root_Ptr, void *Value_Ptr) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Add_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Add_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Value_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Add_C: the value to add is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - return( ND_DataStruct_Value_Add_I( Root_Ptr, Value_Ptr)); + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + ND_NOT_NULL_CHECK( Value_Ptr, "Value"); + + return( ND_DataStruct_Value_Add_I( Root_Ptr, Value_Ptr)); } @@ -2693,29 +2361,9 @@ NDT_Status ND_Index_Value_Remove_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id NDT_Status ND_Index_Value_Remove_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, void *Value_Ptr) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Value_Remove_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Value_Remove_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Value_Ptr) - { - sprintf (NDG_Base.Err_String, "Error ND_Index_Value_Remove_C: the value is null"); - ND_Error_Print (); - - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + ND_NOT_NULL_CHECK( Value_Ptr, "Value"); return( ND_Index_Value_Remove_I( Root_Ptr, Index_Id, Value_Ptr)); } @@ -2762,29 +2410,9 @@ NDT_Status ND_DataStruct_Value_Remove_I( NDT_Root *Root_Ptr, void *Value_Ptr) NDT_Status ND_DataStruct_Value_Remove_C( NDT_Root *Root_Ptr, void *Value_Ptr) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Remove_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Remove_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Value_Ptr) - { - sprintf (NDG_Base.Err_String, "Error ND_DataStruct_Value_Remove_C: the value is null"); - ND_Error_Print (); - - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + ND_NOT_NULL_CHECK( Value_Ptr, "Value"); return( ND_DataStruct_Value_Remove_I( Root_Ptr, Value_Ptr)); } @@ -2868,32 +2496,12 @@ NDT_Status ND_Index_Value_Print_C( FILE *Out, NDT_Root *Root_Ptr, NDT_Index_I va_list user_args; + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + ND_NOT_NULL_CHECK( Out, "Stream descriptor"); + va_start( user_args, Recursive_Offset); - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Value_Print_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Value_Print_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Out) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Value_Print_C: the stream descriptor is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - status = ND_Index_Value_Print_VI( Out, Root_Ptr, Index_Id, Recursive_Mode, Recursive_Depth, Recursive_Offset, &user_args); va_end( user_args); @@ -2976,31 +2584,12 @@ NDT_Status ND_DataStruct_Value_Print_C( FILE *Out, NDT_Root *Root_Ptr, NDT_Re va_list user_args; + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + ND_NOT_NULL_CHECK( Out, "Stream descriptor"); + va_start( user_args, Recursive_Offset); - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Print_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Print_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Out) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Print_C: the stream descriptor is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } status = ND_DataStruct_Value_Print_VI( Out, Root_Ptr, Recursive_Mode, Recursive_Depth, Recursive_Offset, &user_args); @@ -3049,29 +2638,9 @@ NDT_Status ND_Index_Node_Add_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, ND NDT_Status ND_Index_Node_Add_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Add_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf (NDG_Base.Err_String, "Error ND_Index_Node_Add_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Node_Ptr) - { - sprintf (NDG_Base.Err_String, "Error ND_Index_Node_Add_C: the node to add is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + ND_NOT_NULL_CHECK( Node_Ptr, "Node"); return( ND_Index_Node_Add_I( Root_Ptr, Index_Id, Node_Ptr)); } @@ -3192,21 +2761,8 @@ NDT_Status ND_Index_Node_Remove_I( NDT_Node *Node_Ptr) NDT_Status ND_Index_Node_Remove_C( NDT_Node *Node_Ptr) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Remove_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Node_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Remove_C: the node to remove is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Node_Ptr, "Node"); return( ND_Index_Node_Remove_I( Node_Ptr)); } @@ -3250,21 +2806,8 @@ NDT_Status ND_Index_Node_First_Get_I( NDT_Node **First_Node_Ptr_Ptr, NDT_Root NDT_Status ND_Index_Node_First_Get_C( NDT_Node **First_Node_Ptr_Ptr, NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Node_First_Get_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Node_First_Get_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); return( ND_Index_Node_First_Get_I( First_Node_Ptr_Ptr, Root_Ptr, Index_Id)); } @@ -3307,21 +2850,8 @@ NDT_Status ND_Index_Node_Last_Get_I ( NDT_Node **Last_Node_Ptr_Ptr, NDT_Root * NDT_Status ND_Index_Node_Last_Get_C( NDT_Node **Last_Node_Ptr_Ptr, NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Last_Get_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Last_Get_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); return( ND_Index_Node_Last_Get_I( Last_Node_Ptr_Ptr, Root_Ptr, Index_Id)); } @@ -3373,21 +2903,8 @@ NDT_Status ND_Index_Node_Next_Get_I ( NDT_Node **Next_Node_Ptr_Ptr, NDT_Node * NDT_Status ND_Index_Node_Next_Get_C( NDT_Node **Next_Node_Ptr_Ptr, NDT_Node *Node_Ptr) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Next_Get_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Node_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Next_Get_C: node is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Node_Ptr, "Node"); return( ND_Index_Node_Next_Get_I( Next_Node_Ptr_Ptr, Node_Ptr)); } @@ -3437,21 +2954,8 @@ NDT_Status ND_Index_Node_Previous_Get_I( NDT_Node **Prev_Node_Ptr_Ptr, NDT_Nod NDT_Status ND_Index_Node_Previous_Get_C( NDT_Node **Prev_Node_Ptr_Ptr, NDT_Node *Node_Ptr) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Previous_Get_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Node_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Previous_Get_C: node is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Node_Ptr, "Node"); return( ND_Index_Node_Previous_Get_I( Prev_Node_Ptr_Ptr, Node_Ptr)); } @@ -3510,29 +3014,9 @@ NDT_Status ND_Index_Node_Find_VC( NDT_Node **Node_Ptr_Ptr, NDT_Root *Root_Ptr NDT_Status status; - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Find_VC: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Find_VC: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Value_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Find_VC: the value to find is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + ND_NOT_NULL_CHECK( Value_Ptr, "Value"); status = ND_Index_Node_Find_VI( Node_Ptr_Ptr, Root_Ptr, Index_Id, Value_Ptr, Args_Ptr); @@ -3600,32 +3084,12 @@ NDT_Status ND_Index_Node_Find_C( NDT_Node **Node_Ptr_Ptr, NDT_Root *Root_Ptr, va_list user_args; + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + ND_NOT_NULL_CHECK( Value_Ptr, "Value"); + va_start( user_args, Value_Ptr); - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Find_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Find_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Value_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Find_C: the value to find is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - status = ND_Index_Node_Find_VI( Node_Ptr_Ptr, Root_Ptr, Index_Id, Value_Ptr, &user_args); va_end( user_args); @@ -3690,29 +3154,9 @@ NDT_Status ND_DataStruct_Value_Find_VC( void **Value_Ptr_Ptr, NDT_Root *Root_ NDT_Status status; - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Find_VC: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Find_VC: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Ref_Value_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Find_VC: the ref value to find is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + ND_NOT_NULL_CHECK( Ref_Value_Ptr, "Ref value"); status = ND_DataStruct_Value_Find_VI( Value_Ptr_Ptr, Root_Ptr, Ref_Value_Ptr, Args_Ptr); @@ -3782,32 +3226,12 @@ NDT_Status ND_DataStruct_Value_Find_C( void **Value_Ptr_Ptr, NDT_Root *Root_P va_list user_args; + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + ND_NOT_NULL_CHECK( Ref_Value_Ptr, "Ref value"); + va_start( user_args, Ref_Value_Ptr); - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Find_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Find_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Ref_Value_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Find_C: the ref value to find is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - status = ND_DataStruct_Value_Find_VI( Value_Ptr_Ptr, Root_Ptr, Ref_Value_Ptr, &user_args); va_end( user_args); @@ -3846,21 +3270,8 @@ NDT_Status ND_Node_Root_Get_I( NDT_Root **Root_Ptr_Ptr, NDT_Node *Node_Ptr) NDT_Status ND_Node_Root_Get_C( NDT_Root **Root_Ptr_Ptr, NDT_Node *Node_Ptr ) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Node_Root_Get_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Node_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Node_Root_Get_C: node is null"); - ND_Error_Print(); - - return(NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Node_Ptr, "Node"); return( ND_Node_Root_Get_I( Root_Ptr_Ptr, Node_Ptr)); } @@ -3914,21 +3325,8 @@ NDT_Status ND_Value_Alloc_C( void **Value_Ptr_Ptr, NDT_Root *Root_Ptr, ...) va_list user_args; - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Value_Alloc_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Value_Alloc_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); /* Récupération des arguments pour l'allocation de la valeur */ @@ -3972,29 +3370,9 @@ NDT_Status ND_Value_Free_I( NDT_Root *Root_Ptr, void *Value_Ptr) NDT_Status ND_Value_Free_C( NDT_Root *Root_Ptr, void *Value_Ptr) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Value_Free_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Value_Free_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Value_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Value_Free_C: the value to free is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + ND_NOT_NULL_CHECK( Value_Ptr, "Value"); /* Appel du manager */ @@ -4029,8 +3407,7 @@ NDT_Status ND_Manager_Exec_VI( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT { if( ND_Symbol_Find( (void **)&manager_ptr, Root_Ptr->Manager_Name) != NDS_OK) { - sprintf( NDG_Base.Err_String, "ND_Manager_Exec_VI: cant't find manger function"); - ND_Error_Print(); + LG_LOG_ERROR_0( "Cant't find manger function"); return( NDS_KO); } @@ -4059,26 +3436,12 @@ NDT_Status ND_Manager_Exec_VC( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT NDT_Status status; - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Manager_Exec_VC: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Manager_Exec_VC: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); if( !Root_Ptr->Manager_Ptr || !*(Root_Ptr->Manager_Ptr)) { - sprintf( NDG_Base.Err_String, "Error ND_Manager_Exec_VC: undefined function name"); - ND_Error_Print(); + LG_LOG_ERROR_0( "Undefined function name"); return( NDS_ERRAPI); } @@ -4119,8 +3482,7 @@ NDT_Status ND_Manager_Exec_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_ { if( ND_Symbol_Find( (void **)&manager_ptr, Root_Ptr->Manager_Name) != NDS_OK) { - sprintf( NDG_Base.Err_String, "ND_Manager_Exec_I: cant't find manger function"); - ND_Error_Print(); + LG_LOG_ERROR_0( "Cant't find manger function"); return( NDS_KO); } @@ -4153,28 +3515,14 @@ NDT_Status ND_Manager_Exec_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_ va_list args; + ND_LIBNODE_OPEN_CHECK(); + ND_NOT_NULL_CHECK( Root_Ptr, "Root structure"); + va_start( args, Command); - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Manager_Exec_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - - if( !Root_Ptr) - { - sprintf( NDG_Base.Err_String, "Error ND_Manager_Exec_C: structure root is null"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } - if( !Root_Ptr->Manager_Ptr || !*(Root_Ptr->Manager_Ptr)) { - sprintf( NDG_Base.Err_String, "Error ND_Manager_Exec_C: undefined function name"); - ND_Error_Print(); + LG_LOG_ERROR_0( "Undefined function name"); return( NDS_ERRAPI); } @@ -4212,8 +3560,7 @@ NDT_Status ND_Allocator_Exec_I( void **Ptr_Ptr, size_t Size, NDT_Allocator_Na { if( ND_Symbol_Find( (void **)&allocator_ptr, Allocator_Name) != NDS_OK) { - sprintf( NDG_Base.Err_String, "Error ND_Manager_Exec_I: cant't find allocator function"); - ND_Error_Print(); + LG_LOG_ERROR_0( "Cant't find allocator function"); return( NDS_KO); } @@ -4237,18 +3584,11 @@ NDT_Status ND_Allocator_Exec_I( void **Ptr_Ptr, size_t Size, NDT_Allocator_Na NDT_Status ND_Allocator_Exec_C( void **Ptr_Ptr, size_t Size, NDT_Allocator_Name Allocator_Name, NDT_Allocator *Allocator_Ptr, void *Data_Ptr) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Allocator_Exec_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); if( ( Allocator_Name == NULL) && ( Allocator_Ptr == NULL)) { - sprintf( NDG_Base.Err_String, "Error ND_Allocator_Exec_C: undefined function name"); - ND_Error_Print(); + LG_LOG_ERROR_0( "Undefined function name"); return( NDS_ERRAPI); } @@ -4282,8 +3622,7 @@ NDT_Status ND_Deallocator_Exec_I( void *Ptr, NDT_Deallocator_Name Deallocator_ { if( ND_Symbol_Find( (void **)&deallocator_ptr, Deallocator_Name) != NDS_OK) { - sprintf( NDG_Base.Err_String, "Error ND_Manager_Exec_I: cant't find deallocator function"); - ND_Error_Print(); + LG_LOG_ERROR_0( "Cant't find deallocator function"); return( NDS_KO); } @@ -4307,18 +3646,11 @@ NDT_Status ND_Deallocator_Exec_I( void *Ptr, NDT_Deallocator_Name Deallocator_ NDT_Status ND_Deallocator_Exec_C( void *Ptr, NDT_Deallocator_Name Deallocator_Name, NDT_Deallocator *Deallocator_Ptr, void *Data_Ptr) { - if( NDG_Base.Open_Status != NDD_TRUE) - { - sprintf( NDG_Base.Err_String, "Error ND_Deallocator_Exec_C: library is not open"); - ND_Error_Print(); - - return( NDS_ERRAPI); - } + ND_LIBNODE_OPEN_CHECK(); if( ( Deallocator_Name == NULL) && ( Deallocator_Ptr == NULL)) { - sprintf( NDG_Base.Err_String, "Error ND_Deallocator_Exec_C: undefined function name"); - ND_Error_Print(); + LG_LOG_ERROR_0( "Undefined function name"); return( NDS_ERRAPI); } @@ -4370,8 +3702,7 @@ NDT_Status ND_Symbol_Find( void **Ptr_Ptr, const char *Symbol_Name) if( ( *Ptr_Ptr = dlsym( NDG_Base.DL_Ptr, (const char *)Symbol_Name)) == NULL) { - sprintf( NDG_Base.Err_String, "Error ND_Symbol_Find: unable to find \"%s\"' in symbol table (%s)", Symbol_Name, dlerror()); - ND_Error_Print(); + LG_LOG_ERROR_2( "Unable to find: [%s] in symbol table: (%s)", Symbol_Name, dlerror()); return( NDS_KO); } @@ -4379,8 +3710,7 @@ NDT_Status ND_Symbol_Find( void **Ptr_Ptr, const char *Symbol_Name) Symbol_Ptr = (NDT_Symbol *)malloc( sizeof( NDT_Symbol)); if( Symbol_Ptr == NULL) { - sprintf( NDG_Base.Err_String, "Error ND_Symbol_Find: no more memory"); - ND_Error_Print(); + LG_LOG_ERROR_0( "No more memory"); return( NDS_KO); } @@ -4526,8 +3856,8 @@ NDT_Status ND_Node_Root_Alloc( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_Nb, { if( ( status = ND_Index_Clear( *Root_Ptr_Ptr, index_id)) != NDS_OK) { - sprintf( NDG_Base.Err_String, "Error ND_Index_Open_I: Index cleaning error"); - ND_Error_Print(); + LG_LOG_ERROR_0( "Index cleaning error"); + return( NDS_KO); } @@ -5378,8 +4708,7 @@ int ND_Node_Compare( void **Node1_Ptr_Ptr, void **Node2_Ptr_Ptr) default: { - sprintf( NDG_Base.Err_String, "Error ND_Node_Compare : incorrect return code from the manager: %d", rc); - ND_Error_Print(); + LG_LOG_ERROR_1( "Incorrect return code from the manager: (%d)", rc); return( 0); } @@ -5862,16 +5191,14 @@ NDT_Status ND_Address_Check( void *Address) if( ( rc = sigaction( SIGBUS, &act, &oact_bus)) != 0) { - sprintf( NDG_Base.Err_String, "Error ND_Address_Check: sigaction (Add SIGBUS Hdl) rc: %d errno: %d", rc, errno); - ND_Error_Print(); + LG_LOG_ERROR_2( "Sigaction (Add SIGBUS Hdl) rc: (%d) errno: (%d)", rc, errno); return( NDS_KO); } if( ( rc = sigaction( SIGSEGV, &act, &oact_segv)) != 0) { - sprintf( NDG_Base.Err_String, "Error ND_Address_Check: sigaction (Add SIGSEGV Hdl) rc: %d errno: %d", rc, errno); - ND_Error_Print(); + LG_LOG_ERROR_2( "Sigaction (Add SIGSEGV Hdl) rc: (%d) errno: (%d)", rc, errno); return( NDS_KO); } @@ -5897,16 +5224,14 @@ NDT_Status ND_Address_Check( void *Address) if( ( rc = sigaction( SIGBUS, &oact_bus, &act)) != 0) { - sprintf( NDG_Base.Err_String, "Error ND_Address_Check: sigaction (Remove SIGBUS Hdl) rc: %d errno: %d", rc, errno); - ND_Error_Print(); + LG_LOG_ERROR_2( "Sigaction (Remove SIGBUS Hdl) rc: (%d) errno: (%d)", rc, errno); return( NDS_KO); } if( ( rc = sigaction( SIGSEGV, &oact_segv, &act)) != 0) { - sprintf( NDG_Base.Err_String, "Error ND_Address_Check: sigaction (Remove SIGSEGV Hdl) rc: %d errno: %d", rc, errno); - ND_Error_Print(); + LG_LOG_ERROR_2( "Sigaction (Remove SIGSEGV Hdl) rc: (%d) errno: (%d)", rc, errno); return( NDS_KO); } @@ -5926,8 +5251,7 @@ NDT_Status ND_Address_Check( void *Address) if( ( old_sigsegv_sighandler = signal( SIGSEGV, ND_Signal_Trap)) == SIG_ERR) { - sprintf( NDG_Base.Err_String, "Error ND_Address_Check: signal (Add SIGSEGV Hdl) errno: %d", errno); - ND_Error_Print(); + LG_LOG_ERROR_1( "Signal (Add SIGSEGV Hdl) errno: (%d)", errno); return( NDS_KO); } @@ -5953,8 +5277,7 @@ NDT_Status ND_Address_Check( void *Address) if( ( old_sigsegv_sighandler = signal( SIGSEGV, old_sigsegv_sighandler)) == SIG_ERR) { - sprintf( NDG_Base.Err_String, "Error ND_Address_Check: signal (Remove SIGSEGV Hdl) errno: %d", errno); - ND_Error_Print(); + LG_LOG_ERROR_1( "Signal (Remove SIGSEGV Hdl) errno: (%d)", errno); return( NDS_KO); } diff --git a/lib/libnode.h b/lib/libnode.h index 01d0451..f1f5d41 100644 --- a/lib/libnode.h +++ b/lib/libnode.h @@ -118,6 +118,14 @@ NDT_Base NDG_Base = }; +/*------------------------------------------------------------------------------*/ +/* */ +/*------------------------------------------------------------------------------*/ + +#define ND_LIBNODE_OPEN_CHECK() if( NDG_Base.Open_Status != NDD_TRUE) { LG_LOG_ERROR_0( "LibNode library is not opened"); return( NDS_ERRAPI); } +#define ND_NOT_NULL_CHECK( ptr, msg) if( !(ptr)) { LG_LOG_ERROR_1( "%s is null", (msg)); return( NDS_ERRAPI); } + +