libnode/include/node.h
2024-05-04 12:10:31 +02:00

1365 lines
67 KiB
C

/*----------------------------------------------------------------------------*/
/* 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 LibNode. If not, see */
/* <https://www.gnu.org/licenses/>. */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* Includes */
/*----------------------------------------------------------------------------*/
#ifndef _LIBNODE_H_
# define _LIBNODE_H_
# ifdef __cplusplus
//extern "C" {
# endif
# include <stdlib.h>
# include <stdio.h>
# include <string.h>
# include <stdarg.h>
# ifdef _LIBVER_SUPPORT
# include <ver.h>
# endif
# include <log.h>
# define NDD_TRUE 1
# define NDD_FALSE 0
# define NDD_MIN(A,B) ( ( A > B) ? B : A)
# define NDD_MAX(A,B) ( ( A < B) ? B : A)
/*
Default allowed maximum depth between tree branches before rebalancing
*/
# define DEF_MAX_DIF 100
/* Types de structure */
typedef short NDT_Root_Type;
typedef int NDT_Index_Type;
# define NDD_INDEX_MSK 0xffff
# define NDD_INDEX_RMSK 0x0000
# define NDD_INDEX_STATUS_UNKNOWN 0x0000
# define NDD_INDEX_STATUS_OPENED 0x0001
# define NDD_INDEX_STATUS_CLOSED 0x0002
# define NDD_INDEX_STATUS_MSK ( NDD_INDEX_STATUS_UNKNOWN | NDD_INDEX_STATUS_OPENED | NDD_INDEX_STATUS_CLOSED)
# define NDD_INDEX_STATUS_RMSK ( NDD_INDEX_MSK ^ NDD_INDEX_STATUS_MSK)
# define ND_INDEX_STATUS_VALUE_UNKNOWN_IS( v) ( ( (v) & NDD_INDEX_STATUS_MSK) == NDD_INDEX_STATUS_UNKNOWN)
# define ND_INDEX_STATUS_VALUE_OPENED_IS( v) ( ( (v) & NDD_INDEX_STATUS_MSK) == NDD_INDEX_STATUS_OPENED)
# define ND_INDEX_STATUS_VALUE_CLOSED_IS( v) ( ( (v) & NDD_INDEX_STATUS_MSK) == NDD_INDEX_STATUS_CLOSED)
# define ND_INDEX_STATUS_UNKNOWN_IS( r, i) ND_INDEX_STATUS_VALUE_UNKNOWN_IS( (r)->Index_Tab[(i)].Type)
# define ND_INDEX_STATUS_OPENED_IS( r, i) ND_INDEX_STATUS_VALUE_OPENED_IS( (r)->Index_Tab[(i)].Type)
# define ND_INDEX_STATUS_CLOSED_IS( r, i) ND_INDEX_STATUS_VALUE_CLOSED_IS( (r)->Index_Tab[(i)].Type)
# define ND_INDEX_STATUS_VALUE_ASCII_GET( v) ( ND_INDEX_STATUS_VALUE_UNKNOWN_IS( (v)) ? "UNKNOWN" : ( ND_INDEX_STATUS_VALUE_OPENED_IS( (v)) ? "OPENED" : ( ND_INDEX_STATUS_VALUE_CLOSED_IS( (v)) ? "CLOSED" : "???")))
# define ND_INDEX_STATUS_ASCII_GET( r, i) ND_INDEX_STATUS_VALUE_ASCII_GET( (r)->Index_Tab[(i)].Type)
# define NDD_INDEX_TYPE_UNKNOWN 0x0000
# define NDD_INDEX_TYPE_LIST 0x0010
# define NDD_INDEX_TYPE_TREE 0x0020
# define NDD_INDEX_TYPE_MSK ( NDD_INDEX_TYPE_UNKNOWN | NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)
# define NDD_INDEX_TYPE_RMSK ( NDD_INDEX_MSK ^ NDD_INDEX_TYPE_MSK)
# define ND_INDEX_TYPE_VALUE_UNKNOWN_IS( v) ( ( (v) & NDD_INDEX_TYPE_MSK) == NDD_INDEX_TYPE_UNKNOWN)
# define ND_INDEX_TYPE_VALUE_LIST_IS( v) ( ( (v) & NDD_INDEX_TYPE_MSK) == NDD_INDEX_TYPE_LIST)
# define ND_INDEX_TYPE_VALUE_TREE_IS( v) ( ( (v) & NDD_INDEX_TYPE_MSK) == NDD_INDEX_TYPE_TREE)
# define ND_INDEX_TYPE_UNKNOWN_IS( r, i) ND_INDEX_TYPE_VALUE_UNKNOWN_IS( (r)->Index_Tab[(i)].Type)
# define ND_INDEX_TYPE_LIST_IS( r, i) ND_INDEX_TYPE_VALUE_LIST_IS( (r)->Index_Tab[(i)].Type)
# define ND_INDEX_TYPE_TREE_IS( r, i) ND_INDEX_TYPE_VALUE_TREE_IS( (r)->Index_Tab[(i)].Type)
# define ND_INDEX_TYPE_VALUE_ASCII_GET( v) ( ND_INDEX_TYPE_VALUE_UNKNOWN_IS( (v)) ? "UNKNOWN" : ( ND_INDEX_TYPE_VALUE_LIST_IS( (v)) ? "LIST" : ( ND_INDEX_TYPE_VALUE_TREE_IS( (v)) ? "TREE" : "???")))
# define ND_INDEX_TYPE_ASCII_GET( r, i) ND_INDEX_TYPE_VALUE_ASCII_GET( (r)->Index_Tab[(i)].Type)
# define NDD_INDEX_SUBTYPE_UNKNOWN 0x0000
# define NDD_INDEX_SUBTYPE_FIFO 0x0100 /* First In First Out list (queue) */
# define NDD_INDEX_SUBTYPE_LILO NDD_INDEX_SUBTYPE_FIFO
# define NDD_INDEX_SUBTYPE_LIFO 0x0200 /* First In Last Out list (stack) */
# define NDD_INDEX_SUBTYPE_FILO NDD_INDEX_SUBTYPE_LIFO
# define NDD_INDEX_SUBTYPE_SORTED 0x0300 /* Sorted list */
# define NDD_INDEX_SUBTYPE_UNBALANCED 0x0400
# define NDD_INDEX_SUBTYPE_BALANCED 0x0500 /* Auto balanced tree */
# define NDD_INDEX_SUBTYPE_MSK ( NDD_INDEX_SUBTYPE_UNKNOWN | NDD_INDEX_SUBTYPE_FIFO | NDD_INDEX_SUBTYPE_FILO | NDD_INDEX_SUBTYPE_SORTED | NDD_INDEX_SUBTYPE_UNBALANCED | NDD_INDEX_SUBTYPE_BALANCED)
# define NDD_INDEX_SUBTYPE_RMSK ( NDD_INDEX_MSK ^ NDD_INDEX_SUBTYPE_MSK)
# define ND_INDEX_SUBTYPE_VALUE_UNKNOWN_IS( v) ( ( (v) & NDD_INDEX_SUBTYPE_MSK) == NDD_INDEX_SUBTYPE_UNKNOWN)
# define ND_INDEX_SUBTYPE_VALUE_FIFO_IS( v) ( ( (v) & NDD_INDEX_SUBTYPE_MSK) == NDD_INDEX_SUBTYPE_FIFO)
# define ND_INDEX_SUBTYPE_VALUE_LILO_IS( v) ND_INDEX_SUBTYPE_VALUE_FIFO_IS( v)
# define ND_INDEX_SUBTYPE_VALUE_LIFO_IS( v) ( ( (v) & NDD_INDEX_SUBTYPE_MSK) == NDD_INDEX_SUBTYPE_LIFO)
# define ND_INDEX_SUBTYPE_VALUE_FILO_IS( v) ND_INDEX_SUBTYPE_LIFO_IS( r, i)
# define ND_INDEX_SUBTYPE_VALUE_SORTED_IS( v) ( ( (v) & NDD_INDEX_SUBTYPE_MSK) == NDD_INDEX_SUBTYPE_SORTED)
# define ND_INDEX_SUBTYPE_VALUE_UNBALANCED_IS( v) ( ( (v) & NDD_INDEX_SUBTYPE_MSK) == NDD_INDEX_SUBTYPE_UNBALANCED)
# define ND_INDEX_SUBTYPE_VALUE_BALANCED_IS( v) ( ( (v) & NDD_INDEX_SUBTYPE_MSK) == NDD_INDEX_SUBTYPE_BALANCED)
# define ND_INDEX_SUBTYPE_UNKNOWN_IS( r, i) ND_INDEX_SUBTYPE_VALUE_UNKNOWN_IS( (r)->Index_Tab[(i)].Type)
# define ND_INDEX_SUBTYPE_FIFO_IS( r, i) ND_INDEX_SUBTYPE_VALUE_FIFO_IS( (r)->Index_Tab[(i)].Type)
# define ND_INDEX_SUBTYPE_LILO_IS( r, i) ND_INDEX_SUBTYPE_VALUE_LILO_IS( (r)->Index_Tab[(i)].Type)
# define ND_INDEX_SUBTYPE_LIFO_IS( r, i) ND_INDEX_SUBTYPE_VALUE_LIFO_IS( (r)->Index_Tab[(i)].Type)
# define ND_INDEX_SUBTYPE_FILO_IS( r, i) ND_INDEX_SUBTYPE_VALUE_FILO_IS( (r)->Index_Tab[(i)].Type)
# define ND_INDEX_SUBTYPE_SORTED_IS( r, i) ND_INDEX_SUBTYPE_VALUE_SORTED_IS( (r)->Index_Tab[(i)].Type)
# define ND_INDEX_SUBTYPE_UNBALANCED_IS( r, i) ND_INDEX_SUBTYPE_VALUE_UNBALANCED_IS( (r)->Index_Tab[(i)].Type)
# define ND_INDEX_SUBTYPE_BALANCED_IS( r, i) ND_INDEX_SUBTYPE_VALUE_BALANCED_IS( (r)->Index_Tab[(i)].Type)
# define ND_INDEX_SUBTYPE_VALUE_ASCII_GET( v) ( ND_INDEX_SUBTYPE_VALUE_UNKNOWN_IS( v) ? "UNKNOWN" : ( ND_INDEX_SUBTYPE_VALUE_FIFO_IS( v) ? "FIFO" : ( ND_INDEX_SUBTYPE_VALUE_LIFO_IS( v) ? "LIFO" : ( ND_INDEX_SUBTYPE_VALUE_SORTED_IS( v) ? "SORTED" : ( ND_INDEX_SUBTYPE_VALUE_UNBALANCED_IS( v) ? "UNBALANCED" : ( ND_INDEX_SUBTYPE_VALUE_BALANCED_IS( v) ? "BALANCED" : "???"))))))
# define ND_INDEX_SUBTYPE_ASCII_GET( r, i) ND_INDEX_SUBTYPE_VALUE_ASCII_GET( (r)->Index_Tab[(i)].Type)
/* Manager Template */
// NDT_Status ND_Example_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;
//
//
// 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 = "$Revision: 2.13 $ $Name: libnode-2_2_0-1 $ $Date: 2010/06/06 21:26:31 $ $Author: agibert $";
//
// 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);
// */
//
//
// Command_Name = "NDD_CMD_VALUE_ALLOC";
//
// /*
// if( ( *Value_Ptr_Ptr = (void *)malloc( sizeof(void))) == NULL)
// {
// return(NDS_ERRMEM);
// }
// else
// {
// ...
//
// return( NDS_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);
// */
//
//
// Command_Name = "NDD_CMD_VALUE_FREE";
//
// /*
// free( 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);
// */
//
//
// Command_Name = "NDD_CMD_VALUE_COMP";
//
// switch( Index_Id)
// {
// case 0:
// {
// int rc;
//
//
// rc = strcmp( Value1_Ptr->..., Value2_Ptr->...);
//
// if( rc < 0)
// {
// return(NDS_LOWER);
// }
// else
// {
// if( rc > 0)
// {
// return(NDS_GREATER);
// }
// else
// {
// return(NDS_EQUAL);
// }
// }
// }
//
// case 1:
// {
// int val1 = atoi(Value1_Ptr->...);
// int val2 = atoi(Value2_Ptr->...);
//
//
// if( val1 < val2)
// {
// return(NDS_LOWER);
// }
// else
// {
// if( val1 > val2)
// {
// return(NDS_GREATER);
// }
// else
// {
// return(NDS_EQUAL);
// }
// }
// }
//
// case 2:
// {
// ...
// }
//
// default:
// {
// printf( "Unknown COMP idx (%d) !\n", 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;
// */
//
//
// Command_Name = "NDD_CMD_VALUE_PRINT";
//
// /*
// fprintf( Out, "...\n", Value_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);
// */
//
//
// 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);
// }
/* Var Args Manager Macros */
# define ND_VA_LIST_OPEN( VA_List_Target, VA_List_Source) va_list VA_List_Target; va_copy( VA_List_Target, *va_arg( VA_List_Source, va_list *))
# define ND_VA_LIST_CLOSE( VA_List) va_end( VA_List)
# define ND_VA_ARG_GET( Arg, VA_List, Type) Type Arg = va_arg( VA_List, Type)
/* Manager Commands */
typedef int NDT_Command;
# define NDD_CMD_UNKNOWN (NDT_Command)0
# define NDD_CMD_MANAGER_VERSION (NDT_Command)1
# define NDD_CMD_INDEX_GET (NDT_Command)2
# define NDD_CMD_VALUE_ALLOC (NDT_Command)3
# define NDD_CMD_VALUE_FREE (NDT_Command)4
# define NDD_CMD_VALUE_COMP (NDT_Command)5
# define NDD_CMD_VALUE_ADD (NDT_Command)6
# define NDD_CMD_VALUE_REMOVE (NDT_Command)7
# define NDD_CMD_VALUE_PRINT (NDT_Command)8
# define NDD_CMD_VALUE_FIND (NDT_Command)9
# define NDD_CMD_INFO_PRINT (NDT_Command)10
# define NDD_CMD_USER_TRAVERSE (NDT_Command)17
typedef char *NDT_Command_Name;
typedef char *NDT_Version_Name;
/* Manager or Functions Return Codes */
typedef int NDT_Status;
# define ND_ERROR(s) ( ( s) <= 0) /* All negative or 0 status are errors */
# define NDS_OK 1
# define NDS_KO 0
# define NDS_YES 1
# define NDS_NO 0
# define NDS_EQUAL 1
# define NDS_GREATER 2
# define NDS_LOWER 3
# define NDS_ERRMEM -1 /* Memory allocation problem */
# define NDS_ERRAPI -2 /* Bad API usage */
typedef short NDT_Index_Id;
typedef short NDT_Index_Nb;
# define NDD_INDEX_UNKNOWN (NDT_Index_Id)-1
# define NDD_INDEX_PRIMARY (NDT_Index_Id) 0
/* Predefinition */
typedef struct NDT_Node NDT_Node;
typedef struct NDT_Index NDT_Index;
typedef struct NDT_Root NDT_Root;
/* Manager function pointer */
# define NDD_MANAGER_NAME_LEN_MAX 64
# define NDD_MANAGER_NAME_SIZE_MAX ( NDD_MANAGER_NAME_LEN_MAX + 1)
typedef char *NDT_Manager_Name;
typedef NDT_Status NDT_Manager( struct NDT_Root *, NDT_Index_Id, struct NDT_Node *, NDT_Command, va_list *);
/* Memory allocator function pointer */
# define NDD_ALLOCATOR_NAME_LEN_MAX 64
# define NDD_ALLOCATOR_NAME_SIZE_MAX ( NDD_ALLOCATOR_NAME_LEN_MAX + 1)
typedef char *NDT_Allocator_Name;
typedef NDT_Status NDT_Allocator( void **, NDT_Root *, size_t, void *);
/* Memory deallocator function pointer */
# define NDD_DEALLOCATOR_NAME_LEN_MAX 64
# define NDD_DEALLOCATOR_NAME_SIZE_MAX ( NDD_DEALLOCATOR_NAME_LEN_MAX + 1)
typedef char *NDT_Deallocator_Name;
typedef NDT_Status NDT_Deallocator( void *, NDT_Root *, void *);
typedef struct NDT_Index
{
NDT_Index_Type Type; /* Structure Type (Queue, Stack, Tree, ... ) */
long Node_Number; /* Number of node in the structure */
long Min_Depth; /* Minimum tree depth */
long Max_Depth; /* Maximum tree depth */
long Max_Dif; /* Maximum allowed depth between tree branches before rebalancing */
long Nb_Equ; /* Rebalancing count */
struct NDT_Node *Head; /* Head node */
struct NDT_Node *Tail; /* Tail node */
struct NDT_Node *Save; /* Save pointer (Used by restore function) */
} NDT_Index;
typedef struct NDT_Root
{
NDT_Manager *Manager_Ptr; /* Manager function pointer */
char Manager_Name[ NDD_MANAGER_NAME_SIZE_MAX]; /* Manager function name */
NDT_Allocator *Allocator_Ptr; /* Value allocator function pointer */
char Allocator_Name[ NDD_ALLOCATOR_NAME_SIZE_MAX]; /* Value allocator function name */
NDT_Deallocator *Deallocator_Ptr; /* Value deallocator function pointer */
char Deallocator_Name[ NDD_DEALLOCATOR_NAME_SIZE_MAX]; /* Value deallocator function name */
short Own_Value; /* Flag indicating if the structure is the node owner */
void *User_Ptr; /* User pointer */
NDT_Index_Nb Index_Nb;
NDT_Index_Nb Index_Open_Count;
NDT_Index Index_Tab[ 1];
} NDT_Root;
typedef struct NDT_DataStruct
{
NDT_Root *Root_Ptr;
NDT_Manager *Manager_Ptr; /* Manager function pointer */
NDT_Allocator *Allocator_Ptr; /* Value allocator function pointer */
NDT_Deallocator *Deallocator_Ptr; /* Value deallocator function pointer */
} NDT_DataStruct;
/* Node structure */
typedef struct NDT_Node
{
NDT_Root *Root;
NDT_Index_Id Index;
struct NDT_Node *Parent;
struct NDT_Node *Left;
struct NDT_Node *Right;
void *Value;
} NDT_Node;
typedef int NDT_Recursive_Mode;
typedef int NDT_Recursive_Depth;
typedef int NDT_Recursive_Offset;
# define NDD_RECURSIVE_MODE_UNKNOWN ( NDT_Recursive_Mode)0x00
# define NDD_RECURSIVE_MODE_PARENT ( NDT_Recursive_Mode)0x01
# define NDD_RECURSIVE_MODE_CHILD ( NDT_Recursive_Mode)0x02
# define NDD_RECURSIVE_MODE_PARENT_CHILD ( NDT_Recursive_Mode)0x03
# define ND_RECURSIVE_PARENT_IS(m) ( m & NDD_RECURSIVE_MODE_PARENT)
# define ND_RECURSIVE_CHILD_IS(m) ( m & NDD_RECURSIVE_MODE_CHILD)
# define ND_RECURSIVE_PRINT_OFFSET 8
/* Alias API definition */
# ifndef ND_MODE
# define ND_MODE 0
# endif
# if ND_MODE == 1 /* No arg checking API */
# define ND_Library_Open ND_Library_Open_I
# define ND_Library_Close ND_Library_Close_I
# define ND_Library_StdErr_Set ND_Library_StdErr_Set_I
# define ND_DataStruct_Open ND_DataStruct_Open_I
# define ND_DataStruct_Close ND_DataStruct_Close_I
# define ND_DataStruct_Flush ND_DataStruct_Flush_I
# define ND_DataStruct_Check ND_DataStruct_Check_I
# define ND_DataStruct_Convert ND_DataStruct_Convert_I
# define ND_DataStruct_Reorg ND_DataStruct_Reorg_I
# define ND_DataStruct_Traverse_V ND_DataStruct_Traverse_VI
# define ND_DataStruct_Traverse ND_DataStruct_Traverse_I
# define ND_DataStruct_Info_Print ND_DataStruct_Info_Print_I
# define ND_DataStruct_Value_Add ND_DataStruct_Value_Add_I
# define ND_DataStruct_Value_Remove ND_DataStruct_Value_Remove_I
# define ND_DataStruct_Value_Print ND_DataStruct_Value_Print_I
# define ND_DataStruct_Value_Find ND_DataStruct_Value_Find_I
# define ND_Index_Open ND_Index_Open_I
# define ND_Index_Close ND_Index_Close_I
# define ND_Index_Flush ND_Index_Flush_I
# define ND_Index_Check ND_Index_Check_I
# define ND_Index_Convert ND_Index_Convert_I
# define ND_Index_Reorg ND_Index_Reorg_I
# define ND_Index_Traverse_V ND_Index_Traverse_VI
# define ND_Index_Traverse ND_Index_Traverse_I
# define ND_Index_Info_Print ND_Index_Info_Print_I
# define ND_Index_Value_Add ND_Index_Value_Add_I
# define ND_Index_Value_Remove ND_Index_Value_Remove_I
# define ND_Index_Value_Print ND_Index_Value_Print_I
# define ND_Index_Node_Add ND_Index_Node_Add_I
# define ND_Index_Node_Remove ND_Index_Node_Remove_I
# define ND_Index_Node_First_Get ND_Index_Node_First_Get_I
# define ND_Index_Node_Last_Get ND_Index_Node_Last_Get_I
# define ND_Index_Node_Next_Get ND_Index_Node_Next_Get_I
# define ND_Index_Node_Previous_Get ND_Index_Node_Previous_Get_I
# define ND_Index_Node_Find ND_Index_Node_Find_I
# define ND_Node_Root_Get ND_Node_Root_Get_I
# define ND_Value_Alloc ND_Value_Alloc_I
# define ND_Value_Free ND_Value_Free_I
# define ND_Manager_Exec_V ND_Manager_Exec_VI
# define ND_Manager_Exec ND_Manager_Exec_I
# define ND_Alloc ND_Alloc_I
# define ND_Free ND_Free_I
# define ND_Allocator_Exec ND_Allocator_Exec_I
# define ND_Deallocator_Exec ND_Deallocator_Exec_I
# else /* Arg checking API */
# define ND_Library_Open ND_Library_Open_C
# define ND_Library_Close ND_Library_Close_C
# define ND_Library_StdErr_Set ND_Library_StdErr_Set_C
# define ND_DataStruct_Open ND_DataStruct_Open_C
# define ND_DataStruct_Close ND_DataStruct_Close_C
# define ND_DataStruct_Flush ND_DataStruct_Flush_C
# define ND_DataStruct_Check ND_DataStruct_Check_C
# define ND_DataStruct_Convert ND_DataStruct_Convert_C
# define ND_DataStruct_Reorg ND_DataStruct_Reorg_C
# define ND_DataStruct_Traverse_V ND_DataStruct_Traverse_VC
# define ND_DataStruct_Traverse ND_DataStruct_Traverse_C
# define ND_DataStruct_Info_Print ND_DataStruct_Info_Print_C
# define ND_DataStruct_Value_Add ND_DataStruct_Value_Add_C
# define ND_DataStruct_Value_Remove ND_DataStruct_Value_Remove_C
# define ND_DataStruct_Value_Print ND_DataStruct_Value_Print_C
# define ND_DataStruct_Value_Find ND_DataStruct_Value_Find_C
# define ND_Index_Open ND_Index_Open_C
# define ND_Index_Close ND_Index_Close_C
# define ND_Index_Flush ND_Index_Flush_C
# define ND_Index_Check ND_Index_Check_C
# define ND_Index_Convert ND_Index_Convert_C
# define ND_Index_Reorg ND_Index_Reorg_C
# define ND_Index_Traverse_V ND_Index_Traverse_VC
# define ND_Index_Traverse ND_Index_Traverse_C
# define ND_Index_Info_Print ND_Index_Info_Print_C
# define ND_Index_Value_Add ND_Index_Value_Add_C
# define ND_Index_Value_Remove ND_Index_Value_Remove_C
# define ND_Index_Value_Print ND_Index_Value_Print_C
# define ND_Index_Node_Add ND_Index_Node_Add_C
# define ND_Index_Node_Remove ND_Index_Node_Remove_C
# define ND_Index_Node_First_Get ND_Index_Node_First_Get_C
# define ND_Index_Node_Last_Get ND_Index_Node_Last_Get_C
# define ND_Index_Node_Next_Get ND_Index_Node_Next_Get_C
# define ND_Index_Node_Previous_Get ND_Index_Node_Previous_Get_C
# define ND_Index_Node_Find ND_Index_Node_Find_C
# define ND_Node_Root_Get ND_Node_Root_Get_C
# define ND_Value_Alloc ND_Value_Alloc_C
# define ND_Value_Free ND_Value_Free_C
# define ND_Manager_Exec_V ND_Manager_Exec_VC
# define ND_Manager_Exec ND_Manager_Exec_C
# define ND_Alloc ND_Alloc_C
# define ND_Free ND_Free_C
# define ND_Allocator_Exec ND_Allocator_Exec_C
# define ND_Deallocator_Exec ND_Deallocator_Exec_C
# endif
/*----------------------------------------------------------------------------*/
# if defined( _WIN32) && !defined( LIBNODE_STATIC)
# ifndef _LIBNODE_C_
# define NDD_DLL_API __declspec( dllimport)
# else
# define NDD_DLL_API __declspec( dllexport)
# endif
# else
# ifndef _LIBNODE_C_
# define NDD_DLL_API
# else
# define NDD_DLL_API extern
# endif
# endif
/*----------------------------------------------------------------------------*/
/* Library initialisation */
/*----------------------------------------------------------------------------*/
/* (I) Debug_Mode: Open library in debug mode */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Library_Open_I ( int);
NDD_DLL_API NDT_Status ND_Library_Open_C ( int);
/*----------------------------------------------------------------------------*/
/* Library deinitialisation */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Library_Close_I( void);
NDD_DLL_API NDT_Status ND_Library_Close_C( void);
/*----------------------------------------------------------------------------*/
/* Library Standard Error output setup */
/*----------------------------------------------------------------------------*/
/* (I) Stream: StdErr output stream */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Library_StdErr_Set_I( FILE *);
NDD_DLL_API NDT_Status ND_Library_StdErr_Set_C( FILE *);
/*----------------------------------------------------------------------------*/
/* Create a new data structure */
/*----------------------------------------------------------------------------*/
/* (O) Root_Ptr_Ptr: Pointer adress of the new data structure */
/* (I) Index_Nb: Number of index */
/* (I) Index_Type_Ptr: Array of Index type (List, tree, ...) */
/* (I) Manager_Name: Manager function name */
/* (I) Manager_Ptr: Manager function pointer */
/* (I) Allocator_Name: Value allocator function name */
/* (I) Allocator_Ptr: Value allocator function pointer */
/* (I) Deallocator_Name: Value deallocator function name */
/* (I) Deallocator_Ptr: Value deallocator function pointer */
/* (I) Own_Value: Flag indicating if the structure is the node owner */
/* (I) Data_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_DataStruct_Open_I( NDT_Root **, NDT_Index_Nb, NDT_Index_Type *, NDT_Manager_Name, NDT_Manager *, NDT_Allocator_Name, NDT_Allocator *, NDT_Deallocator_Name, NDT_Deallocator *, short, void *);
NDD_DLL_API NDT_Status ND_DataStruct_Open_C( NDT_Root **, NDT_Index_Nb, NDT_Index_Type *, NDT_Manager_Name, NDT_Manager *, NDT_Allocator_Name, NDT_Allocator *, NDT_Deallocator_Name, NDT_Deallocator *, short, void *);
/*----------------------------------------------------------------------------*/
/* Destroy a data structure */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_DataStruct_Close_I( NDT_Root *);
NDD_DLL_API NDT_Status ND_DataStruct_Close_C( NDT_Root *);
/*----------------------------------------------------------------------------*/
/* Destroy all data of a data structure */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_DataStruct_Flush_I( NDT_Root *);
NDD_DLL_API NDT_Status ND_DataStruct_Flush_C( NDT_Root *);
/*----------------------------------------------------------------------------*/
/* 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 */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_DataStruct_Check_I( NDT_Root *, int *, int *, FILE *);
NDD_DLL_API NDT_Status ND_DataStruct_Check_C( NDT_Root *, int *, int *, FILE *);
/*----------------------------------------------------------------------------*/
/* Convert a data structure indexe types */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Type_Ptr: Array of index type (List, tree, ...) */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_DataStruct_Convert_I( NDT_Root *, NDT_Index_Type *);
NDD_DLL_API NDT_Status ND_DataStruct_Convert_C( NDT_Root *, NDT_Index_Type *);
/*----------------------------------------------------------------------------*/
/* Reorganise a data structure indexes: */
/* - Sort a non-sorted list */
/* - Rebalance a non auto-balanced tree */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_DataStruct_Reorg_I( NDT_Root *);
NDD_DLL_API NDT_Status ND_DataStruct_Reorg_C( NDT_Root *);
/*----------------------------------------------------------------------------*/
/* Traverse a data structure & execute a command on each node */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Command: Manager command */
/* (I) ...: User args */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_DataStruct_Traverse_VI( NDT_Root *, NDT_Command, va_list *);
NDD_DLL_API NDT_Status ND_DataStruct_Traverse_VC( NDT_Root *, NDT_Command, va_list *);
NDD_DLL_API NDT_Status ND_DataStruct_Traverse_I( NDT_Root *, NDT_Command, ...);
NDD_DLL_API NDT_Status ND_DataStruct_Traverse_C( NDT_Root *, NDT_Command, ...);
/*----------------------------------------------------------------------------*/
/* 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 */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_DataStruct_Info_Print_I( FILE *, NDT_Root *, NDT_Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset);
NDD_DLL_API NDT_Status ND_DataStruct_Info_Print_C( FILE *, NDT_Root *, NDT_Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset);
/*----------------------------------------------------------------------------*/
/* Add a new value to a data structure */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Value_Ptr: Value pointer */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_DataStruct_Value_Add_I( NDT_Root *, void *);
NDD_DLL_API NDT_Status ND_DataStruct_Value_Add_C( NDT_Root *, void *);
/*----------------------------------------------------------------------------*/
/* Remove the first matching value from a data structure */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Ref_Value_Ptr: Reference value pointer to search */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_DataStruct_Value_Remove_I( NDT_Root *, void *);
NDD_DLL_API NDT_Status ND_DataStruct_Value_Remove_C( NDT_Root *, void *);
/*----------------------------------------------------------------------------*/
/* 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 */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_DataStruct_Value_Print_VI( FILE *, NDT_Root *, NDT_Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset, va_list *);
NDD_DLL_API NDT_Status ND_DataStruct_Value_Print_I( FILE *, NDT_Root *, NDT_Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset, ...);
NDD_DLL_API NDT_Status ND_DataStruct_Value_Print_C( FILE *, NDT_Root *, NDT_Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset, ...);
/*----------------------------------------------------------------------------*/
/* 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 */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_DataStruct_Value_Find_VI( void **, NDT_Root *, void *, va_list *);
NDD_DLL_API NDT_Status ND_DataStruct_Value_Find_VC( void **, NDT_Root *, void *, va_list *);
NDD_DLL_API NDT_Status ND_DataStruct_Value_Find_I( void **, NDT_Root *, void *, ...);
NDD_DLL_API NDT_Status ND_DataStruct_Value_Find_C( void **, NDT_Root *, void *, ...);
/*----------------------------------------------------------------------------*/
/* Create a new index */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/* (I) Index_Type: Index type (List, tree, ...) */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Open_I( NDT_Root *, NDT_Index_Id, NDT_Index_Type);
NDD_DLL_API NDT_Status ND_Index_Open_C( NDT_Root *, NDT_Index_Id, NDT_Index_Type);
/*----------------------------------------------------------------------------*/
/* Remove an Index */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Close_I( NDT_Root *, NDT_Index_Id);
NDD_DLL_API NDT_Status ND_Index_Close_C( NDT_Root *, NDT_Index_Id);
/*----------------------------------------------------------------------------*/
/* Remove an Index (Private API ?) */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Flush_I( NDT_Root *, NDT_Index_Id);
NDD_DLL_API NDT_Status ND_Index_Flush_C( NDT_Root *, NDT_Index_Id);
/*----------------------------------------------------------------------------*/
/* 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 */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Check_I( NDT_Root *, NDT_Index_Id, int *, int *, FILE *);
NDD_DLL_API NDT_Status ND_Index_Check_C( NDT_Root *, NDT_Index_Id, int *, int *, FILE *);
/*----------------------------------------------------------------------------*/
/* 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, ...) */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Convert_I ( NDT_Root *, NDT_Index_Id, NDT_Index_Type);
NDD_DLL_API NDT_Status ND_Index_Convert_C ( NDT_Root *, NDT_Index_Id, NDT_Index_Type);
/*----------------------------------------------------------------------------*/
/* 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 */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Reorg_I( NDT_Root *, NDT_Index_Id);
NDD_DLL_API NDT_Status ND_Index_Reorg_C( NDT_Root *, NDT_Index_Id);
/*----------------------------------------------------------------------------*/
/* Traverse a data structure index & execute a command on each node */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/* (I) Command: Manager command */
/* (I) ...: User args */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Traverse_VI( NDT_Root *, NDT_Index_Id, NDT_Command, va_list *);
NDD_DLL_API NDT_Status ND_Index_Traverse_VC( NDT_Root *, NDT_Index_Id, NDT_Command, va_list *);
NDD_DLL_API NDT_Status ND_Index_Traverse_I( NDT_Root *, NDT_Index_Id, NDT_Command, ...);
NDD_DLL_API NDT_Status ND_Index_Traverse_C( NDT_Root *, NDT_Index_Id, NDT_Command, ...);
/*----------------------------------------------------------------------------*/
/* 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 */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Info_Print_I( FILE *, NDT_Root *, NDT_Index_Id, NDT_Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset);
NDD_DLL_API NDT_Status ND_Index_Info_Print_C( FILE *, NDT_Root *, NDT_Index_Id, NDT_Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset);
/*----------------------------------------------------------------------------*/
/* Add a new value to a data structure index */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/* (I) Value_Ptr: Value pointer */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Value_Add_I( NDT_Root *, NDT_Index_Id, void *);
NDD_DLL_API NDT_Status ND_Index_Value_Add_C( NDT_Root *, NDT_Index_Id, void *);
/*----------------------------------------------------------------------------*/
/* Remove the first matching value from a data structure index */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/* (I) Ref_Value_Ptr: Reference value pointer to search */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Value_Remove_I( NDT_Root *, NDT_Index_Id, void *);
NDD_DLL_API NDT_Status ND_Index_Value_Remove_C( NDT_Root *, NDT_Index_Id, void *);
/*----------------------------------------------------------------------------*/
/* Print all the data structure index values */
/*----------------------------------------------------------------------------*/
/* (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 */
/* (I) ...: User args */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Value_Print_VI( FILE *, NDT_Root *, NDT_Index_Id, NDT_Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset, va_list *);
NDD_DLL_API NDT_Status ND_Index_Value_Print_I( FILE *, NDT_Root *, NDT_Index_Id, NDT_Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset, ...);
NDD_DLL_API NDT_Status ND_Index_Value_Print_C( FILE *, NDT_Root *, NDT_Index_Id, NDT_Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset, ...);
/*----------------------------------------------------------------------------*/
/* Add a new node to a data structure index */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/* (I) Node_Ptr: Node pointer */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Node_Add_I( NDT_Root *, NDT_Index_Id, NDT_Node *);
NDD_DLL_API NDT_Status ND_Index_Node_Add_C( NDT_Root *, NDT_Index_Id, NDT_Node *);
/*----------------------------------------------------------------------------*/
/* Remove a node from a data structure index */
/*----------------------------------------------------------------------------*/
/* (I) Node_Ptr: Node pointer */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Node_Remove_I( NDT_Node *);
NDD_DLL_API NDT_Status ND_Index_Node_Remove_C( NDT_Node *);
/*----------------------------------------------------------------------------*/
/* Get the first node of a data structure index */
/*----------------------------------------------------------------------------*/
/* (O) Node_Ptr_Ptr: Node pointer address */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Node_First_Get_I( NDT_Node **, NDT_Root *, NDT_Index_Id);
NDD_DLL_API NDT_Status ND_Index_Node_First_Get_C( NDT_Node **, NDT_Root *, NDT_Index_Id);
/*----------------------------------------------------------------------------*/
/* Get the last node of a data structure index */
/*----------------------------------------------------------------------------*/
/* (O) Node_Ptr_Ptr: Node pointer address */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Node_Last_Get_I( NDT_Node **, NDT_Root *, NDT_Index_Id);
NDD_DLL_API NDT_Status ND_Index_Node_Last_Get_C( NDT_Node **, NDT_Root *, NDT_Index_Id);
/*----------------------------------------------------------------------------*/
/* Get the next node of a data structure index */
/*----------------------------------------------------------------------------*/
/* (O) Node_Ptr_Ptr: Node pointer address */
/* (I) Node_Ptr: Node pointer */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Node_Next_Get_I( NDT_Node **, NDT_Node *);
NDD_DLL_API NDT_Status ND_Index_Node_Next_Get_C( NDT_Node **, NDT_Node *);
/*----------------------------------------------------------------------------*/
/* Get the previous node of a data structure index */
/*----------------------------------------------------------------------------*/
/* (O) Node_Ptr_Ptr: Node pointer address */
/* (I) Node_Ptr: Node pointer */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Node_Previous_Get_I( NDT_Node **, NDT_Node *);
NDD_DLL_API NDT_Status ND_Index_Node_Previous_Get_C( NDT_Node **, NDT_Node *);
/*----------------------------------------------------------------------------*/
/* Find a node from a value in a data structure index */
/*----------------------------------------------------------------------------*/
/* (O) Node_Ptr_Ptr: Node pointer address */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/* (I) Ref_Value_Ptr: Reference value pointer to search */
/* (I) ...: User args */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Index_Node_Find_VI( NDT_Node **, NDT_Root *, NDT_Index_Id, void *, va_list *);
NDD_DLL_API NDT_Status ND_Index_Node_Find_VC( NDT_Node **, NDT_Root *, NDT_Index_Id, void *, va_list *);
NDD_DLL_API NDT_Status ND_Index_Node_Find_I( NDT_Node **, NDT_Root *, NDT_Index_Id, void *, ...);
NDD_DLL_API NDT_Status ND_Index_Node_Find_C( NDT_Node **, NDT_Root *, NDT_Index_Id, void *, ...);
/*----------------------------------------------------------------------------*/
/* Get the root node of a data structure */
/*----------------------------------------------------------------------------*/
/* (O) Root_Ptr_Ptr: Data structure pointer address */
/* (I) Node_Ptr: Node pointer */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Node_Root_Get_I( NDT_Root **, NDT_Node *);
NDD_DLL_API NDT_Status ND_Node_Root_Get_C( NDT_Root **, NDT_Node *);
/*----------------------------------------------------------------------------*/
/* Allocate a new value */
/*----------------------------------------------------------------------------*/
/* (O) Value_Ptr_Ptr: Value pointer address */
/* (I) Root_Ptr: Data structure pointer */
/* (I) ...: User args */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Value_Alloc_I( void **, NDT_Root *, ...);
NDD_DLL_API NDT_Status ND_Value_Alloc_C( void **, NDT_Root *, ...);
/*----------------------------------------------------------------------------*/
/* Deallocate a value */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Value_Ptr: Value pointer */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Value_Free_I( NDT_Root *, void *);
NDD_DLL_API NDT_Status ND_Value_Free_C( NDT_Root *, void *);
/*----------------------------------------------------------------------------*/
/* Execute a manager command */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/* (I) Node_Ptr: Node pointer */
/* (I) Command: Manager command */
/* (I) ...: User args */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Manager_Exec_VI( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list *);
NDD_DLL_API NDT_Status ND_Manager_Exec_VC( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list *);
NDD_DLL_API NDT_Status ND_Manager_Exec_I( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, ...);
NDD_DLL_API NDT_Status ND_Manager_Exec_C( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, ...);
/*----------------------------------------------------------------------------*/
/* Alloc memory unsing data structure allocator - Manager function */
/*----------------------------------------------------------------------------*/
/* (O) Memory_Ptr_Ptr: Memory pointer address */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Size: Allocation size */
/* (I) Data_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Alloc_I( void **, NDT_Root *, size_t, void *);
NDD_DLL_API NDT_Status ND_Alloc_C( void **, NDT_Root *, size_t, void *);
/*----------------------------------------------------------------------------*/
/* Free memory unsing data structure allocator - Manager function */
/*----------------------------------------------------------------------------*/
/* (I) Memory_Ptr: Memory pointer */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Data_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Free_I( void *, NDT_Root *, void *);
NDD_DLL_API NDT_Status ND_Free_C( void *, NDT_Root *, void *);
/*----------------------------------------------------------------------------*/
/* Execute an allocator function */
/*----------------------------------------------------------------------------*/
/* (O) Value_Ptr_Ptr: Value pointer address */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Size: Allocation size */
/* (I) Allocator_Name: Value allocator function name */
/* (I) Allocator_Ptr: Value allocator function pointer */
/* (I) Data_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Allocator_Exec_I( void **, NDT_Root *, size_t, NDT_Allocator_Name, NDT_Allocator *, void *);
NDD_DLL_API NDT_Status ND_Allocator_Exec_C( void **, NDT_Root *, size_t, NDT_Allocator_Name, NDT_Allocator *, void *);
/*----------------------------------------------------------------------------*/
/* Execute a deallocator function */
/*----------------------------------------------------------------------------*/
/* (I) Value_Ptr: Value pointer */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Allocator_Name: Value deallocator function name */
/* (I) Allocator_Ptr: Value deallocator function pointer */
/* (I) Data_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Deallocator_Exec_I( void *, NDT_Root *, NDT_Deallocator_Name, NDT_Deallocator *, void *);
NDD_DLL_API NDT_Status ND_Deallocator_Exec_C( void *, NDT_Root *, NDT_Deallocator_Name, NDT_Deallocator *, void *);
# ifdef __cplusplus
//}
# endif
#endif