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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int CmdCommandLoad (Abc_Frame_t *pAbc, int argc, char **argv)
 DECLARATIONS ///. More...
 
Vec_Ptr_tCmdCollectFileNames ()
 
void Load_Init (Abc_Frame_t *pAbc)
 
void Load_End (Abc_Frame_t *pAbc)
 

Function Documentation

Vec_Ptr_t* CmdCollectFileNames ( )

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

Synopsis []

Description []

SideEffects []

SeeAlso [] Function*************************************************************

Synopsis [Collect file names ending with .exe]

Description []

SideEffects []

SeeAlso []

Definition at line 163 of file cmdLoad.c.

164 {
165  return NULL;
166 }
ABC_NAMESPACE_IMPL_START 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
void Load_End ( Abc_Frame_t pAbc)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 217 of file cmdLoad.c.

218 {
219 }
void Load_Init ( Abc_Frame_t pAbc)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 182 of file cmdLoad.c.

183 {
184  Vec_Ptr_t * vFileNames;
185  char * pName, * pStop;
186  int i;
187  vFileNames = CmdCollectFileNames();
188  if ( vFileNames == NULL )
189  return;
190  Vec_PtrForEachEntry( char *, vFileNames, pName, i )
191  {
192  if ( strncmp( pName, "abccmd_", 7 ) )
193  continue;
194  // get the command name
195 // pName[6] = '!';
196  pStop = strstr( pName + 7, "." );
197  if ( pStop )
198  *pStop = 0;
199  // add the command
200  Cmd_CommandAdd( pAbc, "ZZ", pName+7, CmdCommandLoad, 0 );
201 // printf( "Loaded command \"%s\"\n", pName+7 );
202  }
203  Vec_PtrFreeFree( vFileNames );
204 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
ABC_NAMESPACE_IMPL_START int CmdCommandLoad(Abc_Frame_t *pAbc, int argc, char **argv)
DECLARATIONS ///.
Definition: cmdLoad.c:48
static void Vec_PtrFreeFree(Vec_Ptr_t *p)
Definition: vecPtr.h:569
void Cmd_CommandAdd(Abc_Frame_t *pAbc, const char *sGroup, const char *sName, Cmd_CommandFuncType pFunc, int fChanges)
Definition: cmdApi.c:63
char * strstr()
Vec_Ptr_t * CmdCollectFileNames()
Definition: cmdLoad.c:163
int strncmp()
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55