abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cmdAlias.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [cmdAlias.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Command processing package.]
8 
9  Synopsis [Procedures dealing with aliases in the command package.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: cmdAlias.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "base/abc/abc.h"
22 #include "cmdInt.h"
23 
25 
26 
27 ////////////////////////////////////////////////////////////////////////
28 /// DECLARATIONS ///
29 ////////////////////////////////////////////////////////////////////////
30 
31 ////////////////////////////////////////////////////////////////////////
32 /// FUNCTION DEFINITIONS ///
33 ////////////////////////////////////////////////////////////////////////
34 
35 /**Function*************************************************************
36 
37  Synopsis []
38 
39  Description []
40 
41  SideEffects []
42 
43  SeeAlso []
44 
45 ***********************************************************************/
46 void CmdCommandAliasAdd( Abc_Frame_t * pAbc, char * sName, int argc, char ** argv )
47 {
48  Abc_Alias * pAlias;
49  int fStatus, i;
50 
51  pAlias = ABC_ALLOC(Abc_Alias, 1);
52  pAlias->sName = Extra_UtilStrsav(sName);
53  pAlias->argc = argc;
54  pAlias->argv = ABC_ALLOC(char *, pAlias->argc);
55  for(i = 0; i < argc; i++)
56  pAlias->argv[i] = Extra_UtilStrsav(argv[i]);
57  fStatus = st__insert( pAbc->tAliases, pAlias->sName, (char *) pAlias );
58  assert(!fStatus);
59 }
60 
61 /**Function********************************************************************
62 
63  Synopsis [required]
64 
65  Description [optional]
66 
67  SideEffects [required]
68 
69  SeeAlso [optional]
70 
71 ******************************************************************************/
72 void CmdCommandAliasPrint( Abc_Frame_t * pAbc, Abc_Alias * pAlias )
73 {
74  int i;
75  fprintf(pAbc->Out, "%-15s", pAlias->sName);
76  for(i = 0; i < pAlias->argc; i++)
77  fprintf( pAbc->Out, " %s", pAlias->argv[i] );
78  fprintf( pAbc->Out, "\n" );
79 }
80 
81 /**Function********************************************************************
82 
83  Synopsis [required]
84 
85  Description [optional]
86 
87  SideEffects [required]
88 
89  SeeAlso [optional]
90 
91 ******************************************************************************/
92 char * CmdCommandAliasLookup( Abc_Frame_t * pAbc, char * sCommand )
93 {
94  Abc_Alias * pAlias;
95  char * value;
96  if (! st__lookup( pAbc->tAliases, sCommand, &value))
97  return sCommand;
98  pAlias = (Abc_Alias *) value;
99  return pAlias->argv[0];
100 }
101 
102 /**Function*************************************************************
103 
104  Synopsis []
105 
106  Description []
107 
108  SideEffects []
109 
110  SeeAlso []
111 
112 ***********************************************************************/
114 {
115  CmdFreeArgv( pAlias->argc, pAlias->argv );
116  ABC_FREE(pAlias->sName);
117  ABC_FREE(pAlias);
118 }
119 
120 ////////////////////////////////////////////////////////////////////////
121 /// END OF FILE ///
122 ////////////////////////////////////////////////////////////////////////
123 
124 
126 
char ** argv
Definition: cmdInt.h:55
int argc
Definition: cmdInt.h:54
int st__insert(st__table *table, const char *key, char *value)
Definition: st.c:171
Definition: cmdInt.h:51
void CmdCommandAliasFree(Abc_Alias *pAlias)
Definition: cmdAlias.c:113
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
char * Extra_UtilStrsav(const char *s)
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
void CmdFreeArgv(int argc, char **argv)
Definition: cmdUtils.c:485
void CmdCommandAliasPrint(Abc_Frame_t *pAbc, Abc_Alias *pAlias)
Definition: cmdAlias.c:72
int st__lookup(st__table *table, const char *key, char **value)
Definition: st.c:114
char * sName
Definition: cmdInt.h:53
#define ABC_FREE(obj)
Definition: abc_global.h:232
int value
char * CmdCommandAliasLookup(Abc_Frame_t *pAbc, char *sCommand)
Definition: cmdAlias.c:92
#define assert(ex)
Definition: util_old.h:213
ABC_NAMESPACE_IMPL_START void CmdCommandAliasAdd(Abc_Frame_t *pAbc, char *sName, int argc, char **argv)
DECLARATIONS ///.
Definition: cmdAlias.c:46