Add Lib_Open and Lib_Close commands,
Code clean up.
This commit is contained in:
parent
3c40fadbff
commit
898992430e
134
util/ndbench.c
134
util/ndbench.c
@ -1,9 +1,9 @@
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* $RCSfile: ndbench.c,v $ */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* $Revision: 2.6 $ */
|
||||
/* $Revision: 2.7 $ */
|
||||
/* $Name: $ */
|
||||
/* $Date: 2004/06/17 22:28:30 $ */
|
||||
/* $Date: 2004/08/01 23:38:52 $ */
|
||||
/* $Author: agibert $ */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
||||
@ -41,19 +41,13 @@
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
# include <sys/timeb.h>
|
||||
|
||||
#else
|
||||
|
||||
# include <sys/time.h>
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _LIBVER_SUPPORT
|
||||
|
||||
# include <ver.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -65,44 +59,44 @@
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef _LIBVER_SUPPORT
|
||||
VER_INFO_EXPORT( ndbench, "$Revision: 2.6 $", "$Name: $", __FILE__, "$Author: agibert $")
|
||||
VER_INFO_EXPORT( ndbench, "$Revision: 2.7 $", "$Name: $", __FILE__, "$Author: agibert $");
|
||||
# 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"
|
||||
|
||||
#endif
|
||||
|
||||
#define ND_MODE 1
|
||||
#include <node.h>
|
||||
|
||||
|
||||
|
||||
#define QUIT 0
|
||||
#define DS_OPEN 1
|
||||
#define DS_CLOSE 2
|
||||
#define DS_FLUSH 3
|
||||
#define DS_CHECK 4
|
||||
#define DS_REORG 5
|
||||
#define DS_INFO_PRINT 6
|
||||
#define DS_VALUE_ADD 7
|
||||
#define DS_VALUE_REMOVE 8
|
||||
#define DS_VALUE_PRINT 9
|
||||
#define DS_VALUE_FIND 10
|
||||
#define INDEX_LIST_OPEN 11
|
||||
#define INDEX_TREE_OPEN 12
|
||||
#define INDEX_CLOSE 13
|
||||
#define INDEX_FLUSH 14
|
||||
#define INDEX_CHECK 15
|
||||
#define INDEX_LIST_SUBTYPE_SET 16
|
||||
#define INDEX_LIST_TO_TREE 17
|
||||
#define INDEX_TREE_SUBTYPE_SET 18
|
||||
#define INDEX_TREE_TO_LIST 19
|
||||
#define INDEX_REORG 20
|
||||
#define INDEX_INFO_PRINT 21
|
||||
#define INDEX_VALUE_PRINT 22
|
||||
#define BATCH_RUN 23
|
||||
#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
|
||||
#define BATCH_RUN 25
|
||||
|
||||
#define COMMAND_NB 24
|
||||
#define COMMAND_NB 26
|
||||
|
||||
#define INDEX_NB 32
|
||||
|
||||
@ -118,6 +112,11 @@
|
||||
|
||||
|
||||
|
||||
#define BUF_LEN 99
|
||||
#define BUF_SIZE (BUF_LEN + 1)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
@ -218,6 +217,8 @@ void Batch_Run( NDT_Root **, FILE *, FILE *, short);
|
||||
Command Command_Tab[] =
|
||||
{
|
||||
{ QUIT, "Quit", "Quit", ( DS_STATE_OPENED | DS_STATE_CLOSED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)},
|
||||
{ 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)},
|
||||
{ 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)},
|
||||
@ -264,7 +265,7 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
|
||||
|
||||
Command_Name = "NDD_CMD_MANAGER_VERSION";
|
||||
|
||||
*Version_Name_Ptr = "$Revision: 2.6 $ $Name: $ $Date: 2004/06/17 22:28:30 $ $Author: agibert $";
|
||||
*Version_Name_Ptr = "$Revision: 2.7 $ $Name: $ $Date: 2004/08/01 23:38:52 $ $Author: agibert $";
|
||||
|
||||
return( NDS_OK);
|
||||
}
|
||||
@ -551,7 +552,7 @@ void Command_Get( int *choice, char **arg1, char **arg2, FILE *File_Output,
|
||||
fprintf( File_Output, "\nChoice ? ");
|
||||
}
|
||||
|
||||
if( fgets( buf, 99, File_Input) != NULL)
|
||||
if( fgets( buf, BUF_LEN, File_Input) != NULL)
|
||||
{
|
||||
while( ( buf[ strlen( buf) - 1] == '\r') || ( buf[ strlen( buf) - 1] == '\n') || ( buf[ strlen( buf) - 1] == '\t') || ( buf[ strlen( buf) - 1] == ' '))
|
||||
{
|
||||
@ -665,7 +666,7 @@ void Command_Index_Range_Get( FILE *File_Output, int *Low, int *High, char
|
||||
if( Arg == NULL)
|
||||
{
|
||||
fprintf( File_Output, "%s: %s range (?-?) : ", Command_Tab[Choice].Name, Obj_Name);
|
||||
fgets( buf, 99, File_Input);
|
||||
fgets( buf, BUF_LEN, File_Input);
|
||||
|
||||
Arg = buf;
|
||||
}
|
||||
@ -704,7 +705,7 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
||||
{
|
||||
int low, high, i, j, nb_removed, Nb_Detected, Nb_Corrected;
|
||||
T_Module Ref_Module, *Module_Ptr;
|
||||
char buf[100];
|
||||
char buf[BUF_SIZE];
|
||||
NDT_Index_Type index_subtype;
|
||||
|
||||
|
||||
@ -717,6 +718,40 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
||||
break;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Choice = atoi( Arg1);
|
||||
|
||||
t_start( t_exec);
|
||||
ND_Library_Open( Choice);
|
||||
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;
|
||||
}
|
||||
|
||||
case DS_OPEN:
|
||||
{
|
||||
Command_Exec_Begin_Print( File_Output, Choice);
|
||||
@ -807,7 +842,7 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
||||
if( Arg2 == NULL)
|
||||
{
|
||||
fprintf( File_Output, "DS_Value_Add: Add order ( 0:croissant | 1:decroissant) ? ");
|
||||
fgets( buf, 99 ,stdin);
|
||||
fgets( buf, BUF_LEN ,stdin);
|
||||
|
||||
Arg2 = buf;
|
||||
}
|
||||
@ -881,7 +916,7 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
||||
if( Arg2 == NULL)
|
||||
{
|
||||
fprintf( File_Output, "\nDS_Value_Remove: Remove order (croissant=0 | decroissant=1) ? ");
|
||||
fgets( buf, 99, File_Input);
|
||||
fgets( buf, BUF_LEN, File_Input);
|
||||
|
||||
Arg2 = buf;
|
||||
}
|
||||
@ -1062,7 +1097,7 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
||||
if( Arg2 == NULL)
|
||||
{
|
||||
fprintf( File_Output, "Index_List_SubType_Set: List SubType ( 0:FIFO | 1:LIFO | 2:Sorted) ? ");
|
||||
fgets( buf, 99, File_Input);
|
||||
fgets( buf, BUF_LEN, File_Input);
|
||||
|
||||
Arg2 = buf;
|
||||
}
|
||||
@ -1133,7 +1168,7 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
||||
if( Arg2 == NULL)
|
||||
{
|
||||
fprintf( File_Output, "Index_Tree_SubType_Set: Tree SubType (0:UnBalanced | 1:Balanced) ? ");
|
||||
fgets( buf, 99, stdin);
|
||||
fgets( buf, BUF_LEN, stdin);
|
||||
|
||||
Arg2 = buf;
|
||||
}
|
||||
@ -1322,7 +1357,7 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
||||
{
|
||||
fprintf( File_Output, "Batch_Run: Batch file name ? ");
|
||||
|
||||
fgets( buf, 99, stdin);
|
||||
fgets( buf, BUF_LEN, stdin);
|
||||
buf[ strlen( buf) - 1] = '\0';
|
||||
Arg1 = buf;
|
||||
}
|
||||
@ -1399,7 +1434,6 @@ void Batch_Run( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, FILE *File_Input,
|
||||
int main( int argc, char ** argv)
|
||||
{
|
||||
NDT_Root *ds_ptr = NULL;
|
||||
int Debug = NDD_TRUE;
|
||||
|
||||
|
||||
/* Args Parsing */
|
||||
@ -1428,18 +1462,14 @@ int main( int argc, char ** argv)
|
||||
{
|
||||
/* Batch Mode */
|
||||
|
||||
ND_Library_Open( Debug);
|
||||
|
||||
Command_Exec( &ds_ptr, stdout, BATCH_RUN, argv[2], NULL, stdin);
|
||||
|
||||
ND_Library_Close();
|
||||
|
||||
return( 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( stderr, USAGE, argv[0]);
|
||||
return(0);
|
||||
return( -1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1447,11 +1477,7 @@ int main( int argc, char ** argv)
|
||||
|
||||
/* Interactive Mode */
|
||||
|
||||
ND_Library_Open( Debug);
|
||||
|
||||
Batch_Run( &ds_ptr, stdout, stdin, 1);
|
||||
|
||||
ND_Library_Close();
|
||||
|
||||
return( 0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user