abc/src/base/cmd/cmdHist.c

116 lines
3.0 KiB
C
Raw Normal View History

2005-07-29 17:01:00 +02:00
/**CFile****************************************************************
FileName [cmdHist.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Command processing package.]
Synopsis [Procedures working with history.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: cmdHist.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "base/abc/abc.h"
#include "base/main/mainInt.h"
2005-07-29 17:01:00 +02:00
#include "cmd.h"
#include "cmdInt.h"
2010-11-01 09:35:04 +01:00
ABC_NAMESPACE_IMPL_START
2005-07-29 17:01:00 +02:00
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
2008-01-31 05:01:00 +01:00
/// FUNCTION DEFINITIONS ///
2005-07-29 17:01:00 +02:00
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
2010-11-01 09:35:04 +01:00
void Cmd_HistoryAddCommand( Abc_Frame_t * p, const char * command )
2005-07-29 17:01:00 +02:00
{
2008-01-31 05:01:00 +01:00
static char Buffer[MAX_STR];
2005-07-29 17:01:00 +02:00
strcpy( Buffer, command );
if ( command[strlen(command)-1] != '\n' )
strcat( Buffer, "\n" );
2008-01-31 05:01:00 +01:00
Vec_PtrPush( p->aHistory, Extra_UtilStrsav(Buffer) );
2005-07-29 17:01:00 +02:00
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Cmd_HistoryRead( Abc_Frame_t * p )
{
char Buffer[1000];
FILE * pFile;
assert( Vec_PtrSize(p->aHistory) == 0 );
pFile = fopen( "abc.history", "rb" );
if ( pFile == NULL )
{
// Abc_Print( 0, "Cannot open file \"abc.history\" for reading.\n" );
return;
}
while ( fgets( Buffer, 1000, pFile ) != NULL )
Vec_PtrPush( p->aHistory, Extra_UtilStrsav(Buffer) );
fclose( pFile );
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Cmd_HistoryWrite( Abc_Frame_t * p )
{
FILE * pFile;
char * pName;
int i;
pFile = fopen( "abc.history", "wb" );
if ( pFile == NULL )
{
Abc_Print( 0, "Cannot open file \"abc.history\" for writing.\n" );
return;
}
Vec_PtrForEachEntry( char *, p->aHistory, pName, i )
fputs( pName, pFile );
fclose( pFile );
}
2005-07-29 17:01:00 +02:00
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
2010-11-01 09:35:04 +01:00
ABC_NAMESPACE_IMPL_END