From 3a3002375f43805de62e96d22430e528e08a9ebb Mon Sep 17 00:00:00 2001 From: "Arnaud G. GIBERT" Date: Thu, 18 Apr 2024 00:54:52 +0200 Subject: [PATCH] - Start LibLog support implementation, - Fix .h and .c file headers. --- Makefile | 6 ---- demo/Makefile | 12 ++++---- demo/nddemo0.c | 5 +++ include/node.h | 52 +++++++++++++++---------------- lib/Makefile | 4 +-- lib/libnode.c | 84 ++++++++++++++++++++++++++++++++------------------ lib/libnode.h | 57 ++++++++++++++++++---------------- util/Makefile | 14 ++++----- 8 files changed, 131 insertions(+), 103 deletions(-) diff --git a/Makefile b/Makefile index 57eae10..bb88aab 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,3 @@ -# $RCSfile: Makefile,v $ -# $Revision: 1.3 $ -# $Name: $ -# $Date: 2003/07/16 23:32:06 $ -# $Author: agibert $ - #------------------------------------------------------------------------------ # Main Makefile #------------------------------------------------------------------------------ diff --git a/demo/Makefile b/demo/Makefile index 486c993..947a4cb 100644 --- a/demo/Makefile +++ b/demo/Makefile @@ -10,12 +10,12 @@ include ../Makefile.rule -DEP_STATIC += ../lib/libnode.a -DEP_DYNAMIC += ../lib/libnode.so -INCLUDE += -I . -I ../include -LIBDIR += -L . -L ../lib -LIB_STATIC += ../lib/libnode.a -ldl -LIB_DYNAMIC += -lnode -ldl +DEP_STATIC += ../lib/libnode.a ../../liblog/lib/liblog.a +DEP_DYNAMIC += ../lib/libnode.so ../../liblog/lib/liblog.so +INCLUDE += -I . -I ../include -I ../../liblog/include +LIBDIR += -L . -L ../lib -L ../../liblog/lib +LIB_STATIC += ../lib/libnode.a ../../liblog/lib/liblog.a -ldl +LIB_DYNAMIC += -lnode -llog -ldl CFLAGS += -rdynamic ifdef _LIBVER_SUPPORT diff --git a/demo/nddemo0.c b/demo/nddemo0.c index 07cfeb5..897f159 100644 --- a/demo/nddemo0.c +++ b/demo/nddemo0.c @@ -107,6 +107,7 @@ NDT_Status Demo_DS_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_No 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); @@ -167,6 +168,7 @@ NDT_Status Demo_DS_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_No ND_VA_LIST_CLOSE( user_args); */ + ND_VA_ARG_GET( Value_Ptr_Ptr, *Args_Ptr, Demo_Value **); @@ -198,6 +200,7 @@ NDT_Status Demo_DS_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_No ND_VA_LIST_CLOSE( user_args); */ + ND_VA_ARG_GET( Value_Ptr, *Args_Ptr, Demo_Value *); @@ -220,6 +223,7 @@ NDT_Status Demo_DS_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_No ND_VA_LIST_CLOSE( user_args); */ + ND_VA_ARG_GET( Value1_Ptr, *Args_Ptr, Demo_Value *); ND_VA_ARG_GET( Value2_Ptr, *Args_Ptr, Demo_Value *); @@ -367,6 +371,7 @@ NDT_Status Demo_DS_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_No 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); diff --git a/include/node.h b/include/node.h index 9895ff6..cbbfb23 100644 --- a/include/node.h +++ b/include/node.h @@ -1,33 +1,30 @@ -/*---------------------------------------------------------------------------------*/ -/* $RCSfile: node.h,v $ */ -/*---------------------------------------------------------------------------------*/ -/* $Revision: 2.13 $ */ -/* $Name: libnode-2_2_0-1 $ */ -/* $Date: 2010/06/06 21:26:31 $ */ -/* $Author: agibert $ */ -/*---------------------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------------------*/ -/* This file is part of LibNode */ -/* */ -/* LibNode is free software; you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public Licence as published by */ -/* the Free Software Foundation; either version 2.1 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* LibNode 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 LibNode; if not, write to the Free Software */ -/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/*---------------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ +/* node.h */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ +/* This file is part of LibNode */ +/* */ +/* LibNode 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. */ +/* */ +/* LibNode 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 Drummer. If not, see */ +/* . */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ +/* Includes */ +/*----------------------------------------------------------------------------*/ #ifndef _LIBNODE_H_ # define _LIBNODE_H_ @@ -45,6 +42,9 @@ extern "C" { # include # endif +# include + + diff --git a/lib/Makefile b/lib/Makefile index 879da18..97e319d 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -9,8 +9,8 @@ include ../Makefile.rule -DEP += libnode.h ../include/node.h Makefile -INCLUDE += -I . -I ../include +DEP += libnode.h ../include/node.h ../../liblog/include/log.h Makefile +INCLUDE += -I . -I ../include -I ../../liblog/include ifdef _LIBVER_SUPPORT DEP += ../../libver/ver.h diff --git a/lib/libnode.c b/lib/libnode.c index 94e43f5..0485017 100644 --- a/lib/libnode.c +++ b/lib/libnode.c @@ -1,40 +1,37 @@ -/*---------------------------------------------------------------------------------*/ -/* $RCSfile: libnode.c,v $ */ -/*---------------------------------------------------------------------------------*/ -/* $Revision: 2.17 $ */ -/* $Name: libnode-2_2_0-1 $ */ -/* $Date: 2010/06/06 21:26:31 $ */ -/* $Author: agibert $ */ -/*---------------------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------------------*/ -/* This file is part of LibNode */ -/* */ -/* LibNode is free software; you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public Licence as published by */ -/* the Free Software Foundation; either version 2.1 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* LibNode 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 LibNode; if not, write to the Free Software */ -/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/*---------------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ +/* libnode.c */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ +/* This file is part of LibNode */ +/* */ +/* LibNode 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. */ +/* */ +/* LibNode 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 Drummer. If not, see */ +/* . */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ +/* Includes */ +/*----------------------------------------------------------------------------*/ #define _LIBNODE_C_ #include #ifdef _LIBVER_SUPPORT -VER_INFO_EXPORT( libnode, "$Revision: 2.17 $", "$Name: libnode-2_2_0-1 $", __FILE__, "$Author: agibert $") +//VER_INFO_EXPORT( libnode, "$Revision: 2.17 $", "$Name: libnode-2_2_0-1 $", __FILE__, "$Author: agibert $") #endif @@ -76,6 +73,7 @@ NDT_Status ND_Default_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT 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); @@ -359,7 +357,6 @@ NDT_Status ND_Default_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT ND_VA_LIST_CLOSE( user_args); - void *Value_Ptr = Node_Ptr->Value; */ @@ -669,6 +666,9 @@ NDT_Status ND_OpenStruct_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Status ND_Library_Open_I( int Debug_Mode) { + LGT_Status lg_status; + + NDG_Base.Debug_Mode = Debug_Mode; NDG_Base.Open_Status = NDD_TRUE; @@ -677,6 +677,13 @@ NDT_Status ND_Library_Open_I( int Debug_Mode) ND_Library_StdErr_Set_I( stderr); } + if( ( lg_status = LG_Library_Open( LGD_LOG_WRITER_DEFAULT, true)) != LGS_OK) + { + fprintf( stderr, "Can't open LibLog library: (%d)\n", lg_status); + return( -1); + } + + #if !defined(_WIN32) if( ( NDG_Base.DL_Ptr = dlopen( NULL, ( RTLD_NOW | RTLD_GLOBAL))) == NULL) { @@ -2300,13 +2307,22 @@ NDT_Status ND_Index_Info_Print_I( FILE *Out, NDT_Root *Root_Ptr, NDT_Index_Id { memset( offset, ' ', Recursive_Offset * ND_RECURSIVE_PRINT_OFFSET); offset[Recursive_Offset * ND_RECURSIVE_PRINT_OFFSET] = '\0'; - +/* fprintf( Out, "%s Index Id: (%d)\tType: (%#06x) [%s:%s:%s]\tNode Nb: (%ld)\tHead: (%s%p)\tTail: (%s%p)\n%s Min Depth: (%ld)\tMax Depth: (%ld)\tMax Dif: (%ld)\tNb Equ: (%ld)\tSave: (%s%p)\n\n", offset, Index_Id, Root_Ptr->Index_Tab[Index_Id].Type, ND_INDEX_STATUS_ASCII_GET( Root_Ptr, Index_Id), ND_INDEX_TYPE_ASCII_GET( Root_Ptr, Index_Id), ND_INDEX_SUBTYPE_ASCII_GET( Root_Ptr, Index_Id), Root_Ptr->Index_Tab[Index_Id].Node_Number, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Index_Tab[Index_Id].Head, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Index_Tab[Index_Id].Tail, offset, Root_Ptr->Index_Tab[Index_Id].Min_Depth, Root_Ptr->Index_Tab[Index_Id].Max_Depth, Root_Ptr->Index_Tab[Index_Id].Max_Dif, Root_Ptr->Index_Tab[Index_Id].Nb_Equ, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Index_Tab[Index_Id].Save); +*/ + + LG_LOG_INFO_11( "%s Index Id: (%d)\tType: (%#06x) [%s:%s:%s]\tNode Nb: (%ld)\tHead: (%s%p)\tTail: (%s%p)", + offset, Index_Id, Root_Ptr->Index_Tab[Index_Id].Type, ND_INDEX_STATUS_ASCII_GET( Root_Ptr, Index_Id), ND_INDEX_TYPE_ASCII_GET( Root_Ptr, Index_Id), ND_INDEX_SUBTYPE_ASCII_GET( Root_Ptr, Index_Id), + Root_Ptr->Index_Tab[Index_Id].Node_Number, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Index_Tab[Index_Id].Head, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Index_Tab[Index_Id].Tail); + LG_LOG_INFO_7( "%s Min Depth: (%ld)\tMax Depth: (%ld)\tMax Dif: (%ld)\tNb Equ: (%ld)\tSave: (%s%p)", + offset, Root_Ptr->Index_Tab[Index_Id].Min_Depth, Root_Ptr->Index_Tab[Index_Id].Max_Depth, Root_Ptr->Index_Tab[Index_Id].Max_Dif, Root_Ptr->Index_Tab[Index_Id].Nb_Equ, + NDD_PRINTF_PTR_PREFIX, Root_Ptr->Index_Tab[Index_Id].Save); + LG_LOG_INFO_0( ""); } if( ND_RECURSIVE_CHILD_IS(Recursive_Mode)) @@ -2394,11 +2410,19 @@ NDT_Status ND_DataStruct_Info_Print_I( FILE *Out, NDT_Root *Root_Ptr, NDT_Recu status = ND_Manager_Exec_I( Root_Ptr, NDD_INDEX_UNKNOWN, NULL, NDD_CMD_MANAGER_VERSION, &version_name); if( ND_ERROR( status)) return( status); - +/* fprintf( Out, "%sRoot: (%s%p)\tIndex Nb: (%d)\tIndex Open Count: (%d)\tManager: (%s%p) [%s]\n%sAllocator: (%s%p) [%s]\tDeallocator: (%s%p) [%s]\tUser: (%s%p)\n%sManager Version: [%s]\n\n", offset, NDD_PRINTF_PTR_PREFIX, Root_Ptr, Root_Ptr->Index_Nb, Root_Ptr->Index_Open_Count, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Manager_Ptr, Root_Ptr->Manager_Name, offset, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Allocator_Ptr, Root_Ptr->Allocator_Name, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Deallocator_Ptr, Root_Ptr->Deallocator_Name, NDD_PRINTF_PTR_PREFIX, Root_Ptr->User_Ptr, offset, version_name); +*/ + + LG_LOG_INFO_8( "%sRoot: (%s%p)\tIndex Nb: (%d)\tIndex Open Count: (%d)\tManager: (%s%p) [%s]", + offset, NDD_PRINTF_PTR_PREFIX, Root_Ptr, Root_Ptr->Index_Nb, Root_Ptr->Index_Open_Count, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Manager_Ptr, Root_Ptr->Manager_Name); + LG_LOG_INFO_9( "%sAllocator: (%s%p) [%s]\tDeallocator: (%s%p) [%s]\tUser: (%s%p)", + offset, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Allocator_Ptr, Root_Ptr->Allocator_Name, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Deallocator_Ptr, Root_Ptr->Deallocator_Name, NDD_PRINTF_PTR_PREFIX, Root_Ptr->User_Ptr); + LG_LOG_INFO_2( "%sManager Version: [%s]", offset, version_name); + LG_LOG_INFO_0( ""); } if( ND_RECURSIVE_CHILD_IS( Recursive_Mode)) diff --git a/lib/libnode.h b/lib/libnode.h index e6343b8..8a6bf6b 100644 --- a/lib/libnode.h +++ b/lib/libnode.h @@ -1,33 +1,30 @@ -/*---------------------------------------------------------------------------------*/ -/* $RCSfile: libnode.h,v $ */ -/*---------------------------------------------------------------------------------*/ -/* $Revision: 2.10 $ */ -/* $Name: libnode-2_2_0-1 $ */ -/* $Date: 2010/06/06 21:26:31 $ */ -/* $Author: agibert $ */ -/*---------------------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------------------*/ -/* This file is part of LibNode */ -/* */ -/* LibNode is free software; you can redistribute it and/or modify */ -/* it under the terms of the GNU Lesser General Public Licence as published by */ -/* the Free Software Foundation; either version 2.1 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* LibNode 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 LibNode; if not, write to the Free Software */ -/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/*---------------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ +/* libnode.h */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ +/* This file is part of LibNode */ +/* */ +/* LibNode 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. */ +/* */ +/* LibNode 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 Drummer. If not, see */ +/* . */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ +/* Includes */ +/*----------------------------------------------------------------------------*/ #include #include @@ -51,6 +48,14 @@ +/*----------------------------------------------------------------------------*/ +/* Definitions */ +/*----------------------------------------------------------------------------*/ + +#define LGD_MODULE_NAME "nd" + + + #ifdef __linux # define NDD_PRINTF_PTR_PREFIX "" #else diff --git a/util/Makefile b/util/Makefile index 12c983c..791d02e 100644 --- a/util/Makefile +++ b/util/Makefile @@ -1,4 +1,4 @@ -SRC := ndbench.c +SRC := ndbench.c TARGETS := ndbench ndbench-c ndbench-static ndbench-static-c FILE_BIN := ndbench ndbench-c ndbench-static ndbench-static-c FILE_LIB := *.ndb @@ -11,12 +11,12 @@ include ../Makefile.rule -DEP_STATIC += ../lib/libnode.a -DEP_DYNAMIC += ../lib/libnode.so -INCLUDE += -I . -I ../include -LIBDIR += -L . -L ../lib -LIB_STATIC += ../lib/libnode.a -ldl -LIB_DYNAMIC += -lnode -ldl +DEP_STATIC += ../lib/libnode.a ../../liblog/lib/liblog.a +DEP_DYNAMIC += ../lib/libnode.so ../../liblog/lib/liblog.so +INCLUDE += -I . -I ../include -I ../../liblog/include +LIBDIR += -L . -L ../lib -L ../../liblog/lib +LIB_STATIC += ../lib/libnode.a ../../liblog/lib/liblog.a -ldl +LIB_DYNAMIC += -lnode -llog -ldl CFLAGS += -rdynamic ifdef _LIBVER_SUPPORT