1 /**CFile****************************************************************
2 
3   FileName    [cmdFlag.c]
4 
5   SystemName  [ABC: Logic synthesis and verification system.]
6 
7   PackageName [Command processing package.]
8 
9   Synopsis    [Procedures working with flags.]
10 
11   Author      [Alan Mishchenko]
12 
13   Affiliation [UC Berkeley]
14 
15   Date        [Ver. 1.0. Started - June 20, 2005.]
16 
17   Revision    [$Id: cmdFlag.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "base/abc/abc.h"
22 #include "base/main/mainInt.h"
23 
24 ABC_NAMESPACE_IMPL_START
25 
26 
27 ////////////////////////////////////////////////////////////////////////
28 ///                        DECLARATIONS                              ///
29 ////////////////////////////////////////////////////////////////////////
30 
31 ////////////////////////////////////////////////////////////////////////
32 ///                     FUNCTION DEFINITIONS                         ///
33 ////////////////////////////////////////////////////////////////////////
34 
35 
36 /**Function********************************************************************
37 
38   Synopsis    [Looks up value of flag in table of named values.]
39 
40   Description [The command parser maintains a table of named values.  These
41   are manipulated using the 'set' and 'unset' commands.  The value of the
42   named flag is returned, or NULL is returned if the flag has not been set.]
43 
44   SideEffects []
45 
46 ******************************************************************************/
Cmd_FlagReadByName(Abc_Frame_t * pAbc,char * flag)47 char * Cmd_FlagReadByName( Abc_Frame_t * pAbc, char * flag )
48 {
49     char * value;
50     if ( st__lookup(pAbc->tFlags, flag, &value) )
51         return value;
52     return NULL;
53 }
54 
55 
56 /**Function********************************************************************
57 
58   Synopsis    [Updates a set value by calling instead of set command.]
59 
60   Description [Updates a set value by calling instead of set command.]
61 
62   SideEffects []
63 
64 ******************************************************************************/
Cmd_FlagUpdateValue(Abc_Frame_t * pAbc,const char * key,char * value)65 void Cmd_FlagUpdateValue( Abc_Frame_t * pAbc, const char * key, char * value )
66 {
67     char * oldValue, * newValue;
68     if ( !key )
69         return;
70     if ( value )
71         newValue = Extra_UtilStrsav(value);
72     else
73         newValue = Extra_UtilStrsav("");
74 //        newValue = NULL;
75     if ( st__delete(pAbc->tFlags, &key, &oldValue) )
76         ABC_FREE(oldValue);
77     st__insert( pAbc->tFlags, key, newValue );
78 }
79 
80 
81 /**Function********************************************************************
82 
83   Synopsis    [Deletes a set value by calling instead of unset command.]
84 
85   Description [Deletes a set value by calling instead of unset command.]
86 
87   SideEffects []
88 
89 ******************************************************************************/
Cmd_FlagDeleteByName(Abc_Frame_t * pAbc,const char * key)90 void Cmd_FlagDeleteByName( Abc_Frame_t * pAbc, const char * key )
91 {
92     char *value;
93     if ( !key )
94         return;
95     if ( st__delete( pAbc->tFlags, &key, &value ) )
96     {
97         ABC_FREE(key);
98         ABC_FREE(value);
99     }
100 }
101 
102 
103 
104 ////////////////////////////////////////////////////////////////////////
105 ///                       END OF FILE                                ///
106 ////////////////////////////////////////////////////////////////////////
107 
108 
109 ABC_NAMESPACE_IMPL_END
110 
111