abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cmd.h File Reference

Go to the source code of this file.

Typedefs

typedef
typedefABC_NAMESPACE_HEADER_START
struct MvCommand 
Abc_Command
 INCLUDES ///. More...
 
typedef struct MvAlias Abc_Alias
 
typedef int(* Cmd_CommandFuncType )(Abc_Frame_t *, int, char **)
 

Functions

void Cmd_Init (Abc_Frame_t *pAbc)
 MACRO DEFINITIONS ///. More...
 
void Cmd_End (Abc_Frame_t *pAbc)
 
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)
 
ABC_DLL int Cmd_CommandExecute (Abc_Frame_t *pAbc, const char *sCommand)
 
char * Cmd_FlagReadByName (Abc_Frame_t *pAbc, char *flag)
 DECLARATIONS ///. More...
 
void Cmd_FlagDeleteByName (Abc_Frame_t *pAbc, const char *key)
 
void Cmd_FlagUpdateValue (Abc_Frame_t *pAbc, const char *key, char *value)
 
void Cmd_HistoryAddCommand (Abc_Frame_t *pAbc, const char *command)
 DECLARATIONS ///. More...
 
void Cmd_HistoryRead (Abc_Frame_t *p)
 
void Cmd_HistoryWrite (Abc_Frame_t *p, int Limit)
 
void Cmd_HistoryPrint (Abc_Frame_t *p, int Limit)
 
int CmdCommandLoad (Abc_Frame_t *pAbc, int argc, char **argv)
 DECLARATIONS ///. More...
 

Typedef Documentation

typedef struct MvAlias Abc_Alias

Definition at line 40 of file cmd.h.

typedef typedefABC_NAMESPACE_HEADER_START struct MvCommand Abc_Command

INCLUDES ///.

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

FileName [cmd.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [External declarations of the command package.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id:
cmd.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

]PARAMETERS ///STRUCTURE DEFINITIONS ///

Definition at line 39 of file cmd.h.

typedef int(* Cmd_CommandFuncType)(Abc_Frame_t *, int, char **)

Definition at line 54 of file cmd.h.

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
ABC_DLL 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
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
void Cmd_End ( Abc_Frame_t pAbc)

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

Synopsis [Ends the command package.]

Description [Ends the command package. Tables are freed.]

SideEffects []

SeeAlso []

Definition at line 127 of file cmd.c.

128 {
129  st__generator * gen;
130  char * pKey, * pValue;
132 
133 // st__free_table( pAbc->tCommands, (void (*)()) 0, CmdCommandFree );
134 // st__free_table( pAbc->tAliases, (void (*)()) 0, CmdCommandAliasFree );
135 // st__free_table( pAbc->tFlags, free, free );
136 
137  st__foreach_item( pAbc->tCommands, gen, (const char **)&pKey, (char **)&pValue )
138  CmdCommandFree( (Abc_Command *)pValue );
139  st__free_table( pAbc->tCommands );
140 
141  st__foreach_item( pAbc->tAliases, gen, (const char **)&pKey, (char **)&pValue )
142  CmdCommandAliasFree( (Abc_Alias *)pValue );
143  st__free_table( pAbc->tAliases );
144 
145  st__foreach_item( pAbc->tFlags, gen, (const char **)&pKey, (char **)&pValue )
146  ABC_FREE( pKey ), ABC_FREE( pValue );
147  st__free_table( pAbc->tFlags );
148 
149  Vec_PtrFreeFree( pAbc->aHistory );
150 }
void st__free_table(st__table *table)
Definition: st.c:81
typedefABC_NAMESPACE_HEADER_START struct MvCommand Abc_Command
INCLUDES ///.
Definition: cmd.h:39
Definition: cmdInt.h:51
void CmdCommandAliasFree(Abc_Alias *pAlias)
Definition: cmdAlias.c:113
static void Vec_PtrFreeFree(Vec_Ptr_t *p)
Definition: vecPtr.h:569
void CmdCommandFree(Abc_Command *pCommand)
Definition: cmdUtils.c:535
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
#define st__foreach_item(table, gen, key, value)
Definition: st.h:107
#define const
Definition: zconf.h:196
void Cmd_HistoryWrite(Abc_Frame_t *p, int Limit)
Definition: cmdHist.c:131
void Cmd_FlagDeleteByName ( Abc_Frame_t pAbc,
const char *  key 
)

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

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

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

SideEffects []

Definition at line 90 of file cmdFlag.c.

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 }
int st__delete(st__table *table, const char **keyp, char **value)
Definition: st.c:375
#define ABC_FREE(obj)
Definition: abc_global.h:232
enum keys key
int value
char* Cmd_FlagReadByName ( Abc_Frame_t pAbc,
char *  flag 
)

DECLARATIONS ///.

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

]FUNCTION DEFINITIONS /// 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 named flag is returned, or NULL is returned if the flag has not been set.]

SideEffects []

Definition at line 47 of file cmdFlag.c.

48 {
49  char * value;
50  if ( st__lookup(pAbc->tFlags, flag, &value) )
51  return value;
52  return NULL;
53 }
int st__lookup(st__table *table, const char *key, char **value)
Definition: st.c:114
int value
void Cmd_FlagUpdateValue ( Abc_Frame_t pAbc,
const char *  key,
char *  value 
)

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

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

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

SideEffects []

Definition at line 65 of file cmdFlag.c.

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 }
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
char * Extra_UtilStrsav(const char *s)
#define ABC_FREE(obj)
Definition: abc_global.h:232
enum keys key
int value
void Cmd_HistoryAddCommand ( Abc_Frame_t p,
const char *  command 
)

DECLARATIONS ///.

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

FileName [cmdHist.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [Procedures working with history.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file cmdHist.c.

49 {
50  int nLastLooked = 10; // do not add history if the same entry appears among the last entries
51  int nLastSaved = 1000; // when saving a file, save no more than this number of last entries
52  char Buffer[ABC_MAX_STR];
53  int Len;
54  if ( p->fBatchMode )
55  return;
56  Len = strlen(command);
57  strcpy( Buffer, command );
58  if ( Buffer[Len-1] == '\n' )
59  Buffer[Len-1] = 0;
60  if ( strlen(Buffer) > 3 &&
61  strncmp(Buffer,"set",3) &&
62  strncmp(Buffer,"unset",5) &&
63  strncmp(Buffer,"time",4) &&
64  strncmp(Buffer,"quit",4) &&
65  strncmp(Buffer,"alias",5) &&
66 // strncmp(Buffer,"source",6) &&
67  strncmp(Buffer,"history",7) && strncmp(Buffer,"hi ", 3) && strcmp(Buffer,"hi") &&
68  Buffer[strlen(Buffer)-1] != '?' )
69  {
70  char * pStr = NULL;
71  int i, Start = Abc_MaxInt( 0, Vec_PtrSize(p->aHistory) - nLastLooked );
72  // do not enter if the same command appears among nLastLooked commands
73  Vec_PtrForEachEntryStart( char *, p->aHistory, pStr, i, Start )
74  if ( !strcmp(pStr, Buffer) )
75  break;
76  if ( i == Vec_PtrSize(p->aHistory) )
77  { // add new entry
78  Vec_PtrPush( p->aHistory, Extra_UtilStrsav(Buffer) );
79  Cmd_HistoryWrite( p, nLastSaved );
80  }
81  else
82  { // put at the end
83  Vec_PtrRemove( p->aHistory, pStr );
84  Vec_PtrPush( p->aHistory, pStr );
85  }
86  }
87 }
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition: vecPtr.h:57
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void Vec_PtrRemove(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:714
void Cmd_HistoryWrite(Abc_Frame_t *p, int Limit)
Definition: cmdHist.c:131
char * Extra_UtilStrsav(const char *s)
int strcmp()
#define ABC_MAX_STR
Definition: mainInt.h:50
if(last==0)
Definition: sparse_int.h:34
#define Len
Definition: deflate.h:78
char * strcpy()
int strncmp()
int strlen()
void Cmd_HistoryPrint ( Abc_Frame_t p,
int  Limit 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 161 of file cmdHist.c.

162 {
163 #if defined(WIN32)
164  char * pStr;
165  int i;
166  Limit = Abc_MaxInt( 0, Vec_PtrSize(p->aHistory)-Limit );
167  printf( "================== Command history ==================\n" );
168  Vec_PtrForEachEntryStart( char *, p->aHistory, pStr, i, Limit )
169  printf( "%s\n", pStr );
170  printf( "=====================================================\n" );
171 #endif
172 }
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition: vecPtr.h:57
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
void Cmd_HistoryRead ( Abc_Frame_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 100 of file cmdHist.c.

101 {
102 #if defined(WIN32)
103  char Buffer[ABC_MAX_STR];
104  FILE * pFile;
105  assert( Vec_PtrSize(p->aHistory) == 0 );
106  pFile = fopen( "abc.history", "rb" );
107  if ( pFile == NULL )
108  return;
109  while ( fgets( Buffer, ABC_MAX_STR, pFile ) != NULL )
110  {
111  int Len = strlen(Buffer);
112  if ( Buffer[Len-1] == '\n' )
113  Buffer[Len-1] = 0;
114  Vec_PtrPush( p->aHistory, Extra_UtilStrsav(Buffer) );
115  }
116  fclose( pFile );
117 #endif
118 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
char * Extra_UtilStrsav(const char *s)
#define ABC_MAX_STR
Definition: mainInt.h:50
#define Len
Definition: deflate.h:78
#define assert(ex)
Definition: util_old.h:213
int strlen()
void Cmd_HistoryWrite ( Abc_Frame_t p,
int  Limit 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 131 of file cmdHist.c.

132 {
133 #if defined(WIN32)
134  FILE * pFile;
135  char * pStr;
136  int i;
137  pFile = fopen( "abc.history", "wb" );
138  if ( pFile == NULL )
139  {
140  Abc_Print( 0, "Cannot open file \"abc.history\" for writing.\n" );
141  return;
142  }
143  Limit = Abc_MaxInt( 0, Vec_PtrSize(p->aHistory)-Limit );
144  Vec_PtrForEachEntryStart( char *, p->aHistory, pStr, i, Limit )
145  fprintf( pFile, "%s\n", pStr );
146  fclose( pFile );
147 #endif
148 }
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition: vecPtr.h:57
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
void Cmd_Init ( Abc_Frame_t pAbc)

MACRO DEFINITIONS ///.

FUNCTION DEFINITIONS ///

MACRO DEFINITIONS ///.

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

Synopsis [Initializes the command package.]

SideEffects [Commands are added to the command table.]

SeeAlso [Cmd_End]

Definition at line 79 of file cmd.c.

80 {
81  pAbc->tCommands = st__init_table(strcmp, st__strhash);
82  pAbc->tAliases = st__init_table(strcmp, st__strhash);
83  pAbc->tFlags = st__init_table(strcmp, st__strhash);
84  pAbc->aHistory = Vec_PtrAlloc( 100 );
85  Cmd_HistoryRead( pAbc );
86 
87  Cmd_CommandAdd( pAbc, "Basic", "time", CmdCommandTime, 0 );
88  Cmd_CommandAdd( pAbc, "Basic", "echo", CmdCommandEcho, 0 );
89  Cmd_CommandAdd( pAbc, "Basic", "quit", CmdCommandQuit, 0 );
90  Cmd_CommandAdd( pAbc, "Basic", "history", CmdCommandHistory, 0 );
91  Cmd_CommandAdd( pAbc, "Basic", "alias", CmdCommandAlias, 0 );
92  Cmd_CommandAdd( pAbc, "Basic", "unalias", CmdCommandUnalias, 0 );
93  Cmd_CommandAdd( pAbc, "Basic", "help", CmdCommandHelp, 0 );
94  Cmd_CommandAdd( pAbc, "Basic", "source", CmdCommandSource, 0 );
95  Cmd_CommandAdd( pAbc, "Basic", "set", CmdCommandSetVariable, 0 );
96  Cmd_CommandAdd( pAbc, "Basic", "unset", CmdCommandUnsetVariable, 0 );
97  Cmd_CommandAdd( pAbc, "Basic", "undo", CmdCommandUndo, 0 );
98  Cmd_CommandAdd( pAbc, "Basic", "recall", CmdCommandRecall, 0 );
99  Cmd_CommandAdd( pAbc, "Basic", "empty", CmdCommandEmpty, 0 );
100 #if defined(WIN32) && !defined(__cplusplus)
101  Cmd_CommandAdd( pAbc, "Basic", "scandir", CmdCommandScanDir, 0 );
102  Cmd_CommandAdd( pAbc, "Basic", "renamefiles", CmdCommandRenameFiles, 0 );
103  Cmd_CommandAdd( pAbc, "Basic", "ls", CmdCommandLs, 0 );
104  Cmd_CommandAdd( pAbc, "Basic", "scrgen", CmdCommandScrGen, 0 );
105 #endif
106  Cmd_CommandAdd( pAbc, "Basic", "version", CmdCommandVersion, 0 );
107 
108  Cmd_CommandAdd( pAbc, "Various", "sis", CmdCommandSis, 1 );
109  Cmd_CommandAdd( pAbc, "Various", "mvsis", CmdCommandMvsis, 1 );
110  Cmd_CommandAdd( pAbc, "Various", "capo", CmdCommandCapo, 0 );
111  Cmd_CommandAdd( pAbc, "Various", "starter", CmdCommandStarter, 0 );
112 
113  Cmd_CommandAdd( pAbc, "Various", "load_plugin", Cmd_CommandAbcLoadPlugIn, 0 );
114 }
static ABC_NAMESPACE_IMPL_START int CmdCommandTime(Abc_Frame_t *pAbc, int argc, char **argv)
DECLARATIONS ///.
Definition: cmd.c:165
static int CmdCommandSource(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:555
static int CmdCommandRecall(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:927
void Cmd_CommandAdd(Abc_Frame_t *pAbc, const char *sGroup, const char *sName, Cmd_CommandFuncType pFunc, int fChanges)
Definition: cmdApi.c:63
static int CmdCommandSetVariable(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:738
int Cmd_CommandAbcLoadPlugIn(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmdPlugin.c:642
int strcmp()
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
static int CmdCommandVersion(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:2469
int st__strhash(const char *string, int modulus)
Definition: st.c:449
static int CmdCommandHelp(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:501
static int CmdCommandCapo(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:2201
static int CmdCommandQuit(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:288
static int CmdCommandMvsis(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:1992
static int CmdCommandEmpty(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:1043
void Cmd_HistoryRead(Abc_Frame_t *p)
Definition: cmdHist.c:100
static int CmdCommandUnalias(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:449
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
static int CmdCommandEcho(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:232
static int CmdCommandAlias(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:392
static int CmdCommandSis(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:1850
static int CmdCommandUnsetVariable(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:838
static int CmdCommandHistory(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:347
static int CmdCommandStarter(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:2384
static int CmdCommandUndo(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:893
int CmdCommandLoad ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)

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 48 of file cmdLoad.c.

49 {
50  Vec_Str_t * vCommand;
51  FILE * pFile;
52  int i;
53  vCommand = Vec_StrAlloc( 100 );
54  Vec_StrAppend( vCommand, "abccmd_" );
55  Vec_StrAppend( vCommand, argv[0] );
56  Vec_StrAppend( vCommand, ".exe" );
57  Vec_StrPush( vCommand, 0 );
58  // check if there is the binary
59  if ( (pFile = fopen( Vec_StrArray(vCommand), "r" )) == NULL )
60  {
61  Vec_StrFree( vCommand );
62  Abc_Print( -1, "Cannot run the binary \"%s\".\n\n", Vec_StrArray(vCommand) );
63  return 1;
64  }
65  fclose( pFile );
66  Vec_StrPop( vCommand );
67  // add other arguments
68  for ( i = 1; i < argc; i++ )
69  {
70  Vec_StrAppend( vCommand, " " );
71  Vec_StrAppend( vCommand, argv[i] );
72  }
73  Vec_StrPush( vCommand, 0 );
74  // run the command line
75  if ( Util_SignalSystem( Vec_StrArray(vCommand) ) )
76  {
77  Vec_StrFree( vCommand );
78  Abc_Print( -1, "The following command has returned non-zero exit status:\n" );
79  Abc_Print( -1, "\"%s\"\n", Vec_StrArray(vCommand) );
80  return 1;
81  }
82  Vec_StrFree( vCommand );
83  return 0;
84 }
static char * Vec_StrArray(Vec_Str_t *p)
Definition: vecStr.h:272
static Vec_Str_t * Vec_StrAlloc(int nCap)
Definition: bblif.c:495
static void Vec_StrPush(Vec_Str_t *p, char Entry)
Definition: vecStr.h:535
static char Vec_StrPop(Vec_Str_t *p)
Definition: vecStr.h:558
static void Vec_StrAppend(Vec_Str_t *p, const char *pString)
Definition: vecStr.h:645
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
ABC_NAMESPACE_IMPL_START int Util_SignalSystem(const char *cmd)
DECLARATIONS ///.
Definition: utilSignal.c:46