Code cleanup.

This commit is contained in:
agibert 2004-08-23 22:48:37 +00:00
parent 7c96ad706b
commit 3f6d118ae2

View File

@ -1,9 +1,9 @@
/*---------------------------------------------------------------------------------*/
/* $RCSfile: nddemo0.c,v $ */
/*---------------------------------------------------------------------------------*/
/* $Revision: 2.7 $ */
/* $Revision: 2.8 $ */
/* $Name: $ */
/* $Date: 2004/08/01 23:35:39 $ */
/* $Date: 2004/08/23 22:48:37 $ */
/* $Author: agibert $ */
/*---------------------------------------------------------------------------------*/
@ -37,25 +37,25 @@
#define DEMO_FILE_NAME "nddemo0.dat"
#define STRING_LEN (short)1024
#define STRING_SIZE (short)(STRING_LEN + 1)
#define VAL_LEN (short)64
#define VAL_SIZE (short)(VAL_LEN + 1)
#define INDEX_NB (short)4
#define STRING_LEN ( short) 1024
#define STRING_SIZE ( short) ( STRING_LEN + 1)
#define VAL_LEN ( short) 64
#define VAL_SIZE ( short) ( VAL_LEN + 1)
#define INDEX_NB ( short) 4
#define NDT_CMD_INDEX0_PRINT (NDT_Command)64
#define NDT_CMD_INDEX1_PRINT (NDT_Command)65
#define NDT_CMD_INDEX2_PRINT (NDT_Command)66
#define NDT_CMD_INDEX3_PRINT (NDT_Command)67
#define NDD_CMD_INDEX0_PRINT ( NDT_Command) 64
#define NDD_CMD_INDEX1_PRINT ( NDT_Command) 65
#define NDD_CMD_INDEX2_PRINT ( NDT_Command) 66
#define NDD_CMD_INDEX3_PRINT ( NDT_Command) 67
typedef struct Demo_Value
{
char Val0[VAL_SIZE];
char Val1[VAL_SIZE];
char Val2[VAL_SIZE];
char Val3[VAL_SIZE];
char Val0[ VAL_SIZE];
char Val1[ VAL_SIZE];
char Val2[ VAL_SIZE];
char Val3[ VAL_SIZE];
} Demo_Value;
@ -64,7 +64,7 @@ typedef struct Demo_Value
/* Prototypes */
/*---------------------------------------------------------------------------------*/
NDT_Status Manager_Demo_DS( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list);
NDT_Status Demo_DS_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list);
void DataStruct_Load( NDT_Root *, FILE *);
void DataStruct_Load( NDT_Root *, FILE *);
void Demo( char *, short);
@ -80,7 +80,7 @@ int main( int, char **);
/* */
/*---------------------------------------------------------------------------------*/
NDT_Status Manager_Demo_DS( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list Args)
NDT_Status Demo_DS_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list Args)
{
NDT_Command_Name Command_Name;
@ -94,7 +94,7 @@ NDT_Status Manager_Demo_DS( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_No
Command_Name = "NDD_CMD_MANAGER_VERSION";
*Version_Name_Ptr = "$Revision: 2.7 $ $Name: $ $Date: 2004/08/01 23:35:39 $ $Author: agibert $";
*Version_Name_Ptr = "$Revision: 2.8 $ $Name: $ $Date: 2004/08/23 22:48:37 $ $Author: agibert $";
return( NDS_OK);
}
@ -117,28 +117,28 @@ NDT_Status Manager_Demo_DS( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_No
switch(Cmd)
{
case NDT_CMD_INDEX0_PRINT:
case NDD_CMD_INDEX0_PRINT:
{
*Reply_Index_Id_Ptr = 0;
*Reply_Command_Ptr = NDD_CMD_VALUE_PRINT;
break;
}
case NDT_CMD_INDEX1_PRINT:
case NDD_CMD_INDEX1_PRINT:
{
*Reply_Index_Id_Ptr = 1;
*Reply_Command_Ptr = NDD_CMD_VALUE_PRINT;
break;
}
case NDT_CMD_INDEX2_PRINT:
case NDD_CMD_INDEX2_PRINT:
{
*Reply_Index_Id_Ptr = 2;
*Reply_Command_Ptr = NDD_CMD_VALUE_PRINT;
break;
}
case NDT_CMD_INDEX3_PRINT:
case NDD_CMD_INDEX3_PRINT:
{
*Reply_Index_Id_Ptr = 3;
*Reply_Command_Ptr = NDD_CMD_VALUE_PRINT;
@ -228,63 +228,63 @@ NDT_Status Manager_Demo_DS( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_No
if( rc < 0)
{
return(NDS_LOWER);
return( NDS_LOWER);
}
else
{
if( rc > 0)
{
return(NDS_GREATER);
return( NDS_GREATER);
}
else
{
return(NDS_EQUAL);
return( NDS_EQUAL);
}
}
}
case 1:
{
int val1 = atoi(Value1_Ptr->Val1);
int val2 = atoi(Value2_Ptr->Val1);
int val1 = atoi( Value1_Ptr->Val1);
int val2 = atoi( Value2_Ptr->Val1);
if( val1 < val2)
{
return(NDS_LOWER);
return( NDS_LOWER);
}
else
{
if( val1 > val2)
{
return(NDS_GREATER);
return( NDS_GREATER);
}
else
{
return(NDS_EQUAL);
return( NDS_EQUAL);
}
}
}
case 2:
{
int val1 = strlen(Value1_Ptr->Val2);
int val2 = strlen(Value2_Ptr->Val2);
int val1 = strlen( Value1_Ptr->Val2);
int val2 = strlen( Value2_Ptr->Val2);
if( val1 < val2)
{
return(NDS_LOWER);
return( NDS_LOWER);
}
else
{
if( val1 > val2)
{
return(NDS_GREATER);
return( NDS_GREATER);
}
else
{
return(NDS_EQUAL);
return( NDS_EQUAL);
}
}
}
@ -323,6 +323,7 @@ NDT_Status Manager_Demo_DS( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_No
*/
Command_Name = "NDD_CMD_VALUE_REMOVE";
return( NDS_OK);
}
@ -380,12 +381,12 @@ NDT_Status Manager_Demo_DS( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_No
default:
{
printf( "Demo_DS_Manager() called with an undefined command %d\n", Command);
return NDS_ERRAPI;
return( NDS_ERRAPI);
}
}
printf( "Demo_DS_Manager() called with command %d (%s)\n", Command, Command_Name);
return NDS_OK;
return( NDS_OK);
}
@ -492,7 +493,7 @@ void DataStruct_Dump( NDT_Root *ds_ptr)
printf( "Traverse DataStructure Index 0:\n");
if( ( status = ND_DataStruct_Traverse( ds_ptr, NDT_CMD_INDEX0_PRINT, stdout, NDD_RECURSIVE_MODE_PARENT, 0)) != NDS_OK)
if( ( status = ND_DataStruct_Traverse( ds_ptr, NDD_CMD_INDEX0_PRINT, stdout, NDD_RECURSIVE_MODE_PARENT, 0)) != NDS_OK)
{
printf( "ND_DataStruct_Traverse() failed (%d) !\n", status);
}
@ -503,7 +504,7 @@ void DataStruct_Dump( NDT_Root *ds_ptr)
printf( "Traverse DataStructure Index 1:\n");
if( ( status = ND_DataStruct_Traverse( ds_ptr, NDT_CMD_INDEX1_PRINT, stdout, NDD_RECURSIVE_MODE_PARENT, 0)) != NDS_OK)
if( ( status = ND_DataStruct_Traverse( ds_ptr, NDD_CMD_INDEX1_PRINT, stdout, NDD_RECURSIVE_MODE_PARENT, 0)) != NDS_OK)
{
printf( "ND_DataStruct_Traverse() failed (%d) !\n", status);
}
@ -514,7 +515,7 @@ void DataStruct_Dump( NDT_Root *ds_ptr)
printf( "Traverse DataStructure Index 2:\n");
if( ( status = ND_DataStruct_Traverse( ds_ptr, NDT_CMD_INDEX2_PRINT, stdout, NDD_RECURSIVE_MODE_PARENT, 0)) != NDS_OK)
if( ( status = ND_DataStruct_Traverse( ds_ptr, NDD_CMD_INDEX2_PRINT, stdout, NDD_RECURSIVE_MODE_PARENT, 0)) != NDS_OK)
{
printf( "ND_DataStruct_Traverse() failed (%d) !\n", status);
}
@ -525,7 +526,7 @@ void DataStruct_Dump( NDT_Root *ds_ptr)
printf( "Traverse DataStructure Index 3:\n");
if( ( status = ND_DataStruct_Traverse( ds_ptr, NDT_CMD_INDEX3_PRINT, stdout, NDD_RECURSIVE_MODE_PARENT, 0)) != NDS_OK)
if( ( status = ND_DataStruct_Traverse( ds_ptr, NDD_CMD_INDEX3_PRINT, stdout, NDD_RECURSIVE_MODE_PARENT, 0)) != NDS_OK)
{
printf( "ND_DataStruct_Traverse() failed (%d) !\n", status);
}
@ -584,7 +585,7 @@ void Demo( char *Demo_File_Name, short Optimized_Mode)
index_type_ptr = index_type_final_tab;
}
if( ( status = ND_DataStruct_Open( &demo_ds_ptr, INDEX_NB, index_type_ptr, "Manager_Demo_DS", Manager_Demo_DS, NULL, NULL, NULL, NULL,0, NULL)) != NDS_OK)
if( ( status = ND_DataStruct_Open( &demo_ds_ptr, INDEX_NB, index_type_ptr, "Demo_DS_Manager", Demo_DS_Manager, NULL, NULL, NULL, NULL,0, NULL)) != NDS_OK)
{
printf( "ND_DataStruct_Open() failed (%d) !\n", status);
}
@ -607,16 +608,11 @@ void Demo( char *Demo_File_Name, short Optimized_Mode)
printf( "\n\n\nLaod Data File:\n\n");
DataStruct_Load( demo_ds_ptr, demo_file);
if( Optimized_Mode)
{
printf( "\n\n\nInitial Structure Dump:\n\n");
DataStruct_Dump( demo_ds_ptr);
printf( "Convert data structure: ");
if( ( status = ND_DataStruct_Convert( demo_ds_ptr, index_type_final_tab)) != NDS_OK)
@ -634,8 +630,6 @@ void Demo( char *Demo_File_Name, short Optimized_Mode)
printf( "\n\n\nFinal Structure Dump:\n\n");
DataStruct_Dump( demo_ds_ptr);
printf( "Close demo datafile: ");
if( fclose( demo_file) != 0)