cmdFlag.c 3.14 KB
Newer Older
Alan Mishchenko committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/**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 $]

***********************************************************************/

21
#include "abc.h"
Alan Mishchenko committed
22 23
#include "mainInt.h"

24 25 26
ABC_NAMESPACE_IMPL_START


Alan Mishchenko committed
27 28 29 30 31
////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////
Alan Mishchenko committed
32
///                     FUNCTION DEFINITIONS                         ///
Alan Mishchenko committed
33 34 35 36 37 38 39 40 41
////////////////////////////////////////////////////////////////////////


/**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
Alan Mishchenko committed
42
  named flag is returned, or NULL is returned if the flag has not been set.]
Alan Mishchenko committed
43 44 45 46 47 48

  SideEffects []

******************************************************************************/
char * Cmd_FlagReadByName( Abc_Frame_t * pAbc, char * flag )
{
Alan Mishchenko committed
49 50 51 52
    char * value;
    if ( st_lookup(pAbc->tFlags, flag, &value) )
        return value;
    return NULL;
Alan Mishchenko committed
53 54 55 56 57 58 59 60 61 62 63 64
}


/**Function********************************************************************

  Synopsis    [Updates a set value by calling instead of set command.]

  Description [Updates a set value by calling instead of set command.]

  SideEffects []

******************************************************************************/
65
void Cmd_FlagUpdateValue( Abc_Frame_t * pAbc, const char * key, char * value )
Alan Mishchenko committed
66
{
Alan Mishchenko committed
67 68 69 70
    char * oldValue, * newValue;
    if ( !key )
        return;
    if ( value )
Alan Mishchenko committed
71
        newValue = Extra_UtilStrsav(value);
Alan Mishchenko committed
72
    else
Alan Mishchenko committed
73
        newValue = Extra_UtilStrsav("");
Alan Mishchenko committed
74 75
//        newValue = NULL;
    if ( st_delete(pAbc->tFlags, &key, &oldValue) )
Alan Mishchenko committed
76
        ABC_FREE(oldValue);
Alan Mishchenko committed
77
    st_insert( pAbc->tFlags, key, newValue );
Alan Mishchenko committed
78 79 80 81 82 83 84 85 86 87 88 89
}


/**Function********************************************************************

  Synopsis    [Deletes a set value by calling instead of unset command.]

  Description [Deletes a set value by calling instead of unset command.]

  SideEffects []

******************************************************************************/
90
void Cmd_FlagDeleteByName( Abc_Frame_t * pAbc, const char * key )
Alan Mishchenko committed
91
{
Alan Mishchenko committed
92 93 94 95 96
    char *value;
    if ( !key )
        return;
    if ( st_delete( pAbc->tFlags, &key, &value ) ) 
    {
Alan Mishchenko committed
97 98
        ABC_FREE(key);
        ABC_FREE(value);
Alan Mishchenko committed
99
    }
Alan Mishchenko committed
100 101 102 103 104 105 106 107 108
}



////////////////////////////////////////////////////////////////////////
///                       END OF FILE                                ///
////////////////////////////////////////////////////////////////////////


109 110
ABC_NAMESPACE_IMPL_END