abc/src/base/cmd/cmdFlag.c

111 lines
3.2 KiB
C
Raw Normal View History

2005-07-29 17:01:00 +02:00
/**CFile****************************************************************
FileName [cmdFlag.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Command processing package.]
Synopsis [Procedures working with flags.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: cmdFlag.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
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 [Looks up value of flag in table of named values.]
Description [The command parser maintains a table of named values. These
are manipulated using the 'set' and 'unset' commands. The value of the
2008-01-31 05:01:00 +01:00
named flag is returned, or NULL is returned if the flag has not been set.]
2005-07-29 17:01:00 +02:00
SideEffects []
******************************************************************************/
char * Cmd_FlagReadByName( Abc_Frame_t * pAbc, char * flag )
{
2005-09-05 17:01:00 +02:00
char * value;
if ( st__lookup(pAbc->tFlags, flag, &value) )
2005-09-05 17:01:00 +02:00
return value;
return NULL;
2005-07-29 17:01:00 +02:00
}
/**Function********************************************************************
Synopsis [Updates a set value by calling instead of set command.]
Description [Updates a set value by calling instead of set command.]
SideEffects []
******************************************************************************/
2010-11-01 09:35:04 +01:00
void Cmd_FlagUpdateValue( Abc_Frame_t * pAbc, const char * key, char * value )
2005-07-29 17:01:00 +02:00
{
2005-09-05 17:01:00 +02:00
char * oldValue, * newValue;
if ( !key )
return;
if ( value )
2008-01-31 05:01:00 +01:00
newValue = Extra_UtilStrsav(value);
2005-09-05 17:01:00 +02:00
else
2008-01-31 05:01:00 +01:00
newValue = Extra_UtilStrsav("");
2005-09-05 17:01:00 +02:00
// newValue = NULL;
if ( st__delete(pAbc->tFlags, &key, &oldValue) )
2009-02-15 17:01:00 +01:00
ABC_FREE(oldValue);
st__insert( pAbc->tFlags, key, newValue );
2005-07-29 17:01:00 +02:00
}
/**Function********************************************************************
Synopsis [Deletes a set value by calling instead of unset command.]
Description [Deletes a set value by calling instead of unset command.]
SideEffects []
******************************************************************************/
2010-11-01 09:35:04 +01:00
void Cmd_FlagDeleteByName( Abc_Frame_t * pAbc, const char * key )
2005-07-29 17:01:00 +02:00
{
2005-09-05 17:01:00 +02:00
char *value;
if ( !key )
return;
if ( st__delete( pAbc->tFlags, &key, &value ) )
2005-09-05 17:01:00 +02:00
{
2009-02-15 17:01:00 +01:00
ABC_FREE(key);
ABC_FREE(value);
2005-09-05 17:01:00 +02:00
}
2005-07-29 17:01:00 +02:00
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
2010-11-01 09:35:04 +01:00
ABC_NAMESPACE_IMPL_END