abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cmdApi.c File Reference
#include "base/abc/abc.h"
#include "base/main/mainInt.h"
#include "cmdInt.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Cmd_CommandIsDefined (Abc_Frame_t *pAbc, const char *sName)
 DECLARATIONS ///. More...
 
void Cmd_CommandAdd (Abc_Frame_t *pAbc, const char *sGroup, const char *sName, Cmd_CommandFuncType pFunc, int fChanges)
 
int Cmd_CommandExecute (Abc_Frame_t *pAbc, const char *sCommand)
 

Function Documentation

void Cmd_CommandAdd ( Abc_Frame_t pAbc,
const char *  sGroup,
const char *  sName,
Cmd_CommandFuncType  pFunc,
int  fChanges 
)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 63 of file cmdApi.c.

64 {
65  const char * key;
66  char * value;
67  Abc_Command * pCommand;
68  int fStatus;
69 
70  key = sName;
71  if ( st__delete( pAbc->tCommands, &key, &value ) )
72  {
73  // delete existing definition for this command
74  fprintf( pAbc->Err, "Cmd warning: redefining '%s'\n", sName );
75  CmdCommandFree( (Abc_Command *)value );
76  }
77 
78  // create the new command
79  pCommand = ABC_ALLOC( Abc_Command, 1 );
80  pCommand->sName = Extra_UtilStrsav( sName );
81  pCommand->sGroup = Extra_UtilStrsav( sGroup );
82  pCommand->pFunc = pFunc;
83  pCommand->fChange = fChanges;
84  fStatus = st__insert( pAbc->tCommands, pCommand->sName, (char *)pCommand );
85  assert( !fStatus ); // the command should not be in the table
86 }
typedefABC_NAMESPACE_HEADER_START struct MvCommand Abc_Command
INCLUDES ///.
Definition: cmd.h:39
int st__delete(st__table *table, const char **keyp, char **value)
Definition: st.c:375
int st__insert(st__table *table, const char *key, char *value)
Definition: st.c:171
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
char * Extra_UtilStrsav(const char *s)
void CmdCommandFree(Abc_Command *pCommand)
Definition: cmdUtils.c:535
enum keys key
int value
#define assert(ex)
Definition: util_old.h:213
int Cmd_CommandExecute ( Abc_Frame_t pAbc,
const char *  sCommand 
)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 99 of file cmdApi.c.

100 {
101  int fStatus = 0, argc, loop;
102  const char * sCommandNext;
103  char **argv;
104 
105  if ( !pAbc->fAutoexac && !pAbc->fSource )
106  Cmd_HistoryAddCommand(pAbc, sCommand);
107  sCommandNext = sCommand;
108  do
109  {
110  sCommandNext = CmdSplitLine( pAbc, sCommandNext, &argc, &argv );
111  loop = 0;
112  fStatus = CmdApplyAlias( pAbc, &argc, &argv, &loop );
113  if ( fStatus == 0 )
114  fStatus = CmdCommandDispatch( pAbc, &argc, &argv );
115  CmdFreeArgv( argc, argv );
116  }
117  while ( fStatus == 0 && *sCommandNext != '\0' );
118  return fStatus;
119 }
int CmdCommandDispatch(Abc_Frame_t *pAbc, int *argc, char ***argv)
Definition: cmdUtils.c:93
const char * CmdSplitLine(Abc_Frame_t *pAbc, const char *sCommand, int *argc, char ***argv)
Definition: cmdUtils.c:181
void Cmd_HistoryAddCommand(Abc_Frame_t *pAbc, const char *command)
DECLARATIONS ///.
Definition: cmdHist.c:48
void CmdFreeArgv(int argc, char **argv)
Definition: cmdUtils.c:485
int CmdApplyAlias(Abc_Frame_t *pAbc, int *argc, char ***argv, int *loop)
Definition: cmdUtils.c:267
ABC_NAMESPACE_IMPL_START int Cmd_CommandIsDefined ( Abc_Frame_t pAbc,
const char *  sName 
)

DECLARATIONS ///.

CFile****************************************************************

FileName [cmdApi.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [External procedures of the command package.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
cmdApi.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file cmdApi.c.

48 {
49  return st__is_member( pAbc->tCommands, sName );
50 }
#define st__is_member(table, key)
Definition: st.h:70