ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
cmdLoad.c
Go to the documentation of this file.
1
20
21#include "base/abc/abc.h"
22#include "base/main/mainInt.h"
23#include "cmd.h"
24#include "cmdInt.h"
26
28
32
36
48int CmdCommandLoad( Abc_Frame_t * pAbc, int argc, char ** argv )
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 Abc_Print( -1, "Cannot run the binary \"%s\".\n\n", Vec_StrArray(vCommand) );
62 Vec_StrFree( 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 Abc_Print( -1, "The following command has returned non-zero exit status:\n" );
78 Abc_Print( -1, "\"%s\"\n", Vec_StrArray(vCommand) );
79 Vec_StrFree( vCommand );
80 return 1;
81 }
82 Vec_StrFree( vCommand );
83 return 0;
84}
85
97#if defined(WIN32) && !defined(__cplusplus)
98
99#include <direct.h>
100#include <io.h>
101
114{
115 Vec_Ptr_t * vFileNames;
116 struct _finddata_t c_file;
117 //long hFile;
118 ABC_PTRINT_T hFile;
119 if( (hFile = _findfirst( "*.exe", &c_file )) == -1L )
120 {
121// Abc_Print( 0, "No files with extention \"%s\" in the current directory.\n", "exe" );
122 return NULL;
123 }
124 vFileNames = Vec_PtrAlloc( 100 );
125 do {
126 Vec_PtrPush( vFileNames, Extra_UtilStrsav( c_file.name ) );
127 } while( _findnext( hFile, &c_file ) == 0 );
128 _findclose( hFile );
129 return vFileNames;
130}
131
132#else
133
146{
147 return NULL;
148}
149
150#endif
151
152
164void Load_Init( Abc_Frame_t * pAbc )
165{
166 Vec_Ptr_t * vFileNames;
167 char * pName, * pStop;
168 int i;
169 vFileNames = CmdCollectFileNames();
170 if ( vFileNames == NULL )
171 return;
172 Vec_PtrForEachEntry( char *, vFileNames, pName, i )
173 {
174 if ( strncmp( pName, "abccmd_", 7 ) )
175 continue;
176 // get the command name
177// pName[6] = '!';
178 pStop = strstr( pName + 7, "." );
179 if ( pStop )
180 *pStop = 0;
181 // add the command
182 Cmd_CommandAdd( pAbc, "ZZ", pName+7, CmdCommandLoad, 0 );
183// printf( "Loaded command \"%s\"\n", pName+7 );
184 }
185 Vec_PtrFreeFree( vFileNames );
186}
187
199void Load_End( Abc_Frame_t * pAbc )
200{
201}
202
203
207
208
210
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
Definition abcapis.h:38
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
void Load_End(Abc_Frame_t *pAbc)
Definition cmdLoad.c:199
Vec_Ptr_t * CmdCollectFileNames()
Definition cmdLoad.c:145
void Load_Init(Abc_Frame_t *pAbc)
Definition cmdLoad.c:164
ABC_NAMESPACE_IMPL_START int CmdCommandLoad(Abc_Frame_t *pAbc, int argc, char **argv)
DECLARATIONS ///.
Definition cmdLoad.c:48
void Cmd_CommandAdd(Abc_Frame_t *pAbc, const char *sGroup, const char *sName, Cmd_CommandFuncType pFunc, int fChanges)
Definition cmdApi.c:63
int CmdCommandLoad(Abc_Frame_t *pAbc, int argc, char **argv)
DECLARATIONS ///.
Definition cmdLoad.c:48
char * Extra_UtilStrsav(const char *s)
ABC_NAMESPACE_IMPL_START int Util_SignalSystem(const char *cmd)
DECLARATIONS ///.
Definition utilSignal.c:44
int strncmp()
char * strstr()
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55