2024-04-20 09:58:00 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* ndbench.c */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2024-04-24 20:31:34 +02:00
|
|
|
|
/* This file is part of LibNode. */
|
2024-04-20 09:58:00 +02:00
|
|
|
|
/* */
|
2024-04-24 20:31:34 +02:00
|
|
|
|
/* LibNode is free software: you can redistribute it and/or modify it */
|
2024-04-20 09:58:00 +02:00
|
|
|
|
/* under the terms of the GNU General Public License as published by */
|
|
|
|
|
/* the Free Software Foundation, either version 3 of the License, or */
|
|
|
|
|
/* (at your option) any later version. */
|
|
|
|
|
/* */
|
2024-04-24 20:31:34 +02:00
|
|
|
|
/* LibNode is distributed in the hope that it will be useful, */
|
2024-04-20 09:58:00 +02:00
|
|
|
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
|
|
|
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
|
|
|
|
/* GNU General Public License for more details. */
|
|
|
|
|
/* */
|
|
|
|
|
/* You should have received a copy of the GNU General Public License */
|
2024-04-24 20:31:34 +02:00
|
|
|
|
/* along with LibNode. If not, see <https://www.gnu.org/licenses/>. */
|
2024-04-20 09:58:00 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Includes */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2002-02-28 23:00:00 +01:00
|
|
|
|
|
2000-07-18 16:51:56 +02:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdarg.h>
|
2001-11-26 11:17:44 +01:00
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
# include <sys/timeb.h>
|
|
|
|
|
#else
|
|
|
|
|
# include <sys/time.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef _LIBVER_SUPPORT
|
|
|
|
|
# include <ver.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-04-21 12:54:13 +02:00
|
|
|
|
#include <log.h>
|
|
|
|
|
#include <node.h>
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-04-20 09:58:00 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Defines */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2024-04-21 12:54:13 +02:00
|
|
|
|
#define LGD_MODULE_NAME "ndb"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-01-17 09:06:57 +01:00
|
|
|
|
#ifdef _LIBVER_SUPPORT
|
2024-04-20 09:58:00 +02:00
|
|
|
|
//VER_INFO_EXPORT( ndbench, "$Revision: 2.10 $", "$Name: $", __FILE__, "$Author: agibert $");
|
2003-01-17 09:06:57 +01:00
|
|
|
|
# define USAGE "Usage : %s [ --help | --version [-v] | --batch_run <batch_file_name>]\n"
|
|
|
|
|
#else
|
|
|
|
|
# define USAGE "Usage : %s [ --help | --batch_run <batch_file_name>]\n"
|
2001-11-26 11:17:44 +01:00
|
|
|
|
#endif
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define QUIT 0
|
2004-08-02 01:38:52 +02:00
|
|
|
|
#define LIB_OPEN 1
|
|
|
|
|
#define LIB_CLOSE 2
|
|
|
|
|
#define DS_OPEN 3
|
|
|
|
|
#define DS_CLOSE 4
|
|
|
|
|
#define DS_FLUSH 5
|
|
|
|
|
#define DS_CHECK 6
|
|
|
|
|
#define DS_REORG 7
|
|
|
|
|
#define DS_INFO_PRINT 8
|
|
|
|
|
#define DS_VALUE_ADD 9
|
|
|
|
|
#define DS_VALUE_REMOVE 10
|
|
|
|
|
#define DS_VALUE_PRINT 11
|
|
|
|
|
#define DS_VALUE_FIND 12
|
|
|
|
|
#define INDEX_LIST_OPEN 13
|
|
|
|
|
#define INDEX_TREE_OPEN 14
|
|
|
|
|
#define INDEX_CLOSE 15
|
|
|
|
|
#define INDEX_FLUSH 16
|
|
|
|
|
#define INDEX_CHECK 17
|
|
|
|
|
#define INDEX_LIST_SUBTYPE_SET 18
|
|
|
|
|
#define INDEX_LIST_TO_TREE 19
|
|
|
|
|
#define INDEX_TREE_SUBTYPE_SET 20
|
|
|
|
|
#define INDEX_TREE_TO_LIST 21
|
|
|
|
|
#define INDEX_REORG 22
|
|
|
|
|
#define INDEX_INFO_PRINT 23
|
|
|
|
|
#define INDEX_VALUE_PRINT 24
|
2004-08-24 22:31:28 +02:00
|
|
|
|
#define INDEX_VALUE_BREAK 25
|
|
|
|
|
#define INDEX_NODE_BREAK 26
|
|
|
|
|
#define BATCH_RUN 27
|
2004-08-02 01:38:52 +02:00
|
|
|
|
|
2004-08-24 22:31:28 +02:00
|
|
|
|
#define COMMAND_NB 28
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
#define INDEX_NB 32
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define DS_STATE_UNKNOWN 0
|
|
|
|
|
#define DS_STATE_OPENED 1
|
|
|
|
|
#define DS_STATE_CLOSED 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define ARG_SIZE ( 32 + 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
#define BUF_LEN 99
|
|
|
|
|
#define BUF_SIZE (BUF_LEN + 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
|
2024-04-20 09:58:00 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Types */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
typedef struct Command
|
|
|
|
|
{
|
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
short id;
|
|
|
|
|
char Name[25];
|
|
|
|
|
char FullName[64];
|
|
|
|
|
short DS_State;
|
|
|
|
|
NDT_Index_Type Index_Type;
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
} Command;
|
|
|
|
|
|
|
|
|
|
typedef char Arg[32 + 1];
|
|
|
|
|
|
|
|
|
|
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
/* Mesure des temps d'ex<65>cution */
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
2004-08-02 01:38:52 +02:00
|
|
|
|
double sec;
|
|
|
|
|
struct _timeb start;
|
|
|
|
|
struct _timeb stop;
|
2001-11-26 11:17:44 +01:00
|
|
|
|
} cpt;
|
|
|
|
|
|
2004-08-24 22:31:28 +02:00
|
|
|
|
# define t_start(x) { _ftime( &(x.start));}
|
|
|
|
|
# define t_stop(x) { _ftime( &(x.stop)); x.sec = (double)(x.stop.time) - (double)(x.start.time) + ((double)(x.stop.millitm) - (double)(x.start.millitm)) / 1000;}
|
|
|
|
|
# define seed_get(x) (int)( (x).start.time)
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
2004-08-02 01:38:52 +02:00
|
|
|
|
double sec;
|
|
|
|
|
struct timeval start;
|
|
|
|
|
struct timeval stop;
|
2001-11-26 11:17:44 +01:00
|
|
|
|
} cpt;
|
|
|
|
|
|
2004-08-24 22:31:28 +02:00
|
|
|
|
# define t_start(x) { gettimeofday( &((x).start), NULL);}
|
|
|
|
|
# define t_stop(x) { gettimeofday( &((x).stop), NULL); (x).sec = (double)((x).stop.tv_sec) - (double)((x).start.tv_sec) + ((double)((x).stop.tv_usec) - (double)((x).start.tv_usec)) / 1000000;}
|
|
|
|
|
# define seed_get(x) (int)( (x).start.tv_sec)
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
#endif
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
cpt t_exec;
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
|
2000-07-18 16:51:56 +02:00
|
|
|
|
/* D<>finition des valeurs attach<63>es aux noeuds de la structure */
|
|
|
|
|
|
2024-05-04 12:10:31 +02:00
|
|
|
|
# define NAME_LEN 64
|
|
|
|
|
# define NAME_SIZE ( NAME_LEN + 1)
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
typedef struct
|
|
|
|
|
{
|
2004-08-02 01:38:52 +02:00
|
|
|
|
int Id;
|
2024-05-04 12:10:31 +02:00
|
|
|
|
char Name[ NAME_SIZE];
|
2000-07-18 16:51:56 +02:00
|
|
|
|
} T_Module;
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
|
2024-05-03 00:24:51 +02:00
|
|
|
|
NDT_Index_Type idx_type_tab[ INDEX_NB];
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
NDT_Index_Type idx_type_fifo = NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_FIFO;
|
|
|
|
|
|
|
|
|
|
NDT_Index_Type idx_type_sorted_list = NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_SORTED;
|
|
|
|
|
|
|
|
|
|
NDT_Index_Type idx_type_balanced_tree = NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-04-20 09:58:00 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Prototype */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2010-06-06 23:27:12 +02:00
|
|
|
|
NDT_Status Module_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list *);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
void Menu_Print( FILE *, NDT_Root *);
|
|
|
|
|
void Command_Get( int *, char **, char **, FILE *, FILE *, short);
|
|
|
|
|
void Command_Exec_Begin_Print( FILE *, int);
|
|
|
|
|
void Command_Exec_End_Print( FILE *, int, cpt, int);
|
|
|
|
|
void Command_Index_Range_Get( FILE *, int *, int *, char *, FILE *, int, char *);
|
|
|
|
|
void Command_Exec( NDT_Root **, FILE *, int, char *, char *, FILE *);
|
|
|
|
|
void Batch_Run( NDT_Root **, FILE *, FILE *, short);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-04-20 09:58:00 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Global Variable */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
Command Command_Tab[] =
|
2000-07-18 16:51:56 +02:00
|
|
|
|
{
|
2001-11-26 11:17:44 +01:00
|
|
|
|
{ QUIT, "Quit", "Quit", ( DS_STATE_OPENED | DS_STATE_CLOSED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
2004-08-02 01:38:52 +02:00
|
|
|
|
{ LIB_OPEN, "Lib_Open", "Open Library", ( DS_STATE_OPENED | DS_STATE_CLOSED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
|
|
|
|
{ LIB_CLOSE, "Lib_Close", "Close Library", ( DS_STATE_OPENED | DS_STATE_CLOSED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
2001-11-26 11:17:44 +01:00
|
|
|
|
{ DS_OPEN, "DS_Open", "Open DataStructure", ( DS_STATE_CLOSED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
|
|
|
|
{ DS_CLOSE, "DS_Close", "Close DataStructure", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
|
|
|
|
{ DS_FLUSH, "DS_Flush", "Flush DataStructure", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
|
|
|
|
{ DS_CHECK, "DS_Check", "Check DataStructure", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
|
|
|
|
{ DS_REORG, "DS_Reorg", "Reorg DataStructure", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
|
|
|
|
{ DS_INFO_PRINT, "DS_Info_Print", "Print DataStructure Informations", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
|
|
|
|
{ DS_VALUE_ADD, "DS_Value_Add", "Add Values to DataStructure", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
|
|
|
|
{ DS_VALUE_REMOVE, "DS_Value_Remove", "Remove Values from DataStructure", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
|
|
|
|
{ DS_VALUE_PRINT, "DS_Value_Print", "Print DataStructure Values", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
|
|
|
|
{ DS_VALUE_FIND, "DS_Value_Find", "Find Values in DataStructure", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
|
|
|
|
{ INDEX_LIST_OPEN, "Index_List_Open", "Open List Index", ( DS_STATE_CLOSED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
|
|
|
|
{ INDEX_TREE_OPEN, "Index_Tree_Open", "Open Tree Index", ( DS_STATE_CLOSED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
|
|
|
|
{ INDEX_CLOSE, "Index_Close", "Close Index", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
|
|
|
|
{ INDEX_FLUSH, "Index_Flush", "Flush Index", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
|
|
|
|
{ INDEX_CHECK, "Index_Check", "Check Index", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
|
|
|
|
{ INDEX_LIST_SUBTYPE_SET, "Index_List_SubType_Set", "Set List SubType", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST)},
|
|
|
|
|
{ INDEX_LIST_TO_TREE, "Index_List_To_Tree", "Convert List to Tree", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST)},
|
|
|
|
|
{ INDEX_TREE_SUBTYPE_SET, "Index_Tree_SubType_Set", "Set Tree SubType", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_TREE)},
|
|
|
|
|
{ INDEX_TREE_TO_LIST, "Index_Tree_To_List", "Convert Tree to List", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_TREE)},
|
|
|
|
|
{ INDEX_REORG, "Index_Reorg", "Reorg Index", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
|
|
|
|
{ INDEX_INFO_PRINT, "Index_Info_Print", "Print Index Informations", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
|
|
|
|
{ INDEX_VALUE_PRINT, "Index_Value_Print", "Print Index Values", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
2004-08-24 22:31:28 +02:00
|
|
|
|
{ INDEX_VALUE_BREAK, "Index_Value_Break", "Break Index Value", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
|
|
|
|
{ INDEX_NODE_BREAK, "Index_Node_Break", "Break Index Node", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
2001-11-26 11:17:44 +01:00
|
|
|
|
{ BATCH_RUN, "Batch_Run", "Run NDBench Bach", ( DS_STATE_OPENED | DS_STATE_CLOSED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-04-20 09:58:00 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Module_Manager */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2010-06-06 23:27:12 +02:00
|
|
|
|
NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list *Args_Ptr)
|
2001-11-26 11:17:44 +01:00
|
|
|
|
{
|
|
|
|
|
NDT_Command_Name Command_Name;
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
switch( Command)
|
2000-07-18 16:51:56 +02:00
|
|
|
|
{
|
2001-11-26 11:17:44 +01:00
|
|
|
|
case NDD_CMD_MANAGER_VERSION:
|
|
|
|
|
{
|
2010-06-06 23:27:12 +02:00
|
|
|
|
ND_VA_ARG_GET( Version_Name_Ptr, *Args_Ptr, NDT_Version_Name *);
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_MANAGER_VERSION";
|
|
|
|
|
|
2010-06-06 23:27:12 +02:00
|
|
|
|
*Version_Name_Ptr = "$Revision: 2.10 $ $Name: $ $Date: 2010/06/06 21:27:12 $ $Author: agibert $";
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case NDD_CMD_INDEX_GET:
|
|
|
|
|
{
|
|
|
|
|
/*
|
2010-06-06 23:27:12 +02:00
|
|
|
|
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 *);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
*/
|
2024-04-21 12:54:13 +02:00
|
|
|
|
|
2010-06-06 23:27:12 +02:00
|
|
|
|
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( Module_Ptr_Ptr, *Args_Ptr, T_Module **);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_INDEX_GET";
|
|
|
|
|
|
|
|
|
|
switch(Cmd)
|
|
|
|
|
{
|
|
|
|
|
/*
|
2004-08-02 01:38:52 +02:00
|
|
|
|
case NDT_CMD_SOME_USER_CMD:
|
|
|
|
|
{
|
|
|
|
|
*Reply_Index_Id_Ptr = 0;
|
|
|
|
|
*Reply_Command_Ptr = NDD_CMD_SOME_OTHER_CMD;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
...
|
2001-11-26 11:17:44 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
*Reply_Index_Id_Ptr = Index_Id;
|
|
|
|
|
*Reply_Command_Ptr = Cmd;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_ALLOC:
|
|
|
|
|
{
|
|
|
|
|
/*
|
2010-06-06 23:27:12 +02:00
|
|
|
|
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);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
*/
|
2024-04-21 12:54:13 +02:00
|
|
|
|
|
2010-06-06 23:27:12 +02:00
|
|
|
|
ND_VA_ARG_GET( Module_Ptr_Ptr, *Args_Ptr, T_Module **);
|
|
|
|
|
|
|
|
|
|
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
|
|
|
|
|
2024-05-04 12:10:31 +02:00
|
|
|
|
ND_VA_ARG_GET( Name, user_args, char *);
|
2010-06-06 23:27:12 +02:00
|
|
|
|
ND_VA_ARG_GET( Id, user_args, int);
|
|
|
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( user_args);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_VALUE_ALLOC";
|
|
|
|
|
|
2024-05-04 12:10:31 +02:00
|
|
|
|
if( ( ND_Alloc( (void **)Module_Ptr_Ptr, Root_Ptr, sizeof(T_Module), NULL)) != NDS_OK)
|
2001-11-26 11:17:44 +01:00
|
|
|
|
{
|
2024-05-04 12:10:31 +02:00
|
|
|
|
return( NDS_KO);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-05-04 12:10:31 +02:00
|
|
|
|
strncpy( ( *Module_Ptr_Ptr)->Name, Name, NAME_LEN);
|
|
|
|
|
( *Module_Ptr_Ptr)->Name[ NAME_LEN] = '\0';
|
|
|
|
|
( *Module_Ptr_Ptr)->Id = Id;
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2024-05-04 12:10:31 +02:00
|
|
|
|
return( NDS_OK);
|
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_FREE:
|
|
|
|
|
{
|
|
|
|
|
/*
|
2010-06-06 23:27:12 +02:00
|
|
|
|
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);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
*/
|
2024-04-21 12:54:13 +02:00
|
|
|
|
|
2010-06-06 23:27:12 +02:00
|
|
|
|
ND_VA_ARG_GET( Module_Ptr, *Args_Ptr, T_Module *);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_VALUE_FREE";
|
|
|
|
|
|
|
|
|
|
|
2024-05-04 12:10:31 +02:00
|
|
|
|
if( ( ND_Free( (void *)Module_Ptr, Root_Ptr, NULL)) != NDS_OK)
|
|
|
|
|
{
|
|
|
|
|
return( NDS_KO);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return( NDS_OK);
|
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_COMP:
|
|
|
|
|
{
|
|
|
|
|
/*
|
2010-06-06 23:27:12 +02:00
|
|
|
|
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);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
*/
|
2024-04-21 12:54:13 +02:00
|
|
|
|
|
2010-06-06 23:27:12 +02:00
|
|
|
|
ND_VA_ARG_GET( Module1_Ptr, *Args_Ptr, T_Module *);
|
|
|
|
|
ND_VA_ARG_GET( Module2_Ptr, *Args_Ptr, T_Module *);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_VALUE_COMP";
|
|
|
|
|
|
|
|
|
|
if( ( Index_Id >= 0) && ( Index_Id < INDEX_NB))
|
|
|
|
|
{
|
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
|
2010-06-06 23:27:12 +02:00
|
|
|
|
rc = Module1_Ptr->Id - Module2_Ptr->Id;
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
if( rc < 0)
|
|
|
|
|
{
|
|
|
|
|
return(NDS_LOWER);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if( rc > 0)
|
|
|
|
|
{
|
|
|
|
|
return(NDS_GREATER);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return(NDS_EQUAL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-08-02 01:38:52 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
2001-11-26 11:17:44 +01:00
|
|
|
|
printf( "Unknown COMP idx (%d) !\n", Index_Id);
|
|
|
|
|
return( NDS_KO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_ADD:
|
|
|
|
|
{
|
|
|
|
|
/*
|
2010-06-06 23:27:12 +02:00
|
|
|
|
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);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_VALUE_ADD";
|
|
|
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_REMOVE:
|
|
|
|
|
{
|
|
|
|
|
/*
|
2010-06-06 23:27:12 +02:00
|
|
|
|
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);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_VALUE_REMOVE";
|
2024-04-28 17:29:28 +02:00
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
return( NDS_OK);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_PRINT:
|
|
|
|
|
{
|
2010-06-06 23:27:12 +02:00
|
|
|
|
/*
|
|
|
|
|
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;
|
2001-11-26 11:17:44 +01:00
|
|
|
|
*/
|
2024-04-21 12:54:13 +02:00
|
|
|
|
|
2010-06-06 23:27:12 +02:00
|
|
|
|
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2010-06-06 23:27:12 +02:00
|
|
|
|
ND_VA_LIST_OPEN( lib_args, *Args_Ptr);
|
|
|
|
|
|
|
|
|
|
ND_VA_ARG_GET( Out, lib_args, FILE *);
|
|
|
|
|
ND_VA_ARG_GET( Recursive_Mode, lib_args, NDT_Recursive_Mode);
|
|
|
|
|
ND_VA_ARG_GET( Recursive_Depth, lib_args, NDT_Recursive_Depth);
|
|
|
|
|
ND_VA_ARG_GET( Recursive_Offset, lib_args, NDT_Recursive_Offset);
|
|
|
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( lib_args);
|
|
|
|
|
|
|
|
|
|
T_Module *Module_Ptr = Node_Ptr->Value;
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_VALUE_PRINT";
|
|
|
|
|
|
2024-05-04 12:10:31 +02:00
|
|
|
|
fprintf( Out, "Id=%d\tName: [%s]\n", Module_Ptr->Id, Module_Ptr->Name);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case NDD_CMD_INFO_PRINT:
|
|
|
|
|
{
|
|
|
|
|
/*
|
2010-06-06 23:27:12 +02:00
|
|
|
|
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);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_INFO_PRINT";
|
|
|
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
printf( "Module_Manager() called with an undefined command %d\n", Command);
|
2024-04-28 17:29:28 +02:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
return( NDS_ERRAPI);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf( "Module_Manager() called with command %d (%s)\n", Command, Command_Name);
|
2004-08-02 01:38:52 +02:00
|
|
|
|
return( NDS_OK);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-04-20 09:58:00 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Menu_Print */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
void Menu_Print( FILE *File_Output, NDT_Root *DS_Ptr)
|
|
|
|
|
{
|
|
|
|
|
short i;
|
|
|
|
|
char headc;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fprintf( File_Output, "\n-----------------------------------------------------------------------\nMenu :\n");
|
|
|
|
|
|
|
|
|
|
for( i = 0; i < COMMAND_NB; i++)
|
|
|
|
|
{
|
|
|
|
|
if( ( DS_Ptr && ( Command_Tab[i].DS_State & DS_STATE_OPENED) && ( DS_Ptr->Index_Tab[0].Type & Command_Tab[i].Index_Type))
|
|
|
|
|
|| ( !DS_Ptr && ( Command_Tab[i].DS_State & DS_STATE_CLOSED)))
|
|
|
|
|
{
|
|
|
|
|
headc = '-';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
headc = '*';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fprintf( File_Output, "\t%c (%2d) [%s]%*s%s\n", headc, i, Command_Tab[i].Name, ( 25 - strlen(Command_Tab[i].Name)), " ", Command_Tab[i].FullName);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-04-20 09:58:00 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Command_Get */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
void Command_Get( int *choice, char **arg1, char **arg2, FILE *File_Output, FILE *File_Input, short Interactive_Flag)
|
|
|
|
|
{
|
|
|
|
|
char buf[100];
|
2004-08-02 01:38:52 +02:00
|
|
|
|
char *tmp_arg1, *tmp_arg2;
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do
|
2000-07-18 16:51:56 +02:00
|
|
|
|
{
|
2001-11-26 11:17:44 +01:00
|
|
|
|
if( Interactive_Flag)
|
|
|
|
|
{
|
|
|
|
|
fprintf( File_Output, "\nChoice ? ");
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
if( fgets( buf, BUF_LEN, File_Input) != NULL)
|
2001-11-26 11:17:44 +01:00
|
|
|
|
{
|
|
|
|
|
while( ( buf[ strlen( buf) - 1] == '\r') || ( buf[ strlen( buf) - 1] == '\n') || ( buf[ strlen( buf) - 1] == '\t') || ( buf[ strlen( buf) - 1] == ' '))
|
|
|
|
|
{
|
|
|
|
|
buf[ strlen( buf) - 1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( isdigit( *buf))
|
|
|
|
|
{
|
|
|
|
|
*choice = atoi( buf);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for( *choice = 0; ( *choice < COMMAND_NB) && ( strncmp( buf, Command_Tab[*choice].Name, strlen(Command_Tab[*choice].Name))) ; (*choice)++);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( ( *choice < 0) || ( *choice >= COMMAND_NB))
|
|
|
|
|
{
|
|
|
|
|
if( strlen( buf) != 0) fprintf( File_Output, "\nUndefined choice (%s) !\n",buf);
|
|
|
|
|
|
|
|
|
|
*choice = -1;
|
|
|
|
|
*arg1 = NULL;
|
|
|
|
|
*arg2 = NULL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if( ( tmp_arg1 = strstr( buf, " ")) != NULL)
|
|
|
|
|
{
|
|
|
|
|
tmp_arg1++;
|
|
|
|
|
|
|
|
|
|
if( ( tmp_arg2 = strstr( tmp_arg1, " ")) != NULL)
|
|
|
|
|
{
|
|
|
|
|
*tmp_arg2 = '\0';
|
|
|
|
|
tmp_arg2++;
|
|
|
|
|
|
|
|
|
|
*arg2 = malloc( ARG_SIZE);
|
|
|
|
|
if( *arg2 != NULL) strcpy( *arg2, tmp_arg2);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*arg2 = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*arg1 = malloc( ARG_SIZE);
|
|
|
|
|
if( *arg1 != NULL) strcpy( *arg1, tmp_arg1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*arg1 = NULL;
|
|
|
|
|
*arg2 = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*choice = 0;
|
|
|
|
|
*arg1 = NULL;
|
|
|
|
|
*arg2 = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
while( *choice == -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-04-20 09:58:00 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Command_Exec_Begin_Print */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
void Command_Exec_Begin_Print( FILE *File_Output, int Choice)
|
|
|
|
|
{
|
2024-04-21 12:54:13 +02:00
|
|
|
|
// fprintf( File_Output, "%s: %s...\n", Command_Tab[Choice].Name, Command_Tab[Choice].FullName);
|
|
|
|
|
LG_LOG_INFO_2( "%s: %s...", Command_Tab[Choice].Name, Command_Tab[Choice].FullName);
|
|
|
|
|
// fflush( File_Output);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-04-20 09:58:00 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2024-04-21 12:54:13 +02:00
|
|
|
|
/* Command_Exec_End_Print */
|
2024-04-20 09:58:00 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
void Command_Exec_End_Print( FILE *File_Output, int Choice, cpt T_Exec, int nb)
|
|
|
|
|
{
|
2004-08-02 01:38:52 +02:00
|
|
|
|
if( nb == 1)
|
|
|
|
|
{
|
2024-04-21 12:54:13 +02:00
|
|
|
|
// fprintf( File_Output, "%s: Completed in (%.4f) second !\n", Command_Tab[Choice].Name, T_Exec.sec);
|
|
|
|
|
LG_LOG_INFO_2( "%s: Completed in (%.4f) second !", Command_Tab[Choice].Name, T_Exec.sec);
|
2004-08-02 01:38:52 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-04-21 12:54:13 +02:00
|
|
|
|
// fprintf( File_Output, "%s: Completed in (%.4f) second, (%.2f) per second !\n", Command_Tab[Choice].Name, T_Exec.sec, nb / T_Exec.sec);
|
|
|
|
|
LG_LOG_INFO_3( "%s: Completed in (%.4f) second, (%.2f) per second !", Command_Tab[Choice].Name, T_Exec.sec, nb / T_Exec.sec);
|
2004-08-02 01:38:52 +02:00
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-04-20 09:58:00 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Command_Index_Range_Get */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
void Command_Index_Range_Get( FILE *File_Output, int *Low, int *High, char *Arg, FILE *File_Input, int Choice, char *Obj_Name)
|
|
|
|
|
{
|
|
|
|
|
char buf[100];
|
|
|
|
|
char *tmp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( Arg == NULL)
|
|
|
|
|
{
|
|
|
|
|
fprintf( File_Output, "%s: %s range (?-?) : ", Command_Tab[Choice].Name, Obj_Name);
|
2004-08-02 01:38:52 +02:00
|
|
|
|
fgets( buf, BUF_LEN, File_Input);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
Arg = buf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tmp = strstr( Arg, "-");
|
|
|
|
|
|
|
|
|
|
if( tmp != NULL)
|
|
|
|
|
{
|
|
|
|
|
*tmp = '\0';
|
|
|
|
|
*Low = atoi( Arg);
|
|
|
|
|
tmp++;
|
|
|
|
|
*High = atoi( tmp);
|
|
|
|
|
|
|
|
|
|
if( ( *High < *Low) || ( !strcmp( Obj_Name, "Index") && ( *High >= INDEX_NB)))
|
|
|
|
|
{
|
|
|
|
|
fprintf( File_Output, "%s: Invalit range (%d-%d) !\n", Command_Tab[Choice].Name, *Low, *High);
|
|
|
|
|
*Low = *High = -1;
|
|
|
|
|
}
|
2000-07-18 16:51:56 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2001-11-26 11:17:44 +01:00
|
|
|
|
fprintf( File_Output, "%s: Invalit range !\n", Command_Tab[Choice].Name);
|
|
|
|
|
*Low = *High = -1;
|
2000-07-18 16:51:56 +02:00
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-04-20 09:58:00 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Command_Exec */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, char *Arg1, char *Arg2, FILE *File_Input)
|
|
|
|
|
{
|
2024-04-21 12:54:13 +02:00
|
|
|
|
int sub_choice, low, high, i, j, nb_removed, Nb_Detected, Nb_Corrected;
|
2004-08-24 22:31:28 +02:00
|
|
|
|
T_Module Ref_Module, *Module_Ptr;
|
|
|
|
|
char buf[BUF_SIZE];
|
2004-08-02 01:38:52 +02:00
|
|
|
|
NDT_Index_Type index_subtype;
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
|
2024-04-21 12:54:13 +02:00
|
|
|
|
// fprintf( File_Output, "\n");
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
switch( Choice)
|
2000-07-18 16:51:56 +02:00
|
|
|
|
{
|
2001-11-26 11:17:44 +01:00
|
|
|
|
case QUIT:
|
|
|
|
|
{
|
2000-07-18 16:51:56 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
case LIB_OPEN:
|
|
|
|
|
{
|
|
|
|
|
Command_Exec_Begin_Print( File_Output, Choice);
|
|
|
|
|
|
|
|
|
|
if( Arg1 == NULL)
|
|
|
|
|
{
|
|
|
|
|
fprintf( File_Output, "Library_Open: Debug Mode ( 0:OFF | 1:ON) ? ");
|
|
|
|
|
fgets( buf, BUF_LEN, File_Input);
|
|
|
|
|
|
|
|
|
|
Arg1 = buf;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-21 12:54:13 +02:00
|
|
|
|
sub_choice = atoi( Arg1);
|
2004-08-02 01:38:52 +02:00
|
|
|
|
|
|
|
|
|
t_start( t_exec);
|
2024-04-21 12:54:13 +02:00
|
|
|
|
ND_Library_Open( sub_choice);
|
2004-08-02 01:38:52 +02:00
|
|
|
|
t_stop( t_exec);
|
|
|
|
|
|
|
|
|
|
Command_Exec_End_Print( File_Output, Choice, t_exec, 1);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case LIB_CLOSE:
|
|
|
|
|
{
|
|
|
|
|
Command_Exec_Begin_Print( File_Output, Choice);
|
|
|
|
|
|
|
|
|
|
t_start( t_exec);
|
|
|
|
|
ND_Library_Close();
|
|
|
|
|
t_stop( t_exec);
|
|
|
|
|
|
|
|
|
|
Command_Exec_End_Print( File_Output, Choice, t_exec, 1);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
case DS_OPEN:
|
2000-07-18 16:51:56 +02:00
|
|
|
|
{
|
2001-11-26 11:17:44 +01:00
|
|
|
|
Command_Exec_Begin_Print( File_Output, Choice);
|
|
|
|
|
|
2005-01-20 01:07:27 +01:00
|
|
|
|
if( Arg1 == NULL)
|
|
|
|
|
{
|
|
|
|
|
fprintf( File_Output, "DataStruct_Open: Symbol Lookup ( 0:OFF | 1:ON) ? ");
|
|
|
|
|
fgets( buf, BUF_LEN, File_Input);
|
|
|
|
|
|
|
|
|
|
Arg1 = buf;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-21 12:54:13 +02:00
|
|
|
|
sub_choice = atoi( Arg1);
|
2005-01-20 01:07:27 +01:00
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
for( i = 0; i < INDEX_NB; i++)
|
|
|
|
|
{
|
|
|
|
|
idx_type_tab[i] = NDD_INDEX_STATUS_CLOSED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
t_start( t_exec);
|
2024-04-21 12:54:13 +02:00
|
|
|
|
if( sub_choice == 0)
|
2005-01-20 01:07:27 +01:00
|
|
|
|
{
|
|
|
|
|
ND_DataStruct_Open( DS_Ptr_Ptr, INDEX_NB, idx_type_tab, "Module_Manager", Module_Manager, NULL, NULL, NULL, NULL, NDD_TRUE, NULL);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ND_DataStruct_Open( DS_Ptr_Ptr, INDEX_NB, idx_type_tab, "Module_Manager", NULL, NULL, NULL, NULL, NULL, NDD_TRUE, NULL);
|
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
t_stop( t_exec);
|
|
|
|
|
|
|
|
|
|
Command_Exec_End_Print( File_Output, Choice, t_exec, 1);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case DS_CLOSE:
|
|
|
|
|
{
|
|
|
|
|
Command_Exec_Begin_Print( File_Output, Choice);
|
|
|
|
|
|
|
|
|
|
t_start( t_exec);
|
|
|
|
|
ND_DataStruct_Close( *DS_Ptr_Ptr);
|
|
|
|
|
t_stop( t_exec);
|
|
|
|
|
|
|
|
|
|
*DS_Ptr_Ptr = NULL;
|
|
|
|
|
|
|
|
|
|
Command_Exec_End_Print( File_Output, Choice, t_exec, 1);
|
|
|
|
|
break;
|
2000-07-18 16:51:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
case DS_FLUSH:
|
2000-07-18 16:51:56 +02:00
|
|
|
|
{
|
2001-11-26 11:17:44 +01:00
|
|
|
|
Command_Exec_Begin_Print( File_Output, Choice);
|
|
|
|
|
|
|
|
|
|
t_start( t_exec);
|
|
|
|
|
ND_DataStruct_Flush( *DS_Ptr_Ptr);
|
|
|
|
|
t_stop( t_exec);
|
|
|
|
|
|
|
|
|
|
Command_Exec_End_Print( File_Output, Choice, t_exec, 1);
|
|
|
|
|
break;
|
2000-07-18 16:51:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
case DS_CHECK:
|
|
|
|
|
{
|
|
|
|
|
Command_Exec_Begin_Print( File_Output, Choice);
|
|
|
|
|
|
|
|
|
|
Nb_Corrected = Nb_Detected = 0;
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
t_start( t_exec);
|
2002-02-27 17:14:22 +01:00
|
|
|
|
ND_DataStruct_Check( *DS_Ptr_Ptr, &Nb_Detected, &Nb_Corrected, File_Output);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
t_stop( t_exec);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
Command_Exec_End_Print( File_Output, Choice, t_exec, 1);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case DS_REORG:
|
2000-07-18 16:51:56 +02:00
|
|
|
|
{
|
2001-11-26 11:17:44 +01:00
|
|
|
|
Command_Exec_Begin_Print( File_Output, Choice);
|
|
|
|
|
|
|
|
|
|
t_start( t_exec);
|
|
|
|
|
ND_DataStruct_Reorg( *DS_Ptr_Ptr);
|
|
|
|
|
t_stop( t_exec);
|
|
|
|
|
|
|
|
|
|
Command_Exec_End_Print( File_Output, Choice, t_exec, 1);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
case DS_INFO_PRINT:
|
2000-07-18 16:51:56 +02:00
|
|
|
|
{
|
2001-11-26 11:17:44 +01:00
|
|
|
|
Command_Exec_Begin_Print( File_Output, Choice);
|
|
|
|
|
|
|
|
|
|
ND_DataStruct_Info_Print( File_Output, *DS_Ptr_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 99, 0);
|
|
|
|
|
|
|
|
|
|
break;
|
2000-07-18 16:51:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
case DS_VALUE_ADD:
|
2000-07-18 16:51:56 +02:00
|
|
|
|
{
|
2001-11-26 11:17:44 +01:00
|
|
|
|
int order;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Value");
|
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
if( low != -1)
|
|
|
|
|
{
|
|
|
|
|
if( Arg2 == NULL)
|
|
|
|
|
{
|
|
|
|
|
fprintf( File_Output, "DS_Value_Add: Add order ( 0:croissant | 1:decroissant) ? ");
|
|
|
|
|
fgets( buf, BUF_LEN ,stdin);
|
|
|
|
|
|
|
|
|
|
Arg2 = buf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
order = atoi( Arg2);
|
|
|
|
|
|
2024-04-21 12:54:13 +02:00
|
|
|
|
// fprintf( File_Output, "DS_Value_Add: Adding from: (%d) to: (%d) order: (%d)...\n", low, high, order);
|
|
|
|
|
// fflush( File_Output);
|
2004-08-02 01:38:52 +02:00
|
|
|
|
|
2024-04-21 12:54:13 +02:00
|
|
|
|
LG_LOG_INFO_3( "DS_Value_Add: Adding from: (%d) to: (%d) order: (%d)...", low, high, order);
|
|
|
|
|
|
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
t_start( t_exec);
|
|
|
|
|
|
|
|
|
|
if( order == 0)
|
|
|
|
|
{
|
|
|
|
|
i = low;
|
|
|
|
|
j = high + 1;
|
|
|
|
|
|
|
|
|
|
while( i < j)
|
|
|
|
|
{
|
2024-04-28 17:29:28 +02:00
|
|
|
|
if( ND_Value_Alloc( (void **)&Module_Ptr, *DS_Ptr_Ptr, "x", i) == NDS_OK)
|
2004-08-02 01:38:52 +02:00
|
|
|
|
{
|
|
|
|
|
ND_DataStruct_Value_Add( *DS_Ptr_Ptr, Module_Ptr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-04-21 12:54:13 +02:00
|
|
|
|
// fprintf( File_Output, "DS_Value_Add: Allocation Failled !\n");
|
|
|
|
|
|
|
|
|
|
LG_LOG_ERROR_0( "DS_Value_Add: Allocation Failled !");
|
2004-08-02 01:38:52 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
i = high;
|
|
|
|
|
j = low - 1;
|
|
|
|
|
|
|
|
|
|
while( i > j)
|
|
|
|
|
{
|
2024-04-28 17:29:28 +02:00
|
|
|
|
if( ND_Value_Alloc( (void **)&Module_Ptr, *DS_Ptr_Ptr, "x", i) == NDS_OK)
|
2001-11-26 11:17:44 +01:00
|
|
|
|
{
|
2004-08-02 01:38:52 +02:00
|
|
|
|
ND_DataStruct_Value_Add( *DS_Ptr_Ptr, Module_Ptr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-04-21 12:54:13 +02:00
|
|
|
|
// fprintf( File_Output, "DS_Value_Add: Allocation Failled !\n");
|
|
|
|
|
LG_LOG_ERROR_0( "DS_Value_Add: Allocation Failled !");
|
2004-08-02 01:38:52 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
i--;
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
t_stop( t_exec);
|
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
Command_Exec_End_Print( File_Output, Choice, t_exec, high - low);
|
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
break;
|
2000-07-18 16:51:56 +02:00
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
case DS_VALUE_REMOVE:
|
2000-07-18 16:51:56 +02:00
|
|
|
|
{
|
2001-11-26 11:17:44 +01:00
|
|
|
|
int order;
|
|
|
|
|
nb_removed = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Value");
|
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
if( low != -1)
|
|
|
|
|
{
|
|
|
|
|
if( Arg2 == NULL)
|
|
|
|
|
{
|
|
|
|
|
fprintf( File_Output, "\nDS_Value_Remove: Remove order (croissant=0 | decroissant=1) ? ");
|
|
|
|
|
fgets( buf, BUF_LEN, File_Input);
|
|
|
|
|
|
|
|
|
|
Arg2 = buf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
order = atoi( Arg2);
|
|
|
|
|
|
|
|
|
|
t_start( t_exec);
|
|
|
|
|
|
|
|
|
|
if( order == 0)
|
|
|
|
|
{
|
|
|
|
|
i = low;
|
|
|
|
|
j = high + 1;
|
|
|
|
|
|
|
|
|
|
while( i < j)
|
|
|
|
|
{
|
|
|
|
|
Ref_Module.Id = i;
|
|
|
|
|
|
2024-04-28 17:29:28 +02:00
|
|
|
|
if( ( ND_DataStruct_Value_Find( (void **)&Module_Ptr, *DS_Ptr_Ptr, &Ref_Module) == NDS_OK) && ( Module_Ptr != NULL))
|
2001-11-26 11:17:44 +01:00
|
|
|
|
{
|
2024-04-28 17:29:28 +02:00
|
|
|
|
if( ND_DataStruct_Value_Remove( *DS_Ptr_Ptr, (void *)Module_Ptr) == NDS_OK)
|
2004-08-02 01:38:52 +02:00
|
|
|
|
{
|
|
|
|
|
nb_removed++;
|
|
|
|
|
ND_Value_Free( *DS_Ptr_Ptr, Module_Ptr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
i = high;
|
|
|
|
|
j = low - 1;
|
|
|
|
|
t_start( t_exec);
|
|
|
|
|
|
|
|
|
|
while( i > j)
|
|
|
|
|
{
|
|
|
|
|
Ref_Module.Id = i;
|
|
|
|
|
|
2024-04-28 17:29:28 +02:00
|
|
|
|
if( ( ND_DataStruct_Value_Find( (void **)&Module_Ptr, *DS_Ptr_Ptr, &Ref_Module) == NDS_OK) && ( Module_Ptr != NULL))
|
2004-08-02 01:38:52 +02:00
|
|
|
|
{
|
2024-04-28 17:29:28 +02:00
|
|
|
|
if( ND_DataStruct_Value_Remove( *DS_Ptr_Ptr, (void *)Module_Ptr) == NDS_OK)
|
2004-08-02 01:38:52 +02:00
|
|
|
|
{
|
|
|
|
|
nb_removed++;
|
|
|
|
|
ND_Value_Free( *DS_Ptr_Ptr, Module_Ptr);
|
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
i--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
t_stop( t_exec);
|
|
|
|
|
|
|
|
|
|
Command_Exec_End_Print( File_Output, Choice, t_exec, high - low);
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-18 16:51:56 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
case DS_VALUE_PRINT:
|
2000-07-18 16:51:56 +02:00
|
|
|
|
{
|
2001-11-26 11:17:44 +01:00
|
|
|
|
Command_Exec_Begin_Print( File_Output, Choice);
|
|
|
|
|
|
|
|
|
|
ND_DataStruct_Value_Print( File_Output, *DS_Ptr_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 99, 0);
|
|
|
|
|
break;
|
2000-07-18 16:51:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
case DS_VALUE_FIND:
|
2000-07-18 16:51:56 +02:00
|
|
|
|
{
|
2001-11-26 11:17:44 +01:00
|
|
|
|
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Search");
|
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
if( low != -1)
|
|
|
|
|
{
|
2024-04-21 12:54:13 +02:00
|
|
|
|
// fprintf( File_Output, "DS_Value_Find: from: (%d) to: (%d)...\n", low, high);
|
|
|
|
|
// fflush( File_Output);
|
|
|
|
|
|
|
|
|
|
LG_LOG_INFO_2( "DS_Value_Find: from: (%d) to: (%d)...", low, high);
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
i = low;
|
|
|
|
|
j = high + 1;
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
t_start( t_exec);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
while( i < j)
|
|
|
|
|
{
|
2004-08-24 22:31:28 +02:00
|
|
|
|
Ref_Module.Id = low + (int)( (double)( high - low) * rand() / ( RAND_MAX + 1.0));
|
2024-04-28 17:29:28 +02:00
|
|
|
|
ND_DataStruct_Value_Find( (void *)&Module_Ptr, *DS_Ptr_Ptr, &Ref_Module);
|
2004-08-02 01:38:52 +02:00
|
|
|
|
i++;
|
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
t_stop (t_exec);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
Command_Exec_End_Print( File_Output, Choice, t_exec, high - low);
|
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
break;
|
2000-07-18 16:51:56 +02:00
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
case INDEX_LIST_OPEN:
|
2000-07-18 16:51:56 +02:00
|
|
|
|
{
|
2001-11-26 11:17:44 +01:00
|
|
|
|
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
|
|
|
|
|
|
|
|
|
|
if( low != -1)
|
2000-07-18 16:51:56 +02:00
|
|
|
|
{
|
2024-04-21 12:54:13 +02:00
|
|
|
|
// fprintf( File_Output, "Index_List_Open: Opening a FIFO List from: (%d) to: (%d)...\n", low, high);
|
|
|
|
|
// fflush( File_Output);
|
|
|
|
|
|
|
|
|
|
LG_LOG_INFO_2( "Index_List_Open: Opening a FIFO List from: (%d) to: (%d)...", low, high);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
t_start( t_exec);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
for( i = low; i <= high; i++)
|
|
|
|
|
{
|
|
|
|
|
ND_Index_Open( *DS_Ptr_Ptr, (NDT_Index_Id)i, idx_type_fifo);
|
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
t_stop( t_exec);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
Command_Exec_End_Print( File_Output, Choice, t_exec, high - low);
|
|
|
|
|
}
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
break;
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case INDEX_TREE_OPEN:
|
|
|
|
|
{
|
|
|
|
|
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
|
|
|
|
|
|
|
|
|
|
if( low != -1)
|
|
|
|
|
{
|
2024-04-21 12:54:13 +02:00
|
|
|
|
// fprintf( File_Output, "Index_Tree_Open: Opening a balanced Tree from: (%d) to: (%d)...\n", low, high);
|
|
|
|
|
// fflush( File_Output);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2024-04-21 12:54:13 +02:00
|
|
|
|
LG_LOG_INFO_2( "Index_Tree_Open: Opening a balanced Tree from: (%d) to: (%d)...", low, high);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
t_start( t_exec);
|
|
|
|
|
|
|
|
|
|
for( i = low; i <= high; i++)
|
2004-08-02 01:38:52 +02:00
|
|
|
|
{
|
2001-11-26 11:17:44 +01:00
|
|
|
|
ND_Index_Open( *DS_Ptr_Ptr, (NDT_Index_Id)i, idx_type_balanced_tree);
|
2004-08-02 01:38:52 +02:00
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
t_stop( t_exec);
|
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
Command_Exec_End_Print( File_Output, Choice, t_exec, high - low);
|
|
|
|
|
}
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
break;
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-26 00:35:51 +01:00
|
|
|
|
case INDEX_CLOSE:
|
|
|
|
|
{
|
|
|
|
|
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
|
|
|
|
|
|
|
|
|
|
if( low != -1)
|
|
|
|
|
{
|
2024-04-21 12:54:13 +02:00
|
|
|
|
// fprintf( File_Output, "Index_Close: Closing index from: (%d) to: (%d)...\n", low, high);
|
|
|
|
|
// fflush( File_Output);
|
2002-02-26 00:35:51 +01:00
|
|
|
|
|
2024-04-21 12:54:13 +02:00
|
|
|
|
LG_LOG_INFO_2( "Index_Close: Closing index from: (%d) to: (%d)...", low, high);
|
2002-02-26 00:35:51 +01:00
|
|
|
|
|
|
|
|
|
t_start( t_exec);
|
|
|
|
|
|
|
|
|
|
for( i = high; i >= low; i--)
|
|
|
|
|
{
|
|
|
|
|
ND_Index_Close( *DS_Ptr_Ptr, (NDT_Index_Id)i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
t_stop( t_exec);
|
|
|
|
|
|
|
|
|
|
Command_Exec_End_Print( File_Output, Choice, t_exec, high - low);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
case INDEX_LIST_SUBTYPE_SET:
|
|
|
|
|
{
|
2004-08-24 22:31:28 +02:00
|
|
|
|
int subtype;
|
|
|
|
|
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
|
|
|
|
|
|
|
|
|
|
if( low != -1)
|
|
|
|
|
{
|
|
|
|
|
if( Arg2 == NULL)
|
2004-08-02 01:38:52 +02:00
|
|
|
|
{
|
|
|
|
|
fprintf( File_Output, "Index_List_SubType_Set: List SubType ( 0:FIFO | 1:LIFO | 2:Sorted) ? ");
|
|
|
|
|
fgets( buf, BUF_LEN, File_Input);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
Arg2 = buf;
|
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-24 22:31:28 +02:00
|
|
|
|
subtype = atoi( Arg2);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-24 22:31:28 +02:00
|
|
|
|
switch( subtype)
|
2001-11-26 11:17:44 +01:00
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
{
|
|
|
|
|
index_subtype = NDD_INDEX_SUBTYPE_FIFO;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
{
|
|
|
|
|
index_subtype = NDD_INDEX_SUBTYPE_FILO;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
{
|
|
|
|
|
index_subtype = NDD_INDEX_SUBTYPE_SORTED;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
index_subtype = NDD_INDEX_SUBTYPE_UNKNOWN;
|
2004-08-24 22:31:28 +02:00
|
|
|
|
printf ("Index_List_SubType_Set: Invalid selection (%d) !\n", subtype);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
if( index_subtype != NDD_INDEX_SUBTYPE_UNKNOWN)
|
|
|
|
|
{
|
2024-04-21 12:54:13 +02:00
|
|
|
|
// fprintf( File_Output, "Index_List_SubType_Set: Setting List SubType to: (%d) (%s) !\n", index_subtype, ND_INDEX_SUBTYPE_VALUE_ASCII_GET( index_subtype));
|
|
|
|
|
LG_LOG_INFO_2( "Index_List_SubType_Set: Setting List SubType to: (%d) (%s) !", index_subtype, ND_INDEX_SUBTYPE_VALUE_ASCII_GET( index_subtype));
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
t_start( t_exec);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
for( i = low; i <= high; i++)
|
|
|
|
|
{
|
|
|
|
|
if( ND_INDEX_TYPE_LIST_IS( *DS_Ptr_Ptr, i))
|
|
|
|
|
{
|
|
|
|
|
(*DS_Ptr_Ptr)->Index_Tab[i].Type = ( (*DS_Ptr_Ptr)->Index_Tab[i].Type & NDD_INDEX_SUBTYPE_RMSK) | index_subtype;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fprintf( File_Output, "Index_List_SubType_Set: Error: index (%d) is not a List !\n", i);
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
t_stop( t_exec);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
Command_Exec_End_Print( File_Output, Choice, t_exec, high - low);
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
break;
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case INDEX_TREE_SUBTYPE_SET:
|
|
|
|
|
{
|
2004-08-24 22:31:28 +02:00
|
|
|
|
int subtype;
|
|
|
|
|
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
|
|
|
|
|
|
|
|
|
|
if( low != -1)
|
|
|
|
|
{
|
2004-08-02 01:38:52 +02:00
|
|
|
|
if( Arg2 == NULL)
|
|
|
|
|
{
|
|
|
|
|
fprintf( File_Output, "Index_Tree_SubType_Set: Tree SubType (0:UnBalanced | 1:Balanced) ? ");
|
|
|
|
|
fgets( buf, BUF_LEN, stdin);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
Arg2 = buf;
|
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-24 22:31:28 +02:00
|
|
|
|
subtype = atoi( Arg2);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-24 22:31:28 +02:00
|
|
|
|
switch( subtype)
|
2001-11-26 11:17:44 +01:00
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
{
|
|
|
|
|
index_subtype = NDD_INDEX_SUBTYPE_UNBALANCED;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
{
|
|
|
|
|
index_subtype = NDD_INDEX_SUBTYPE_BALANCED;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
{
|
2004-08-02 01:38:52 +02:00
|
|
|
|
index_subtype = NDD_INDEX_SUBTYPE_UNKNOWN;
|
2004-08-24 22:31:28 +02:00
|
|
|
|
printf ("Index_Tree_SubType_Set: Invalid selection (%d)!\n", subtype);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
2004-08-02 01:38:52 +02:00
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
if( index_subtype != NDD_INDEX_SUBTYPE_UNKNOWN)
|
|
|
|
|
{
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
t_start( t_exec);
|
|
|
|
|
|
|
|
|
|
for( i = low; i <= high; i++)
|
|
|
|
|
{
|
|
|
|
|
if( ND_INDEX_TYPE_TREE_IS( *DS_Ptr_Ptr, i))
|
|
|
|
|
{
|
|
|
|
|
(*DS_Ptr_Ptr)->Index_Tab[i].Type = ( (*DS_Ptr_Ptr)->Index_Tab[i].Type & NDD_INDEX_SUBTYPE_RMSK) | index_subtype;
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
2004-08-02 01:38:52 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fprintf( File_Output, "Index_Tree_SubType_Set: Error: index (%d) is not a Tree !\n", i);
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
t_stop( t_exec);
|
|
|
|
|
|
|
|
|
|
Command_Exec_End_Print( File_Output, Choice, t_exec, high - low);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case INDEX_REORG:
|
|
|
|
|
{
|
|
|
|
|
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
|
|
|
|
|
|
|
|
|
|
if( low != -1)
|
|
|
|
|
{
|
2004-08-02 01:38:52 +02:00
|
|
|
|
t_start( t_exec);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
for( i = low; i <= high; i++)
|
|
|
|
|
{
|
2024-04-21 12:54:13 +02:00
|
|
|
|
// fprintf( File_Output, "Index_Reorg: Reorganizing index (%d)...\n", i);
|
|
|
|
|
// fflush( File_Output);
|
|
|
|
|
|
|
|
|
|
LG_LOG_INFO_1( "Index_Reorg: Reorganizing index (%d)...", i);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
ND_Index_Reorg( *DS_Ptr_Ptr, (NDT_Index_Id)i);
|
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
t_stop( t_exec);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
Command_Exec_End_Print( File_Output, Choice, t_exec, high - low);
|
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
break;
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case INDEX_TREE_TO_LIST:
|
|
|
|
|
{
|
|
|
|
|
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
|
|
|
|
|
|
|
|
|
|
if( low != -1)
|
|
|
|
|
{
|
|
|
|
|
t_start( t_exec);
|
|
|
|
|
|
|
|
|
|
for( i = low; i <= high; i++)
|
2004-08-02 01:38:52 +02:00
|
|
|
|
{
|
2024-04-21 12:54:13 +02:00
|
|
|
|
// fprintf( File_Output, "Index_Tree_To_List: Converting Index (%d)...\n", i);
|
|
|
|
|
// fflush( File_Output);
|
|
|
|
|
|
|
|
|
|
LG_LOG_INFO_1( "Index_Tree_To_List: Converting Index (%d)...", i);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
ND_Index_Convert( *DS_Ptr_Ptr, (NDT_Index_Id)i, idx_type_sorted_list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
t_stop (t_exec);
|
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
Command_Exec_End_Print( File_Output, Choice, t_exec, high - low);
|
|
|
|
|
}
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
case INDEX_LIST_TO_TREE:
|
|
|
|
|
{
|
|
|
|
|
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
if( low != -1)
|
|
|
|
|
{
|
|
|
|
|
t_start( t_exec);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
for( i = low; i <= high; i++)
|
2004-08-02 01:38:52 +02:00
|
|
|
|
{
|
2024-04-21 12:54:13 +02:00
|
|
|
|
// fprintf( File_Output, "Index_List_To_Tree: Converting Index (%d)...\n", i);
|
|
|
|
|
// fflush( File_Output);
|
|
|
|
|
|
|
|
|
|
LG_LOG_INFO_1( "Index_List_To_Tree: Converting Index (%d)...", i);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
ND_Index_Convert( *DS_Ptr_Ptr, (NDT_Index_Id)i, idx_type_balanced_tree);
|
|
|
|
|
}
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
t_stop (t_exec);
|
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
Command_Exec_End_Print( File_Output, Choice, t_exec, high - low);
|
|
|
|
|
}
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case INDEX_INFO_PRINT:
|
2000-07-18 16:51:56 +02:00
|
|
|
|
{
|
2002-02-26 00:35:51 +01:00
|
|
|
|
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2002-02-26 00:35:51 +01:00
|
|
|
|
if( low != -1)
|
|
|
|
|
{
|
2024-04-21 12:54:13 +02:00
|
|
|
|
// fprintf( File_Output, "Index_Info_Print: Printing index from: (%d) to: (%d)...\n", low, high);
|
|
|
|
|
// fflush( File_Output);
|
|
|
|
|
|
|
|
|
|
LG_LOG_INFO_2( "Index_Info_Print: Printing index from: (%d) to: (%d)...", low, high);
|
2002-02-26 00:35:51 +01:00
|
|
|
|
|
|
|
|
|
for( i = low; i <= high; i++)
|
|
|
|
|
{
|
2004-08-02 01:38:52 +02:00
|
|
|
|
ND_Index_Info_Print( File_Output, *DS_Ptr_Ptr, (NDT_Index_Id)i, NDD_RECURSIVE_MODE_PARENT_CHILD, 99, 0);
|
2002-02-26 00:35:51 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
break;
|
2000-07-18 16:51:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
case INDEX_VALUE_PRINT:
|
|
|
|
|
{
|
2024-04-21 12:54:13 +02:00
|
|
|
|
// fprintf( File_Output, "DS_Value_Print:\n");
|
|
|
|
|
// fflush( File_Output);
|
|
|
|
|
|
|
|
|
|
LG_LOG_INFO_0( "DS_Value_Print:");
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
ND_DataStruct_Value_Print( File_Output, *DS_Ptr_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 99, 0);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-24 22:31:28 +02:00
|
|
|
|
case INDEX_VALUE_BREAK:
|
|
|
|
|
{
|
|
|
|
|
int position;
|
|
|
|
|
NDT_Node *node_ptr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
|
|
|
|
|
|
|
|
|
|
if( low != -1)
|
|
|
|
|
{
|
|
|
|
|
if( Arg2 == NULL)
|
|
|
|
|
{
|
|
|
|
|
fprintf( File_Output, "Index_Value_Break: Value position (0:Head | 1:Tail | 2:Random) ? ");
|
|
|
|
|
fgets( buf, BUF_LEN, stdin);
|
|
|
|
|
|
|
|
|
|
Arg2 = buf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
position = atoi( Arg2);
|
|
|
|
|
|
2024-04-21 12:54:13 +02:00
|
|
|
|
// fprintf( File_Output, "Index_Value_Break: Breaking %s values from index : (%d) to: (%d)...\n",
|
|
|
|
|
// ( position == 0 ) ? "Head" : ( ( position == 1) ? "Tail" : "Random"),
|
|
|
|
|
// low, high);
|
|
|
|
|
// fflush( File_Output);
|
|
|
|
|
|
|
|
|
|
LG_LOG_INFO_3( "Index_Value_Break: Breaking: (%s) values from index: (%d) to: (%d)...",
|
2004-08-24 22:31:28 +02:00
|
|
|
|
( position == 0 ) ? "Head" : ( ( position == 1) ? "Tail" : "Random"),
|
|
|
|
|
low, high);
|
|
|
|
|
|
|
|
|
|
t_start( t_exec);
|
|
|
|
|
|
2024-04-21 12:54:13 +02:00
|
|
|
|
// fprintf( File_Output, "Index_Value_Break: Breaking value of nodes: ");
|
|
|
|
|
// fflush( File_Output);
|
2004-08-24 22:31:28 +02:00
|
|
|
|
|
|
|
|
|
for( i = low; i <= high; i++)
|
|
|
|
|
{
|
|
|
|
|
switch( position)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
{
|
|
|
|
|
node_ptr =(*DS_Ptr_Ptr)->Index_Tab[i].Head;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
{
|
|
|
|
|
node_ptr=(*DS_Ptr_Ptr)->Index_Tab[i].Tail;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
{
|
|
|
|
|
j = (int)( (double)( (*DS_Ptr_Ptr)->Index_Tab[i].Node_Number) * rand() / ( RAND_MAX + 1.0));
|
|
|
|
|
|
|
|
|
|
for( node_ptr = (*DS_Ptr_Ptr)->Index_Tab[i].Head; j > 0; j--)
|
|
|
|
|
{
|
|
|
|
|
node_ptr = node_ptr->Right;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-21 12:54:13 +02:00
|
|
|
|
// fprintf( File_Output, "0x(%x)", node_ptr);
|
|
|
|
|
// fflush( File_Output);
|
|
|
|
|
|
|
|
|
|
LG_LOG_INFO_1( "Index_Value_Break: Breaking value of node: 0x(%x)", node_ptr);
|
2004-08-24 22:31:28 +02:00
|
|
|
|
|
|
|
|
|
node_ptr->Value = (void *)-1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
t_stop (t_exec);
|
|
|
|
|
|
|
|
|
|
fprintf( File_Output, "\n");
|
|
|
|
|
fflush( File_Output);
|
|
|
|
|
|
|
|
|
|
Command_Exec_End_Print( File_Output, Choice, t_exec, high - low);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case INDEX_NODE_BREAK:
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
case INDEX_CHECK:
|
2000-07-18 16:51:56 +02:00
|
|
|
|
{
|
2001-11-26 11:17:44 +01:00
|
|
|
|
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
|
|
|
|
|
|
|
|
|
|
if( low != -1)
|
|
|
|
|
{
|
|
|
|
|
t_start( t_exec);
|
|
|
|
|
|
|
|
|
|
for( i = low; i <= high; i++)
|
2004-08-02 01:38:52 +02:00
|
|
|
|
{
|
2024-04-21 12:54:13 +02:00
|
|
|
|
// fprintf( File_Output, "Index_Check: Checking Index (%d)...\n", i);
|
|
|
|
|
// fprintf( File_Output, "Index_Check: ");
|
|
|
|
|
// fflush( File_Output);
|
|
|
|
|
|
|
|
|
|
LG_LOG_INFO_1( "Index_Check: Checking Index (%d)...", i);
|
|
|
|
|
LG_LOG_INFO_0( "Index_Check: ");
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
Nb_Corrected = Nb_Detected = 0;
|
|
|
|
|
ND_Index_Check( *DS_Ptr_Ptr, (NDT_Index_Id)i, &Nb_Detected, &Nb_Corrected, File_Output);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
t_stop (t_exec);
|
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
Command_Exec_End_Print( File_Output, Choice, t_exec, high - low);
|
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
break;
|
2000-07-18 16:51:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
case BATCH_RUN:
|
|
|
|
|
{
|
|
|
|
|
FILE *file_input;
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
if( Arg1 == NULL)
|
|
|
|
|
{
|
|
|
|
|
fprintf( File_Output, "Batch_Run: Batch file name ? ");
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
fgets( buf, BUF_LEN, stdin);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
buf[ strlen( buf) - 1] = '\0';
|
|
|
|
|
Arg1 = buf;
|
|
|
|
|
}
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
file_input = fopen( Arg1, "r");
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
if( file_input == NULL)
|
|
|
|
|
{
|
2024-04-21 12:54:13 +02:00
|
|
|
|
// fprintf( File_Output, "Batch_Run: Can't open file (%s)!\n", Arg1);
|
|
|
|
|
LG_LOG_ERROR_1( "Batch_Run: Can't open file (%s)!", Arg1);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-04-21 12:54:13 +02:00
|
|
|
|
// fprintf( File_Output, "\n\n--------------------------------------------------------------------------------\n");
|
|
|
|
|
// fprintf( File_Output, "Batch_Run: Starting execution (%s)...\n", Arg1);
|
|
|
|
|
LG_LOG_INFO_0( "--------------------------------------------------------------------------------");
|
|
|
|
|
LG_LOG_INFO_1( "Batch_Run: Starting execution (%s)...", Arg1);
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
Batch_Run( DS_Ptr_Ptr, File_Output, file_input, 0);
|
2024-04-21 12:54:13 +02:00
|
|
|
|
|
|
|
|
|
// fprintf( File_Output, "\n");
|
|
|
|
|
// fprintf( File_Output, "Batch_Run: Ending execution (%s)...\n", Arg1);
|
|
|
|
|
LG_LOG_INFO_1( "Batch_Run: Ending execution (%s)...", Arg1);
|
2002-07-29 16:55:57 +02:00
|
|
|
|
|
|
|
|
|
fclose( file_input);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
2000-07-18 16:51:56 +02:00
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
fprintf( File_Output, "\nUndefined command (%d) !\n", Choice);
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-07-18 16:51:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-04-20 09:58:00 +02:00
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Batch_Run */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
void Batch_Run( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, FILE *File_Input, short Interactive_Flag)
|
2000-07-18 16:51:56 +02:00
|
|
|
|
{
|
2001-11-26 11:17:44 +01:00
|
|
|
|
int choice;
|
|
|
|
|
char *arg1, *arg2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
if( Interactive_Flag)
|
|
|
|
|
{
|
|
|
|
|
Menu_Print( File_Output, *DS_Ptr_Ptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Command_Get( &choice, &arg1, &arg2, File_Output, File_Input, Interactive_Flag);
|
|
|
|
|
|
|
|
|
|
if( ( choice != QUIT) && ( choice != -1))
|
|
|
|
|
{
|
|
|
|
|
Command_Exec( DS_Ptr_Ptr, File_Output, choice, arg1, arg2, File_Input);
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-02 01:38:52 +02:00
|
|
|
|
if( arg1 != NULL) free( arg1);
|
|
|
|
|
if( arg2 != NULL) free( arg2);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
|
|
|
|
while( choice != QUIT);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
2024-04-20 09:58:00 +02:00
|
|
|
|
/* main */
|
2001-11-26 11:17:44 +01:00
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
|
|
2004-08-24 22:31:28 +02:00
|
|
|
|
int main( int argc, char **argv)
|
2000-07-18 16:51:56 +02:00
|
|
|
|
{
|
2024-04-21 12:54:13 +02:00
|
|
|
|
int rc = 0;
|
|
|
|
|
LGT_Status lg_status;
|
|
|
|
|
NDT_Root *ds_ptr = NULL;
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
|
2024-04-21 12:54:13 +02:00
|
|
|
|
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);
|
|
|
|
|
}
|
2004-08-24 22:31:28 +02:00
|
|
|
|
|
2024-04-21 12:54:13 +02:00
|
|
|
|
LG_LOG_INFO_0( "Start NDBench");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Init Random numbers... */
|
2004-08-24 22:31:28 +02:00
|
|
|
|
t_start( t_exec);
|
|
|
|
|
t_stop( t_exec);
|
|
|
|
|
srand( seed_get(t_exec));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-02-26 00:35:51 +01:00
|
|
|
|
/* Args Parsing */
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
|
|
|
|
if( argc >= 2)
|
|
|
|
|
{
|
|
|
|
|
if( !strcmp( argv[1], "--help"))
|
|
|
|
|
{
|
|
|
|
|
fprintf( stderr, USAGE, argv[0]);
|
2024-04-21 12:54:13 +02:00
|
|
|
|
rc = 1;
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
2003-01-17 09:06:57 +01:00
|
|
|
|
#ifdef _LIBVER_SUPPORT
|
2001-11-26 11:17:44 +01:00
|
|
|
|
else if( !strcmp( argv[1], "--version"))
|
|
|
|
|
{
|
|
|
|
|
if( argc >= 3 && !strcmp( argv[2], "-v"))
|
|
|
|
|
{
|
2024-04-21 12:54:13 +02:00
|
|
|
|
ec = VER_Object_Print( stdout, VERD_VERBOSE);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-04-21 12:54:13 +02:00
|
|
|
|
rc = VER_Object_Print( stdout, VERD_MINIMAL);
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-01-17 09:06:57 +01:00
|
|
|
|
#endif
|
2001-11-26 11:17:44 +01:00
|
|
|
|
else if( !strcmp( argv[1], "--batch_run"))
|
|
|
|
|
{
|
2002-02-26 00:35:51 +01:00
|
|
|
|
/* Batch Mode */
|
|
|
|
|
|
2001-11-26 11:17:44 +01:00
|
|
|
|
Command_Exec( &ds_ptr, stdout, BATCH_RUN, argv[2], NULL, stdin);
|
2024-04-21 12:54:13 +02:00
|
|
|
|
rc = 0;
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fprintf( stderr, USAGE, argv[0]);
|
2024-04-21 12:54:13 +02:00
|
|
|
|
rc = -1;
|
2001-11-26 11:17:44 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-04-21 12:54:13 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Interactive Mode */
|
|
|
|
|
|
|
|
|
|
Batch_Run( &ds_ptr, stdout, stdin, 1);
|
|
|
|
|
rc = 0;
|
|
|
|
|
}
|
2001-11-26 11:17:44 +01:00
|
|
|
|
|
2024-04-21 12:54:13 +02:00
|
|
|
|
|
|
|
|
|
LG_LOG_INFO_0( "End NDBench");
|
2002-02-26 00:35:51 +01:00
|
|
|
|
|
2024-04-21 12:54:13 +02:00
|
|
|
|
if( ( lg_status = LG_Library_Close( true)) != LGS_OK)
|
|
|
|
|
{
|
|
|
|
|
fprintf( stderr, "Can't close LibLog library: (%d)\n", lg_status);
|
|
|
|
|
rc = -1;
|
|
|
|
|
}
|
2002-02-26 00:35:51 +01:00
|
|
|
|
|
2024-04-21 12:54:13 +02:00
|
|
|
|
return( rc);
|
2000-07-18 16:51:56 +02:00
|
|
|
|
}
|